From 1629cb4a35884cdbd52088377fffd37fca2c225e Mon Sep 17 00:00:00 2001 From: liuwh <hugeinfo123> Date: Mon, 23 Mar 2020 16:47:09 +0800 Subject: [PATCH] 123 --- SunshineLnsMinApp/pages/createSubList/createSubList.js | 136 ++++----------------------------------------- 1 files changed, 13 insertions(+), 123 deletions(-) diff --git a/SunshineLnsMinApp/pages/createSubList/createSubList.js b/SunshineLnsMinApp/pages/createSubList/createSubList.js index ebb07f0..06c0369 100644 --- a/SunshineLnsMinApp/pages/createSubList/createSubList.js +++ b/SunshineLnsMinApp/pages/createSubList/createSubList.js @@ -7,8 +7,10 @@ * 页面的初始数据 */ data: { + user: app.globalData.imgUrl + '/image/user.svg', question: {}, - confirm: true + confirm: true, + data: {} }, // 去单选页面 toRadio(e) { @@ -17,73 +19,19 @@ url: '/pages/radio/radio?type=' + types, }) }, - //去编辑页面 - edit(e) { - var index = e.currentTarget.dataset.index; - wx.navigateTo({ - url: '/pages/radio/radio?index=' + index, - }) - }, - // 提交信息 - submit() { - if ($v.psqList.length == 0) { - wx.showToast({ - title: '你还没有创建题目', - icon: "none", - duration: 800 - }); - return; - } - this.setData({ - confirm: false - }) - }, - // 发布信息 - publish() { - app.res({ - url: "psq/save", - method: "POST", - data: $v, - callback: res => { - $v.paper = {}; - $v.psqList = []; - wx.showModal({ - title: '提示', - content: '发布成功,跳转新建问卷', - showCancel: false, - success: res => { - if (res.confirm) { - wx.switchTab({ - url: '/pages/creat/creat', - success: function (e) { - var page = getCurrentPages().pop(); - if (page == undefined || page == null) return; - page.onLoad(); - } - }) - } - } - }) - } - }) - }, - returnEdit() { - this.setData({ - confirm: true - }) - }, /** * 生命周期函数--监听页面加载 */ - onLoad: function (options) { - var _m = "question"; - + onLoad: function(options) { var that = this; wx.request({ url: app.globalData.url + '/api/question/examination', - success: function (res) { + success: function(res) { + console.log(res.data.data) if (res.data.code == 0) { - console.log(res) + that.setData({ + data: res.data.data + }) } else { wx.showModal({ title: '提示', @@ -92,71 +40,13 @@ } } }) - 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" - }] - }] - } - }); + }, - onChange: function (e) { - var index = e.currentTarget.dataset['index']; - const { - value - } = e.detail; - console.log('checkbox', e, '索引', index); - const data = this.data.question.psqList[index].value || []; - const idx = data.indexOf(value) - const current = idx === -1 ? [...data, value] : data.filter((n) => n !== value) - console.log('current', current); - this.data.question.psqList[index].value = current - this.setData({ - question: this.data.question + businessSchedule: function(event) { + wx.navigateTo({ + url: '../createSub/createSub?id=' + this.data.data.id, }) - } }) \ No newline at end of file -- Gitblit v1.8.0