setting.js 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. import common from '../../utils/util';
  2. import main from '../../utils/main';
  3. const app = getApp();
  4. const arrSortType = ["随机抽取的题卡", "时间较早的题卡", "时间较近的题卡"];
  5. const arrSortType2 = ["随机的", "较早的", "较近的"];
  6. const arrClickType=["专属按钮","点击空白","两种方式"];
  7. var arrUserName = ["程晟涵", "大耳兔", "teresa", "古利古拉", "Lucy-chan","临时"];
  8. var arrUserID = [2, 11, 8, 9, 10, 108];
  9. Page({
  10. data: {
  11. CardNumber: [],
  12. IsShowChange: false,
  13. ProgramName: app.globalData.ProgramName,
  14. Version:app.globalData.Version,
  15. RecommendName:"启用",
  16. },
  17. onLoad: function () {
  18. wx.hideShareMenu();
  19. var that = this;
  20. for (var i = 5; i <= 200; i++) {
  21. that.data.CardNumber.push(i);
  22. }
  23. that.setData({
  24. Containnerheight: main.getWindowHeight(),
  25. CardNumber: that.data.CardNumber,
  26. MinSecond: 10,
  27. TimeSecond: 60,
  28. });
  29. common.getStorageValue(this, "CardMaxNumberNew", 10, function () {
  30. that.setData({
  31. CardMaxNumberNewIndex: that.data.CardMaxNumberNew - 5,
  32. });
  33. });
  34. common.getStorageValue(this, "CardMaxNumberHistory", 30, function () {
  35. that.setData({
  36. CardMaxNumberHistoryIndex: that.data.CardMaxNumberHistory - 5,
  37. });
  38. });
  39. common.getStorageValue(this, "SortTypeIndex", 0, function () {
  40. that.setData({
  41. SortType: arrSortType2[that.data.SortTypeIndex],
  42. });
  43. });
  44. common.getStorageValue(this, "UserID", 1, function () {
  45. for (var i = 0; i < arrUserID.length; i++) {
  46. if (arrUserID[i] == that.data.UserID) {
  47. that.setData({
  48. UserName: arrUserName[i],
  49. });
  50. break;
  51. }
  52. }
  53. });
  54. if (app.globalData.userInfo.UserID == 1 || app.globalData.userInfo.UserID == 2) {
  55. that.setData({
  56. IsShowChange: true,
  57. });
  58. }
  59. },
  60. onShow: function () {
  61. var that=this;
  62. var colorIndex = wx.getStorageSync("ColorIndexArr");
  63. if (!colorIndex || colorIndex.length>1) {
  64. this.setData({
  65. ColorName: "多色变换",
  66. });
  67. }
  68. else {
  69. var color = main.getDetailColor(colorIndex[0]);
  70. this.setData({
  71. ColorName: color.Name,
  72. });
  73. }
  74. var secondConfig = wx.getStorageSync("SecondConfigArray");
  75. if (secondConfig && secondConfig[0] > 0) {
  76. that.setData({
  77. RecommendName: "启用",
  78. });
  79. }
  80. else {
  81. that.setData({
  82. RecommendName: "禁用",
  83. });
  84. }
  85. that.setData({
  86. ClickTypeName: arrClickType[app.globalData.ClickType],
  87. });
  88. this.getMemoryLevel();
  89. },
  90. bindUpdateCardNumberNewMax: function (e) {
  91. this.data.CardMaxNumberNewIndex = e.detail.value;
  92. this.setData({
  93. CardMaxNumberNewIndex: this.data.CardMaxNumberNewIndex,
  94. CardMaxNumberNew: this.data.CardNumber[this.data.CardMaxNumberNewIndex],
  95. });
  96. wx.setStorageSync("CardMaxNumberNew", this.data.CardNumber[this.data.CardMaxNumberNewIndex]);
  97. main.UploadUserConfig();
  98. },
  99. bindUpdateCardNumberHistoryMax: function (e) {
  100. this.data.CardMaxNumberHistoryIndex = e.detail.value;
  101. this.setData({
  102. CardMaxNumberHistoryIndex: this.data.CardMaxNumberHistoryIndex,
  103. CardMaxNumberHistory: this.data.CardNumber[this.data.CardMaxNumberHistoryIndex],
  104. });
  105. wx.setStorageSync("CardMaxNumberHistory", this.data.CardNumber[this.data.CardMaxNumberHistoryIndex]);
  106. main.UploadUserConfig();
  107. },
  108. setSortType: function () {
  109. var that = this;
  110. wx.showActionSheet({
  111. itemList: arrSortType,
  112. success(res) {
  113. that.setData({
  114. SortType: arrSortType2[res.tapIndex],
  115. });
  116. wx.setStorageSync("SortTypeIndex", res.tapIndex);
  117. main.UploadUserConfig();
  118. },
  119. fail(res) {
  120. console.log(res.errMsg)
  121. }
  122. })
  123. },
  124. setSelectUser: function () {
  125. var that = this;
  126. wx.showActionSheet({
  127. itemList: arrUserName,
  128. success(res) {
  129. for (var i = 0; i < arrUserName.length; i++) {
  130. if (i == res.tapIndex) {
  131. that.setData({
  132. UserName: arrUserName[i],
  133. });
  134. wx.setStorageSync("UserID", arrUserID[i]);
  135. wx.setStorageSync("UserName", arrUserName[i]);
  136. app.globalData.userInfo.UserID = arrUserID[i];
  137. break;
  138. }
  139. }
  140. },
  141. fail(res) {
  142. console.log(res.errMsg)
  143. }
  144. })
  145. },
  146. setColorPlan: function () {
  147. wx.navigateTo({
  148. url: './colorplan',
  149. })
  150. },
  151. setMemoryLevel: function () {
  152. wx.navigateTo({
  153. url: './memoryLevel',
  154. })
  155. },
  156. setClickType: function () {
  157. wx.navigateTo({
  158. url: './clicktype',
  159. })
  160. },
  161. updateMember:function(){
  162. wx.reLaunch({
  163. url: '../index/index',
  164. })
  165. },
  166. getMemoryLevel: function () {
  167. var that=this;
  168. var index = wx.getStorageSync("MemoryLevel");
  169. if (!index) {
  170. index = 0;
  171. }
  172. app.globalData.MemoryLevel = index;
  173. var list = main.getMemoryLevelAll();
  174. for (var i = 0; i < list.length; i++) {
  175. if (i == index) {
  176. that.setData({
  177. MemoryLevelName:list[i].Key,
  178. });
  179. break;
  180. }
  181. }
  182. },
  183. setRecommend:function(){
  184. wx.navigateTo({
  185. url: './recommend',
  186. })
  187. },
  188. onShareAppMessage: function () {
  189. return {
  190. title: app.globalData.ShareTitle,
  191. path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID,
  192. imageUrl: app.globalData.ShareImage,
  193. }
  194. },
  195. });