Browse Source

fix[litemall-wx]: 原代码中如果规格没有选择完毕,那么商品页面会出现不完全的规格文本。现在checkedSpecText显示完整的规格文本,而tmpSpecText显示用户点击时部分规格文本。

Junling Bu 7 years ago
parent
commit
37b7d03dcd
2 changed files with 20 additions and 7 deletions
  1. 19 6
      litemall-wx/pages/goods/goods.js
  2. 1 1
      litemall-wx/pages/goods/goods.wxml

+ 19 - 6
litemall-wx/pages/goods/goods.js

@@ -18,7 +18,8 @@ Page({
     cartGoodsCount: 0,
     userHasCollect: 0,
     number: 1,
-    checkedSpecText: '请选择规格数量',
+    checkedSpecText: '规格数量',
+    tmpSpecText: '请选择规格数量',
     openAttr: false,
     noCollectImage: '/static/images/icon_collect.png',
     hasCollectImage: '/static/images/icon_collect_checked.png',
@@ -35,7 +36,8 @@ Page({
           if (_specificationList[0].valueList.length == 1) {
             _specificationList[0].valueList[0].checked = true
             that.setData({
-              checkedSpecText: '已选择:' + _specificationList[0].valueList[0].value
+              checkedSpecText: _specificationList[0].valueList[0].value,
+              tmpSpecText: '已选择:' + _specificationList[0].valueList[0].value
             });
           }
         }
@@ -105,7 +107,7 @@ Page({
       }
     }
     this.setData({
-      specificationList: _specificationList
+      specificationList: _specificationList,
     });
     //重新计算spec改变后的信息
     this.changeSpecInfo();
@@ -132,7 +134,6 @@ Page({
     }
 
     return checkedValues;
-
   },
   //根据已选的值,计算其它值的状态
   setSpecValueStatus: function () {
@@ -168,11 +169,23 @@ Page({
     });
     if (checkedValue.length > 0) {
       this.setData({
-        checkedSpecText: checkedValue.join(' ')
+        tmpSpecText: checkedValue.join(' ')
       });
     } else {
       this.setData({
-        checkedSpecText: '请选择规格数量'
+        tmpSpecText: '请选择规格数量'
+      });
+    }
+
+
+    if (this.isCheckedAllSpec()) {
+      this.setData({
+        checkedSpecText: this.data.tmpSpecText
+      });
+    }
+    else{
+      this.setData({
+        checkedSpecText: '规格数量'
       });
     }
 

+ 1 - 1
litemall-wx/pages/goods/goods.wxml

@@ -106,7 +106,7 @@
       <view class="info">
         <view class="c">
           <view class="p">价格:¥{{goods.retailPrice}}</view>
-          <view class="a">{{checkedSpecText}}</view>
+          <view class="a">{{tmpSpecText}}</view>
         </view>
       </view>
     </view>