vue实现移动手机电商商品分类列表添加购物车结算页面代码

代码语言:html

所属分类:电商

代码描述:vue实现移动手机电商商品分类列表添加购物车结算页面代码

代码标签: vue 移动 手机 电商 商品 分类 列表 添加 购物车 结算 页面 代码

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">
  

  
  
<style>
body {
    font-size: 14px;
    color: #363636;
    background-color: #333;
}

h1,
ul,
li,
p {
    margin: 0;
    padding: 0;
}

li {
    list-style: none;
}

.g-panel {
    margin: 0 auto;
    width: 790px;
}

.cate,
.filter-opt,
.save {
    cursor: pointer;
}

.device {
    position: relative;
    margin: 10px;
    float: left;
    width: 375px;
    height: 667px;
    background-color: #eee;
    border-radius: 4px;
    overflow: hidden;
}

header {
    padding: 0 4%;
    position: relative;
    height: 44px;
    line-height: 44px;
    background-color: #fff;
    border-bottom: 1px solid #ddd;
}

.header-title {
    position: absolute;
    margin-left: 21%;
    width: 50%;
    font-size: 16px;
    text-align: center;
}

.header-edit {
    float: right;
    padding: 0 10px;
    cursor: pointer;
}

.tab-wrap {
    height: 60px;
    background: red;
    overflow: hidden;
}

.cate-tab {
    white-space: nowrap;
    overflow-x: scroll;
    -webkit-overflow-scrolling: touch;
    background-color: #5D4285;
}

.cate {
    display: inline-block;
    width: 80px;
    height: 70px;
    color: #fff;
    line-height: 60px;
    text-align: center;
}

.tab-active {
    background-color: #9A51FF;
}

.filter-bar {
    display: flex;
    height: 40px;
    background-color: #fff;
    border-bottom: 1px solid #E5E5E5;
    line-height: 40px;
}

.filter-opt {
    position: relative;
    width: 33.3%;
    color: #5F646E;
    text-align: center;
}

.filter-active {
    color: #7B57C5;
}

.filter-price:after {
    position: absolute;
    top: 13px;
    margin-left: 4px;
    content: '';
    display: inline-block;
    width: 8px;
    height: 14px;
    background: url('//repo.bfw.wiki/bfwrepo/icon/5dbed9c613b32.png') no-repeat;
    background-size: 14px 14px;
}

.filter-active.price-up:after {
    background: url('//repo.bfw.wiki/bfwrepo/image/6070ea24c5c5f.png') no-repeat;
    background-size: 8px 14px;
}

.filter-active.price-down:after {
    background: url('//repo.bfw.wiki/bfwrepo/image/6070ea4e4bd1a.png') no-repeat;
    background-size: 8px 14px;
}

.goods-list {
    padding-top: 8px;
    height: 513px;
    overflow-y: scroll;
}

.cart-list {
    height: 560px;
}

.goods-item {
    display: flex;
    margin-bottom: 8px;
    padding: 10px 6px;
    min-height: 62px;
    background: #fff;
}

.goods-img {
    position: relative;
    margin-right: 4%;
    display: block;
    width: 16%;
}

.goods-img img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
}

.goods-item .flag {
    position: absolute;
    top: 0;
    left: 0;
    width: 20px;
    height: 20px;
    font-size: 12px;
    color: #fff;
    text-align: center;
    line-height: 20px;
    background-color: #FC5951;
    border-radius: 50%;
}

.goods-info {
    position: relative;
    width: 80%;
}

.goods-title {
    width: 80%;
    height: 38px;
    color: #363636;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
}

.goods-price {
    margin-top: 6px;
    line-height: 1;
}

.goods-price span {
    font-size: 15px;
    color: #7a45e5;
    /*   background: linear-gradient(90deg, #03D2B3 0, #2181FB 80%, #2181FB 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent; */
}

.des {
    font-size: 12px;
    color: #888;
}

.save {
    position: absolute;
    right: 10px;
    bottom: 2px;
    width: 32px;
    height: 22px;
    background-color: #7a45e5;
    font-size: 16px;
    line-height: 19px;
    text-align: center;
    color: #fff;
    border-radius: 12px;
    overflow: hidden;
}

.empty-states {
    padding-top: 60px;
    font-size: 18px;
    color: #AEB0B7;
    text-align: center;
}

.cart-list .goods-info {
    width: 68%;
}

.item-selector {
    width: 12%;
}

.icon-selector {
    position: relative;
    margin: 16px auto 0 auto;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid #ccc;
    cursor: pointer;
}

.selector-active {
    background-color: #7a45e5;
    border-color: #7a45e5;
}

.selector-active .icon {
    position: absolute;
    top: 2px;
    left: 2px;
}

.goods-num {
    position: absolute;
    right: 10px;
    top: 4px;
    width: 32px;
    color: #999;
    text-align: center;
}

.show-num {
    line-height: 28px;
}

