recommend.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. IsChangeRecommend: true,
  8. SecondConfig: [{
  9. Key: "蓝色",
  10. }, {
  11. Key: "绿色",
  12. }, {
  13. Key: "黄色",
  14. }
  15. ]
  16. },
  17. onLoad: function (options) {
  18. var that = this;
  19. that.init();
  20. that.setData({
  21. Containnerheight: main.getWindowHeight(),
  22. });
  23. },
  24. init:function(){
  25. var that=this;
  26. var secondConfig = wx.getStorageSync("SecondConfigArray");
  27. if (!secondConfig || secondConfig[0]==0){
  28. that.data.IsChangeRecommend = false;
  29. secondConfig=[0,0,0];
  30. }
  31. else{
  32. secondConfig = DefaultSecondArray;
  33. that.data.IsChangeRecommend = true;
  34. for (var j = 0; j < 3; j++) {
  35. var arr = [];
  36. for (var i = 3; i <= 90; i++) {
  37. arr.push(i);
  38. }
  39. that.data.SecondConfig[j].Value = secondConfig[j];
  40. that.data.SecondConfig[j].NumberArray = arr;
  41. }
  42. }
  43. that.setData({
  44. IsChangeRecommend: that.data.IsChangeRecommend,
  45. SecondConfig: that.data.SecondConfig,
  46. });
  47. wx.setStorageSync("SecondConfigArray", secondConfig);
  48. },
  49. bindRecommendTime: function (e) {
  50. var that = this;
  51. var index = e.currentTarget.dataset.index;
  52. this.data.SecondConfig[index].Value = Number(e.detail.value) + 3;
  53. if (this.data.SecondConfig[0].Value >= this.data.SecondConfig[1].Value) {
  54. wx.showToast({
  55. title: '绿需大于蓝',
  56. });
  57. }
  58. else if (this.data.SecondConfig[1].Value >= this.data.SecondConfig[2].Value) {
  59. wx.showToast({
  60. title: '黄需大于绿',
  61. });
  62. }
  63. else {
  64. this.setData({
  65. SecondConfig: this.data.SecondConfig,
  66. });
  67. var arr = [this.data.SecondConfig[0].Value, this.data.SecondConfig[1].Value, this.data.SecondConfig[2].Value];
  68. wx.setStorageSync("SecondConfigArray", arr);
  69. main.UploadUserConfig();
  70. }
  71. },
  72. switch1Change(e) {
  73. var that = this;
  74. that.data.IsChangeRecommend = e.detail.value;
  75. that.setData({
  76. IsChangeRecommend: that.data.IsChangeRecommend,
  77. });
  78. if (that.data.IsChangeRecommend)
  79. wx.setStorageSync("SecondConfigArray", DefaultSecondArray);
  80. else
  81. wx.setStorageSync("SecondConfigArray", [0, 0, 0]);
  82. main.UploadUserConfig();
  83. that.init();
  84. },
  85. onShareAppMessage: function () {
  86. return {
  87. title: app.globalData.ShareTitle,
  88. path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID,
  89. imageUrl: app.globalData.ShareImage,
  90. }
  91. },
  92. })