Przeglądaj źródła

自定义分类选择页面优化

zhaoxiaohai 2 lat temu
rodzic
commit
6bd8a07834
2 zmienionych plików z 10 dodań i 5 usunięć
  1. 3 1
      packageA/options/index.js
  2. 7 4
      packageA/options/index.wxml

+ 3 - 1
packageA/options/index.js

@@ -10,9 +10,10 @@ Page({
     },
     onLoad(options) {
         let item = JSON.parse(options.data);
+        console.log(item)
         this.setData({
             item,
-            result: item.value ? [item.value] : []
+            result: item.value ? Array.isArray(item.value) ? item.value : [item.value] : []
         })
         this.getList();
     },
@@ -35,6 +36,7 @@ Page({
             this.setData({
                 result: [item.value]
             })
+            this.submit();
         }
     },
     getList(init = false) {

+ 7 - 4
packageA/options/index.wxml

@@ -6,7 +6,10 @@
     </van-cell-group>
 </van-checkbox-group>
 <My_empty wx:if="{{list.length==0}}" />
-<view style="height: 130rpx;" />
-<view class="new-footer">
-    <van-button custom-class='new-submit' disabled='{{!result.length}}' bindclick='submit'>提交</van-button>
-</view>
+
+<block wx:if="{{item.optionType == 'checkbox'}}">
+    <view style="height: 130rpx;" />
+    <view class="new-footer">
+        <van-button custom-class='new-submit' disabled='{{!result.length}}' bindclick='submit'>提交</van-button>
+    </view>
+</block>