import common from '../../utils/util'; import main from '../../utils/main'; const app = getApp(); var isClick = true; Page({ data: { IsSelect: false, ImagePath: app.globalData.uploadImageUrl, }, onLoad: function(options) { var that = this; that.setData({ BookID:options.id, Containnerheight: main.getWindowHeight(), Name1: options.name1, }); isClick = true; main.getHanzi(function(arr) { if (!arr) { wx.removeStorageSync("HanziUpdateTime"); wx.removeStorageSync("HanziAll"); main.getHanzi(function(arr) { that.init(options); }); } else { that.init(options); } }); }, init: function(options) { var that = this; var name = options.name1; if (name.indexOf(" ") > 0) name = name.substr(name.indexOf(" ") + 1); wx.setNavigationBarTitle({ title: name }); var arr = []; if (that.data.BookID==13 || that.data.BookID==14 || that.data.BookID==15) arr = wx.getStorageSync("EnglishAll"); else if (that.data.BookID<=12) arr = wx.getStorageSync("HanziAll"); var testReportList = wx.getStorageSync("UserTestReport"); arr = JSON.parse(arr); var id = Number(options.id); for (var i = 0; i < arr.length; i++) { if (arr[i].ID == id) { var list = arr[i].Units; for (var j = 0; j < list.length; j++) { var str = ""; for (var k = 0; k < list[j].Words.length; k++) { if (k < 27 && k < list[j].Words.length - 1) str += list[j].Words[k].Name + "、"; else if (k == list[j].Words.length - 1) str += list[j].Words[k].Name; else { str += list[j].Words[k].Name + "…"; break; } } list[j].WordList = str; list[j].TestTypeReadFinished = true; list[j].TestTypeWriteFinished = true; for (var k = 0; k < testReportList.length; k++) { if (testReportList[k].Name[0] == options.name1 && testReportList[k].Name[1] == list[j].Name) { if (testReportList[k].TestType == "read") { if (testReportList[k].IsFinished == 1) list[j].TestTypeRead = 1; if ((testReportList[k].TestRight + testReportList[k].TestWrong + testReportList[k].TestSkip) < testReportList[k].TestTotal) { list[j].TestTypeReadFinished = false; } list[j].ReadReportID = testReportList[k].ID; } if (testReportList[k].TestType == "write") { if (testReportList[k].IsFinished == 1) list[j].TestTypeWrite = 1; if ((testReportList[k].TestRight + testReportList[k].TestWrong + testReportList[k].TestSkip) < testReportList[k].TestTotal) { list[j].TestTypeWriteFinished = false; } list[j].WriteReportID = testReportList[k].ID; } } } } that.setData({ List: list, UnitsID: id, }); } } }, onShowFrame: function(e) { var selectItem; var id = e.currentTarget.dataset.id; for (var i = 0; i < this.data.List.length; i++) { if (id == this.data.List[i].ID) { selectItem = this.data.List[i]; } } this.setData({ IsSelect: true, SelectItem: selectItem, }); }, onClose: function() { this.setData({ IsSelect: false, }); }, goto: function(e) { var url = e.currentTarget.dataset.url; wx.navigateTo({ url: url, }); this.onClose(); }, gotoTestReportInfo: function(e) { var that=this; if (isClick) { isClick=false; setTimeout(function(){ isClick=true; },2000); var id = e.currentTarget.dataset.id; var userid = app.globalData.userInfo.UserID; if (id) { var reporttype = e.currentTarget.dataset.type; // main.getData('GetTestReportInfo?UserID=' + userid + '&ID=' + id, function(data) { // if (data) { // wx.setStorageSync("TestTask2", data); // that.onClose(); // wx.navigateTo({ // url: "./item?type=" + reporttype, // }); // } // }); main.GetTestReportInfo(id,function(data){ wx.setStorageSync("TestTask2", data); that.onClose(); wx.navigateTo({ url: "./item?type=" + reporttype, }); }); } else { that.onClose(); var url = e.currentTarget.dataset.url; wx.navigateTo({ url: url, }); } } }, onShareAppMessage: function() { return { title: app.globalData.ShareTitle, path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID, imageUrl: app.globalData.ShareImage, } }, })