import common from '../../utils/util'; import main from '../../utils/main'; import constant from '../../utils/constant'; const app = getApp(); var isClick = true; var isStart = 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 () { main.getEnglish(function () { that.init(); isStart=false; }); }); }, onUnload:function(){ isStart = true; }, onShow:function(){ if (!isStart) this.init(); }, init: function () { var that = this; var name = that.data.Name1; if (name.indexOf(" ") > 0) name = name.substr(name.indexOf(" ") + 1); wx.setNavigationBarTitle({ title: name }); var arr = []; var listType="hanzi",fieldName="单词",fieldName2="说含义"; if (that.data.BookID > 164){ arr = wx.getStorageSync("CEWEngList"); listType="english"; } else if (that.data.BookID > 160){ arr = wx.getStorageSync("BEWEngList"); listType="english"; } else if (that.data.BookID > 150){ arr = wx.getStorageSync("MiddleSchoolTestWords"); listType="english"; } else if (that.data.BookID > 140){ arr = wx.getStorageSync("EEWEngList"); listType="english"; } else if (that.data.BookID > 130){ arr = wx.getStorageSync("CambridgeEngList"); listType="english"; if (that.data.BookID==135) fieldName="词组"; } else if (that.data.BookID > 120){ arr = wx.getStorageSync("NewConceptEngList"); listType="english"; } else if (that.data.BookID > 110){ arr = wx.getStorageSync("EnglishAll"); listType="english"; } else if (that.data.BookID > 100){ arr = wx.getStorageSync("PhoneticEngList"); fieldName="音标"; fieldName2=""; listType="english"; } else if (that.data.BookID >= 43 && that.data.BookID <= 44){ arr = constant.arrPinyinList; fieldName="拼音"; fieldName2=""; listType="音"; } else{ arr = wx.getStorageSync("HanziAll"); fieldName="汉字"; fieldName2=""; if (that.data.BookID == 73){ fieldName="含义"; listType="Wenyanwen"; } else if (that.data.BookID == 86){ fieldName="句子"; listType="Guwen"; } else if (that.data.BookID >= 45 && that.data.BookID <= 60){ fieldName="词语"; } } that.setData({ ListType: listType, FieldName:fieldName, FieldName2:fieldName2, }); if (that.data.BookID < 43 ||that.data.BookID > 44){ arr = JSON.parse(arr); } var id = that.data.BookID; var testReportList = wx.getStorageSync("UserTestReport"); 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){ if (that.data.BookID==73) str += list[j].Words[k] + " "; else str += list[j].Words[k] + "、"; } else if (k == list[j].Words.length - 1) str += list[j].Words[k]; else { str += list[j].Words[k] + "…"; 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] == that.data.Name1 && testReportList[k].Name[1] == list[j].Name) { var testRightCount = 0; if (testReportList[k].TestRightStr){ testRightCount = testReportList[k].TestRightStr.length; if (id==73 && testReportList[k].TestRightStr.length>0){ testRightCount=testReportList[k].TestRightStr.toString().split(",").length; } } var testWrongCount = 0; if (testReportList[k].TestWrongStr){ testWrongCount = testReportList[k].TestWrongStr.length; if (id==73 && testReportList[k].TestWrongStr.length>0){ var arrTemp=testReportList[k].TestWrongStr.toString().split(","); testWrongCount=arrTemp.length; } } var testSkipCount = 0; if (testReportList[k].TestSkipStr){ testSkipCount = testReportList[k].TestSkipStr.length; if (id==73 && testReportList[k].TestSkipStr.length>0){ testSkipCount=testReportList[k].TestSkipStr.toString().split(",").length; } } if (testReportList[k].TestType == "read") { if (testReportList[k].IsFinished == 1) list[j].TestTypeRead = 1; if ((testRightCount + testWrongCount + testSkipCount) < 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 ((testRightCount + testWrongCount + testSkipCount) < testReportList[k].TestTotal) { list[j].TestTypeWriteFinished = false; } list[j].WriteReportID = testReportList[k].ID; } } } } //console.log("List:"+list.length); 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; if (reporttype=="restart"){ var testReportList = wx.getStorageSync("UserTestReport"); for(var i=0;i