爱简收旧衣按件回收前端代码仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

137 lines
4.3 KiB

  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. const pages_mixins_pullRefreshMixin = require("../mixins/pullRefreshMixin.js");
  4. const _sfc_main = {
  5. mixins: [pages_mixins_pullRefreshMixin.pullRefreshMixin],
  6. data() {
  7. return {
  8. brandItems: [
  9. {
  10. name: "MONCLER GENIUS Maya 70 By Palm A",
  11. image: "/static/brand/moncler.png",
  12. price: "3-10",
  13. selected: false
  14. },
  15. {
  16. name: "加拿大鹅 Wyndham系列羽绒服 冬季 男装",
  17. image: "/static/brand/canada-goose.png",
  18. price: "3-10",
  19. selected: false
  20. },
  21. {
  22. name: "THE NORTH FACE 1992 Nupse 填充夹克",
  23. image: "/static/brand/tnf-1992.png",
  24. price: "3-10",
  25. selected: false
  26. },
  27. {
  28. name: "THE NORTH FACE M'S 1996 Novelty",
  29. image: "/static/brand/tnf-1996.png",
  30. price: "3-10",
  31. selected: false
  32. },
  33. {
  34. name: "THE NORTH FACE 1996 系列 FW23",
  35. image: "/static/brand/tnf-fw23.png",
  36. price: "3-10",
  37. selected: false
  38. },
  39. {
  40. name: "THE NORTH FACE 城市户外系列羽绒服",
  41. image: "/static/brand/tnf-urban.png",
  42. price: "3-10",
  43. selected: false
  44. },
  45. {
  46. name: "THE NORTH FACE 城市户外系列羽绒服 红色",
  47. image: "/static/brand/tnf-red.png",
  48. price: "3-10",
  49. selected: false
  50. },
  51. {
  52. name: "THE NORTH FACE 韩国男款 1996 Nov",
  53. image: "/static/brand/tnf-korea.png",
  54. price: "3-10",
  55. selected: false
  56. }
  57. ],
  58. selectedFromRecycle: []
  59. };
  60. },
  61. onLoad(options) {
  62. if (options.selectedItems) {
  63. try {
  64. this.selectedFromRecycle = JSON.parse(decodeURIComponent(options.selectedItems));
  65. this.syncSelectionWithRecycle();
  66. } catch (e) {
  67. common_vendor.index.__f__("error", "at pages/subcomponent/brand.vue:106", "解析选中衣物数据失败:", e);
  68. }
  69. }
  70. },
  71. methods: {
  72. async onRefresh() {
  73. await new Promise((resolve) => setTimeout(resolve, 1e3));
  74. common_vendor.index.stopPullRefresh();
  75. },
  76. goBack() {
  77. common_vendor.index.navigateBack();
  78. },
  79. // 同步recycle页面选中的衣物到品牌页面
  80. syncSelectionWithRecycle() {
  81. const brandSelected = this.selectedFromRecycle.find((item) => item.showBrandCheck);
  82. if (brandSelected) {
  83. this.brandItems[0].selected = true;
  84. }
  85. },
  86. selectItem(index) {
  87. this.brandItems[index].selected = !this.brandItems[index].selected;
  88. },
  89. goToPickup() {
  90. const selectedBrandItems = this.brandItems.filter((item) => item.selected).map((item) => ({
  91. name: item.name,
  92. icon: item.image,
  93. quantity: 1,
  94. unitPrice: item.price.split("-")[0],
  95. desc: "品牌羽绒服,状态良好"
  96. }));
  97. const itemsStr = encodeURIComponent(JSON.stringify([
  98. ...this.selectedFromRecycle,
  99. ...selectedBrandItems
  100. ]));
  101. common_vendor.index.navigateTo({
  102. url: `/pages/component/pickup?fromRecycle=true&items=${itemsStr}`
  103. });
  104. }
  105. }
  106. };
  107. if (!Array) {
  108. const _easycom_uni_icons2 = common_vendor.resolveComponent("uni-icons");
  109. _easycom_uni_icons2();
  110. }
  111. const _easycom_uni_icons = () => "../../uni_modules/uni-icons/components/uni-icons/uni-icons.js";
  112. if (!Math) {
  113. _easycom_uni_icons();
  114. }
  115. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  116. return {
  117. a: common_vendor.p({
  118. type: "left",
  119. size: "20"
  120. }),
  121. b: common_vendor.o((...args) => $options.goBack && $options.goBack(...args)),
  122. c: common_vendor.f($data.brandItems, (item, index, i0) => {
  123. return {
  124. a: item.image,
  125. b: common_vendor.t(item.name),
  126. c: common_vendor.t(item.price),
  127. d: index,
  128. e: item.selected ? 1 : "",
  129. f: common_vendor.o(($event) => $options.selectItem(index), index)
  130. };
  131. }),
  132. d: common_vendor.o((...args) => $options.goToPickup && $options.goToPickup(...args))
  133. };
  134. }
  135. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-f4b4ba20"]]);
  136. wx.createPage(MiniProgramPage);
  137. //# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/subcomponent/brand.js.map