const getHeight = require("../../utils/getRheRemainingHeight"), _Http = getApp().globalData.http; Page({ data: { "content": { "pageNumber": 1, pageTotal: 1, "pageSize": 20, "sat_coursewareid": 0, "where": { "status": "未完成" } } }, onLoad(options) { this.getList() }, getList(init = false) { if (init.detail != undefined) init = init.detail; let content = this.data.content; if (init) content.pageNumber = 1; if (content.pageNumber > content.pageTotal) return; _Http.basic({ "classname": "saletool.courseware.coursewaretest", "method": "queryTestList", content }).then(res => { console.log("试卷列表", res) this.selectComponent('#ListBox').RefreshToComplete(); if (res.msg != '成功') return wx.showToast({ title: res.msg, icon: "none" }) content.pageNumber = res.pageNumber + 1; content.pageTotal = res.pageTotal; this.setData({ list: (res.pageNumber == 1) ? res.data : this.data.list.concat(res.data), total: res.total }) }) }, onSearch({ detail }) { this.data.content.where.condition = detail; this.getList(true); }, startTest(e) { const { sat_coursewareid } = e.currentTarget.dataset; let that = this; _Http.basic({ "classname": "saletool.courseware.coursewaretest", "method": "queryTestList", "content": { "pageNumber": 1, "pageSize": 999, sat_coursewareid, "where": { "status": "" } } }).then(res => { if (res.msg != '成功') return wx.showToast({ title: res.msg, icon: "none" }); if (res.data.length == 0) { this.createTest(); } else { wx.navigateTo({ url: '/pages/exam/detail?id=' + res.data[res.data.length - 1].sat_courseware_testid, }) } }) }, createTest(sat_coursewareid) { _Http.basic({ "classname": "saletool.courseware.coursewaretest", "method": "createTest", "content": { sat_coursewareid } }).then(res => { console.log("开始考试", res) if (res.msg != '成功') return wx.showToast({ title: res.msg, icon: "none" }) this.getList(true); wx.navigateTo({ url: '/pages/exam/detail?id=' + res.data.sat_courseware_testid, }) }) }, tabChange(e) { this.data.content.where.status = e.detail.title; this.getList(true) }, onReady() { //滚动区域高度 getHeight.getHeight('.head', this).then(res => { this.setData({ scrollHeight: res }) }) }, })