7UQPV1X6D0Z54SW\Administrator преди 4 години
родител
ревизия
591b9a61f7

+ 15 - 13
client/pages/servant/servantsettings/servantsettings.acss

@@ -26,7 +26,7 @@
 .setting-list{
   background: #FFFFFF;
   border-radius: 18px;
-  margin: 25.99rpx 24rpx 120rpx 24rpx;
+  margin: 25.99rpx 24rpx 20rpx 24rpx;
 }
 .setting-list-title{
   color: #333333;
@@ -60,18 +60,7 @@
   margin-bottom: 24rpx;
   padding-left: 20rpx;
 }
-.item-body-checkbox{
-  width: 24rpx;
-  height: 24rpx;
-  border-radius: 2rpx;
-  border: 1rpx solid #D7DBE0;
-}
-.item-body-checkbox:before{
-  width: 24rpx;
-  height: 24rpx;
-  border-radius: 2rpx;
-  border: 1rpx solid #09AFFF;
-}
+
 .item-body textarea{
   background-color: #EEEEEE;
   border: none;
@@ -82,4 +71,17 @@
   font-size: 24rpx;
   padding: 12rpx;
   width: 80%;
+}
+.checkbox {
+  display: block;
+  margin-bottom: 20rpx;
+}
+
+button + button {
+  margin-top: 32rpx;
+}
+
+.checkbox-text {
+  font-size:34rpx;
+  line-height: 1.2;
 }

+ 7 - 4
client/pages/servant/servantsettings/servantsettings.axml

@@ -13,12 +13,15 @@
     <view class="setting-list-item" a:for="{{item.subjectList}}" a:for-item="subjectitem" key="{{subjectindex}}">
       <view  a:if="{{subjectitem.isChoose}}">
         <text class="item-title">{{subjectitem.subject}}</text>
-        <view class="item-body" a:for="{{subjectitem.answer}}" a:for-item="answeritem" key="{{answerindex}}">
-          <checkbox value="{{answeritem.answer}}" checked="{{answeritem.isChoose}}" onChange="answerselected" class="item-body-checkbox"/><text>{{answeritem.answer}}</text>
-        </view>
+         <checkbox-group onChange="answerselected"  data-id="{{subjectitem.subjectId}}">
+          <label class="checkbox" a:for="{{subjectitem.answer}}"  a:for-item="answeritem" key="label-{{answerindex}}">
+            <checkbox value="{{answeritem.answer}}" checked="{{answeritem.isChoose}}" />
+            <text class="checkbox-text">{{answeritem.answer}}</text>
+          </label>
+        </checkbox-group>
       </view>
       <view class="item-body">
-        <textarea placeholder="请输入文字"></textarea>
+        <textarea placeholder="请输入文字" onBlur="customanswer" data-id="{{subjectitem.subjectId}}">{{subjectitem.customAnswer}}</textarea>
       </view>
     </view>
   </view>

+ 48 - 3
client/pages/servant/servantsettings/servantsettings.js

@@ -13,7 +13,7 @@ Page({
   },
   getservantlist(subjectType){
      request.httpServiceGet(apiUrl.servantappletservicePath,{subjectType:subjectType}).then(data=>{
-        console.log(data);
+        //console.log(data);
         this.setData({
           servantlist: data
         });
@@ -41,8 +41,53 @@ Page({
       });
   },
   answerselected(e){
-      let checkeditem=e.detail.value;
-      console.log(checkeditem);
+    //console.log(e.target.dataset.id);
+    //console.log(e.detail.value);
+
+    let checkedlist=e.detail.value;
+    let servantlist=this.data.servantlist;
+    //先做清除
+    for(let i=0;i<servantlist.length;i++){
+        for(let j=0;j<servantlist[i].subjectList.length;j++){
+          if(servantlist[i].subjectList[j].subjectId==e.target.dataset.id){
+            for(let t=0;t<servantlist[i].subjectList[j].answer.length;t++){
+                servantlist[i].subjectList[j].answer[t].isChoose=0;
+            }
+          }
+        }
+    }
+    //添加选中
+    for(let i=0;i<servantlist.length;i++){
+        for(let j=0;j<servantlist[i].subjectList.length;j++){
+          if(servantlist[i].subjectList[j].subjectId==e.target.dataset.id){
+            for(let t=0;t<servantlist[i].subjectList[j].answer.length;t++){
+              for(let u=0;u<checkedlist.length;u++){
+                if(checkedlist[u]==servantlist[i].subjectList[j].answer[t].answer){
+                  servantlist[i].subjectList[j].answer[t].isChoose=1;
+                }
+              }
+            }
+          }
+        }
+    }
+    this.setData({
+      servantlist: servantlist
+    })
+  },
+  customanswer(e){
+    console.log(e.target.dataset.id);
+    let servantlist=this.data.servantlist;
+    for(let i=0;i<servantlist.length;i++){
+        for(let j=0;j<servantlist[i].subjectList.length;j++){
+          if(servantlist[i].subjectList[j].subjectId==e.target.dataset.id){
+              servantlist[i].subjectList[j].customAnswer = e.detail.value;
+              break;
+           }
+        }
+    }
+    this.setData({
+      servantlist: servantlist
+    })
   },
 });