//logs.js // const util = require('../../utils/util.js') const tools = require('../../utils/tools.js'); const app = require('../../utils/util.js'); Page({ data: { showNull: false, dataArr: [ // { // "image": "/images/scdj1.jpg", // "name": "长春市社区工作者线上培训班", // "lecturer": "李老师", // "examBegin": "2020年07月10日", // examBegin:'2020202020222222' // },{ // "image": "/images/scdj2.jpg", // "name": "长春市专职党务工作者线上培训班", // "lecturer": "刘老师", // "examBegin": "2020年07月12日" // },{ // "image": "/images/scdj4.jpg", // "name": "区域党建联盟", // "lecturer": "王老师", // "examBegin": "2020年07月15日" // },{ // "image": "/images/scdj3.jpg", // "name": "小区党组织建设", // "lecturer": "张老师", // "examBegin": "2020年07月30日" // } ], sessionKey: '', }, checkboxChange() { }, startAnswer(e) { let id = e.currentTarget.dataset.idx; let paperId = e.currentTarget.dataset.paperid; let answersId = e.currentTarget.dataset.answersid; console.log(this.data.sessionKey, "787878"); if (answersId) { this.toPath(id, paperId, answersId); } else { // 获取answerid this.beginKao(id, paperId, this.data.sessionKey); } }, toPath(id, paperId, answersId) { wx.navigateTo({ url: '/pages/answerAfterclasses/answerAfterclasses?id=' + id + '&paperId=' + paperId + '&answersId=' + answersId, }) }, beginKao(id, paperId, sessionKey) { console.log(paperId, "8888888"); wx.request({ url: app.globalData.publicUrl + '/wx/exam/begin', method: "post", data: { sessionKey: sessionKey, id: id, paperId: paperId }, success: (res) => { console.log(res); if (res.data.code == 0) { console.log(res, "为我么我们微妙"); // 提交答案是后 this.toPath(id, paperId, res.data.answersId); } } }) }, lookAnswer(e) { console.log("00000"); let answersId = e.currentTarget.dataset.answersid; wx.request({ url: app.globalData.publicUrl + '/wx/answer/detail', method: "post", data: { sessionKey: this.data.sessionKey, answersId: answersId }, success: (res) => { console.log(res); if (res.data.code == 0) { console.log(res, "suoyoude"); // wx.navigateTo({ // url: '/pages/grade/grade?answersId=' + answersId, // }) if (res.data.list[0].answerScore) { wx.navigateTo({ url: '/pages/grade/grade?answersId=' + answersId, }) } else { wx.showModal({ title: '提示', content: '当前老师批阅中,请耐心等待', showCancel: false, }) } // res.data.list[0].forEach(item => { // if (item.answerScore) { // wx.navigateTo({ // url: '/pages/grade/grade?answersId=' + answersId, // }) // } else { // wx.showModal({ // showCancel: false, // content: '当前老师批阅中,请耐心等待', // success(res) {} // }) // // wx.showModal({ // // title: '提示', // // content: '当前老师批阅中,请耐心等待', // // showCancel: false, // // }) // } // }) } } }) }, async onLoad() { const sessionKey = await tools.checkSessionAndLogin(); //const sessionKey = 'yoa0rZTt2bAiTVDsiRjysw=='; this.setData({ sessionKey: sessionKey }) //.................... // if (wx.getStorageSync('questionList')) { // console.log("缓存锕锕66666666666666666666666666666666666666666666666666666"); // this.setData({ // questionList: wx.getStorageSync('questionList'), // index: wx.getStorageSync('titleINDEX'), // answersId:wx.getStorageSync('answersId'), // chooseValue:wx.getStorageSync('chooseValue'), // }) // } else { // console.log("请求了锕66666666666666666666666666666666666666666666666666666"); // } this.getBanner(sessionKey); //.................... }, getBanner(sessionKey) { console.log(sessionKey, "sessionKey"); wx.request({ url: app.globalData.publicUrl + '/wx/exam/list', method: "post", data: { sessionKey: sessionKey, }, success: (res) => { if (res.data.code == 0) { if (res.data.list.length == 0) { this.setData({ showNull: true }) } else { this.setData({ dataArr: res.data.list }) } } }, fail: () => { this.setData({ showNull: true }) } }) }, })