setting.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. import common from '../../utils/util';
  2. import main from '../../utils/main';
  3. const app = getApp();
  4. const arrSortType = ["时间较早的题卡", "时间较近的题卡"];
  5. const arrSortType2 = ["较早的", "较近的"];
  6. var arrUserName = ["程杰", "程晟涵", "洪立人", "唱意班主任"];
  7. var arrUserID = [1, 2, 3, 4];
  8. Page({
  9. data: {
  10. CardNumber: [],
  11. IsShowChange: false,
  12. ProgramName: app.globalData.ProgramName,
  13. Version:app.globalData.Version,
  14. },
  15. onLoad: function () {
  16. wx.hideShareMenu();
  17. var that = this;
  18. for (var i = 5; i <= 200; i++) {
  19. that.data.CardNumber.push(i);
  20. }
  21. that.setData({
  22. Containnerheight: main.getWindowHeight(),
  23. CardNumber: that.data.CardNumber,
  24. MinSecond: 10,
  25. TimeSecond: 60,
  26. });
  27. common.getStorageValue(this, "CardMaxNumberNew", 10, function () {
  28. that.setData({
  29. CardMaxNumberNewIndex: that.data.CardMaxNumberNew - 5,
  30. });
  31. });
  32. common.getStorageValue(this, "CardMaxNumberHistory", 30, function () {
  33. that.setData({
  34. CardMaxNumberHistoryIndex: that.data.CardMaxNumberHistory - 5,
  35. });
  36. });
  37. common.getStorageValue(this, "SortTypeIndex", 0, function () {
  38. that.setData({
  39. SortType: arrSortType2[that.data.SortTypeIndex],
  40. });
  41. });
  42. common.getStorageValue(this, "UserID", 1, function () {
  43. for (var i = 0; i < arrUserID.length; i++) {
  44. if (arrUserID[i] == that.data.UserID) {
  45. that.setData({
  46. UserName: arrUserName[i],
  47. });
  48. break;
  49. }
  50. }
  51. });
  52. if (app.globalData.userInfo.UserID == 1 || app.globalData.userInfo.UserID == 2) {
  53. that.setData({
  54. IsShowChange: true,
  55. });
  56. }
  57. },
  58. onShow: function () {
  59. var colorIndex = wx.getStorageSync("ColorIndex");
  60. if (!colorIndex) {
  61. this.setData({
  62. ColorName: "每次更换配色",
  63. });
  64. }
  65. else {
  66. var color = main.getDetailColor(colorIndex);
  67. this.setData({
  68. ColorName: color.Name,
  69. });
  70. }
  71. },
  72. bindUpdateCardNumberNewMax: function (e) {
  73. this.data.CardMaxNumberNewIndex = e.detail.value;
  74. this.setData({
  75. CardMaxNumberNewIndex: this.data.CardMaxNumberNewIndex,
  76. CardMaxNumberNew: this.data.CardNumber[this.data.CardMaxNumberNewIndex],
  77. });
  78. wx.setStorageSync("CardMaxNumberNew", this.data.CardNumber[this.data.CardMaxNumberNewIndex]);
  79. },
  80. bindUpdateCardNumberHistoryMax: function (e) {
  81. this.data.CardMaxNumberHistoryIndex = e.detail.value;
  82. this.setData({
  83. CardMaxNumberHistoryIndex: this.data.CardMaxNumberHistoryIndex,
  84. CardMaxNumberHistory: this.data.CardNumber[this.data.CardMaxNumberHistoryIndex],
  85. });
  86. wx.setStorageSync("CardMaxNumberHistory", this.data.CardNumber[this.data.CardMaxNumberHistoryIndex]);
  87. },
  88. setSortType: function () {
  89. var that = this;
  90. wx.showActionSheet({
  91. itemList: arrSortType,
  92. success(res) {
  93. that.setData({
  94. SortType: arrSortType2[res.tapIndex],
  95. });
  96. wx.setStorageSync("SortTypeIndex", res.tapIndex);
  97. },
  98. fail(res) {
  99. console.log(res.errMsg)
  100. }
  101. })
  102. },
  103. setSelectUser: function () {
  104. var that = this;
  105. wx.showActionSheet({
  106. itemList: arrUserName,
  107. success(res) {
  108. for (var i = 0; i < arrUserName.length; i++) {
  109. if (i == res.tapIndex) {
  110. that.setData({
  111. UserName: arrUserName[i],
  112. });
  113. wx.setStorageSync("UserID", arrUserID[i]);
  114. wx.setStorageSync("UserName", arrUserName[i]);
  115. app.globalData.userInfo.UserID = arrUserID[i];
  116. break;
  117. }
  118. }
  119. },
  120. fail(res) {
  121. console.log(res.errMsg)
  122. }
  123. })
  124. },
  125. setColorPlan: function () {
  126. wx.navigateTo({
  127. url: './colorplan',
  128. })
  129. },
  130. onShareAppMessage: function () {
  131. return {
  132. title: app.globalData.ShareTitle,
  133. path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID,
  134. imageUrl: app.globalData.ShareImage,
  135. }
  136. },
  137. });