roose 5 年之前
父節點
當前提交
c25d00e9c9

+ 60 - 26
pages/answerAfterclass/answerAfterclass.js

@@ -59,14 +59,16 @@ Page({
     json.currentAnswer = e.detail.value;
     json.id = e.currentTarget.dataset.idx;
     json.questType = e.currentTarget.dataset.questtypes;
-    console.log("题目", this.data.questionList)
     this.data.chooseValue[this.data.index] = json;
-    this.data.questionList[this.data.index].checked = e.detail.value;
-
+    const items = this.data.questionList[this.data.index].QuestChoice
+    for (let i = 0, len = items.length; i < len; ++i) {
+      items[i].checked = items[i].value === e.detail.value
+    }
+    console.log( this.data.chooseValue,"尅额么");
+    console.log(this.data.questionList);
     this.setData({
       questionList: this.data.questionList
     })
-
     wx.setStorageSync('questionList' + wx.getStorageSync('answersId'), this.data.questionList);
     wx.setStorageSync('titleINDEX' + wx.getStorageSync('answersId'), this.data.index);
     wx.setStorageSync('chooseValue' + wx.getStorageSync('answersId'), this.data.chooseValue);
@@ -205,25 +207,25 @@ Page({
   //   })
 
   // }
-  onShow: function () {
-    console.log("show0000000000000000000000000000000000000000000000000000000000000000000000");
-    console.log(wx.getStorageSync('answersId'),"onshow  的 answeid");
-    // console.log(wx.getStorageSync('questionList'+((wx.getStorageSync('answersId'))),"78978978979877777");
-    if (wx.getStorageSync('questionList'+wx.getStorageSync('answersId'))) {
-      console.log("缓村了锕");
-      const questionList = wx.getStorageSync('questionList'+wx.getStorageSync('answersId'));
-      this.setData({
-        questionList: questionList,
-        index: wx.getStorageSync('titleINDEX'+wx.getStorageSync('answersId')),
-        answersId: wx.getStorageSync('answersId'+wx.getStorageSync('answersId')),
-        chooseValue:wx.getStorageSync('chooseValue'+wx.getStorageSync('answersId')),
-      })
-      console.log(this.data.questionList,"show 缓存的数据");
-    }else{
-      this.allShi(this.data.id, this.data.paperId, this.data.sessionKey);
-      console.log(this.data.questionList,"show 没有缓存");
-    }
-  },
+  // onShow: function () {
+  //   console.log("show0000000000000000000000000000000000000000000000000000000000000000000000");
+  //   console.log(wx.getStorageSync('answersId'),"onshow  的 answeid");
+  //   // console.log(wx.getStorageSync('questionList'+((wx.getStorageSync('answersId'))),"78978978979877777");
+  //   if (wx.getStorageSync('questionList'+wx.getStorageSync('answersId'))) {
+  //     console.log("缓村了锕");
+  //     const questionList = wx.getStorageSync('questionList'+wx.getStorageSync('answersId'));
+  //     this.setData({
+  //       questionList: questionList,
+  //       index: wx.getStorageSync('titleINDEX'+wx.getStorageSync('answersId')),
+  //       answersId: wx.getStorageSync('answersId'+wx.getStorageSync('answersId')),
+  //       chooseValue:wx.getStorageSync('chooseValue'+wx.getStorageSync('answersId')),
+  //     })
+  //     console.log(this.data.questionList,"show 缓存的数据");
+  //   }else{
+  //     this.allShi(this.data.id, this.data.paperId, this.data.sessionKey);
+  //     console.log(this.data.questionList,"show 没有缓存");
+  //   }
+  // },
   async onLoad(options) {
     // //const sessionKey = await tools.checkSessionAndLogin();
     // console.log("onload..................................");
@@ -273,14 +275,19 @@ Page({
     if (wx.getStorageSync('questionList' + wx.getStorageSync('answersId'))) {
       console.log("缓村了锕");
       const questionList = wx.getStorageSync('questionList' + wx.getStorageSync('answersId'));
-
+      const titleINDEX  = wx.getStorageSync('titleINDEX' + wx.getStorageSync('answersId'));
+      const chooseValue  = wx.getStorageSync('chooseValue' + wx.getStorageSync('answersId'));
+      console.log(titleINDEX,"打印下看看");
+      console.log(chooseValue,"choosevalue");
       this.setData({
         questionList: questionList,
         answersId: wx.getStorageSync('answersId'),
-        chooseValue: wx.getStorageSync('chooseValue' + wx.getStorageSync('answersId')),
-        index: wx.getStorageSync('titleINDEX' + wx.getStorageSync('answersId')),
+        chooseValue:chooseValue,
+        index: titleINDEX
       })
+      
       console.log(this.data.questionList, "show 缓存的数据");
+      console.log(this.data.index, "indexindex");
     } else {
       console.log("无缓存");
       this.allShi(options.id, options.paperId, sessionKey);
@@ -320,11 +327,38 @@ Page({
             });
             json.QuestChoice = arrJson;
           }
+          if (item.QuestType == '0') {
+            let arr = item.QuestChoice.split('||');
+            let arrJson = arr.map(item => {
+              let json1 = {};
+              json1.name = item;
+              json1.value = item;
+              json1.checked = false;
+              return json1
+            });
+            json.QuestChoice = arrJson;
+          }
+          if (item.QuestType == '2') {
+            let arr = item.QuestChoice.split('||');
+            let arrJson = arr.map(item => {
+              let json1 = {};
+              json1.name = item;
+              json1.value = item;
+              json1.checked = false;
+              return json1
+            });
+            json.QuestChoice = arrJson;
+          }
+
           return json;
         })
+        console.log(jsonArr);
+        
         this.setData({
           questionList: jsonArr
         })
+        wx.setStorageSync('titleINDEX' + wx.getStorageSync('answersId'),0);
+        wx.setStorageSync('chooseValue' + wx.getStorageSync('answersId'),[]),
         wx.setStorageSync('questionList' + wx.getStorageSync('answersId'), this.data.questionList);
       }
     })

+ 1 - 1
pages/answerAfterclass/answerAfterclass.json

@@ -1,4 +1,4 @@
 {
-  "navigationBarTitleText":"答题测试",
+  "navigationBarTitleText":"答题",
   "usingComponents": {}
 }

+ 5 - 5
pages/answerAfterclass/answerAfterclass.wxml

@@ -38,8 +38,8 @@
 	<view class="qiu"></view>
 </view>
 <radio-group class="parameter-wrap" data-questTypes='{{questionList[index].QuestType}}' data-idx='{{questionList[index].id}}' bindchange="radioChange" wx:if="{{questionList[index].QuestType == 0}}">
-	<label class=" radio my-choosebox  {{ questionList[index].checked == item?'checkboxbox':''}}" wx:for-index="idx" wx:for="{{questionList[index].QuestChoice}}">
-		<radio value="{{item}}" />{{item}}
+	<label class=" radio my-choosebox  {{ item.checked?'checkboxbox':''}}" wx:for-index="idx" wx:for="{{questionList[index].QuestChoice}}"  wx:key="{{item.value}}">
+		<radio value="{{item.value}}" checked="{{item.checked}}" />{{item.name}}
 	</label>
 </radio-group>
 <!-- questionList[index].item.checked  -->
@@ -48,9 +48,9 @@
 		<checkbox value="{{item.value}}" checked="{{item.checked}}" />{{item.name}}
 	</label>
 </checkbox-group>
-<radio-group class="parameter-wrap " data-questTypes='{{questionList[index].QuestType}}' data-idx='{{questionList[index].id}}' bindchange="radioChange" wx:if="{{questionList[index].QuestType == 2}}">
-	<label class=" radio my-choosebox   {{ questionList[index].checked == item?'checkboxbox':''}}" wx:for-index="idx" wx:for="{{questionList[index].QuestChoice}}">
-		<radio value="{{item}}" checked="{{questionList[index].checked == item}}" />{{item}}
+<radio-group class="parameter-wrap" data-questTypes='{{questionList[index].QuestType}}' data-idx='{{questionList[index].id}}' bindchange="radioChange" wx:if="{{questionList[index].QuestType == 2}}">
+	<label class=" radio my-choosebox  {{ item.checked?'checkboxbox':''}}" wx:for-index="idx" wx:for="{{questionList[index].QuestChoice}}"  wx:key="{{item.value}}">
+		<radio value="{{item.value}}" checked="{{item.checked}}" />{{item.name}}
 	</label>
 </radio-group>
 <view wx:if="{{questionList[index].QuestType == 3}}" data-idx='{{questionList[index].id}}'>

+ 52 - 2
pages/answerAfterclasses/answerAfterclasses.js

@@ -71,6 +71,26 @@ Page({
     wx.setStorageSync('titleINDEX' + wx.getStorageSync('answersId'), this.data.index);
     wx.setStorageSync('chooseValue' + wx.getStorageSync('answersId'), this.data.chooseValue);
 
+  }, radioChange: function (e) {
+    console.log('checkbox发生change事件,携带value值为:', e.detail.value)
+    let json = {};
+    json.currentAnswer = e.detail.value;
+    json.id = e.currentTarget.dataset.idx;
+    json.questType = e.currentTarget.dataset.questtypes;
+    this.data.chooseValue[this.data.index] = json;
+    const items = this.data.questionList[this.data.index].QuestChoice
+    for (let i = 0, len = items.length; i < len; ++i) {
+      items[i].checked = items[i].value === e.detail.value
+    }
+    console.log( this.data.chooseValue,"尅额么");
+    console.log(this.data.questionList);
+    this.setData({
+      questionList: this.data.questionList
+    })
+    wx.setStorageSync('questionList' + wx.getStorageSync('answersId'), this.data.questionList);
+    wx.setStorageSync('titleINDEX' + wx.getStorageSync('answersId'), this.data.index);
+    wx.setStorageSync('chooseValue' + wx.getStorageSync('answersId'), this.data.chooseValue);
+
   },
   /*
    * 多选事件
@@ -273,13 +293,19 @@ Page({
     if (wx.getStorageSync('questionList' + wx.getStorageSync('answersId'))) {
       console.log("缓村了锕");
       const questionList = wx.getStorageSync('questionList' + wx.getStorageSync('answersId'));
+      const titleINDEX  = wx.getStorageSync('titleINDEX' + wx.getStorageSync('answersId'));
+      const chooseValue  = wx.getStorageSync('chooseValue' + wx.getStorageSync('answersId'));
+      console.log(titleINDEX,"打印下看看");
+      console.log(chooseValue,"choosevalue");
       this.setData({
         questionList: questionList,
         answersId: wx.getStorageSync('answersId'),
-        chooseValue: wx.getStorageSync('chooseValue' + wx.getStorageSync('answersId')),
-        index: wx.getStorageSync('titleINDEX' + wx.getStorageSync('answersId')),
+        chooseValue:chooseValue,
+        index: titleINDEX
       })
+      
       console.log(this.data.questionList, "show 缓存的数据");
+      console.log(this.data.index, "indexindex");
     } else {
       console.log("无缓存");
       this.allShi(options.id, options.paperId, sessionKey);
@@ -319,11 +345,35 @@ Page({
             });
             json.QuestChoice = arrJson;
           }
+          if (item.QuestType == '0') {
+            let arr = item.QuestChoice.split('||');
+            let arrJson = arr.map(item => {
+              let json1 = {};
+              json1.name = item;
+              json1.value = item;
+              json1.checked = false;
+              return json1
+            });
+            json.QuestChoice = arrJson;
+          }
+          if (item.QuestType == '2') {
+            let arr = item.QuestChoice.split('||');
+            let arrJson = arr.map(item => {
+              let json1 = {};
+              json1.name = item;
+              json1.value = item;
+              json1.checked = false;
+              return json1
+            });
+            json.QuestChoice = arrJson;
+          }
           return json;
         })
         this.setData({
           questionList: jsonArr
         })
+        wx.setStorageSync('titleINDEX' + wx.getStorageSync('answersId'),0);
+        wx.setStorageSync('chooseValue' + wx.getStorageSync('answersId'),[]),
         wx.setStorageSync('questionList' + wx.getStorageSync('answersId'), this.data.questionList);
       }
     })

+ 1 - 1
pages/answerAfterclasses/answerAfterclasses.json

@@ -1,4 +1,4 @@
 {
-  "navigationBarTitleText":"答题测试",
+  "navigationBarTitleText":"答题",
   "usingComponents": {}
 }

+ 5 - 5
pages/answerAfterclasses/answerAfterclasses.wxml

@@ -38,8 +38,8 @@
 	<view class="qiu"></view>
 </view>
 <radio-group class="parameter-wrap" data-questTypes='{{questionList[index].QuestType}}' data-idx='{{questionList[index].id}}' bindchange="radioChange" wx:if="{{questionList[index].QuestType == 0}}">
-	<label class=" radio my-choosebox  {{ questionList[index].checked == item?'checkboxbox':''}}" wx:for-index="idx" wx:for="{{questionList[index].QuestChoice}}">
-		<radio value="{{item}}" />{{item}}
+	<label class=" radio my-choosebox  {{ item.checked?'checkboxbox':''}}" wx:for-index="idx" wx:for="{{questionList[index].QuestChoice}}"  wx:key="{{item.value}}">
+		<radio value="{{item.value}}" checked="{{item.checked}}" />{{item.name}}
 	</label>
 </radio-group>
 <!-- questionList[index].item.checked  -->
@@ -48,9 +48,9 @@
 		<checkbox value="{{item.value}}" checked="{{item.checked}}" />{{item.name}}
 	</label>
 </checkbox-group>
-<radio-group class="parameter-wrap " data-questTypes='{{questionList[index].QuestType}}' data-idx='{{questionList[index].id}}' bindchange="radioChange" wx:if="{{questionList[index].QuestType == 2}}">
-	<label class=" radio my-choosebox   {{ questionList[index].checked == item?'checkboxbox':''}}" wx:for-index="idx" wx:for="{{questionList[index].QuestChoice}}">
-		<radio value="{{item}}" checked="{{questionList[index].checked == item}}" />{{item}}
+<radio-group class="parameter-wrap" data-questTypes='{{questionList[index].QuestType}}' data-idx='{{questionList[index].id}}' bindchange="radioChange" wx:if="{{questionList[index].QuestType == 2}}">
+	<label class=" radio my-choosebox  {{ item.checked?'checkboxbox':''}}" wx:for-index="idx" wx:for="{{questionList[index].QuestChoice}}"  wx:key="{{item.value}}">
+		<radio value="{{item.value}}" checked="{{item.checked}}" />{{item.name}}
 	</label>
 </radio-group>
 <view wx:if="{{questionList[index].QuestType == 3}}" data-idx='{{questionList[index].id}}'>