Ver código fonte

Merge branch 'dongyuan' of http://gogs.efunbox.cn:3000/Rorschach/reader into dongyuan

Rorschach 6 anos atrás
pai
commit
8e4e92e267
2 arquivos alterados com 12 adições e 8 exclusões
  1. 11 7
      pages/user/myEdit/myEdit.js
  2. 1 1
      pages/user/myEdit/myEdit.wxml

+ 11 - 7
pages/user/myEdit/myEdit.js

@@ -32,15 +32,19 @@ Page({
     });
   },
   radioSetting:function(e){
-    var occupations = this.data.occupations;
-    var index = e.currentTarget.dataset.index;
-    var arr = occupations.filter(item => {
-      if (item.status){
-        return item.checked = true;
+    let occupations = this.data.occupations;
+    let index = e.currentTarget.dataset.index;
+    for (let i = 0; i < occupations.length;i++){
+      let state = index;//缓存 用户当前点击的索引。
+      if (occupations[state].checked){
+        occupations[state].checked = false;
       }
-    });
+      else{
+        occupations[state].checked = true;
+      }
+    }
     this.setData({
-      occupations: arr
+      occupations: occupations
     });
     console.log(occupations);
   },

+ 1 - 1
pages/user/myEdit/myEdit.wxml

@@ -29,7 +29,7 @@
         <view class='radio-box' wx:for='{{ occupations }}' wx:key='{{ index }}' data-index='{{ index }}' bindtap='radioSetting'>
           <view>{{ item.occupation }}</view>
           <view class='radio'>
-            <view class='circle' wx:if='{{ item.bool === item.bool && item.checked }}'></view>
+            <view class='circle' wx:if='{{ item.status === index && item.checked }}'></view>
           </view>
         </view>
       </view>