Explorar o código

颜选美学v1.3测试bug修改

yuwenjun1997 %!s(int64=2) %!d(string=hai) anos
pai
achega
59886d3f1f

+ 2 - 2
components/views/cm-cart-product/cm-cart-product.vue

@@ -20,9 +20,9 @@
                 </view>
                 <view class="price">
                     <text>¥{{ productInfo.price | priceFormat }}</text>
-                    <!-- <text class="delete" v-if="productInfo.normalPrice">
+                    <text class="delete" v-if="productInfo.normalPrice">
                         ¥{{ productInfo.normalPrice | priceFormat }}
-                    </text> -->
+                    </text>
                 </view>
                 <cm-number-box class="numberbox" v-model="productInfo.num" @change="change"></cm-number-box>
             </template>

+ 2 - 2
components/views/cm-drag/cm-drag.vue

@@ -3,9 +3,9 @@
         id="_drag_button"
         class="cart-icon"
         :style="'left: ' + left + 'px; top:' + top + 'px;'"
-        @touchstart.stop="touchstart"
+        @touchstart="touchstart"
         @touchmove.stop.prevent="touchmove"
-        @touchend.stop="touchend"
+        @touchend="touchend"
         @click.stop.prevent="click"
         :class="{ transition: isDock && !isMove }"
     >

+ 36 - 27
components/views/cm-number-box/cm-number-box.vue

@@ -1,7 +1,7 @@
 <template>
     <view class="number-box">
         <view class="sub" @click="onSub" :class="{ disabled: subDisabled }"></view>
-        <input type="number" class="control-input" v-model="inputValue" @blur="onBlur" />
+        <input type="number" class="control-input" :value="value" @input="onInput" />
         <view class="add" @click="onAdd" :class="{ disabled: addDisabled }"></view>
     </view>
 </template>
@@ -23,51 +23,60 @@ export default {
         },
         value: {
             type: Number,
-            default: 0
-        }
-    },
-    data() {
-        return {
-            inputValue: ''
+            default: 1
         }
     },
     computed: {
         addDisabled() {
-            return this.inputValue === this.max
+            return this.value === this.max
         },
         subDisabled() {
-            return this.inputValue === this.min
+            return this.value === this.min
         }
     },
     watch: {
-        inputValue(nVal) {
-            this.$emit('input', parseInt(this.inputValue))
+        value(nval) {
+            console.log(nval)
         }
     },
-    created() {
-        this.inputValue = this.value
-    },
     methods: {
-        onBlur() {
-            if (this.inputValue < this.min) this.inputValue = this.min
-            if (this.inputValue > this.max) this.inputValue = this.max
-            this.$emit('change', this.inputValue)
-        },
         // 减法
         onSub() {
-            if (this.inputValue <= this.min) {
-                return
+            if (this.subDisabled) return
+            let inputValue = this.value
+            if (inputValue <= this.min) {
+                inputValue = this.min
+            } else {
+                inputValue--
             }
-            this.inputValue--
-            this.$emit('change', this.inputValue)
+            this.$emit('input', inputValue)
+            this.$emit('change', inputValue)
         },
         // 加法
         onAdd() {
-            if (this.inputValue >= this.max) {
-                return
+            if (this.addDisabled) return
+            let inputValue = this.value
+            if (inputValue >= this.max) {
+                inputValue = this.max
+            } else {
+                inputValue++
+            }
+            this.$emit('input', inputValue)
+            this.$emit('change', inputValue)
+        },
+        // 失去焦点
+        onInput(e) {
+            let inputValue = parseInt(e.detail.value)
+            if (isNaN(inputValue)) {
+                inputValue = this.min
+            }
+            if (inputValue < this.min) {
+                inputValue = this.min
+            } else if (inputValue > this.max) {
+                inputValue = this.max
             }
-            this.inputValue++
-            this.$emit('change', this.inputValue)
+            this.$emit('input', inputValue)
+            this.$emit('change', inputValue)
         }
     }
 }

+ 1 - 1
pages/tabBar/home/home.vue

@@ -270,7 +270,7 @@ export default {
                     name: '分享券福利'
                 }
             ]
-            return result.filter(item => this.userId > 0 && this.couponTipStr.indexOf(item.id.toString()) > -1)
+            return result.filter(item => this.couponTipStr.indexOf(item.id.toString()) > -1)
         },
 
         // 分享

+ 3 - 1
pages/views/activity/activity-detail.vue

@@ -40,7 +40,7 @@
 
         <!-- 分享弹窗 -->
         <cm-share-popup ref="sharePopup" :data="posterData" type="activity"></cm-share-popup>
-        
+
         <!-- 返回顶部 -->
         <tui-scroll-top
             :scrollTop="scrollTop"
