// pages/exam/online/online.js import Dialog from '@vant/weapp/dialog/dialog'; import Toast from '@vant/weapp/toast/toast'; import { getExamListTaskByUser, updStuStartTime, updStuSign } from "../../../api/index"; Page({ /** * 页面的初始数据 */ data: { showCount: 10, userSignShow: false, timesOfexamination: 0, currentPage: 1, totalPage: 0, STUDENT_ID: '', varList: [], dataInfo: {}, }, fnInput1(event) { // 签字图片 event.detail updStuSign({ filePath: event.detail, formData:{ STUDENT_ID: this.data.STUDENT_ID } }).then((resData) => { if(resData.code != 0) { wx.showToast({ title: '请重签', mask: false, icon:error }) }else { wx.showToast({ title: '签字已经更新', mask: false }) this.setData({ varList: [] }) this.getData() // if (!this.data.dataInfo.EXAM_FACE_PATH) { // // 去人脸识别 // wx.navigateTo({ // url: '/pages/photo/collection?STUDENT_ID='+this.data.STUDENT_ID, // }) // return // } } }).catch((e) =>{ console.log(e); }) }, userSignShowChange(){ this.setData({ userSignShow:!this.data.userSignShow }) }, goExam(item) { let dataInfo = item.currentTarget.dataset.item this.setData({ STUDENT_ID: dataInfo.STUDENT_ID, dataInfo: dataInfo }) let that = this // 是否签字 if (!dataInfo.SIGNATURE_PATH) { this.userSignShowChange() return } // if (!that.data.dataInfo.EXAM_FACE_PATH) { // // 去人脸识别 // wx.navigateTo({ // url: '/pages/photo/collection?STUDENT_ID='+that.data.STUDENT_ID, // }) // return // } this.setData({ timesOfexamination: dataInfo.NUMBEROFEXAMS - dataInfo.KSCOUNT }) if (this.data.timesOfexamination === 0) { Toast.loading({ type: 'fail', message: '您无考试机会', selector: '#van-toast', }); } else { Dialog.confirm({ message: '你还有' + that.data.timesOfexamination + '次考试机会', context: this }) .then(() => { updStuStartTime({ STUDENT_ID: dataInfo.STUDENT_ID }) wx.navigateTo({ url: '/pages/exam/examination/examination' + '?STAGEEXAMPAPERINPUT_ID=' + dataInfo.PAPER_ID + '&CLASS_ID=' + dataInfo.CLASS_ID + '&EXAMNAME=' + dataInfo.EXAMNAME + '&STUDENT_ID=' + dataInfo.STUDENT_ID + '&PASSSCORE=' + dataInfo.PASSSCORE + '&EXAMSCORE=' + dataInfo.EXAMSCORE + '&NUMBEROFEXAMS=' + this.data.timesOfexamination + '&SIMULATION=0' + '&ANSWERSHEETTIME=' + dataInfo.ANSWERSHEETTIME, }) }) .catch(() => {}); Dialog.confirm({ message: '你还有' + that.data.timesOfexamination + '次考试机会', selector: '#myDialog', }) .then(() => { updStuStartTime({ STUDENT_ID: dataInfo.STUDENT_ID }) wx.navigateTo({ url: '/pages/exam/examination/examination' + '?STAGEEXAMPAPERINPUT_ID=' + dataInfo.PAPER_ID + '&CLASS_ID=' + dataInfo.CLASS_ID + '&EXAMNAME=' + dataInfo.EXAMNAME + '&STUDENT_ID=' + dataInfo.STUDENT_ID + '&PASSSCORE=' + dataInfo.PASSSCORE + '&EXAMSCORE=' + dataInfo.EXAMSCORE + '&NUMBEROFEXAMS=' + this.data.timesOfexamination + '&SIMULATION=0' + '&ANSWERSHEETTIME=' + dataInfo.ANSWERSHEETTIME, }) }) .catch(() => {}); // wx.showModal({ // content: '你还有'+ that.data.timesOfexamination +'次考试机会', // success: function(res) { // if(res.confirm) { // updStuStartTime({ // STUDENT_ID: dataInfo.STUDENT_ID // }) // wx.navigateTo({ // url: '/pages/exam/examination/examination' + // '?STAGEEXAMPAPERINPUT_ID=' + dataInfo.PAPER_ID + // '&CLASS_ID=' + dataInfo.CLASS_ID + // '&EXAMNAME=' + dataInfo.EXAMNAME + // '&STUDENT_ID=' + dataInfo.STUDENT_ID + // '&PASSSCORE=' + dataInfo.PASSSCORE + // '&EXAMSCORE=' + dataInfo.EXAMSCORE + // '&NUMBEROFEXAMS=' + that.data.timesOfexamination + // '&SIMULATION=0' + // '&ANSWERSHEETTIME=' + dataInfo.ANSWERSHEETTIME, // }) // } else if (res.cancel) { // console.log('用户点击了取消') // } // } // }) // Dialog.confirm({ // message: '你还有' + that.data.timesOfexamination + '次考试机会', // selector: '#myDialog', // }) // .then(() => { // updStuStartTime({ // STUDENT_ID: dataInfo.STUDENT_ID // }) // wx.navigateTo({ // url: '/pages/exam/examination/examination' + // '?STAGEEXAMPAPERINPUT_ID=' + dataInfo.PAPER_ID + // '&CLASS_ID=' + dataInfo.CLASS_ID + // '&EXAMNAME=' + dataInfo.EXAMNAME + // '&STUDENT_ID=' + dataInfo.STUDENT_ID + // '&PASSSCORE=' + dataInfo.PASSSCORE + // '&EXAMSCORE=' + dataInfo.EXAMSCORE + // '&NUMBEROFEXAMS=' + this.data.timesOfexamination + // '&SIMULATION=0' + // '&ANSWERSHEETTIME=' + dataInfo.ANSWERSHEETTIME, // }) // }) // .catch(() => {}); } }, /** * 倒计时结束 */ finished() { this.setData({ varList: [] }) this.getData() }, /** * 人脸验证成功回调 */ photoResult(dataInfo) { let that = this this.setData({ timesOfexamination: dataInfo.NUMBEROFEXAMS - dataInfo.KSCOUNT }) if (this.data.timesOfexamination === 0) { Toast.loading({ type: 'fail', message: '您无考试机会', selector: '#van-toast', }); } else { Dialog.confirm({ message: '你还有' + that.data.timesOfexamination + '次考试机会', context: this }) .then(() => { updStuStartTime({ STUDENT_ID: dataInfo.STUDENT_ID }) wx.navigateTo({ url: '/pages/exam/examination/examination' + '?STAGEEXAMPAPERINPUT_ID=' + dataInfo.PAPER_ID + '&CLASS_ID=' + dataInfo.CLASS_ID + '&EXAMNAME=' + dataInfo.EXAMNAME + '&STUDENT_ID=' + dataInfo.STUDENT_ID + '&PASSSCORE=' + dataInfo.PASSSCORE + '&EXAMSCORE=' + dataInfo.EXAMSCORE + '&NUMBEROFEXAMS=' + this.data.timesOfexamination + '&SIMULATION=0' + '&ANSWERSHEETTIME=' + dataInfo.ANSWERSHEETTIME, }) }) .catch(() => {}); Dialog.confirm({ message: '你还有' + that.data.timesOfexamination + '次考试机会', selector: '#myDialog', }) .then(() => { updStuStartTime({ STUDENT_ID: dataInfo.STUDENT_ID }) wx.navigateTo({ url: '/pages/exam/examination/examination' + '?STAGEEXAMPAPERINPUT_ID=' + dataInfo.PAPER_ID + '&CLASS_ID=' + dataInfo.CLASS_ID + '&EXAMNAME=' + dataInfo.EXAMNAME + '&STUDENT_ID=' + dataInfo.STUDENT_ID + '&PASSSCORE=' + dataInfo.PASSSCORE + '&EXAMSCORE=' + dataInfo.EXAMSCORE + '&NUMBEROFEXAMS=' + this.data.timesOfexamination + '&SIMULATION=0' + '&ANSWERSHEETTIME=' + dataInfo.ANSWERSHEETTIME, }) }) .catch(() => {}); // wx.showModal({ // content: '你还有'+ that.data.timesOfexamination+'次考试机会', // success: function(res) { // if(res.confirm) { // updStuStartTime({ // STUDENT_ID: dataInfo.STUDENT_ID // }) // wx.navigateTo({ // url: '/pages/exam/examination/examination' + // '?STAGEEXAMPAPERINPUT_ID=' + dataInfo.PAPER_ID + // '&CLASS_ID=' + dataInfo.CLASS_ID + // '&EXAMNAME=' + dataInfo.EXAMNAME + // '&STUDENT_ID=' + dataInfo.STUDENT_ID + // '&PASSSCORE=' + dataInfo.PASSSCORE + // '&EXAMSCORE=' + dataInfo.EXAMSCORE + // '&NUMBEROFEXAMS=' + that.data.timesOfexamination + // '&SIMULATION=0' + // '&ANSWERSHEETTIME=' + dataInfo.ANSWERSHEETTIME, // }) // } else if (res.cancel) { // console.log('用户点击了取消') // } // } // }) // Dialog.alert({ // message: '你还有'+ that.data.timesOfexamination+'次考试机会', // selector: '#myDialog', // }) // .then(() => { // updStuStartTime({ // STUDENT_ID: dataInfo.STUDENT_ID // }) // wx.navigateTo({ // url: '/pages/exam/examination/examination' + // '?STAGEEXAMPAPERINPUT_ID=' + dataInfo.PAPER_ID + // '&CLASS_ID=' + dataInfo.CLASS_ID + // '&EXAMNAME=' + dataInfo.EXAMNAME + // '&STUDENT_ID=' + dataInfo.STUDENT_ID + // '&PASSSCORE=' + dataInfo.PASSSCORE + // '&EXAMSCORE=' + dataInfo.EXAMSCORE + // '&NUMBEROFEXAMS=' + this.data.timesOfexamination + // '&SIMULATION=0' + // '&ANSWERSHEETTIME=' + dataInfo.ANSWERSHEETTIME, // }) // }) // .catch(() => {}); } }, async getData() { let resData = await getExamListTaskByUser({ showCount: this.data.showCount, currentPage: this.data.currentPage }) this.setData({ varList: [...this.data.varList, ...resData.varList], totalPage: resData.page.totalPage }) }, /** * 生命周期函数--监听页面显示 */ onShow() { this.setData({ showCount: 10, currentPage: 1, totalPage: 0, varList: [], }) this.getData() }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { this.setData({ currentPage: ++this.data.currentPage }) if (this.data.totalPage >= this.data.currentPage) { this.getData() } }, })