pattern.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. import common from '../../utils/util';
  2. import main from '../../utils/main';
  3. const app = getApp();
  4. const DefaultSecondArray = [5, 40, 60];
  5. Page({
  6. data: {
  7. MemoryLevel:0,
  8. IsChangeRecommend: false,
  9. SecondConfig: [{
  10. Key: "蓝色",
  11. }, {
  12. Key: "绿色",
  13. }, {
  14. Key: "黄色",
  15. }
  16. ],
  17. },
  18. onLoad: function (options) {
  19. var that = this;
  20. that.setData({
  21. Containnerheight: main.getWindowHeight(),
  22. ArrMemoryLevelAll: main.getMemoryLevelAll(),
  23. });
  24. that.init();
  25. },
  26. init: function (id) {
  27. var that = this;
  28. var secondConfig = wx.getStorageSync("SecondConfigArray");
  29. secondConfig = secondConfig.toString().split(",");
  30. if (!secondConfig || secondConfig[0] == 0) {
  31. that.data.IsChangeRecommend = false;
  32. secondConfig = ["0", "0", "0"];
  33. }
  34. else {
  35. that.data.IsChangeRecommend = true;
  36. for (var j = 0; j < 3; j++) {
  37. var arr = [];
  38. for (var i = 3; i <= 90; i++) {
  39. arr.push(i);
  40. }
  41. that.data.SecondConfig[j].Value = secondConfig[j];
  42. that.data.SecondConfig[j].NumberArray = arr;
  43. }
  44. }
  45. if (that.data.IsChangeRecommend)
  46. that.data.ArrMemoryLevelAll[1].Value[3].H = 50;
  47. else
  48. that.data.ArrMemoryLevelAll[1].Value[3].H = 10;
  49. that.setData({
  50. IsChangeRecommend: that.data.IsChangeRecommend,
  51. SecondConfig: that.data.SecondConfig,
  52. ArrMemoryLevelAll: that.data.ArrMemoryLevelAll,
  53. });
  54. wx.setStorageSync("SecondConfigArray", secondConfig);
  55. var MemoryLevel = wx.getStorageSync("MemoryLevel");
  56. if (!MemoryLevel) {
  57. MemoryLevel = 0;
  58. }
  59. else if (MemoryLevel>0){
  60. MemoryLevel=1;
  61. }
  62. that.setData({
  63. MemoryLevel: MemoryLevel,
  64. });
  65. app.globalData.MemoryLevel = MemoryLevel;
  66. },
  67. selectPattern:function(e){
  68. var that = this;
  69. var index = e.currentTarget.dataset.index;
  70. that.setData({
  71. MemoryLevel:index,
  72. });
  73. wx.setStorageSync("MemoryLevel", index);
  74. app.globalData.MemoryLevel = index;
  75. main.UploadUserConfig();
  76. },
  77. switch1Change(e) {
  78. var that = this;
  79. that.data.IsChangeRecommend = e.detail.value;
  80. if (that.data.IsChangeRecommend)
  81. that.data.ArrMemoryLevelAll[1].Value[3].H = 50;
  82. else
  83. that.data.ArrMemoryLevelAll[1].Value[3].H = 10;
  84. that.setData({
  85. IsChangeRecommend: that.data.IsChangeRecommend,
  86. ArrMemoryLevelAll: that.data.ArrMemoryLevelAll,
  87. });
  88. if (that.data.IsChangeRecommend)
  89. wx.setStorageSync("SecondConfigArray", DefaultSecondArray);
  90. else
  91. wx.setStorageSync("SecondConfigArray", ["0", "0", "0"]);
  92. main.UploadUserConfig();
  93. that.init();
  94. },
  95. bindRecommendTime: function (e) {
  96. var that = this;
  97. var index = e.currentTarget.dataset.index;
  98. this.data.SecondConfig[index].Value = Number(e.detail.value) + 3;
  99. if (this.data.SecondConfig[0].Value >= this.data.SecondConfig[1].Value) {
  100. wx.showToast({
  101. title: '绿需大于蓝',
  102. });
  103. }
  104. else if (this.data.SecondConfig[1].Value >= this.data.SecondConfig[2].Value) {
  105. wx.showToast({
  106. title: '黄需大于绿',
  107. });
  108. }
  109. else {
  110. this.setData({
  111. SecondConfig: this.data.SecondConfig,
  112. });
  113. var arr = [this.data.SecondConfig[0].Value, this.data.SecondConfig[1].Value, this.data.SecondConfig[2].Value];
  114. wx.setStorageSync("SecondConfigArray", arr);
  115. main.UploadUserConfig();
  116. }
  117. },
  118. goto: function (e) {
  119. var url = e.currentTarget.dataset.url;
  120. wx.navigateTo({
  121. url: url,
  122. });
  123. },
  124. onShareAppMessage: function () {
  125. return {
  126. title: app.globalData.ShareTitle,
  127. path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID,
  128. imageUrl: app.globalData.ShareImage,
  129. }
  130. },
  131. })