import common from '../../utils/util'; import main from '../../utils/main'; const app = getApp(); const DefaultSecondArray = [5, 40, 60]; Page({ data: { MemoryLevel:0, IsChangeRecommend: false, SecondConfig: [{ Key: "蓝色", }, { Key: "绿色", }, { Key: "黄色", } ], }, onLoad: function (options) { var that = this; that.setData({ Containnerheight: main.getWindowHeight(), ArrMemoryLevelAll: main.getMemoryLevelAll(), }); that.init(); }, init: function (id) { var that = this; var secondConfig = wx.getStorageSync("SecondConfigArray"); secondConfig = secondConfig.toString().split(","); if (!secondConfig || secondConfig[0] == 0) { that.data.IsChangeRecommend = false; secondConfig = ["0", "0", "0"]; } else { that.data.IsChangeRecommend = true; for (var j = 0; j < 3; j++) { var arr = []; for (var i = 3; i <= 90; i++) { arr.push(i); } that.data.SecondConfig[j].Value = secondConfig[j]; that.data.SecondConfig[j].NumberArray = arr; } } if (that.data.IsChangeRecommend) that.data.ArrMemoryLevelAll[1].Value[3].H = 50; else that.data.ArrMemoryLevelAll[1].Value[3].H = 10; that.setData({ IsChangeRecommend: that.data.IsChangeRecommend, SecondConfig: that.data.SecondConfig, ArrMemoryLevelAll: that.data.ArrMemoryLevelAll, }); wx.setStorageSync("SecondConfigArray", secondConfig); var MemoryLevel = wx.getStorageSync("MemoryLevel"); if (!MemoryLevel) { MemoryLevel = 0; } else if (MemoryLevel>0){ MemoryLevel=1; } that.setData({ MemoryLevel: MemoryLevel, }); app.globalData.MemoryLevel = MemoryLevel; }, selectPattern:function(e){ var that = this; var index = e.currentTarget.dataset.index; that.setData({ MemoryLevel:index, }); wx.setStorageSync("MemoryLevel", index); app.globalData.MemoryLevel = index; main.UploadUserConfig(); }, switch1Change(e) { var that = this; that.data.IsChangeRecommend = e.detail.value; if (that.data.IsChangeRecommend) that.data.ArrMemoryLevelAll[1].Value[3].H = 50; else that.data.ArrMemoryLevelAll[1].Value[3].H = 10; that.setData({ IsChangeRecommend: that.data.IsChangeRecommend, ArrMemoryLevelAll: that.data.ArrMemoryLevelAll, }); if (that.data.IsChangeRecommend) wx.setStorageSync("SecondConfigArray", DefaultSecondArray); else wx.setStorageSync("SecondConfigArray", ["0", "0", "0"]); main.UploadUserConfig(); that.init(); }, bindRecommendTime: function (e) { var that = this; var index = e.currentTarget.dataset.index; this.data.SecondConfig[index].Value = Number(e.detail.value) + 3; if (this.data.SecondConfig[0].Value >= this.data.SecondConfig[1].Value) { wx.showToast({ title: '绿需大于蓝', }); } else if (this.data.SecondConfig[1].Value >= this.data.SecondConfig[2].Value) { wx.showToast({ title: '黄需大于绿', }); } else { this.setData({ SecondConfig: this.data.SecondConfig, }); var arr = [this.data.SecondConfig[0].Value, this.data.SecondConfig[1].Value, this.data.SecondConfig[2].Value]; wx.setStorageSync("SecondConfigArray", arr); main.UploadUserConfig(); } }, goto: function (e) { 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, } }, })