|
@@ -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);
|
|
|
}
|
|
|
})
|