index.js 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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/api/index.js");
  8. require("../../sheep/api/distri/score.js");
  9. require("../../sheep/request/index.js");
  10. require("../../sheep/config/index.js");
  11. require("../../sheep/store/index.js");
  12. require("../../sheep/store/app.js");
  13. require("../../sheep/api/promotion/diy.js");
  14. require("../../sheep/platform/index.js");
  15. require("../../sheep/platform/provider/wechat/index.js");
  16. require("../../sheep/platform/provider/wechat/miniProgram.js");
  17. require("../../sheep/api/member/auth.js");
  18. require("../../sheep/api/member/social.js");
  19. require("../../sheep/api/member/user.js");
  20. require("../../sheep/platform/provider/apple/index.js");
  21. require("../../sheep/platform/share.js");
  22. require("../../sheep/router/index.js");
  23. require("../../sheep/hooks/useModal.js");
  24. require("../../sheep/helper/index.js");
  25. require("../../sheep/helper/test.js");
  26. require("../../sheep/helper/digit.js");
  27. require("../../sheep/api/member/signin.js");
  28. require("../../sheep/helper/throttle.js");
  29. require("../../sheep/url/index.js");
  30. require("../../sheep/platform/pay.js");
  31. require("../../sheep/api/pay/order.js");
  32. require("../../sheep/store/user.js");
  33. require("../../sheep/store/cart.js");
  34. require("../../sheep/api/trade/cart.js");
  35. require("../../sheep/api/pay/wallet.js");
  36. require("../../sheep/api/trade/order.js");
  37. require("../../sheep/api/promotion/coupon.js");
  38. require("../../sheep/store/sys.js");
  39. require("../../sheep/store/modal.js");
  40. require("../../sheep/api/distri/share.js");
  41. require("../../sheep/api/distri/team.js");
  42. require("../../sheep/api/infra/file.js");
  43. require("../../sheep/api/member/address.js");
  44. require("../../sheep/api/member/point.js");
  45. require("../../sheep/api/migration/app.js");
  46. require("../../sheep/api/migration/chat.js");
  47. require("../../sheep/api/migration/index.js");
  48. require("../../sheep/api/migration/third.js");
  49. require("../../sheep/api/pay/channel.js");
  50. require("../../sheep/api/product/category.js");
  51. require("../../sheep/api/product/comment.js");
  52. require("../../sheep/api/product/favorite.js");
  53. require("../../sheep/api/product/history.js");
  54. require("../../sheep/api/promotion/activity.js");
  55. require("../../sheep/api/promotion/article.js");
  56. require("../../sheep/api/promotion/bargain.js");
  57. require("../../sheep/api/promotion/combination.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. require("../../sheep/util/index.js");
  67. if (!Array) {
  68. const _easycom_su_sticky2 = common_vendor.resolveComponent("su-sticky");
  69. const _easycom_s_goods_column2 = common_vendor.resolveComponent("s-goods-column");
  70. const _easycom_uni_load_more2 = common_vendor.resolveComponent("uni-load-more");
  71. const _easycom_s_layout2 = common_vendor.resolveComponent("s-layout");
  72. (_easycom_su_sticky2 + _easycom_s_goods_column2 + _easycom_uni_load_more2 + _easycom_s_layout2)();
  73. }
  74. const _easycom_su_sticky = () => "../../sheep/ui/su-sticky/su-sticky.js";
  75. const _easycom_s_goods_column = () => "../../sheep/components/s-goods-column/s-goods-column.js";
  76. const _easycom_uni_load_more = () => "../../uni_modules/uni-load-more/components/uni-load-more/uni-load-more.js";
  77. const _easycom_s_layout = () => "../../sheep/components/s-layout/s-layout.js";
  78. if (!Math) {
  79. (_easycom_su_sticky + _easycom_s_goods_column + _easycom_uni_load_more + _easycom_s_layout)();
  80. }
  81. const _sfc_main = {
  82. __name: "index",
  83. setup(__props) {
  84. const state = common_vendor.reactive({
  85. activityId: 0,
  86. // 获得编号
  87. activityInfo: {},
  88. // 获得信息
  89. pagination: {
  90. list: [],
  91. total: 1,
  92. pageNo: 1,
  93. pageSize: 8
  94. },
  95. loadStatus: "",
  96. leftGoodsList: [],
  97. rightGoodsList: []
  98. });
  99. let count = 0;
  100. let leftHeight = 0;
  101. let rightHeight = 0;
  102. function mountMasonry(height = 0, where = "left") {
  103. if (!state.pagination.list[count])
  104. return;
  105. if (where === "left") {
  106. leftHeight += height;
  107. } else {
  108. rightHeight += height;
  109. }
  110. if (leftHeight <= rightHeight) {
  111. state.leftGoodsList.push(state.pagination.list[count]);
  112. } else {
  113. state.rightGoodsList.push(state.pagination.list[count]);
  114. }
  115. count++;
  116. }
  117. async function getList() {
  118. const params = {};
  119. if (state.activityInfo.productScope === 2) {
  120. params.ids = state.activityInfo.productSpuIds.join(",");
  121. } else if (state.activityInfo.productScope === 3) {
  122. params.categoryIds = state.activityInfo.productSpuIds.join(",");
  123. }
  124. state.loadStatus = "loading";
  125. const { code, data } = await sheep_api_product_spu.SpuApi.getSpuPage({
  126. pageNo: state.pagination.pageNo,
  127. pageSize: state.pagination.pageSize,
  128. ...params
  129. });
  130. if (code !== 0) {
  131. return;
  132. }
  133. state.pagination.list = common_vendor._.concat(state.pagination.list, data.list);
  134. state.pagination.total = data.total;
  135. state.loadStatus = state.pagination.list.length < state.pagination.total ? "more" : "noMore";
  136. mountMasonry();
  137. }
  138. async function getActivity(id) {
  139. const { code, data } = await sheep_api_promotion_rewardActivity.RewardActivityApi.getRewardActivity(id);
  140. if (code === 0) {
  141. state.activityInfo = data;
  142. }
  143. }
  144. function loadMore() {
  145. if (state.loadStatus === "noMore") {
  146. return;
  147. }
  148. state.pagination.pageNo++;
  149. getList();
  150. }
  151. common_vendor.onReachBottom(() => {
  152. loadMore();
  153. });
  154. common_vendor.onLoad(async (options) => {
  155. state.activityId = options.activityId;
  156. await getActivity(state.activityId);
  157. await getList(state.activityId);
  158. });
  159. return (_ctx, _cache) => {
  160. return common_vendor.e({
  161. a: common_vendor.f(state.activityInfo.rules, (item, k0, i0) => {
  162. return {
  163. a: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.formatRewardActivityRule)(state.activityInfo, item)),
  164. b: item
  165. };
  166. }),
  167. b: common_vendor.p({
  168. bgColor: "#fff"
  169. }),
  170. c: common_vendor.f(state.leftGoodsList, (item, k0, i0) => {
  171. return {
  172. a: common_vendor.o(($event) => common_vendor.unref(sheep_index.sheep).$router.go("/pages/goods/index", {
  173. id: item.id
  174. }), item.id),
  175. b: common_vendor.o(($event) => mountMasonry($event, "left"), item.id),
  176. c: "2c61ebca-2-" + i0 + ",2c61ebca-0",
  177. d: common_vendor.p({
  178. size: "md",
  179. data: item
  180. }),
  181. e: item.id
  182. };
  183. }),
  184. d: common_vendor.f(state.rightGoodsList, (item, k0, i0) => {
  185. return {
  186. a: common_vendor.o(($event) => common_vendor.unref(sheep_index.sheep).$router.go("/pages/goods/index", {
  187. id: item.id
  188. }), item.id),
  189. b: common_vendor.o(($event) => mountMasonry($event, "right"), item.id),
  190. c: "2c61ebca-3-" + i0 + ",2c61ebca-0",
  191. d: common_vendor.p({
  192. size: "md",
  193. data: item
  194. }),
  195. e: item.id
  196. };
  197. }),
  198. e: state.pagination.total > 0
  199. }, state.pagination.total > 0 ? {
  200. f: common_vendor.o(loadMore),
  201. g: common_vendor.p({
  202. status: state.loadStatus,
  203. ["content-text"]: {
  204. contentdown: "上拉加载更多"
  205. }
  206. })
  207. } : {}, {
  208. h: common_vendor.p({
  209. title: state.activityInfo.title
  210. })
  211. });
  212. };
  213. }
  214. };
  215. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-2c61ebca"], ["__file", "D:/zx/mall-front-app/pages/activity/index.vue"]]);
  216. wx.createPage(MiniProgramPage);