goods-collect.js 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. const sheep_index = require("../../sheep/index.js");
  4. const sheep_api_product_favorite = require("../../sheep/api/product/favorite.js");
  5. const sheep_util_index = require("../../sheep/util/index.js");
  6. require("../../sheep/api/index.js");
  7. require("../../sheep/api/distri/score.js");
  8. require("../../sheep/request/index.js");
  9. require("../../sheep/config/index.js");
  10. require("../../sheep/store/index.js");
  11. require("../../sheep/store/app.js");
  12. require("../../sheep/api/promotion/diy.js");
  13. require("../../sheep/platform/index.js");
  14. require("../../sheep/platform/provider/wechat/index.js");
  15. require("../../sheep/platform/provider/wechat/miniProgram.js");
  16. require("../../sheep/api/member/auth.js");
  17. require("../../sheep/api/member/social.js");
  18. require("../../sheep/api/member/user.js");
  19. require("../../sheep/platform/provider/apple/index.js");
  20. require("../../sheep/platform/share.js");
  21. require("../../sheep/router/index.js");
  22. require("../../sheep/hooks/useModal.js");
  23. require("../../sheep/helper/index.js");
  24. require("../../sheep/helper/test.js");
  25. require("../../sheep/helper/digit.js");
  26. require("../../sheep/api/member/signin.js");
  27. require("../../sheep/helper/throttle.js");
  28. require("../../sheep/url/index.js");
  29. require("../../sheep/platform/pay.js");
  30. require("../../sheep/api/pay/order.js");
  31. require("../../sheep/store/user.js");
  32. require("../../sheep/store/cart.js");
  33. require("../../sheep/api/trade/cart.js");
  34. require("../../sheep/api/pay/wallet.js");
  35. require("../../sheep/api/trade/order.js");
  36. require("../../sheep/api/promotion/coupon.js");
  37. require("../../sheep/store/sys.js");
  38. require("../../sheep/store/modal.js");
  39. require("../../sheep/api/distri/share.js");
  40. require("../../sheep/api/distri/team.js");
  41. require("../../sheep/api/infra/file.js");
  42. require("../../sheep/api/member/address.js");
  43. require("../../sheep/api/member/point.js");
  44. require("../../sheep/api/migration/app.js");
  45. require("../../sheep/api/migration/chat.js");
  46. require("../../sheep/api/migration/index.js");
  47. require("../../sheep/api/migration/third.js");
  48. require("../../sheep/api/pay/channel.js");
  49. require("../../sheep/api/product/category.js");
  50. require("../../sheep/api/product/comment.js");
  51. require("../../sheep/api/product/history.js");
  52. require("../../sheep/api/product/spu.js");
  53. require("../../sheep/api/promotion/activity.js");
  54. require("../../sheep/api/promotion/article.js");
  55. require("../../sheep/api/promotion/bargain.js");
  56. require("../../sheep/api/promotion/combination.js");
  57. require("../../sheep/api/promotion/rewardActivity.js");
  58. require("../../sheep/api/promotion/seckill.js");
  59. require("../../sheep/api/system/area.js");
  60. require("../../sheep/api/system/voice.js");
  61. require("../../sheep/api/trade/afterSale.js");
  62. require("../../sheep/api/trade/brokerage.js");
  63. require("../../sheep/api/trade/config.js");
  64. require("../../sheep/api/trade/delivery.js");
  65. require("../../sheep/config/zIndex.js");
  66. if (!Array) {
  67. const _easycom_s_goods_item2 = common_vendor.resolveComponent("s-goods-item");
  68. const _easycom_su_fixed2 = common_vendor.resolveComponent("su-fixed");
  69. const _easycom_uni_load_more2 = common_vendor.resolveComponent("uni-load-more");
  70. const _easycom_s_empty2 = common_vendor.resolveComponent("s-empty");
  71. const _easycom_s_layout2 = common_vendor.resolveComponent("s-layout");
  72. (_easycom_s_goods_item2 + _easycom_su_fixed2 + _easycom_uni_load_more2 + _easycom_s_empty2 + _easycom_s_layout2)();
  73. }
  74. const _easycom_s_goods_item = () => "../../sheep/components/s-goods-item/s-goods-item.js";
  75. const _easycom_su_fixed = () => "../../sheep/ui/su-fixed/su-fixed.js";
  76. const _easycom_uni_load_more = () => "../../uni_modules/uni-load-more/components/uni-load-more/uni-load-more.js";
  77. const _easycom_s_empty = () => "../../sheep/components/s-empty/s-empty.js";
  78. const _easycom_s_layout = () => "../../sheep/components/s-layout/s-layout.js";
  79. if (!Math) {
  80. (_easycom_s_goods_item + _easycom_su_fixed + _easycom_uni_load_more + _easycom_s_empty + _easycom_s_layout)();
  81. }
  82. const _sfc_main = {
  83. __name: "goods-collect",
  84. setup(__props) {
  85. common_vendor.useCssVars((_ctx) => ({
  86. "a2866b58": common_vendor.unref(sys_navBar)
  87. }));
  88. const sys_navBar = sheep_index.sheep.$platform.navbar;
  89. const state = common_vendor.reactive({
  90. pagination: {
  91. list: [],
  92. total: 0,
  93. pageNo: 1,
  94. pageSize: 6
  95. },
  96. loadStatus: "",
  97. editMode: false,
  98. selectedCollectList: [],
  99. // 选中的 SPU 数组
  100. selectAll: false
  101. });
  102. async function getData() {
  103. state.loadStatus = "loading";
  104. const { code, data } = await sheep_api_product_favorite.FavoriteApi.getFavoritePage({
  105. pageNo: state.pagination.pageNo,
  106. pageSize: state.pagination.pageSize
  107. });
  108. if (code !== 0) {
  109. return;
  110. }
  111. state.pagination.list = common_vendor._.concat(state.pagination.list, data.list);
  112. state.pagination.total = data.total;
  113. state.loadStatus = state.pagination.list.length < state.pagination.total ? "more" : "noMore";
  114. }
  115. const onSelect = (spuId) => {
  116. if (!state.selectedCollectList.includes(spuId)) {
  117. state.selectedCollectList.push(spuId);
  118. } else {
  119. state.selectedCollectList.splice(state.selectedCollectList.indexOf(spuId), 1);
  120. }
  121. state.selectAll = state.selectedCollectList.length === state.pagination.list.length;
  122. };
  123. const onSelectAll = () => {
  124. state.selectAll = !state.selectAll;
  125. if (!state.selectAll) {
  126. state.selectedCollectList = [];
  127. } else {
  128. state.selectedCollectList = state.pagination.list.map((item) => item.spuId);
  129. }
  130. };
  131. async function onCancel() {
  132. if (!state.selectedCollectList) {
  133. return;
  134. }
  135. for (const spuId of state.selectedCollectList) {
  136. await sheep_api_product_favorite.FavoriteApi.deleteFavorite(spuId);
  137. }
  138. state.editMode = false;
  139. state.selectedCollectList = [];
  140. state.selectAll = false;
  141. sheep_util_index.resetPagination(state.pagination);
  142. await getData();
  143. }
  144. function loadMore() {
  145. if (state.loadStatus === "noMore") {
  146. return;
  147. }
  148. state.pagination.pageNo++;
  149. getData();
  150. }
  151. common_vendor.onReachBottom(() => {
  152. loadMore();
  153. });
  154. common_vendor.onLoad(() => {
  155. getData();
  156. });
  157. return (_ctx, _cache) => {
  158. return common_vendor.e({
  159. a: common_vendor.t(state.pagination.total),
  160. b: state.editMode && state.pagination.total
  161. }, state.editMode && state.pagination.total ? {
  162. c: common_vendor.o(($event) => state.editMode = false)
  163. } : {}, {
  164. d: !state.editMode && state.pagination.total
  165. }, !state.editMode && state.pagination.total ? {
  166. e: common_vendor.o(($event) => state.editMode = true)
  167. } : {}, {
  168. f: common_vendor.f(state.pagination.list, (item, k0, i0) => {
  169. return common_vendor.e(state.editMode ? {
  170. a: state.selectedCollectList.includes(item.spuId),
  171. b: common_vendor.o(($event) => onSelect(item.spuId), item.id),
  172. c: common_vendor.o(($event) => onSelect(item.spuId), item.id)
  173. } : {}, {
  174. d: common_vendor.o(($event) => common_vendor.unref(sheep_index.sheep).$router.go("/pages/goods/index", {
  175. id: item.spuId
  176. }), item.id),
  177. e: "28ee79e9-1-" + i0 + ",28ee79e9-0",
  178. f: common_vendor.p({
  179. title: item.spuName,
  180. img: item.picUrl,
  181. price: item.price,
  182. priceColor: "#FF3000",
  183. titleWidth: 400
  184. }),
  185. g: item.id
  186. });
  187. }),
  188. g: state.editMode,
  189. h: state.selectAll,
  190. i: common_vendor.o(onSelectAll),
  191. j: common_vendor.o(onSelectAll),
  192. k: common_vendor.o(onCancel),
  193. l: state.editMode,
  194. m: common_vendor.p({
  195. bottom: true,
  196. val: 0,
  197. placeholder: true
  198. }),
  199. n: state.pagination.total > 0
  200. }, state.pagination.total > 0 ? {
  201. o: common_vendor.o(loadMore),
  202. p: common_vendor.p({
  203. status: state.loadStatus,
  204. ["content-text"]: {
  205. contentdown: "上拉加载更多"
  206. }
  207. })
  208. } : {}, {
  209. q: state.pagination.total === 0
  210. }, state.pagination.total === 0 ? {
  211. r: common_vendor.p({
  212. text: "暂无收藏",
  213. icon: "/static/collect-empty.png"
  214. })
  215. } : {}, {
  216. s: common_vendor.s(_ctx.__cssVars()),
  217. t: common_vendor.p({
  218. title: "商品收藏"
  219. })
  220. });
  221. };
  222. }
  223. };
  224. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-28ee79e9"], ["__file", "D:/zx/mall-front-app/pages/user/goods-collect.vue"]]);
  225. wx.createPage(MiniProgramPage);