.num-btn {
    width: 100%;
    height: 24px;
    font-size: 20px;
    line-height: 20px;
    cursor: pointer;
}

.action-bar {
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 52px;
    font-size: 15px;
    background-color: #fff;
    border-top: 1px solid #ddd;
}

.g-selector {
    float: left;
    width: 70px;
    margin-left: 4%;
    height: 52px;
    cursor: pointer;
}

.g-selector .item-selector {
    position: relative;
    display: inline-block;
}

.g-selector span {
    position: absolute;
    margin-left: 20px;
    color: #5F646E;
    top: 15px;
}

.total {
    float: right;
    color: #363636;
    font-size: 14px;
    line-height: 50px;
    margin-right: 20px;
}

.total span {
    color: #7A45E5;
}

.total b {
    font-size: 17px;
    margin-left: 4px;
}

.action-btn {
    float: right;
    width: 120px;
    height: 100%;
    color: #fff;
    text-align: center;
    font-weight: 300;
    line-height: 52px;
    cursor: pointer;
}

.buy-btn {
    background-color: #7A45E5;
}

.del-btn {
    display: none;
    background-color: #FF4069;
}

.del-box .total {
    display: none;
}

.del-box .buy-btn {
    display: none;
}

.del-box .del-btn {
    display: block;
}
</style>


  
</head>

<body>
  <div class="g-panel">
    <div class="device" id="page-list">
        <header><span class="header-title">商品列表</span></header>
        <div class="page">
            <div class="tab-wrap">
                <ul class="cate-tab">
                    <li class="cate" v-bind:class="{'tab-active': cate_index === index}" v-for="(item, index) in cate" @click="toggleCate(index)">{{ item.des }}</li>
                </ul>
            </div>
            <ul class="filter-bar">
                <li class="filter-opt" v-bind:class="{'filter-active': filter_index === index, 'filter-price': item.method === 'sortPrice', 'price-down': price_isAsc, 'price-up': !price_isAsc}" v-for="(item, index) in sortMethods" @click="sortBy(item.method)">{{ item.name }}</li>
            </ul>
            <ul class="goods-list">
                <li class="goods-item" v-for="(item, index) in list">
                    <div class="goods-img">
                        <img v-bind:src="item.img" v-bind:alt="item.name">
                        <div class="flag" v-if="item.ishot">热</div>        
                    </div>
                    <div class="goods-info">
                        <p class="goods-title">{{ item.name }}</p>
                        <div class="goods-price">
                            <span>¥<b>{{ item.price }}</b></span>
                        </div>
                        <span class="des">{{ item.sales }}人付款</span>
                        <span class="save" @click="addToCart(item)">+</span>
                    </div>
                </li>
            </ul>
        </div>
    </div>

    <div class="device" id="page-cart">
        <header>
            <span class="header-title">购物清单</span>
            <span class="header-edit" @click="toggleDelBtn">
                <span v-show="!delFlag">编辑</span>
                <span v-show="delFlag">完成</span>
            </span>
        </header>
        <div class="page">
            <div class="empty-states" v-if="cart.length === 0">
                <span>这里是空的,快去逛逛吧</span>    
            </div>
            <ul class="goods-list cart-list" v-else>

                <li class="goods-item" v-for="(item, index) in cart">
                    <div class="item-selector">
                        <div class="icon-selector" v-bind:class="{'selector-active': item.checked}" @click="selectGoods(item)">
                            <svg t="1504061791962" class="icon" style="" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2922" xmlns:xlink="http://www.w3.org/1999/xlink" width="12" height="12">
                                <path d="M908.288 127.488l-537.6 537.6-254.976-254.976L0 525.824l254.976 254.976 115.712 115.712L486.4 780.8l537.6-537.6z"
                                    fill="#ffffff" p-id="2923"></path>
                            </svg>
                        </div>
                    </div>
                    <div class="goods-img">
                        <img v-bind:src="item.img" v-bind:alt="item.name">
                    </div>
                    <div class="goods-info">
                        <p class="goods-title">{{ item.name }}</p>
                        <div class="goods-price">
                            <span>¥<b>{{ item.price }}</b></span>
                        </div>
                        <span class="des">库存{{ item.stock }}件</span>
                        <div class="goods-num">
                            <div class="num-btn" @click="changeQty(true, item)">+</div>
                            <div class="show-num">{{ item.quantity }}</div>
                            <div class="num-btn" @click="changeQty(false, item)">-</div>
                        </div>
                    </div>
                </li>
            </ul>

        </div>
        <div class="action-bar" v-bind:class="{ 'del-box': delFlag }">
            <!-- del-box -->
            <div class="g-selector" @click="checkAll">
                <div class="item-selector">
                    <div class="icon-selector" v-bind:class="{'selector-active': checkAllFlag}">
                        <svg t="1504061791962" cla.........完整代码请登录后点击上方下载按钮下载查看

网友评论0