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. var that = this;
  9. that.setData({
  10. Containnerheight: main.getWindowHeight(),
  11. });
  12. that.init(options.id);
  13. },
  14. init: function (id) {
  15. var that = this;
  16. var arr = main.getDetailColor(-1);
  17. common.getStorageValue(this, "ColorIndexArr", [1,2,3,4], function () {
  18. for (var i = 1; i < arr.length; i++) {
  19. for(var j=0;j<that.data.ColorIndexArr.length;j++){
  20. arr[i].SelectedCSS = "";
  21. if (that.data.ColorIndexArr[j] == i) {
  22. arr[i].SelectedCSS = "panelItemSelected";
  23. break;
  24. }
  25. }
  26. }
  27. that.setData({
  28. ColorList: arr,
  29. });
  30. });
  31. },
  32. selectColor: function (e) {
  33. var that = this;
  34. var index = e.currentTarget.dataset.index;
  35. for (var i = 0; i < that.data.ColorList.length; i++) {
  36. //that.data.ColorList[i].SelectedCSS = "";
  37. if (i == index) {
  38. if (that.data.ColorList[i].SelectedCSS == "")
  39. that.data.ColorList[i].SelectedCSS = "panelItemSelected";
  40. else
  41. that.data.ColorList[i].SelectedCSS = "";
  42. }
  43. }
  44. var arr = [];
  45. for (var i = 0; i < that.data.ColorList.length; i++) {
  46. if (that.data.ColorList[i].SelectedCSS == "panelItemSelected")
  47. arr.push(i);
  48. }
  49. if (arr.length==0)
  50. arr.push(1);
  51. that.setData({
  52. ColorList: that.data.ColorList,
  53. });
  54. wx.setStorageSync("ColorIndexArr", arr);
  55. main.UploadUserConfig();
  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. })