index.js 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. const sheep_index = require("../../sheep/index.js");
  4. const sheep_api_promotion_rewardActivity = require("../../sheep/api/promotion/rewardActivity.js");
  5. const sheep_hooks_useGoods = require("../../sheep/hooks/useGoods.js");
  6. const sheep_api_product_spu = require("../../sheep/api/product/spu.js");
  7. require("../../sheep/url/index.js");
  8. require("../../sheep/store/index.js");
  9. require("../../sheep/store/app.js");
  10. require("../../sheep/api/promotion/diy.js");
  11. require("../../sheep/request/index.js");
  12. require("../../sheep/config/index.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/platform/pay.js");
  29. require("../../sheep/api/pay/order.js");
  30. require("../../sheep/store/user.js");
  31. require("../../sheep/store/cart.js");
  32. require("../../sheep/api/trade/cart.js");
  33. require("../../sheep/api/pay/wallet.js");
  34. require("../../sheep/api/trade/order.js");
  35. require("../../sheep/api/promotion/coupon.js");
  36. require("../../sheep/store/sys.js");
  37. require("../../sheep/store/modal.js");
  38. require("../../sheep/config/zIndex.js");
  39. require("../../sheep/util/index.js");
  40. if (!Array) {
  41. const _easycom_su_sticky2 = common_vendor.resolveComponent("su-sticky");
  42. const _easycom_s_goods_column2 = common_vendor.resolveComponent("s-goods-column");
  43. const _easycom_uni_load_more2 = common_vendor.resolveComponent("uni-load-more");
  44. const _easycom_s_layout2 = common_vendor.resolveComponent("s-layout");
  45. (_easycom_su_sticky2 + _easycom_s_goods_column2 + _easycom_uni_load_more2 + _easycom_s_layout2)();
  46. }
  47. const _easycom_su_sticky = () => "../../sheep/ui/su-sticky/su-sticky.js";
  48. const _easycom_s_goods_column = () => "../../sheep/components/s-goods-column/s-goods-column.js";
  49. const _easycom_uni_load_more = () => "../../uni_modules/uni-load-more/components/uni-load-more/uni-load-more.js";
  50. const _easycom_s_layout = () => "../../sheep/components/s-layout/s-layout.js";
  51. if (!Math) {
  52. (_easycom_su_sticky + _easycom_s_goods_column + _easycom_uni_load_more + _easycom_s_layout)();
  53. }
  54. const _sfc_main = {
  55. __name: "index",
  56. setup(__props) {
  57. const state = common_vendor.reactive({
  58. activityId: 0,
  59. // 获得编号
  60. activityInfo: {},
  61. // 获得信息
  62. pagination: {
  63. list: [],
  64. total: 1,
  65. pageNo: 1,
  66. pageSize: 8
  67. },
  68. loadStatus: "",
  69. leftGoodsList: [],
  70. rightGoodsList: []
  71. });
  72. let count = 0;
  73. let leftHeight = 0;
  74. let rightHeight = 0;
  75. function mountMasonry(height = 0, where = "left") {
  76. if (!state.pagination.list[count])
  77. return;
  78. if (where === "left") {
  79. leftHeight += height;
  80. } else {
  81. rightHeight += height;
  82. }
  83. if (leftHeight <= rightHeight) {
  84. state.leftGoodsList.push(state.pagination.list[count]);
  85. } else {
  86. state.rightGoodsList.push(state.pagination.list[count]);
  87. }
  88. count++;
  89. }
  90. async function getList() {
  91. const params = {};
  92. if (state.activityInfo.productScope === 2) {
  93. params.ids = state.activityInfo.productSpuIds.join(",");
  94. } else if (state.activityInfo.productScope === 3) {
  95. params.categoryIds = state.activityInfo.productSpuIds.join(",");
  96. }
  97. state.loadStatus = "loading";
  98. const { code, data } = await sheep_api_product_spu.SpuApi.getSpuPage({
  99. pageNo: state.pagination.pageNo,
  100. pageSize: state.pagination.pageSize,
  101. ...params
  102. });
  103. if (code !== 0) {
  104. return;
  105. }
  106. state.pagination.list = common_vendor._.concat(state.pagination.list, data.list);
  107. state.pagination.total = data.total;
  108. state.loadStatus = state.pagination.list.length < state.pagination.total ? "more" : "noMore";
  109. mountMasonry();
  110. }
  111. async function getActivity(id) {
  112. const { code, data } = await sheep_api_promotion_rewardActivity.RewardActivityApi.getRewardActivity(id);
  113. if (code === 0) {
  114. state.activityInfo = data;
  115. }
  116. }
  117. function loadMore() {
  118. if (state.loadStatus === "noMore") {
  119. return;
  120. }
  121. state.pagination.pageNo++;
  122. getList();
  123. }
  124. common_vendor.onReachBottom(() => {
  125. loadMore();
  126. });
  127. common_vendor.onLoad(async (options) => {
  128. state.activityId = options.activityId;
  129. await getActivity(state.activityId);
  130. await getList(state.activityId);
  131. });
  132. return (_ctx, _cache) => {
  133. return common_vendor.e({
  134. a: common_vendor.f(state.activityInfo.rules, (item, k0, i0) => {
  135. return {
  136. a: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.formatRewardActivityRule)(state.activityInfo, item)),
  137. b: item
  138. };
  139. }),
  140. b: common_vendor.p({
  141. bgColor: "#fff"
  142. }),
  143. c: common_vendor.f(state.leftGoodsList, (item, k0, i0) => {
  144. return {
  145. a: common_vendor.o(($event) => common_vendor.unref(sheep_index.sheep).$router.go("/pages/goods/index", {
  146. id: item.id
  147. }), item.id),
  148. b: common_vendor.o(($event) => mountMasonry($event, "left"), item.id),
  149. c: "2c61ebca-2-" + i0 + ",2c61ebca-0",
  150. d: common_vendor.p({
  151. size: "md",
  152. data: item
  153. }),
  154. e: item.id
  155. };
  156. }),
  157. d: common_vendor.f(state.rightGoodsList, (item, k0, i0) => {
  158. return {
  159. a: common_vendor.o(($event) => common_vendor.unref(sheep_index.sheep).$router.go("/pages/goods/index", {
  160. id: item.id
  161. }), item.id),
  162. b: common_vendor.o(($event) => mountMasonry($event, "right"), item.id),
  163. c: "2c61ebca-3-" + i0 + ",2c61ebca-0",
  164. d: common_vendor.p({
  165. size: "md",
  166. data: item
  167. }),
  168. e: item.id
  169. };
  170. }),
  171. e: state.pagination.total > 0
  172. }, state.pagination.total > 0 ? {
  173. f: common_vendor.o(loadMore),
  174. g: common_vendor.p({
  175. status: state.loadStatus,
  176. ["content-text"]: {
  177. contentdown: "上拉加载更多"
  178. }
  179. })
  180. } : {}, {
  181. h: common_vendor.p({
  182. title: state.activityInfo.title
  183. })
  184. });
  185. };
  186. }
  187. };
  188. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-2c61ebca"], ["__file", "D:/zx/mall-front-app/pages/activity/index.vue"]]);
  189. wx.createPage(MiniProgramPage);