import common from '../../utils/util'; import main from '../../utils/main'; const app = getApp(); Page({ data: { List: [], IsSelectGrade: false, SelectGrade:0, GradeArr: [ { Name: "一年级", Select:"Select", List: [ { ID: 1, Type: "Shizi", Name: "语文识字", Name2: "上学期", Image: "../images/examine_subject_a001.png" }, { ID: 2, Type: "Shizi", Name: "语文识字", Name2: "下学期", Image: "../images/examine_subject_a002.png" }, ] }, { Name: "二年级", Select: "", List: [ { ID: 3, Type: "Shizi", Name: "语文识字", Name2: "上学期", Image: "../images/examine_subject_a003.png" }, { ID: 4, Type: "Shizi", Name: "语文识字", Name2: "下学期", Image: "../images/examine_subject_a004.png" }, ] }, { Name: "三年级", Select: "", List: [ { ID: 5, Type: "Shizi", Name: "语文识字", Name2: "上学期", Image: "../images/examine_subject_a005.png" }, { ID: 6, Type: "Shizi", Name: "语文识字", Name2: "下学期", Image: "../images/examine_subject_a006.png" }, ] } ], }, onLoad: function (options) { var that = this; that.setData({ Containnerheight: main.getWindowHeight(), }); that.getHanzi(function (arr) { if (arr) { } }); }, showSelectGrade: function () { var that = this; that.setData({ IsSelectGrade: true, }); }, closeSelectGrade: function () { var that = this; that.setData({ IsSelectGrade: false, }); }, goto: function (e) { var url = e.currentTarget.dataset.url; wx.navigateTo({ url: url, }); }, getHanzi: function (callback) { var that = this; var time = wx.getStorageSync("HanziUpdateTime"); main.getData('GetHanziAll?UpdateTime=' + time, function (data) { if (data) { var arr = []; if (data.List) { arr = common.Decrypt(data.List); wx.setStorageSync("HanziAll", arr); wx.setStorageSync("HanziUpdateTime", data.UpdateTime); } else { arr = wx.getStorageSync("HanziAll"); arr=JSON.parse(arr); } callback(arr); } }); }, 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({ SelectGrade:index, GradeArr: this.data.GradeArr, }); this.closeSelectGrade(); }, onShareAppMessage: function () { return { title: app.globalData.ShareTitle, path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID, imageUrl: app.globalData.ShareImage, } }, })