MrShi
18 小时以前 e4f9739d74323aacf09d139700f22a383910ee97
mini-program/pages/mall/mall.vue
@@ -8,19 +8,19 @@
               <text>商城</text>
               <view class="head-search-input">
                  <u-search placeholder="搜索商品" height="30" searchIconColor="#999999" borderColor="#eeeeee"
                     bgColor="rgba(255,255,255,0.9)" @custom="search" :showAction="false" v-model="form.goodsName" @search="search" />
                     bgColor="rgba(255,255,255,0.9)" @clear="search" :showAction="false" v-model="form.goodsName" @search="search" />
               </view>
            </view>
            <view class="head-tabs">
               <u-tabs lineColor="#E4001D" :list="list" @click="clickCate"></u-tabs>
               <u-tabs lineColor="#E4001D" :itemStyle="{ height: '100rpx' }" :list="list" @click="clickCate"></u-tabs>
            </view>
         </view>
         
         <view class="head-list">
            <view class="head-list-item" @click="openSearch(1)">
               <text :style="form.sortInfo ? 'color: #222222; font-weight: 500;' : ''">{{form.sortName}}</text>
               <u-icon name="arrow-down" color="#222222" size="13" v-if="form.sortInfo && !show"></u-icon>
               <u-icon name="arrow-up" color="#222222" size="13" v-else-if="form.sortInfo && show === 1"></u-icon>
               <text :style="String(form.sortInfo) ? 'color: #222222; font-weight: 500;' : ''">{{form.sortName}}</text>
               <u-icon name="arrow-down" color="#222222" size="13" v-if="String(form.sortInfo) && !show"></u-icon>
               <u-icon name="arrow-up" color="#222222" size="13" v-else-if="String(form.sortInfo) && show === 1"></u-icon>
               <u-icon name="arrow-down" color="#777777" size="13" v-else></u-icon>
            </view>
            <view class="head-list-item" @click="openSearch(2)">
@@ -44,8 +44,9 @@
            </view>
         </view>
         <!-- 品牌 -->
         <view class="list" style="padding-top: 30rpx; box-sizing: border-box; justify-content: flex-start;" v-if="show === 2">
         <view class="list" style="padding-top: 30rpx; box-sizing: border-box;" v-if="show === 2">
            <view :class="item.active ? 'list-cate active' : 'list-cate'" v-for="(item, index) in pingpai" :key="index" @click="getXiLie(item.id, index)">{{item.name}}</view>
            <view style="width: 216rpx; height: 0;"></view>
         </view>
         <!-- 系列 -->
         <view class="list" v-if="show === 3">
@@ -57,7 +58,7 @@
      </view>
      <view class="commodity">
         <view class="commodity-wu" v-if="goodsList.length === 0">
            <image src="/static/images/default_search@2x.png" mode="widthFix"></image>
            <image src="/static/images/default_nodata_white.png" mode="widthFix"></image>
         </view>
         <view class="commodity-item" v-else v-for="(item, i) in goodsList" :key="i" @click="jumpDetails(item.id)">
            <view class="commodity-item-image">
@@ -77,19 +78,24 @@
                  </view>
               </view>
               <view class="commodity-item-shou">
                  <text>已售{{item.saleNum + item.realSaleNum}}</text>
<<<<<<< HEAD
                  <text>已售{{item.shou}}</text>
=======
                  <text>已售{{(item.saleNum ||0)+ (item.realSaleNum||0)}}</text>
>>>>>>> 7b09a9950f13521190a4aef9bbc2a6163445566c
                  <view class="commodity-item-shou-add" @click.stop="addCard(item)">+</view>
               </view>
            </view>
         </view>
      </view>
      <view class="cart">
      <view class="cart" @click="jumpCart">
         <view class="cart-box">
            <image src="/static/icon/ic_cart@2x.png" mode="widthFix"></image>
            <text>购物车</text>
            <view class="cart-num">{{cardTotal}}</view>
            <view class="cart-num" v-if="cardTotal>0">{{cardTotal}}</view>
         </view>
      </view>
      <Login ref="login" />
   </view>
</template>
@@ -97,9 +103,11 @@
   import {
      mapState
   } from 'vuex'
   import Login from '@/components/login/login.vue'
   export default {
      components: { Login },
      computed: {
         ...mapState(['navHeight', 'statusbarHeight'])
         ...mapState(['navHeight', 'statusbarHeight', 'userInfo'])
      },
      watch: {
         paixu: {
@@ -165,14 +173,28 @@
         };
      },
      onLoad() {
         this.getCartNum()
         this.getLabels()
         this.getGoodsList()
      },
      async onShow() {
         await this.$onLaunched;
         if (this.userInfo) {
            this.getCartNum()
         }
      },
      onReachBottom() {
         this.getGoodsList()
      },
      methods: {
         jumpCart() {
            if (!this.userInfo) {
               this.$refs.login.open()
               return;
            }
            uni.navigateTo({
               url: '/pages/shopping-cart/shopping-cart'
            })
         },
         getCartNum() {
            this.$u.api.cartGoodsTypeNum()
               .then(res => {
@@ -188,13 +210,17 @@
            this.getGoodsList()
         },
         addCard(e) {
            if (!this.userInfo) {
               this.$refs.login.open()
               return;
            }
            this.$u.api.addCart({
               goodsId: e.id,
               goodsSkuId: e.skuResponsesList[0].id,
               goodsSkuId: e.goodsSkuResponseList[0].id,
               num: 1
            }).then(res => {
               if (res.code === 200) {
                  uni.showToast({ title: '添加成功', icon: 'success' })
                  uni.showToast({ title: '添加成功', icon: 'success', mask: true })
                  this.getCartNum()
               }
            })
@@ -215,6 +241,7 @@
               if (res.code === 200) {
                  res.data.records.forEach(item => {
                     item.minPrice = item.minPrice.toFixed(2).split('.')
                     item.shou = (item.salenum || 0) + (item.realSaleNum || 0)
                  })
                  this.goodsList.push(...res.data.records)
                  this.page++
@@ -246,6 +273,8 @@
         },
         // 系列
         getXiLie(parentId, i) {
            this.form.seriesBrandId = ''
            this.form.seriesBrandName = ''
            this.xilie = []
            this.pingpai.forEach((item, index) => {
               item.active = index === i
@@ -395,11 +424,13 @@
            .commodity-item-image {
               width: 100%;
               height: 336rpx;
               overflow: hidden;
               display: flex;
               align-items: center;
               justify-content: center;
               image {
                  width: 100%;
                  max-height:330rpx;
               }
            }
            .commodity-item-box {
@@ -407,6 +438,11 @@
               padding: 20rpx;
               box-sizing: border-box;
               .commodity-item-box-title {
                  width: 100%;
                  display: -webkit-box;
                  -webkit-box-orient: vertical;
                  -webkit-line-clamp: 2;
                  overflow: hidden;
                  font-weight: 600;
                  font-size: 30rpx;
                  color: #222222;
@@ -497,8 +533,8 @@
            .head-tabs {
               width: 100%;
               height: 100rpx;
               display: flex;
               align-items: flex-end;
               // display: flex;
               // align-items: flex-end;
               border-bottom: 1rpx solid #E5E5E5;
            }
         }
@@ -528,10 +564,10 @@
               font-size: 28rpx;
               color: #333333;
               margin-bottom: 24rpx;
               margin-right: 20rpx;
               &:last-child {
                  margin-right: 0 !important;
               }
               // margin-right: 20rpx;
               // &:last-child {
               //    margin-right: 0 !important;
               // }
            }
            .red {
               text {