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"); wx.removeStorageSync("NewConceptEngList"); wx.removeStorageSync("CambridgeEngList"); wx.removeStorageSync("PhoneticEngList"); 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 = []; var listType="hanzi",fieldName="单词",fieldName2="说含义"; if (that.data.BookID > 130){ arr = wx.getStorageSync("CambridgeEngList"); listType="english"; } 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{ arr = wx.getStorageSync("HanziAll"); fieldName="字"; if (that.data.BookID > 24){ fieldName="词"; } } that.setData({ ListType: listType, FieldName:fieldName, FieldName2:fieldName2, }); arr = JSON.parse(arr); var id = Number(options.id); 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) 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] == options.name1 && testReportList[k].Name[1] == list[j].Name) { var testRightCount = 0; if (testReportList[k].TestRightStr) testRightCount = testReportList[k].TestRightStr.length; var testWrongCount = 0; if (testReportList[k].testWrongStr) testWrongCount = testReportList[k].testWrongStr.length; var testSkipCount = 0; if (testReportList[k].TestSkipStr) testSkipCount = testReportList[k].TestSkipStr.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; } } } } 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"){ //main.getData('RestartTestReport?ID='+id+'&UserID=' + app.globalData.userInfo.UserID, function (data) {}); var testReportList = wx.getStorageSync("UserTestReport"); for(var i=0;i