feedBack.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768
  1. //index.js
  2. //获取应用实例
  3. const app = require('../../utils/util.js');
  4. const tools = require('../../utils/tools.js');
  5. Page({
  6. data: {
  7. nameIsTrue: false, //名字是否填写
  8. cultureIsTrue: false, //文化是否填写
  9. graduationIsTrue: false, //毕业学校
  10. majorIsTrue: false, //所有专业
  11. postIsTrue: false, //现任职务
  12. renzhishijianIsTrue: false,
  13. phoneIsTrue: false, //电话
  14. peixunshijianTrue: false, // 培训时间
  15. nameMessage: '',
  16. zaizhiTime: [], //在线时间
  17. peixunTime: '', //培训时间
  18. headmasterText: [], //
  19. names: [],
  20. timeIndex: '',
  21. chooseValue: [], // 选择的答案序列
  22. radio: '1',
  23. renzhiDate: '',
  24. postshow: [],
  25. postshow1: false,
  26. errorIsTrue: false,
  27. currentDate: new Date().getTime(),
  28. currentDate1: new Date().getTime(),
  29. minDate: new Date().getTime,
  30. formatter(type, value) {
  31. if (type === 'year') {
  32. return `${value}年`;
  33. } else if (type === 'month') {
  34. return `${value}月`;
  35. }
  36. return value;
  37. },
  38. questionList: [
  39. // {
  40. // "QuestType": "6",
  41. // "Id": 11,
  42. // name: 'ccccc',
  43. // QuestStem: '时间选择',
  44. // QuestAnswer: ''
  45. // },
  46. // {
  47. // "QuestType": "5",
  48. // "Id": 11,
  49. // name: 'dddd',
  50. // QuestStem: '姓名输入',
  51. // QuestAnswer: ''
  52. // },
  53. // {
  54. // "QuestType": "6",
  55. // "Id": 11,
  56. // name: 'username111',
  57. // QuestStem: '时间2',
  58. // QuestAnswer: ''
  59. // },
  60. // {
  61. // "QuestType": "5",
  62. // "Id": 11,
  63. // name: 'address',
  64. // QuestStem: '姓名输入',
  65. // QuestAnswer: ''
  66. // },
  67. // {
  68. // "QuestType": "0",
  69. // "QuestChoice": [{
  70. // value: 'USA',
  71. // name: '美国'
  72. // },
  73. // {
  74. // value: 'CHN',
  75. // name: '中国',
  76. // checked: 'true'
  77. // },
  78. // {
  79. // value: 'BRA',
  80. // name: '巴西'
  81. // },
  82. // {
  83. // value: 'JPN',
  84. // name: '日本'
  85. // },
  86. // {
  87. // value: 'ENG',
  88. // name: '英国'
  89. // },
  90. // {
  91. // value: 'FRA',
  92. // name: '法国'
  93. // },
  94. // ],
  95. // "Id": 36,
  96. // name: 'sex',
  97. // QuestStem: '性别单选'
  98. // },
  99. // {
  100. // "QuestType": "0",
  101. // "QuestChoice": [{
  102. // value: '男',
  103. // name: '男',
  104. // checked: false,
  105. // },
  106. // {
  107. // value: '女',
  108. // name: '女',
  109. // checked: false,
  110. // },
  111. // ],
  112. // "Id": 36,
  113. // name: 'sex111',
  114. // QuestStem: '性别单选2222'
  115. // },
  116. // {
  117. // "QuestType": "1",
  118. // "QuestAnswer": "equals ()||\nhashCode()||",
  119. // "QuestChoice": [{
  120. // value: 'USA',
  121. // name: '美国'
  122. // },
  123. // {
  124. // value: 'CHN',
  125. // name: '中国',
  126. // checked: false
  127. // },
  128. // {
  129. // value: 'FRA',
  130. // name: '法国'
  131. // }
  132. // ],
  133. // "Id": 38,
  134. // name: 'alls',
  135. // QuestStem: '多选'
  136. // },
  137. // {
  138. // "QuestType": "2",
  139. // "QuestStem": "1+1=2",
  140. // "QuestAnswer": "是",
  141. // "QuestChoice": [{
  142. // value: 'USA',
  143. // name: '是'
  144. // },
  145. // {
  146. // value: 'CHN',
  147. // name: '中国',
  148. // checked: false
  149. // },
  150. // ],
  151. // "Id": 42,
  152. // name: 'lllll',
  153. // QuestStem: '判断1'
  154. // },
  155. // {
  156. // "QuestType": "2",
  157. // "QuestStem": "1+1=2",
  158. // "QuestAnswer": "是",
  159. // "QuestChoice": [{
  160. // value: 'USA',
  161. // name: '是'
  162. // },
  163. // {
  164. // value: 'CHN',
  165. // name: '中国',
  166. // checked: false
  167. // },
  168. // ],
  169. // "Id": 42,
  170. // name: 'lllll',
  171. // QuestStem: '判断2'
  172. // },
  173. // {
  174. // "QuestType": "2",
  175. // "QuestStem": "1+1=2",
  176. // "QuestAnswer": "是",
  177. // "QuestChoice": [{
  178. // value: 'USA',
  179. // name: '是'
  180. // },
  181. // {
  182. // value: 'CHN',
  183. // name: '中国',
  184. // checked: false
  185. // },
  186. // ],
  187. // "Id": 42,
  188. // name: 'lllll',
  189. // QuestStem: '判断3'
  190. // },
  191. // {
  192. // "QuestType": "3",
  193. // "QuestStem": "世纪大厦的萨科技的哈市(解答)",
  194. // "QuestAnswer": "",
  195. // "QuestChoice": "",
  196. // "Id": 39,
  197. // name: 'textarea',
  198. // },
  199. ],
  200. answersId: '', // 提交答案用到
  201. sessionKey: '',
  202. paperId: '',
  203. answersId: '',
  204. id: '',
  205. status: ''
  206. },
  207. onChange(event) {
  208. this.setData({
  209. radio: event.detail,
  210. });
  211. },
  212. radioChange(e) {
  213. console.log(e);
  214. const items = this.data.questionList[e.currentTarget.dataset.index].QuestChoice
  215. for (let i = 0, len = items.length; i < len; ++i) {
  216. items[i].checked = items[i].value === e.detail.value
  217. }
  218. let json = {};
  219. json.currentAnswer = e.detail.value;
  220. json.id = e.currentTarget.dataset.idx;
  221. json.questType = e.currentTarget.dataset.questtypes;
  222. this.data.chooseValue[e.currentTarget.dataset.index] = json;
  223. this.setData({
  224. questionList: this.data.questionList
  225. })
  226. wx.setStorageSync('questionList' + wx.getStorageSync('answersId'), this.data.questionList);
  227. wx.setStorageSync('chooseValue' + wx.getStorageSync('answersId'), this.data.chooseValue);
  228. console.log(this.data.questionList);
  229. console.log(this.data.chooseValue, "0000");
  230. // this.data.questionList[this.data.index].checked = e.detail.value;
  231. // this.setData({
  232. // questionList: this.data.questionList
  233. // })
  234. // const items = this.data.items
  235. // for (let i = 0, len = items.length; i < len; ++i) {
  236. // items[i].checked = items[i].value === e.detail.value
  237. // }
  238. // this.setData({
  239. // items
  240. // })
  241. },
  242. checkboxChange(e) {
  243. const items = this.data.questionList[e.currentTarget.dataset.index].QuestChoice
  244. const values = e.detail.value
  245. for (let i = 0, lenI = items.length; i < lenI; ++i) {
  246. items[i].checked = false
  247. for (let j = 0, lenJ = values.length; j < lenJ; ++j) {
  248. if (items[i].value === values[j]) {
  249. items[i].checked = true
  250. break
  251. }
  252. }
  253. }
  254. let json = {};
  255. let aa = e.detail.value.join("||")
  256. json.currentAnswer = aa;
  257. json.id = e.currentTarget.dataset.idx;
  258. json.questType = e.currentTarget.dataset.questtypes;
  259. this.data.chooseValue[e.currentTarget.dataset.index] = json;
  260. this.setData({
  261. questionList: this.data.questionList
  262. })
  263. wx.setStorageSync('questionList' + wx.getStorageSync('answersId'), this.data.questionList);
  264. wx.setStorageSync('chooseValue' + wx.getStorageSync('answersId'), this.data.chooseValue);
  265. },
  266. bindTextAreaBlur(e) {
  267. console.log(e, "hhhhh");
  268. console.log(e.detail.value);
  269. let json = {};
  270. json.currentAnswer = e.detail.value;
  271. json.id = e.currentTarget.dataset.idx;
  272. json.questType = e.currentTarget.dataset.questtypes;
  273. this.data.chooseValue[e.currentTarget.dataset.index] = json;
  274. this.data.questionList[e.currentTarget.dataset.index].QuestAnswer = e.detail.value;
  275. this.setData({
  276. questionList: this.data.questionList
  277. })
  278. wx.setStorageSync('questionList' + wx.getStorageSync('answersId'), this.data.questionList);
  279. wx.setStorageSync('chooseValue' + wx.getStorageSync('answersId'), this.data.chooseValue);
  280. },
  281. share() {
  282. this.setData({
  283. show: true
  284. });
  285. },
  286. onClose() {
  287. this.setData({
  288. ['postshow[' + this.data.timeIndex + ']']: false,
  289. });
  290. },
  291. onClose1() {
  292. console.log("11111111111111");
  293. this.setData({
  294. postshow1: false
  295. });
  296. },
  297. onInput(event) {
  298. console.log(event, "8888888");
  299. console.log("点击了");
  300. this.setData({
  301. currentDate: event.detail,
  302. });
  303. },
  304. onInput1(event) {
  305. console.log("000");
  306. this.setData({
  307. currentDate1: event.detail,
  308. });
  309. },
  310. formatDate(date) {
  311. date = new Date(date);
  312. return `${date.getFullYear()-1}/${date.getMonth() + 1}/${date.getDate()}`;
  313. },
  314. share1(e) {
  315. console.log(e);
  316. console.log(e.currentTarget.dataset.index);
  317. console.log(e.currentTarget.dataset.names, "8520852085208520");
  318. console.log(this.data.postshow[e.currentTarget.dataset.index]);
  319. this.data.postshow[e.currentTarget.dataset.index] = true;
  320. this.data.names[e.currentTarget.dataset.index] = e.currentTarget.dataset.names;
  321. this.setData({
  322. postshow: this.data.postshow,
  323. timeIndex: e.currentTarget.dataset.index
  324. })
  325. console.log(this.data.postshow, "打印下锕啊啊啊啊锕锕锕");
  326. // this.setData({
  327. // postshow: true
  328. // });
  329. },
  330. share() {
  331. this.setData({
  332. postshow1: true
  333. });
  334. },
  335. formatDate(date) {
  336. date = new Date(date);
  337. return `${date.getFullYear()-1}/${date.getMonth() + 1}/${date.getDate()}`;
  338. },
  339. onConfirm(event) {
  340. console.log(event, "1111111");
  341. let timeValue = this.timeFormat(new Date(event.detail), "yyyy-MM-dd");
  342. let json = {};
  343. json.currentAnswer = timeValue;
  344. json.id = event.currentTarget.dataset.idx;
  345. json.questType = event.currentTarget.dataset.questtypes;
  346. let aa = this.data.chooseValue[event.currentTarget.dataset.index] = json;
  347. this.data.questionList[event.currentTarget.dataset.index].QuestAnswer = timeValue;
  348. this.setData({
  349. questionList: this.data.questionList,
  350. ['chooseValue[' + event.currentTarget.dataset.index + ']']: aa,
  351. ['postshow[' + this.data.timeIndex + ']']: false,
  352. ['headmasterText[' + this.data.timeIndex + ']']: '',
  353. });
  354. wx.setStorageSync('questionList' + wx.getStorageSync('answersId'), this.data.questionList);
  355. wx.setStorageSync('chooseValue' + wx.getStorageSync('answersId'), this.data.chooseValue);
  356. console.log(this.data.chooseValue, "确定后的值锕");
  357. console.log(this.data.questionList, "789789798789");
  358. },
  359. onConfirm1(event) {
  360. console.log(event, "0000");
  361. let timeValue = this.timeFormat(new Date(event.detail), "yyyy-MM-dd");
  362. this.setData({
  363. peixunTime: timeValue,
  364. postshow1: false,
  365. peixunText: ''
  366. });
  367. },
  368. parameterTap: function (e) { //e是获取e.currentTarget.dataset.id所以是必备的,跟前端的data-id获取的方式差不多
  369. let that = this
  370. let this_checked = e.currentTarget.dataset.id
  371. let parameterList = this.data.parameter //获取Json数组
  372. for (let i = 0; i < parameterList.length; i++) {
  373. if (parameterList[i].id == this_checked) {
  374. parameterList[i].checked = true; //当前点击的位置为true即选中
  375. } else {
  376. parameterList[i].checked = false; //其他的位置为false
  377. }
  378. }
  379. that.setData({
  380. parameter: parameterList
  381. })
  382. },
  383. submitForm() {
  384. //let arr1 = this.data.chooseValue.filter(d => d);
  385. //console.log(arr1,"打印下提交");
  386. console.log(this.data.chooseValue, "打印下提交");
  387. wx.request({
  388. url: app.globalData.publicUrl + '/wx/paper/commit',
  389. method: "post",
  390. data: {
  391. sessionKey: this.data.sessionKey,
  392. currentAnswerTemp: this.data.chooseValue,
  393. answersId: wx.getStorageSync('answersId')
  394. },
  395. success: (res) => {
  396. console.log(res);
  397. if (res.data.code == 0) {
  398. wx.showModal({
  399. showCancel: false,
  400. content: '提交成功',
  401. success() {
  402. wx.navigateBack({
  403. delta: 1
  404. })
  405. }
  406. })
  407. } else {
  408. wx.showModal({
  409. showCancel: false,
  410. content: res.data.msg
  411. })
  412. }
  413. // console.log(res);
  414. // if (res.data.msg == "请勿重复提交") {
  415. // wx.showModal({
  416. // showCancel: false,
  417. // content: res.data.msg,
  418. // success(res) {}
  419. // })
  420. // } else {
  421. // wx.switchTab({
  422. // url: '/pages/myClass/myClass',
  423. // })
  424. // }
  425. }
  426. })
  427. // let isTrue = false;
  428. // this.data.chooseValue.forEach(item => {
  429. // console.log(item, "123123");
  430. // if (item.currentAnswer) {
  431. // isTrue = true;
  432. // } else {
  433. // wx.showModal({
  434. // showCancel: false,
  435. // content: item.QuestStem + "不能为空",
  436. // success(res) {}
  437. // })
  438. // }
  439. // })
  440. // if (isTrue) {
  441. // console.log("提交了");
  442. // wx.request({
  443. // url: app.globalData.publicUrl + '/wx/paper/commit',
  444. // method: "post",
  445. // data: {
  446. // sessionKey: this.data.sessionKey,
  447. // currentAnswerTemp: this.data.chooseValue,
  448. // answersId: wx.getStorageSync('answersId')
  449. // },
  450. // success: (res) => {
  451. // console.log(res);
  452. // if(res.data.msg == "请勿重复提交"){
  453. // wx.showModal({
  454. // showCancel: false,
  455. // content: res.data.msg,
  456. // success(res) {}
  457. // })
  458. // }else{
  459. // wx.navigateTo({
  460. // url: '/pages/myClass/myClass',
  461. // })
  462. // }
  463. // }
  464. // })
  465. // }
  466. },
  467. formSubmit(e) {
  468. console.log(e.detail.value, "000000000000000");
  469. let arr1 = this.data.zaizhiTime.filter(d => d);
  470. let arr = this.data.names.filter(d => d);
  471. var activeSubjectsArr = [];
  472. for (var i = 0; i < arr.length; i++) {
  473. var activeSubjectsObject = {};
  474. for (var j = 0; j < arr1.length; j++) {
  475. if (i == j) {
  476. activeSubjectsObject[arr[i]] = arr1[j];
  477. activeSubjectsArr.push(activeSubjectsObject);
  478. }
  479. }
  480. }
  481. console.log(activeSubjectsArr, "7777777");
  482. let count = 0;
  483. let data = {};
  484. for (let a in e.detail.value) {
  485. count += 1;
  486. if (count = 1) {
  487. data[a] = e.detail.value[a]
  488. }
  489. }
  490. activeSubjectsArr.forEach(item => {
  491. Object.assign(data, item)
  492. })
  493. console.log(data, "888888888888888888888888");
  494. // Object.keys(data).forEach(function (key) {
  495. // if (!data[key]) {
  496. // wx.showModal({
  497. // showCancel: false,
  498. // content: key + "不能为空"
  499. // })
  500. // return;
  501. // }
  502. // });
  503. // if (!e.detail.value.username) {
  504. // this.setData({
  505. // nameIsTrue: true
  506. // })
  507. // } else {
  508. // this.setData({
  509. // nameIsTrue: false
  510. // })
  511. // }
  512. // let sex = '';
  513. // if (this.data.parameter[0].checked) {
  514. // sex = this.data.parameter[0].name
  515. // this.setData({
  516. // errorIsTrue: false
  517. // })
  518. // } else if (this.data.parameter[1].checked) {
  519. // sex = this.data.parameter[1].name
  520. // this.setData({
  521. // errorIsTrue: false
  522. // })
  523. // } else {
  524. // this.setData({
  525. // errorIsTrue: true
  526. // })
  527. // }
  528. // if (!e.detail.value.work) {
  529. // this.setData({
  530. // workIsTrue: true
  531. // })
  532. // } else {
  533. // this.setData({
  534. // workIsTrue: false
  535. // })
  536. // }
  537. // if (!e.detail.value.culture) {
  538. // this.setData({
  539. // cultureIsTrue: true
  540. // })
  541. // } else {
  542. // this.setData({
  543. // cultureIsTrue: false
  544. // })
  545. // }
  546. // if (!e.detail.value.graduation) {
  547. // this.setData({
  548. // graduationIsTrue: true
  549. // })
  550. // } else {
  551. // this.setData({
  552. // graduationIsTrue: false
  553. // })
  554. // }
  555. // if (!e.detail.value.major) {
  556. // this.setData({
  557. // majorIsTrue: true
  558. // })
  559. // } else {
  560. // this.setData({
  561. // majorIsTrue: false
  562. // })
  563. // }
  564. // if (!e.detail.value.post) {
  565. // this.setData({
  566. // postIsTrue: true
  567. // })
  568. // } else {
  569. // this.setData({
  570. // postIsTrue: false
  571. // })
  572. // }
  573. // if (!e.detail.value.phone) {
  574. // this.setData({
  575. // phoneIsTrue: true
  576. // })
  577. // } else {
  578. // this.setData({
  579. // phoneIsTrue: false
  580. // })
  581. // }
  582. // if (!this.data.zaizhiTime) {
  583. // this.setData({
  584. // renzhishijianIsTrue: true
  585. // })
  586. // } else {
  587. // this.setData({
  588. // renzhishijianIsTrue: false
  589. // })
  590. // }
  591. // if (!this.data.peixunTime) {
  592. // this.setData({
  593. // peixunshijianTrue: true
  594. // })
  595. // } else {
  596. // this.setData({
  597. // peixunshijianTrue: false
  598. // })
  599. // }
  600. // console.log(this.data.zaizhiTime, "在职时间000");
  601. // console.log(this.data.peixunTime, "培训时间000");
  602. // console.log(sex, "性别的");
  603. // e.detail.value.zaizhiTime = this.data.zaizhiTime;
  604. // e.detail.value.peixunTime = this.data.peixunTime;
  605. // e.detail.value.sex = sex;
  606. // console.log(e.detail.value, "我是合并后的锕");
  607. },
  608. timeFormat(date, fmt) {
  609. let o = {
  610. "M+": date.getMonth() + 1, //月份   
  611. "d+": date.getDate(), //日
  612. "h+": date.getHours(), //小时   
  613. "m+": date.getMinutes(), //分   
  614. "s+": date.getSeconds(), //秒   
  615. "q+": Math.floor((date.getMonth() + 3) / 3), //季度   
  616. "S": date.getMilliseconds() //毫秒   
  617. };
  618. if (/(y+)/.test(fmt))
  619. fmt = fmt.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length));
  620. for (let k in o)
  621. if (new RegExp("(" + k + ")").test(fmt))
  622. fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
  623. return fmt;
  624. },
  625. onReady: function () {},
  626. async onLoad(options) {
  627. const sessionKey = await tools.checkSessionAndLogin();
  628. console.log(sessionKey, "111");
  629. //const sessionKey = 'BqQROCKCxn7R2NXdQLud9Q==';
  630. console.log("onloading.....................");
  631. // let chooceArr = this.data.questionList.map(item => {
  632. // let json = {};
  633. // json.currentAnswer = '';
  634. // json.questType = '';
  635. // json.id = item.Id;
  636. // json.QuestStem = item.QuestStem;
  637. // return json
  638. // })
  639. // console.log(chooceArr);
  640. // this.setData({
  641. // chooseValue: chooceArr
  642. // })
  643. console.log(options.answersId, "00000000000000000000000000");
  644. console.log(options, "11111");
  645. wx.setStorageSync('answersId', options.answersId);
  646. this.setData({
  647. sessionKey: sessionKey,
  648. paperId: options.paperId,
  649. answersId: options.answersId,
  650. id: options.id,
  651. })
  652. if (wx.getStorageSync('questionList' + wx.getStorageSync('answersId'))) {
  653. console.log("缓村了锕");
  654. const questionList = wx.getStorageSync('questionList' + wx.getStorageSync('answersId'));
  655. this.setData({
  656. questionList: questionList,
  657. answersId: wx.getStorageSync('answersId' + wx.getStorageSync('answersId')),
  658. chooseValue: wx.getStorageSync('chooseValue' + wx.getStorageSync('answersId')),
  659. })
  660. console.log(this.data.questionList, "show 缓存的数据");
  661. } else {
  662. console.log("无缓存");
  663. this.allShi(this.data.id, this.data.paperId, this.data.sessionKey);
  664. }
  665. // if (wx.getStorageSync('questionList' + wx.getStorageSync('answersId'))) {
  666. // console.log("缓村了锕");
  667. // const questionList = wx.getStorageSync('questionList' + wx.getStorageSync('answersId'));
  668. // this.setData({
  669. // questionList: questionList,
  670. // answersId: wx.getStorageSync('answersId' + wx.getStorageSync('answersId')),
  671. // chooseValue: wx.getStorageSync('chooseValue' + wx.getStorageSync('answersId')),
  672. // })
  673. // console.log(this.data.questionList, "show 缓存的数据");
  674. // } else {
  675. // console.log("无缓存");
  676. // this.allShi(this.data.id, this.data.paperId, this.data.sessionKey);
  677. // }
  678. },
  679. allShi(id, paperId, sessionKey) {
  680. wx.request({
  681. url: app.globalData.publicUrl + '/wx/paper/detail',
  682. method: "post",
  683. data: {
  684. sessionKey: sessionKey,
  685. id: id,
  686. paperId: paperId
  687. },
  688. success: (res) => {
  689. let jsonArr = JSON.parse(res.data.paperContent).map(item => {
  690. let json = {};
  691. json.QuestType = item.QuestType;
  692. json.Id = item.Id;
  693. json.QuestAnswer = item.QuestAnswer;
  694. json.QuestStem = item.QuestStem;
  695. // if (item.QuestChoice) {
  696. // let arr = item.QuestChoice.split('||');
  697. // json.QuestChoice = arr;
  698. // }
  699. if (item.QuestType == '1' || item.QuestType == '0') {
  700. let arr = item.QuestChoice.split('||');
  701. let arrJson = arr.map(item => {
  702. let json1 = {};
  703. json1.name = item;
  704. json1.value = item;
  705. json1.checked = false;
  706. return json1
  707. });
  708. json.QuestChoice = arrJson;
  709. }
  710. return json;
  711. })
  712. // for(let i = 0 ; i<jsonArr.length; i++){
  713. // let json = {};
  714. // json.currentAnswer = '';
  715. // json.questType = '';
  716. // json.id = '';
  717. // }
  718. // 答案锕
  719. let chooceArr = jsonArr.map(item => {
  720. let json = {};
  721. json.currentAnswer = '';
  722. json.questType = '';
  723. json.id = item.Id;
  724. json.QuestStem = item.QuestStem;
  725. return json
  726. })
  727. this.setData({
  728. questionList: jsonArr,
  729. chooseValue: chooceArr
  730. })
  731. console.log(this.data.questionList, "00000");
  732. wx.setStorageSync('questionList' + wx.getStorageSync('answersId'), this.data.questionList);
  733. wx.setStorageSync('chooseValue' + wx.getStorageSync('answersId'), this.data.chooseValue);
  734. }
  735. })
  736. },
  737. })