colorplan.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. import common from '../../utils/util';
  2. import main from '../../utils/main';
  3. const app = getApp();
  4. Page({
  5. data: {
  6. },
  7. onLoad: function (options) {
  8. wx.hideShareMenu();
  9. var that = this;
  10. that.setData({
  11. Containnerheight: main.getWindowHeight(),
  12. });
  13. that.init(options.id);
  14. },
  15. init: function (id) {
  16. var that = this;
  17. var arr = main.getDetailColor(-1);
  18. common.getStorageValue(this, "ColorIndexArr", [1,2,3,4], function () {
  19. for (var i = 1; i < arr.length; i++) {
  20. for(var j=0;j<that.data.ColorIndexArr.length;j++){
  21. arr[i].SelectedCSS = "";
  22. if (that.data.ColorIndexArr[j] == i) {
  23. arr[i].SelectedCSS = "panelItemSelected";
  24. break;
  25. }
  26. }
  27. }
  28. that.setData({
  29. ColorList: arr,
  30. });
  31. });
  32. },
  33. selectColor: function (e) {
  34. var that = this;
  35. var index = e.currentTarget.dataset.index;
  36. for (var i = 0; i < that.data.ColorList.length; i++) {
  37. //that.data.ColorList[i].SelectedCSS = "";
  38. if (i == index) {
  39. if (that.data.ColorList[i].SelectedCSS == "")
  40. that.data.ColorList[i].SelectedCSS = "panelItemSelected";
  41. else
  42. that.data.ColorList[i].SelectedCSS = "";
  43. }
  44. }
  45. var arr = [];
  46. for (var i = 0; i < that.data.ColorList.length; i++) {
  47. if (that.data.ColorList[i].SelectedCSS == "panelItemSelected")
  48. arr.push(i);
  49. }
  50. if (arr.length==0)
  51. arr.push(1);
  52. that.setData({
  53. ColorList: that.data.ColorList,
  54. });
  55. wx.setStorageSync("ColorIndexArr", arr);
  56. },
  57. onShareAppMessage: function () {
  58. return {
  59. title: app.globalData.ShareTitle,
  60. path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID,
  61. imageUrl: app.globalData.ShareImage,
  62. }
  63. },
  64. })