recommend.js 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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 || (secondConfig[0]==0))
  31. secondConfig = [10, 30, 50];
  32. for (var j = 0; j < 3; j++) {
  33. var arr = [];
  34. for (var i = 3; i <= 90; i++) {
  35. arr.push(i);
  36. }
  37. that.data.SecondConfig[j].Value = secondConfig[j];
  38. that.data.SecondConfig[j].NumberArray = arr;
  39. }
  40. that.setData({
  41. SecondConfig: that.data.SecondConfig,
  42. });
  43. wx.setStorageSync("SecondConfigArray", secondConfig);
  44. },
  45. bindRecommendTime: function (e) {
  46. var that = this;
  47. var index = e.currentTarget.dataset.index;
  48. this.data.SecondConfig[index].Value = Number(e.detail.value) + 3;
  49. if (this.data.SecondConfig[0].Value >= this.data.SecondConfig[1].Value) {
  50. wx.showToast({
  51. title: '绿需大于蓝',
  52. });
  53. }
  54. else if (this.data.SecondConfig[1].Value >= this.data.SecondConfig[2].Value) {
  55. wx.showToast({
  56. title: '黄需大于绿',
  57. });
  58. }
  59. else {
  60. this.setData({
  61. SecondConfig: this.data.SecondConfig,
  62. });
  63. var arr = [this.data.SecondConfig[0].Value, this.data.SecondConfig[1].Value, this.data.SecondConfig[2].Value];
  64. wx.setStorageSync("SecondConfigArray", arr);
  65. }
  66. },
  67. switch1Change(e) {
  68. var that = this;
  69. that.data.IsChangeRecommend = e.detail.value;
  70. that.setData({
  71. IsChangeRecommend: that.data.IsChangeRecommend,
  72. });
  73. if (that.data.IsChangeRecommend)
  74. that.init();
  75. else
  76. wx.setStorageSync("SecondConfigArray", [0,0,0]);
  77. },
  78. onShareAppMessage: function () {
  79. return {
  80. title: app.globalData.ShareTitle,
  81. path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID,
  82. imageUrl: app.globalData.ShareImage,
  83. }
  84. },
  85. })