colorplan.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. import common from '../../utils/util';
  2. import main from '../../utils/main';
  3. const app = getApp();
  4. Page({
  5. data: {
  6. ImagePath: app.globalData.uploadImageUrl,
  7. },
  8. onLoad: function (options) {
  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. main.UploadUserConfig();
  57. },
  58. onShareAppMessage: function () {
  59. return {
  60. title: app.globalData.ShareTitle,
  61. path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID,
  62. imageUrl: app.globalData.ShareImage,
  63. }
  64. },
  65. })