recommend.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. import common from '../../utils/util';
  2. import main from '../../utils/main';
  3. const app = getApp();
  4. Page({
  5. data: {
  6. IsChangeRecommend: true,
  7. SecondConfig: [{
  8. Key: "蓝色",
  9. }, {
  10. Key: "绿色",
  11. }, {
  12. Key: "黄色",
  13. }
  14. ]
  15. },
  16. onLoad: function (options) {
  17. wx.hideShareMenu();
  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 = [5, 40, 60];
  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. }
  70. },
  71. switch1Change(e) {
  72. var that = this;
  73. that.data.IsChangeRecommend = e.detail.value;
  74. that.setData({
  75. IsChangeRecommend: that.data.IsChangeRecommend,
  76. });
  77. if (that.data.IsChangeRecommend)
  78. wx.setStorageSync("SecondConfigArray", [10, 30, 50]);
  79. else
  80. wx.setStorageSync("SecondConfigArray", [0, 0, 0]);
  81. that.init();
  82. },
  83. onShareAppMessage: function () {
  84. return {
  85. title: app.globalData.ShareTitle,
  86. path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID,
  87. imageUrl: app.globalData.ShareImage,
  88. }
  89. },
  90. })