@@ -84,6 +84,7 @@ export default {
         this.listQuery.listType = 6
         this.activityName = option.name
         this.fetchProductList()
+        this.$store.dispatch('cart/fetchCartKindCount')
     },
     computed: {
         ...mapGetters(['userId', 'kindCount']),
@@ -160,6 +161,7 @@ export default {
 
         // 跳转购物车
         btnClick() {
+            console.log('购物车')
             this.$router.navigateTo('cart/cart')
         }
     }

+ 1 - 1
pages/views/coupon/coupon-receive.vue

@@ -14,7 +14,7 @@
             </view>
         </view>
         <!-- 优惠券说明 -->
-        <coupon-desc-entry @click="toDescDetail" v-if="userId" :couponTipStr="couponTipStr"></coupon-desc-entry>
+        <coupon-desc-entry @click="toDescDetail" :couponTipStr="couponTipStr"></coupon-desc-entry>
         <!-- 加载更多 -->
         <cm-loadmore :hasMore="hasNextPage" :isLoading="isLoading" :visiable="visiable"></cm-loadmore>
         <!-- 占位 -->

+ 4 - 4
pages/views/goods/commons/helper.js

@@ -21,10 +21,10 @@ export function generateActivityType(productData) {
 
 // 获取产品价格类型
 export function generatePriceType(productData) {
-    const { couponStatus = 0, collageStatus = 0, activeStatus = 0, discountStatus = 0 } = productData
+    const { couponStatus = 0, collageStatus = 0, activeStatus = 0, discountStatus = 0, couponId } = productData
     // 拼团价
     if (collageStatus > 0) {
-        if (couponStatus === 1) {
+        if (couponStatus === 1 && couponId) {
             return 'groupWithCoupon' // 拼团券后价
         } else {
             return 'group' // 拼团价
@@ -32,7 +32,7 @@ export function generatePriceType(productData) {
     }
     // 限时活动
     else if (discountStatus > 0 || activeStatus > 0) {
-        if (couponStatus === 1) {
+        if (couponStatus === 1 && couponId) {
             return 'activityWithCoupon' // 券后价
         } else {
             return 'normal' // 限时活动价格
@@ -40,7 +40,7 @@ export function generatePriceType(productData) {
     }
     // 无活动价
     else {
-        if (couponStatus === 1) {
+        if (couponStatus === 1 && couponId) {
             return 'normalWithCoupon' // 普通券后价
         } else {
             return 'normal' // 普通价

+ 12 - 9
pages/views/goods/components/goods-receive-buy-popup/goods-receive-buy-popup.vue

@@ -11,7 +11,11 @@
                         <view class="row">
                             <view class="count">
                                 <view class="label">数量</view>
-                                <cm-number-box class="number-box" v-model="count" :max="limitedNum"></cm-number-box>
+                                <cm-number-box
+                                    class="number-box"
+                                    v-model.lazy="count"
+                                    :max="limitedNum"
+                                ></cm-number-box>
                             </view>
                             <view
                                 class="clickable"
@@ -35,13 +39,13 @@
                             </template>
                         </view>
                         <!-- 券后价 -->
-                        <view class="row" v-if="productData.couponStatus === 1">
+                        <view class="row" v-if="productData.couponStatus === 1 && productData.couponId">
                             <view class="tag-qh">券后价¥{{ productData.couponPrice | priceFormat }}</view>
                         </view>
                     </view>
                 </view>
                 <view class="tip">
-                    <template v-if="productData.couponStatus > 0">
+                    <template v-if="productData.couponStatus > 0 && productData.couponId">
                         当前商品可使用
                         <text v-text="couponTip"></text>
                         优惠券
@@ -49,7 +53,7 @@
                 </view>
                 <tui-button type="base" width="600rpx" height="90rpx" shape="circle" @click="$emit('submit', count)">
                     <template v-if="navbarType === 'buy'">
-                        <text v-if="productData.couponStatus === 1">领券购买</text>
+                        <text v-if="productData.couponStatus === 1 && productData.couponId">领券购买</text>
                         <text v-else>立即购买</text>
                     </template>
                     <template v-else>
@@ -104,12 +108,11 @@ export default {
             return this.productData.stock
         }
     },
-    watch: {
-        count() {
-            console.log(this.count, typeof this.count)
-        }
-    },
     methods: {
+        onNumberChange(num) {
+            this.count = num
+        },
+
         open() {
             this.$refs.popup.open()
             this.$emit('open')

+ 15 - 8
pages/views/goods/goods-detail.vue

@@ -152,7 +152,7 @@ export default {
             posterData: {},
             collageId: '',
             groupBuyFlag: false, // 用户是否拼团购买
-            autoplay: true,
+            autoplay: true
         }
     },
     computed: {
@@ -249,13 +249,20 @@ export default {
 
         // 优惠券点击事件
         onCouponClick(couponData) {
-            const coupon = { ...couponData }
-            if (coupon.controlType === 'receive') {
-                const index = this.couponList.findIndex(item => item.couponId === coupon.couponId)
-                this.couponList.splice(index, 1)
-                coupon.controlType = 'buy'
-                coupon.couponStatus = 'received'
-                this.$set(this.couponList, index, coupon)
+            if (couponData.controlType === 'receive') {
+                // const index = this.couponList.findIndex(item => item.couponId === coupon.couponId)
+                // this.couponList.splice(index, 1)
+                // coupon.controlType = 'buy'
+                // coupon.couponStatus = 'received'
+                // this.$set(this.couponList, index, coupon)
+                this.fetchCouponList()
+                // this.couponList = this.couponList.map(coupon => {
+                //     if (coupon.couponId === couponData.couponId) {
+                //         coupon.controlType = 'search'
+                //         coupon.couponStatus = 'received'
+                //     }
+                //     return coupon
+                // })
             }
         },
 

+ 4 - 1
pages/views/order/components/order-product/order-product.vue

@@ -18,7 +18,7 @@
             <view class="price">¥{{ productInfo.price | priceFormat }}</view>
             <view class="buy-num" v-if="numType === 1">×{{ productInfo.num }}</view>
             <view class="buy-num" v-if="numType === 2">
-                <cm-number-box v-model="productInfo.num" @change="onCountChange"></cm-number-box>
+                <cm-number-box v-model="productInfo.num" @change="onCountChange" :max="limitedNum"></cm-number-box>
             </view>
         </view>
     </view>
@@ -56,6 +56,9 @@ export default {
         // 限时特价
         isDiscountPrice() {
             return this.productInfo.discountStatus > 0 || this.productInfo.actProduct === '3'
+        },
+        limitedNum() {
+            return this.productInfo?.limitedNum
         }
     },
     methods: {