setting.js 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. import common from '../../utils/util';
  2. import main from '../../utils/main';
  3. const app = getApp();
  4. const arrSortType = ["自由安排的", "到期时间较早的", "到期时间较近的"];
  5. const arrClickType = ["专属按钮", "点击空白", "两种方式"];
  6. var arrUserName = ["程晟涵", "临时"];
  7. var arrUserID = [2, 662];
  8. Page({
  9. data: {
  10. CardNumber: [],
  11. IsShowChange: false,
  12. ProgramName: app.globalData.ProgramName,
  13. Version: app.globalData.Version,
  14. RecommendName: "启用",
  15. ChildUserID: 0,
  16. IsPay: true,
  17. IsShow: 0,
  18. },
  19. onPullDownRefresh: function () {
  20. //得到当天任务
  21. var that = this;
  22. main.postData('UploadUserConfig?Type=getData&UserID=' + app.globalData.userInfo.UserID, {}, function (data) {
  23. if (data) {
  24. wx.setStorageSync("CardMaxNumberNew", data.CardMaxNumberNew);
  25. wx.setStorageSync("CardMaxNumberHistory", data.CardMaxNumberHistory);
  26. wx.setStorageSync("SortTypeIndex", data.SortTypeIndex);
  27. wx.setStorageSync("MemoryLevel", data.MemoryLevel);
  28. wx.setStorageSync("ClickType", data.ClickType);
  29. wx.setStorageSync("SecondConfigArray", data.SecondConfigArray.split(","));
  30. wx.setStorageSync("ColorIndexArr", data.ColorIndexArr.split(","));
  31. that.onLoad();
  32. that.onShow();
  33. }
  34. });
  35. wx.stopPullDownRefresh();
  36. },
  37. onLoad: function () {
  38. var that = this;
  39. for (var i = 5; i <= 200; i++) {
  40. that.data.CardNumber.push(i);
  41. }
  42. var childUserID = 0;
  43. if (app.globalData.userInfo.ChildUserID && app.globalData.userInfo.ChildUserID != undefined)
  44. childUserID = app.globalData.userInfo.ChildUserID;
  45. var productServiceTime = common.formatDateCHS(common.formatTime(new Date(app.globalData.userInfo.ProductServiceTime)));
  46. var today15 = common.formatDateCHS(common.formatTime(common.addDate("d", 15, new Date())));
  47. var isPay = true;
  48. if (productServiceTime > today15) {
  49. isPay = false;
  50. }
  51. var taskNumber = app.globalData.TaskToday.ListNew.length + app.globalData.TaskToday.ListReview.length + app.globalData.TaskToday.ListHistory.length;
  52. var cardEveryTime = 1 + Math.round(app.globalData.TaskToday.CardEveryTime / 60 * taskNumber);
  53. that.setData({
  54. Containnerheight: main.getWindowHeight(),
  55. CardNumber: that.data.CardNumber,
  56. MinSecond: 10,
  57. TimeSecond: 60,
  58. ChildUserID: childUserID,
  59. ProductServiceTime: productServiceTime,
  60. IsPay: isPay,
  61. IsShow: app.globalData.IsShow,
  62. TaskNumber: taskNumber,
  63. CardEveryTime:cardEveryTime,
  64. CardLimitTimeNumber: app.globalData.TaskToday.CardLimitTimeNumber,
  65. });
  66. common.getStorageValue(this, "UserID", 1, function () {
  67. for (var i = 0; i < arrUserID.length; i++) {
  68. if (arrUserID[i] == that.data.UserID) {
  69. that.setData({
  70. UserName: arrUserName[i],
  71. });
  72. break;
  73. }
  74. }
  75. });
  76. if (app.globalData.userInfo.UserID == 1 || app.globalData.userInfo.UserID == 2) {
  77. that.setData({
  78. IsShowChange: true,
  79. });
  80. }
  81. },
  82. onShow: function () {
  83. var that = this;
  84. common.getStorageValue(this, "CardMaxNumberNew", 10, function () {
  85. });
  86. common.getStorageValue(this, "CardMaxNumberHistory", 30, function () {
  87. });
  88. common.getStorageValue(this, "SortTypeIndex", 0, function () {
  89. that.setData({
  90. SortType: arrSortType[that.data.SortTypeIndex],
  91. });
  92. });
  93. var colorIndex = wx.getStorageSync("ColorIndexArr");
  94. if (!colorIndex || colorIndex.length > 1) {
  95. this.setData({
  96. ColorName: "多色变换",
  97. });
  98. }
  99. else {
  100. var color = main.getDetailColor(colorIndex[0]);
  101. this.setData({
  102. ColorName: color.Name,
  103. });
  104. }
  105. var secondConfig = wx.getStorageSync("SecondConfigArray");
  106. if (secondConfig && secondConfig[0] > 0) {
  107. that.setData({
  108. RecommendName: "启用",
  109. });
  110. }
  111. else {
  112. that.setData({
  113. RecommendName: "禁用",
  114. });
  115. }
  116. that.setData({
  117. ClickTypeName: arrClickType[app.globalData.ClickType],
  118. });
  119. this.getMemoryLevel();
  120. },
  121. setSortType: function () {
  122. wx.navigateTo({
  123. url: './sortRule',
  124. })
  125. },
  126. setSelectUser: function () {
  127. var that = this;
  128. wx.showActionSheet({
  129. itemList: arrUserName,
  130. success(res) {
  131. for (var i = 0; i < arrUserName.length; i++) {
  132. if (i == res.tapIndex) {
  133. that.setData({
  134. UserName: arrUserName[i],
  135. });
  136. wx.setStorageSync("UserID", arrUserID[i]);
  137. wx.setStorageSync("UserName", arrUserName[i]);
  138. app.globalData.userInfo.UserID = arrUserID[i];
  139. break;
  140. }
  141. }
  142. },
  143. fail(res) {
  144. console.log(res.errMsg)
  145. }
  146. })
  147. },
  148. setColorPlan: function () {
  149. wx.navigateTo({
  150. url: './colorplan',
  151. })
  152. },
  153. setMemoryLevel: function () {
  154. wx.navigateTo({
  155. url: './memoryLevel',
  156. })
  157. },
  158. setClickType: function () {
  159. wx.navigateTo({
  160. url: './clicktype',
  161. })
  162. },
  163. gotoBinding: function () {
  164. wx.navigateTo({
  165. url: '../other/binding',
  166. })
  167. },
  168. updateMember: function () {
  169. wx.reLaunch({
  170. url: '../index/index',
  171. })
  172. },
  173. getMemoryLevel: function () {
  174. var that = this;
  175. var index = wx.getStorageSync("MemoryLevel");
  176. if (!index) {
  177. index = 0;
  178. }
  179. app.globalData.MemoryLevel = index;
  180. var list = main.getMemoryLevelAll();
  181. for (var i = 0; i < list.length; i++) {
  182. if (i == index) {
  183. that.setData({
  184. MemoryLevelName: list[i].Key,
  185. });
  186. break;
  187. }
  188. }
  189. },
  190. setRecommend: function () {
  191. wx.navigateTo({
  192. url: './recommend',
  193. })
  194. },
  195. setTaskLimit: function () {
  196. wx.navigateTo({
  197. url: './taskLimit',
  198. })
  199. },
  200. gotoPay: function () {
  201. var payindex = 3;
  202. if (app.globalData.userInfo.IsFinishTask == 1)
  203. payindex = 2;
  204. wx.navigateTo({
  205. url: '../other/pay?paypanel=1&payindex=' + payindex,
  206. });
  207. },
  208. gotoPayTemp: function (e) {
  209. if (app.globalData.userInfo.UserID <= 7) {
  210. wx.navigateTo({
  211. url: '../other/pay?paypanel=0&payindex=0',
  212. });
  213. }
  214. },
  215. gotoLesson: function () {
  216. if (app.globalData.userInfo.UserID <= 7) {
  217. wx.navigateTo({
  218. url: '../other/lessonlist',
  219. });
  220. }
  221. },
  222. onShareAppMessage: function () {
  223. return {
  224. title: app.globalData.ShareTitle,
  225. path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID,
  226. imageUrl: app.globalData.ShareImage,
  227. }
  228. },
  229. });