import common from '../../utils/util'; import main from '../../utils/main'; import constant from '../../utils/constant'; const app = getApp(); var canPress = true; //按钮按下有反应 Page({ data: { List: [], TestSelectGrade: 0, IsIPhoneX: app.globalData.IsIPhoneX, IsIPad: app.globalData.IsIPad, ScrollLeft: 0, }, onLoad: function (options) { if (options.UserID) { app.globalData.userInfo = {}; app.globalData.userInfo.UserID = options.UserID; } var that = this; that.setData({ Containnerheight: main.getWindowHeight(), Subject: "CHN", }); main.getHanzi(function () { main.getEnglish(function () { }); }); canPress = true; }, onShow: function () { this.getTestReportList(); }, selectSubject: function (e) { var subject = e.currentTarget.dataset.type; var that = this; that.setData({ Subject: subject, }); }, goto: function (e) { //console.log("canPress:"+canPress); if (canPress) { var url = e.currentTarget.dataset.url; if (url == "../other/userbook") { } else if (e.currentTarget.dataset.type == "Shici") { var name1 = e.currentTarget.dataset.name1; name1 = name1.replace("语文古诗文", "语文"); url = "./item?testtype=recite&name1=" + name1 + "&bookid=" + e.currentTarget.dataset.bookid; } else if (e.currentTarget.dataset.type == "Word" && e.currentTarget.dataset.bookid == 100) { var name1 = e.currentTarget.dataset.name1; url = "./item?testtype=read&name1=" + name1 + "&name2=英文字母&bookid=100"; } else if (e.currentTarget.dataset.name1 && e.currentTarget.dataset.bookid) { url = "./list?name1=" + e.currentTarget.dataset.name1 + "&id=" + e.currentTarget.dataset.bookid; } wx.navigateTo({ url: url, }); canPress = false; //console.log("canPress:"+canPress); setTimeout(function () { canPress = true; //console.log("canPress:"+canPress); }, 2000); } }, getTestReportList: function () { var that = this; var userid = app.globalData.userInfo.UserID; main.GetTestReportList(userid, function (data, GradeArrResult) { that.setData({ TestReport: data, GradeArr: GradeArrResult, }); common.getStorageValue(that, "TestSelectGrade", 0, function () { that.onSelectGrade({ currentTarget: { dataset: { value: that.data.TestSelectGrade } } }); if (that.data.TestSelectGrade < 9) { that.setData({ Subject: "CHN", }); if (that.data.TestSelectGrade > 4) { that.setData({ ScrollLeft: 500, }); } } else { that.setData({ Subject: "ENG", }); if (that.data.TestSelectGrade > 11) { that.setData({ ScrollLeft: 500, }); } } }); }); }, onSelectGrade: function (e) { var index = e.currentTarget.dataset.value; for (var i = 0; i < this.data.GradeArr.length; i++) this.data.GradeArr[i].Select = ""; this.data.GradeArr[index].Select = "Select"; this.setData({ TestSelectGrade: index, GradeArr: this.data.GradeArr, }); wx.setStorageSync("TestSelectGrade", index); }, gotoTestReportInfo: function (e) { var id = e.currentTarget.dataset.id; var userid = app.globalData.userInfo.UserID; main.GetTestReportInfo(id, function (data) { wx.setStorageSync("TestTask", data); wx.navigateTo({ url: "./report?type=edit", }); }); }, onUnload: function () { wx.removeStorageSync("UserTestReport"); }, gotoReLaunch: function (e) { var url = e.currentTarget.dataset.url; wx.reLaunch({ url: url, }); }, onShareAppMessage: function () { return { title: app.globalData.ShareTitle, path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID, imageUrl: app.globalData.ShareImage, } }, })