pattern.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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. if (!secondConfig || secondConfig[0] == 0) {
  30. that.data.IsChangeRecommend = false;
  31. secondConfig = [0, 0, 0];
  32. }
  33. else {
  34. secondConfig = DefaultSecondArray;
  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. that.setData({
  46. IsChangeRecommend: that.data.IsChangeRecommend,
  47. SecondConfig: that.data.SecondConfig,
  48. });
  49. wx.setStorageSync("SecondConfigArray", secondConfig);
  50. var MemoryLevel = wx.getStorageSync("MemoryLevel");
  51. if (!MemoryLevel) {
  52. MemoryLevel = 0;
  53. }
  54. else if (MemoryLevel>0){
  55. MemoryLevel=1;
  56. }
  57. app.globalData.MemoryLevel = MemoryLevel;
  58. },
  59. selectPattern:function(e){
  60. var that = this;
  61. var index = e.currentTarget.dataset.index;
  62. that.setData({
  63. MemoryLevel:index,
  64. });
  65. wx.setStorageSync("MemoryLevel", index);
  66. app.globalData.MemoryLevel = index;
  67. main.UploadUserConfig();
  68. },
  69. switch1Change(e) {
  70. var that = this;
  71. that.data.IsChangeRecommend = e.detail.value;
  72. that.setData({
  73. IsChangeRecommend: that.data.IsChangeRecommend,
  74. });
  75. if (that.data.IsChangeRecommend)
  76. wx.setStorageSync("SecondConfigArray", DefaultSecondArray);
  77. else
  78. wx.setStorageSync("SecondConfigArray", [0, 0, 0]);
  79. main.UploadUserConfig();
  80. that.init();
  81. },
  82. bindRecommendTime: function (e) {
  83. var that = this;
  84. var index = e.currentTarget.dataset.index;
  85. this.data.SecondConfig[index].Value = Number(e.detail.value) + 3;
  86. if (this.data.SecondConfig[0].Value >= this.data.SecondConfig[1].Value) {
  87. wx.showToast({
  88. title: '绿需大于蓝',
  89. });
  90. }
  91. else if (this.data.SecondConfig[1].Value >= this.data.SecondConfig[2].Value) {
  92. wx.showToast({
  93. title: '黄需大于绿',
  94. });
  95. }
  96. else {
  97. this.setData({
  98. SecondConfig: this.data.SecondConfig,
  99. });
  100. var arr = [this.data.SecondConfig[0].Value, this.data.SecondConfig[1].Value, this.data.SecondConfig[2].Value];
  101. wx.setStorageSync("SecondConfigArray", arr);
  102. main.UploadUserConfig();
  103. }
  104. },
  105. onShareAppMessage: function () {
  106. return {
  107. title: app.globalData.ShareTitle,
  108. path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID,
  109. imageUrl: app.globalData.ShareImage,
  110. }
  111. },
  112. })