// pages/m_consult/consultdetailqa/consultdetailqa.js const consultservice = require("../../../service/consultservice") const app = getApp() Page({ /** * 页面的初始数据 */ data: { showloading: false, question: {}, //问题涉及的项目 questionTag: [{ icon: '', name: '' }], answers: [], showDialog: false, groups: [ 'actionSlot1', // { text: '示例菜单', value: 1 }, // { text: '示例菜单', value: 2 }, // { text: '负向菜单', type: 'warn', value: 3 } ] }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { var that = this this.getOpenerEventChannel().on('acceptDataFromOpenerPage', function (data) { that.setData({ qId: data.qId }) that.getQuestion() that.getAnswers() }) }, getQuestion() { this.setData({ showloading: true }) var that = this consultservice.getQuestion(app.globalData.accessToken.userId, this.data.qId, { success(res) { let questionTag = [] if (res.cqIsPunish) questionTag.push({icon: '/res/icons/cq_punish.png', name: '涉及行政处罚'}) if (res.cqIsIllegal) questionTag.push({icon: '/res/icons/cq_illegal.png', name: '涉及刑事责任'}) if (res.cqIsSupervise) questionTag.push({icon: '/res/icons/cq_supervise.png', name: '涉及环保督察要点'}) if (res.cqIsShotspot) questionTag.push({icon: '/res/icons/cq_shotspot.png', name: '涉及环保管理热点'}) that.setData({ question: res, questionTag }) console.log(res); }, complete(res) { that.setData({ showloading: false }) } }) }, getAnswers() { this.setData({ showloading: true }) var that = this consultservice.getAnswers(app.globalData.accessToken.userId, this.data.qId, { success(res) { res.forEach(r => { r.saContent = r.saContent.replaceAll('\\n', '
') }); that.setData({ answers: res }) console.log(res); }, complete(res) { that.setData({ showloading: false }) } }) }, openDialog: function () { this.setData({ showDialog: true }) }, closeDialog: function () { this.setData({ showDialog: false }) }, btnClick(e) { console.log(e) this.closeDialog() } })