// pages/lianxi/main.js const api = require("../../utils/request.js"); var util = require('../../utils/util.js') Page({ /** * 页面的初始数据 */ data: { sctms: [], tm_index: 0, is_right: false, answerP: false, tmtotal: 0, domain:getApp().globalData.mediahost, }, radioChange: function (e) { var that = this that.data.tm_current['user_answer'] = e.detail.value that.data.sctms[that.data.tm_index] = that.data.tm_current that.showAnswer() }, checkboxChange: function (e) { var that = this that.data.tm_current['user_answer'] = e.detail.value that.data.sctms[that.data.tm_index] = that.data.tm_current }, /** * 生命周期函数--监听页面加载 */ onLoad: function () { var that = this api.request('/crm/consumer/collects/', 'GET').then(res => { for(var i=0;i' if (tm_current.user_answer) { if (key == tm_current.user_answer || tm_current.user_answer.indexOf(key) != -1) { option.checked = true } } else { option.checked = false } options.push(option) } console.log(options) this.setData({ options: options }) }, remove: function () { var that = this var index = that.data.tm_index api.request('/crm/consumer/collects/', 'DELETE', { question: that.data.tm_current.id }).then(res => { that.data.sctms.splice(index, 1) if (that.data.sctms.length > index) { that.showTm(index) } else if (that.data.sctms.length > 0 && index > 1) { that.showTm(index - 1) } else { wx.navigateBack({ }) } }) } })