recommend.js 2.6 KB

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