var WxParse = require('../../wxParse/wxParse.js'); const app = getApp(); var that; var Interval; var wechat; var id; var intt; const baseUrl = getApp(); const api = require('../../config/api.js'); const util = require('../../config/util.js'); Page({ startX: 0, startY: 0, isClear: false, /** * 页面的初始数据 */ data: { reexam: 0, //是否反复作答 0不是,1是 index: 0, hour: 0, minute: 0, second: 0, millisecond: 0, timecount: '00:00:00', cost: 0, flag: 1, endtime: "", baseurl: baseUrl.globalData.baseimgurl, time: 1 * 60 * 60 * 1000, //初始时间 paystatus: 1, //1未开始时间开始状态,2开始 collection: 1, //1不收藏,2已收藏 singdouble: 1, //1单选,2多选 paiduanactive: 1,//1不是判断,2是判断题 zstime: 1, //1正计,0倒计 typeid: 1, //0练习1正式 activeopen: true, coursetypefour_id: 1, itemdatacurrent: [], //当前数据 itemdataall: [], //全部数据 itemdata: ['A', 'B', 'C', 'D'], //选项数据 content: "",//富文本数据 showModalStatus: false, pen: 3, color: '#FFFFFF', currentTab: 0, now: 1, //当前页码 all: 15, //总页码 height: 0, Timer_state: 1, Answer_card: false, Draft_paper: false, false_analysis: false, stem_height: 150, jiexi: false, field: { analysis_text: "", }, img: [], scroll: "scroll", drag_line: false, showvide: false, showexampop: false, //查看交卷, examlistdata: [], examlist: [], }, showPopup: function (params) { console.log("params======="); console.log(params); let coursetypefour_id = params.currentTarget.id; wx.navigateTo({ url: '/pages/indexobjectactiveworkok/indexobjectactiveworkok?coursetypefour_id=' + coursetypefour_id, }) console.log("查看交卷"); }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { baseUrl.islogin(); this.setData({ coursetypefour_id: options.id }) }, /**getcoursetypefourexam * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { this.getcoursetypefourexam(this.data.coursetypefour_id); this.getexamobjectactiovename(this.data.coursetypefour_id); // this.initadddata(this.data.itemdataall, this.data.coursetypefour_id, wx.getStorageSync('wxuserid')); }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { }, finished() { console.log("交卷") }, collectionselect: function (e) { console.log(e); this.getcollectionclick(e.currentTarget.id, wx.getStorageSync('wxuserid')); }, //----------------------------- // 手机触摸开始 //----------------------------- touchStart: function (e) { //得到触摸点的坐标 this.startX = e.changedTouches[0].x this.startY = e.changedTouches[0].y this.context = wx.createContext() this.context.setStrokeStyle(this.data.color) this.context.setLineWidth(this.data.pen) this.context.setLineCap('round') // 让线条圆润 this.context.beginPath() }, //----------------------------- // 触摸后移动 //----------------------------- touchMove: function (e) { var startX1 = e.changedTouches[0].x var startY1 = e.changedTouches[0].y this.context.moveTo(this.startX, this.startY) this.context.lineTo(startX1, startY1) this.context.stroke() this.startX = startX1; this.startY = startY1; wx.drawCanvas({ canvasId: 'myCanvas', reserve: true, actions: this.context.getActions() }) }, //多选 bindList(e) { this.getids(); let index = e.currentTarget.dataset.id; console.log(index); let arr = this.data.itemdata.map(item => { if (item.id == index && item.selectvalue == "1") { item.selectvalue = "2"; } else if (item.id == index) { item.selectvalue = "1"; } return item }) console.log(arr); this.setData({ itemdata: arr }); }, //获取id getids() { let ids = this.data.itemdata.filter(item => item.selectvalue == '2').map(item => item.charmu); let dx = this.data.itemdata.filter(item => item.selectvalue == '2').map(item => item.charmu); console.log(ids); console.log(dx); console.log('多选Id:' + ids) console.log('单选Id:' + dx); console.log(this.data.itemdatacurrent); let itemcurrent = this.data.itemdatacurrent; let user_id = wx.getStorageSync('wxuserid') == '' ? 3 : wx.getStorageSync('wxuserid'); let examanswer = 1; if (itemcurrent.examtype == 1) { examanswer = dx + ''; } else { examanswer = ids + ''; } // this.addexamdata(this.data.coursetypefour_id, itemcurrent.examtype, itemcurrent.typeid, itemcurrent.id, itemcurrent.itemname, examanswer, itemcurrent.answer, user_id, itemcurrent.grouppaper_id, this.data.index, this.data.now); }, bindActive: function (params) { console.log(this.data.coursetypefour_id); console.log(params.currentTarget.id); console.log(params.currentTarget.dataset.id); this.updateexamdata(params.currentTarget.id, params.currentTarget.dataset.id); }, getexamobjectactiovename: function (id) { //得到试卷名称 const that = this; let url = baseUrl.globalData.baseUrl + '/examobjectactive/getexamobjectactiovename'; var param = { id: id, }; //此处为使用封装的post请求 util.post(url, param).then((res) => { wx.setNavigationBarTitle({ title: res.data["name"], }) }).catch((errMsg) => { console.log(errMsg); }); }, updateexamdata: function (id, answer) { //得到练习题目 const that = this; let url = baseUrl.globalData.baseUrl + '/examobjectactive/updateexamdata'; var param = { id: id, answer: answer, user_id: wx.getStorageSync('wxuserid') }; //此处为使用封装的post请求 util.post(url, param).then((res) => { this.getcoursetypefourexam(that.data.coursetypefour_id); }).catch((errMsg) => { console.log(errMsg); }); }, getcoursetypefourexam: function (params) { //得到练习题目 const that = this; let url = baseUrl.globalData.baseUrl + '/examobjectactive/paperexamitem'; var param = { coursetypefour_id: params, user_id: wx.getStorageSync('wxuserid') }; //此处为使用封装的post请求 util.post(url, param).then((res) => { console.log("res===================="); console.log(res); that.setData({ itemdataall: res.data, itemdata: res.data }); }).catch((errMsg) => { console.log(errMsg); }); }, })