import common from '../../utils/util'; import main from '../../utils/main'; const app = getApp(); const arrSortType = ["随机抽取的题卡", "时间较早的题卡", "时间较近的题卡"]; const arrSortType2 = ["随机的", "较早的", "较近的"]; const arrClickType=["专属按钮","点击空白","两种方式"]; var arrUserName = ["程晟涵", "大耳兔", "teresa", "古利古拉", "Lucy-chan","临时"]; var arrUserID = [2, 11, 8, 9, 10, 128]; Page({ data: { CardNumber: [], IsShowChange: false, ProgramName: app.globalData.ProgramName, Version:app.globalData.Version, RecommendName:"启用", }, onLoad: function () { var that = this; for (var i = 5; i <= 200; i++) { that.data.CardNumber.push(i); } that.setData({ Containnerheight: main.getWindowHeight(), CardNumber: that.data.CardNumber, MinSecond: 10, TimeSecond: 60, }); common.getStorageValue(this, "CardMaxNumberNew", 10, function () { that.setData({ CardMaxNumberNewIndex: that.data.CardMaxNumberNew - 5, }); }); common.getStorageValue(this, "CardMaxNumberHistory", 30, function () { that.setData({ CardMaxNumberHistoryIndex: that.data.CardMaxNumberHistory - 5, }); }); common.getStorageValue(this, "SortTypeIndex", 0, function () { that.setData({ SortType: arrSortType2[that.data.SortTypeIndex], }); }); common.getStorageValue(this, "UserID", 1, function () { for (var i = 0; i < arrUserID.length; i++) { if (arrUserID[i] == that.data.UserID) { that.setData({ UserName: arrUserName[i], }); break; } } }); if (app.globalData.userInfo.UserID == 1 || app.globalData.userInfo.UserID == 2) { that.setData({ IsShowChange: true, }); } }, onShow: function () { var that=this; var colorIndex = wx.getStorageSync("ColorIndexArr"); if (!colorIndex || colorIndex.length>1) { this.setData({ ColorName: "多色变换", }); } else { var color = main.getDetailColor(colorIndex[0]); this.setData({ ColorName: color.Name, }); } var secondConfig = wx.getStorageSync("SecondConfigArray"); if (secondConfig && secondConfig[0] > 0) { that.setData({ RecommendName: "启用", }); } else { that.setData({ RecommendName: "禁用", }); } that.setData({ ClickTypeName: arrClickType[app.globalData.ClickType], }); this.getMemoryLevel(); }, bindUpdateCardNumberNewMax: function (e) { this.data.CardMaxNumberNewIndex = e.detail.value; this.setData({ CardMaxNumberNewIndex: this.data.CardMaxNumberNewIndex, CardMaxNumberNew: this.data.CardNumber[this.data.CardMaxNumberNewIndex], }); wx.setStorageSync("CardMaxNumberNew", this.data.CardNumber[this.data.CardMaxNumberNewIndex]); main.UploadUserConfig(); }, bindUpdateCardNumberHistoryMax: function (e) { this.data.CardMaxNumberHistoryIndex = e.detail.value; this.setData({ CardMaxNumberHistoryIndex: this.data.CardMaxNumberHistoryIndex, CardMaxNumberHistory: this.data.CardNumber[this.data.CardMaxNumberHistoryIndex], }); wx.setStorageSync("CardMaxNumberHistory", this.data.CardNumber[this.data.CardMaxNumberHistoryIndex]); main.UploadUserConfig(); }, setSortType: function () { var that = this; wx.showActionSheet({ itemList: arrSortType, success(res) { that.setData({ SortType: arrSortType2[res.tapIndex], }); wx.setStorageSync("SortTypeIndex", res.tapIndex); main.UploadUserConfig(); }, fail(res) { console.log(res.errMsg) } }) }, setSelectUser: function () { var that = this; wx.showActionSheet({ itemList: arrUserName, success(res) { for (var i = 0; i < arrUserName.length; i++) { if (i == res.tapIndex) { that.setData({ UserName: arrUserName[i], }); wx.setStorageSync("UserID", arrUserID[i]); wx.setStorageSync("UserName", arrUserName[i]); app.globalData.userInfo.UserID = arrUserID[i]; break; } } }, fail(res) { console.log(res.errMsg) } }) }, setColorPlan: function () { wx.navigateTo({ url: './colorplan', }) }, setMemoryLevel: function () { wx.navigateTo({ url: './memoryLevel', }) }, setClickType: function () { wx.navigateTo({ url: './clicktype', }) }, updateMember:function(){ wx.reLaunch({ url: '../index/index', }) }, getMemoryLevel: function () { var that=this; var index = wx.getStorageSync("MemoryLevel"); if (!index) { index = 0; } app.globalData.MemoryLevel = index; var list = main.getMemoryLevelAll(); for (var i = 0; i < list.length; i++) { if (i == index) { that.setData({ MemoryLevelName:list[i].Key, }); break; } } }, setRecommend:function(){ wx.navigateTo({ url: './recommend', }) }, gotoPay: function () { wx.navigateTo({ url: '../other/payinfo', }) }, gotoLesson: function () { wx.navigateTo({ url: '../other/lesson', }) }, onShareAppMessage: function () { return { title: app.globalData.ShareTitle, path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID, imageUrl: app.globalData.ShareImage, } }, });