colorplan.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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, "ColorIndex", 0, function () {
  19. var isChangeColor = false;
  20. if (that.data.ColorIndex == 0)
  21. isChangeColor = true;
  22. else {
  23. for (var i = 1; i < arr.length; i++) {
  24. arr[i].SelectedCSS = "";
  25. if (that.data.ColorIndex == i) {
  26. arr[i].SelectedCSS = "panelItemSelected";
  27. }
  28. }
  29. }
  30. that.setData({
  31. ColorList: arr,
  32. IsChangeColor: isChangeColor,
  33. });
  34. });
  35. },
  36. switch1Change(e) {
  37. var that = this;
  38. that.data.IsChangeColor = e.detail.value;
  39. for (var i = 0; i < that.data.ColorList.length; i++) {
  40. that.data.ColorList[i].SelectedCSS = "";
  41. if (!that.data.IsChangeColor && i == 1) {
  42. that.data.ColorList[i].SelectedCSS = "panelItemSelected";
  43. }
  44. }
  45. that.setData({
  46. ColorList: that.data.ColorList,
  47. IsChangeColor: that.data.IsChangeColor,
  48. });
  49. var index = 1;
  50. if (that.data.IsChangeColor)
  51. index = 0;
  52. wx.setStorageSync("ColorIndex", index);
  53. },
  54. selectColor: function (e) {
  55. var that = this;
  56. var index = e.currentTarget.dataset.index;
  57. for (var i = 0; i < that.data.ColorList.length; i++) {
  58. that.data.ColorList[i].SelectedCSS = "";
  59. if (i == index) {
  60. that.data.ColorList[i].SelectedCSS = "panelItemSelected";
  61. }
  62. }
  63. that.setData({
  64. ColorList: that.data.ColorList,
  65. IsChangeColor: false,
  66. });
  67. wx.setStorageSync("ColorIndex", index);
  68. },
  69. onShareAppMessage: function () {
  70. return {
  71. title: app.globalData.ShareTitle,
  72. path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID,
  73. imageUrl: app.globalData.ShareImage,
  74. }
  75. },
  76. })