recommend.js 2.5 KB

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