setting.js 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  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, 128];
  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. var that = this;
  19. for (var i = 5; i <= 200; i++) {
  20. that.data.CardNumber.push(i);
  21. }
  22. that.setData({
  23. Containnerheight: main.getWindowHeight(),
  24. CardNumber: that.data.CardNumber,
  25. MinSecond: 10,
  26. TimeSecond: 60,
  27. });
  28. common.getStorageValue(this, "CardMaxNumberNew", 10, function () {
  29. that.setData({
  30. CardMaxNumberNewIndex: that.data.CardMaxNumberNew - 5,
  31. });
  32. });
  33. common.getStorageValue(this, "CardMaxNumberHistory", 30, function () {
  34. that.setData({
  35. CardMaxNumberHistoryIndex: that.data.CardMaxNumberHistory - 5,
  36. });
  37. });
  38. common.getStorageValue(this, "SortTypeIndex", 0, function () {
  39. that.setData({
  40. SortType: arrSortType2[that.data.SortTypeIndex],
  41. });
  42. });
  43. common.getStorageValue(this, "UserID", 1, function () {
  44. for (var i = 0; i < arrUserID.length; i++) {
  45. if (arrUserID[i] == that.data.UserID) {
  46. that.setData({
  47. UserName: arrUserName[i],
  48. });
  49. break;
  50. }
  51. }
  52. });
  53. if (app.globalData.userInfo.UserID == 1 || app.globalData.userInfo.UserID == 2) {
  54. that.setData({
  55. IsShowChange: true,
  56. });
  57. }
  58. },
  59. onShow: function () {
  60. var that=this;
  61. var colorIndex = wx.getStorageSync("ColorIndexArr");
  62. if (!colorIndex || colorIndex.length>1) {
  63. this.setData({
  64. ColorName: "多色变换",
  65. });
  66. }
  67. else {
  68. var color = main.getDetailColor(colorIndex[0]);
  69. this.setData({
  70. ColorName: color.Name,
  71. });
  72. }
  73. var secondConfig = wx.getStorageSync("SecondConfigArray");
  74. if (secondConfig && secondConfig[0] > 0) {
  75. that.setData({
  76. RecommendName: "启用",
  77. });
  78. }
  79. else {
  80. that.setData({
  81. RecommendName: "禁用",
  82. });
  83. }
  84. that.setData({
  85. ClickTypeName: arrClickType[app.globalData.ClickType],
  86. });
  87. this.getMemoryLevel();
  88. },
  89. bindUpdateCardNumberNewMax: function (e) {
  90. this.data.CardMaxNumberNewIndex = e.detail.value;
  91. this.setData({
  92. CardMaxNumberNewIndex: this.data.CardMaxNumberNewIndex,
  93. CardMaxNumberNew: this.data.CardNumber[this.data.CardMaxNumberNewIndex],
  94. });
  95. wx.setStorageSync("CardMaxNumberNew", this.data.CardNumber[this.data.CardMaxNumberNewIndex]);
  96. main.UploadUserConfig();
  97. },
  98. bindUpdateCardNumberHistoryMax: function (e) {
  99. this.data.CardMaxNumberHistoryIndex = e.detail.value;
  100. this.setData({
  101. CardMaxNumberHistoryIndex: this.data.CardMaxNumberHistoryIndex,
  102. CardMaxNumberHistory: this.data.CardNumber[this.data.CardMaxNumberHistoryIndex],
  103. });
  104. wx.setStorageSync("CardMaxNumberHistory", this.data.CardNumber[this.data.CardMaxNumberHistoryIndex]);
  105. main.UploadUserConfig();
  106. },
  107. setSortType: function () {
  108. var that = this;
  109. wx.showActionSheet({
  110. itemList: arrSortType,
  111. success(res) {
  112. that.setData({
  113. SortType: arrSortType2[res.tapIndex],
  114. });
  115. wx.setStorageSync("SortTypeIndex", res.tapIndex);
  116. main.UploadUserConfig();
  117. },
  118. fail(res) {
  119. console.log(res.errMsg)
  120. }
  121. })
  122. },
  123. setSelectUser: function () {
  124. var that = this;
  125. wx.showActionSheet({
  126. itemList: arrUserName,
  127. success(res) {
  128. for (var i = 0; i < arrUserName.length; i++) {
  129. if (i == res.tapIndex) {
  130. that.setData({
  131. UserName: arrUserName[i],
  132. });
  133. wx.setStorageSync("UserID", arrUserID[i]);
  134. wx.setStorageSync("UserName", arrUserName[i]);
  135. app.globalData.userInfo.UserID = arrUserID[i];
  136. break;
  137. }
  138. }
  139. },
  140. fail(res) {
  141. console.log(res.errMsg)
  142. }
  143. })
  144. },
  145. setColorPlan: function () {
  146. wx.navigateTo({
  147. url: './colorplan',
  148. })
  149. },
  150. setMemoryLevel: function () {
  151. wx.navigateTo({
  152. url: './memoryLevel',
  153. })
  154. },
  155. setClickType: function () {
  156. wx.navigateTo({
  157. url: './clicktype',
  158. })
  159. },
  160. updateMember:function(){
  161. wx.reLaunch({
  162. url: '../index/index',
  163. })
  164. },
  165. getMemoryLevel: function () {
  166. var that=this;
  167. var index = wx.getStorageSync("MemoryLevel");
  168. if (!index) {
  169. index = 0;
  170. }
  171. app.globalData.MemoryLevel = index;
  172. var list = main.getMemoryLevelAll();
  173. for (var i = 0; i < list.length; i++) {
  174. if (i == index) {
  175. that.setData({
  176. MemoryLevelName:list[i].Key,
  177. });
  178. break;
  179. }
  180. }
  181. },
  182. setRecommend:function(){
  183. wx.navigateTo({
  184. url: './recommend',
  185. })
  186. },
  187. gotoPay: function () {
  188. wx.navigateTo({
  189. url: '../other/payinfo',
  190. })
  191. },
  192. gotoLesson: function () {
  193. wx.navigateTo({
  194. url: '../other/lesson',
  195. })
  196. },
  197. onShareAppMessage: function () {
  198. return {
  199. title: app.globalData.ShareTitle,
  200. path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID,
  201. imageUrl: app.globalData.ShareImage,
  202. }
  203. },
  204. });