index.js 6.9 KB

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