// pages/lianxi/main.js const api = require("../../utils/request.js"); var util = require('../../utils/util.js') Page({ /** * 页面的初始数据 */ data: { tms:[], tm_index: 0, ctms:[], domain:getApp().globalData.mediahost, }, radioChange: function (e) { var that = this that.data.tm_current['user_answer'] = e.detail.value that.data.tms[that.data.tm_index] = that.data.tm_current }, checkboxChange: function (e) { var that = this that.data.tm_current['user_answer'] = e.detail.value that.data.tms[that.data.tm_index] = that.data.tm_current }, /** * 生命周期函数--监听页面加载 */ onLoad: function () { var that = this try { var value = wx.getStorageSync('examtest') console.log(value) if (value) { for(var i=0;i 40) { that.data.ctms.length = 40 } } that.data.tms[i].score = tm_result.score score = score + tm_result.score } that.data.examtest.score = score if (score >= that.data.examtest.pass_score){ that.data.examtest.is_pass = true }else{ that.data.examtest.is_pass = false } that.data.examtest.questions = that.data.tms that.data.examtest.start_time = util.formatTime(new Date(that.data.starttimes)) that.data.examtest.end_time = util.formatTime(new Date()) that.data.examtest.took = Math.floor(((new Date()).getTime() - this.data.starttimes) / 1000) api.request('/examtest/examtest/', 'POST', that.data.examtest).then(res => { wx.hideLoading() getApp().globalData.testData = res.data try { wx.removeStorageSync('examtest') } catch (e) { } wx.redirectTo({ url: 'result', }) }) } })