Просмотр исходного кода

fix(frontend): 详情页规格选择用/,按钮始终可点

asus 1 месяц назад
Родитель
Сommit
5afdd251b6
1 измененных файлов с 5 добавлено и 15 удалено
  1. 5 15
      cfc-frontend/pages/discover-detail/product-detail/product-detail.vue

+ 5 - 15
cfc-frontend/pages/discover-detail/product-detail/product-detail.vue

@@ -114,9 +114,9 @@
       </view>
       <view class="action-right">
         <view class="action-extra">
-          <button class="btn-cart" :class="buyButtonDisabled ? 'btn-disabled' : ''" :disabled="buyButtonDisabled" @click="onAddToCart">{{ buyButtonDisabled ? '请选规格' : '加入购物车' }}</button>
+          <button class="btn-cart" @click="onAddToCart">加入购物车</button>
         </view>
-        <button class="btn-buy" :class="buyButtonDisabled ? 'btn-disabled' : ''" :disabled="buyButtonDisabled" @click="onBuy">{{ buyButtonText }}</button>
+          <button class="btn-buy" @click="onBuy">{{ buyButtonText }}</button>
       </view>
     </view>
 
@@ -258,10 +258,9 @@ export default {
       return this.product.stock || 0
     },
     buyButtonDisabled: function() {
-      return this.hasSku && !this.allSpecsSelected
+      return false
     },
     buyButtonText: function() {
-      if (this.hasSku && !this.allSpecsSelected) return '请选择完整规格'
       return '立即购买'
     }
   },
@@ -392,13 +391,12 @@ export default {
 
     selectSpec: function(groupId, option) {
       if (this.selectedSpecs[groupId] === option.id) {
-        delete this.selectedSpecs[groupId]
+        this.$delete(this.selectedSpecs, groupId)
         this.selectedSku = null
       } else {
-        this.selectedSpecs[groupId] = option.id
+        this.$set(this.selectedSpecs, groupId, option.id)
         this.matchSku()
       }
-      this.$forceUpdate()
     },
 
     matchSku: function() {
@@ -486,10 +484,6 @@ export default {
     },
 
     onBuy: function() {
-      if (this.buyButtonDisabled) {
-        uni.showToast({ title: '请选择完整规格', icon: 'none' })
-        return
-      }
       var userId = uni.getStorageSync('userId')
       if (!userId) {
         uni.navigateTo({ url: '/pages/login/login' })
@@ -519,10 +513,6 @@ export default {
       })
     },
     onAddToCart: function() {
-      if (this.buyButtonDisabled) {
-        uni.showToast({ title: '请选择完整规格', icon: 'none' })
-        return
-      }
       var userId = uni.getStorageSync('userId')
       if (!userId) {
         uni.navigateTo({ url: '/pages/login/login' })