From 9c7c21e8eacda173feb418bdfe739f7f97358233 Mon Sep 17 00:00:00 2001 From: liuwh <hugeinfo123> Date: Sun, 29 Mar 2020 17:28:46 +0800 Subject: [PATCH] bug修复 --- SunshineLnsMinApp/pages/createSub/createSub.js | 162 ++++++++++++++++++++++++++++++++++------------------- 1 files changed, 103 insertions(+), 59 deletions(-) diff --git a/SunshineLnsMinApp/pages/createSub/createSub.js b/SunshineLnsMinApp/pages/createSub/createSub.js index fbc5ba0..9f59096 100644 --- a/SunshineLnsMinApp/pages/createSub/createSub.js +++ b/SunshineLnsMinApp/pages/createSub/createSub.js @@ -8,7 +8,8 @@ */ data: { question: {}, - confirm: true + confirm: true, + value1:'' }, // 去单选页面 toRadio(e) { @@ -26,17 +27,22 @@ }, // 提交信息 submit() { - if ($v.psqList.length == 0) { - wx.showToast({ - title: '你还没有创建题目', - icon: "none", - duration: 800 - }); - return; - } - this.setData({ - confirm: false - }) + // if ($v.psqList.length == 0) { + // wx.showToast({ + // title: '你还没有创建题目', + // icon: "none", + // duration: 800 + // }); + // return; + // } + wx.showToast({ + title: '提交成功!', + icon: 'success', + duration: 2000 + }, wx.reLaunch({ + url: '../yshjqyfw/yshjqyfw', + })) + }, // 发布信息 publish() { @@ -77,54 +83,92 @@ */ onLoad: function(options) { var _m = "question"; - this.setData({ - [_m]: { - "paper": { - "title": "11", - "des": "111" - }, - "psqList": [{ - "isMust": 1, - "type": 1, - "question": "111", - "answerslist": [{ - "answer": "11" - }, { - "answer": "111" - }, { - "answer": "11" - }, { - "answer": "111" - }], - 'value': [] - }, { - "isMust": 1, - "type": 1, - "question": "11111", - "answerslist": [{ - "answer": "111" - }, { - "answer": "111" - }], - value: [] - }, { - "isMust": 1, - "type": 0, - "question": "11111" - }, { - "isMust": 0, - "type": 1, - "question": "wqwqw", - "answerslist": [{ - "answer": "qw" - }, { - "answer": "wqw" - }, { - "answer": "wqw" - }] - }] + var id = options.id + console.log(options) + var that = this; + wx.request({ + url: app.globalData.url + '/api/question/find/' + id, + success: function(res) { + console.log(res) + if (res.data.code == 0) { + console.log(res) + that.setData({ + [_m]: { + "paper": { + "title": res.data.data.title, + "des": res.data.data.content + }, + "psqList": res.data.data.questionDtos + // "psqList": [{ + // "isMust": 1, + // "type": 1, + // "question": "111", + // "answerslist": [{ + // "answer": "11" + // }, { + // "answer": "111" + // }, { + // "answer": "11" + // }, { + // "answer": "111" + // }], + // 'value': [] + // }, { + // "isMust": 1, + // "type": 1, + // "question": "11111", + // "answerslist": [{ + // "answer": "111" + // }, { + // "answer": "111" + // }], + // value: [] + // }, { + // "isMust": 1, + // "type": 0, + // "question": "11111" + // }, { + // "isMust": 0, + // "type": 1, + // "question": "wqwqw", + // "answerslist": [{ + // "answer": "qw" + // }, { + // "answer": "wqw" + // }, { + // "answer": "wqw" + // }] + // }] + } + + }); + } else { + wx.showModal({ + title: '提示', + content: "请求失败!" + }) + } } - }); + }) + + }, + + onChange1(e) { + var index = e.currentTarget.dataset['index']; + const { + value + } = e.detail; + console.log('checkbox', e, '索引', index); + console.log('value', value); + console.log('this.data.question', this.data.question); + + const data = this.data.question.psqList[index].value || []; + console.log(data) + this.data.question.psqList[index].value = value + console.log('this.data.question', this.data.question) + this.setData({ + question: this.data.question + }) }, onChange: function(e) { -- Gitblit v1.8.0