import common from '../../utils/util'; import main from '../../utils/main'; const app = getApp(); const DefaultSecondArray=[5,40,60]; Page({ data: { ImagePath: app.globalData.uploadImageUrl, IsChangeRecommend: true, SecondConfig: [{ Key: "蓝色", }, { Key: "绿色", }, { Key: "黄色", } ] }, onLoad: function (options) { var that = this; that.init(); that.setData({ Containnerheight: main.getWindowHeight(), }); }, init:function(){ var that=this; var secondConfig = wx.getStorageSync("SecondConfigArray"); if (!secondConfig || secondConfig[0]==0){ that.data.IsChangeRecommend = false; secondConfig=[0,0,0]; } else{ secondConfig = DefaultSecondArray; 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; } } that.setData({ IsChangeRecommend: that.data.IsChangeRecommend, SecondConfig: that.data.SecondConfig, }); wx.setStorageSync("SecondConfigArray", secondConfig); }, 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(); } }, switch1Change(e) { var that = this; that.data.IsChangeRecommend = e.detail.value; that.setData({ IsChangeRecommend: that.data.IsChangeRecommend, }); if (that.data.IsChangeRecommend) wx.setStorageSync("SecondConfigArray", DefaultSecondArray); else wx.setStorageSync("SecondConfigArray", [0, 0, 0]); main.UploadUserConfig(); that.init(); }, onShareAppMessage: function () { return { title: app.globalData.ShareTitle, path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID, imageUrl: app.globalData.ShareImage, } }, })