list.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. "use strict";
  2. const common_vendor = require("../../../common/vendor.js");
  3. const sheep_index = require("../../../sheep/index.js");
  4. const sheep_hooks_useGoods = require("../../../sheep/hooks/useGoods.js");
  5. const sheep_api_promotion_seckill = require("../../../sheep/api/promotion/seckill.js");
  6. const sheep_util_const = require("../../../sheep/util/const.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_progress2 = common_vendor.resolveComponent("su-progress");
  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_progress2 + _easycom_s_goods_column2 + _easycom_uni_load_more2 + _easycom_s_layout2)();
  46. }
  47. const _easycom_su_progress = () => "../../../sheep/ui/su-progress/su-progress.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_progress + _easycom_s_goods_column + _easycom_uni_load_more + _easycom_s_layout)();
  53. }
  54. const _sfc_main = {
  55. __name: "list",
  56. setup(__props) {
  57. common_vendor.useCssVars((_ctx) => ({
  58. "ac2cc216": common_vendor.unref(headerBg)
  59. }));
  60. const { safeAreaInsets, safeArea } = sheep_index.sheep.$platform.device;
  61. const statusBarHeight = sheep_index.sheep.$platform.device.statusBarHeight * 2;
  62. const pageHeight = (safeArea.height + safeAreaInsets.bottom) * 2 + statusBarHeight - sheep_index.sheep.$platform.navbar - 350;
  63. const headerBg = sheep_index.sheep.$url.css("/static/img/shop/goods/seckill-header.png");
  64. const goodsFields = {
  65. name: { show: true },
  66. introduction: { show: true },
  67. price: { show: true },
  68. marketPrice: { show: true }
  69. };
  70. const timeConfigList = common_vendor.ref([]);
  71. const getSeckillConfigList = async () => {
  72. const { data } = await sheep_api_promotion_seckill.SeckillApi.getSeckillConfigList();
  73. const now = common_vendor.dayjs();
  74. const today = now.format("YYYY-MM-DD");
  75. data.forEach((config, index) => {
  76. const startTime = common_vendor.dayjs(`${today} ${config.startTime}`);
  77. const endTime = common_vendor.dayjs(`${today} ${config.endTime}`);
  78. if (now.isBefore(startTime)) {
  79. config.status = sheep_util_const.TimeStatusEnum.WAIT_START;
  80. } else if (now.isAfter(endTime)) {
  81. config.status = sheep_util_const.TimeStatusEnum.END;
  82. } else {
  83. config.status = sheep_util_const.TimeStatusEnum.STARTED;
  84. activeTimeIndex.value = index;
  85. }
  86. });
  87. timeConfigList.value = data;
  88. handleChangeTimeConfig(activeTimeIndex.value);
  89. scrollToTimeConfig(activeTimeIndex.value);
  90. };
  91. const activeTimeElId = common_vendor.ref("");
  92. const scrollToTimeConfig = (index) => {
  93. common_vendor.nextTick$1(() => activeTimeElId.value = `timeItem${index}`);
  94. };
  95. const activeTimeIndex = common_vendor.ref(0);
  96. const activeTimeConfig = common_vendor.computed(() => timeConfigList.value[activeTimeIndex.value]);
  97. const handleChangeTimeConfig = (index) => {
  98. activeTimeIndex.value = index;
  99. activityPageParams.pageNo = 1;
  100. activityList.value = [];
  101. getActivityList();
  102. };
  103. const countDown = common_vendor.computed(() => {
  104. var _a;
  105. const endTime = (_a = activeTimeConfig.value) == null ? void 0 : _a.endTime;
  106. if (endTime) {
  107. return sheep_hooks_useGoods.useDurationTime(`${common_vendor.dayjs().format("YYYY-MM-DD")} ${endTime}`);
  108. }
  109. });
  110. const activityPageParams = common_vendor.reactive({
  111. id: 0,
  112. // 时间段 ID
  113. pageNo: 1,
  114. // 页码
  115. pageSize: 5
  116. // 每页数量
  117. });
  118. const activityTotal = common_vendor.ref(0);
  119. const activityList = common_vendor.ref([]);
  120. const loadStatus = common_vendor.ref("");
  121. async function getActivityList() {
  122. loadStatus.value = "loading";
  123. const { data } = await sheep_api_promotion_seckill.SeckillApi.getSeckillActivityPage(activityPageParams);
  124. data.list.forEach((activity) => {
  125. activity.percent = parseInt(100 * (activity.totalStock - activity.stock) / activity.totalStock);
  126. });
  127. activityList.value = activityList.value.concat(...data.list);
  128. activityTotal.value = data.total;
  129. loadStatus.value = activityList.value.length < activityTotal.value ? "more" : "noMore";
  130. }
  131. function loadMore() {
  132. if (loadStatus.value !== "noMore") {
  133. activityPageParams.pageNo += 1;
  134. getActivityList();
  135. }
  136. }
  137. common_vendor.onReachBottom(() => loadMore());
  138. common_vendor.onLoad(async () => {
  139. await getSeckillConfigList();
  140. });
  141. return (_ctx, _cache) => {
  142. var _a, _b, _c, _d, _e, _f, _g, _h, _i;
  143. return common_vendor.e({
  144. a: common_vendor.s({
  145. marginTop: "-" + Number(statusBarHeight + 88) + "rpx"
  146. }),
  147. b: ((_b = (_a = activeTimeConfig.value) == null ? void 0 : _a.sliderPicUrls) == null ? void 0 : _b.length) > 0
  148. }, ((_d = (_c = activeTimeConfig.value) == null ? void 0 : _c.sliderPicUrls) == null ? void 0 : _d.length) > 0 ? {
  149. c: common_vendor.f(activeTimeConfig.value.sliderPicUrls, (picUrl, index, i0) => {
  150. return {
  151. a: picUrl,
  152. b: index
  153. };
  154. })
  155. } : {}, {
  156. d: common_vendor.f(timeConfigList.value, (config, index, i0) => {
  157. return {
  158. a: common_vendor.t(config.startTime),
  159. b: common_vendor.t(config.status),
  160. c: index,
  161. d: common_vendor.n({
  162. active: activeTimeIndex.value === index
  163. }),
  164. e: `timeItem${index}`,
  165. f: common_vendor.o(($event) => handleChangeTimeConfig(index), index)
  166. };
  167. }),
  168. e: activeTimeElId.value,
  169. f: ((_e = activeTimeConfig.value) == null ? void 0 : _e.status) === common_vendor.unref(sheep_util_const.TimeStatusEnum).STARTED
  170. }, ((_f = activeTimeConfig.value) == null ? void 0 : _f.status) === common_vendor.unref(sheep_util_const.TimeStatusEnum).STARTED ? {
  171. g: common_vendor.t(countDown.value.h),
  172. h: common_vendor.t(countDown.value.m),
  173. i: common_vendor.t(countDown.value.s)
  174. } : {
  175. j: common_vendor.t((_g = activeTimeConfig.value) == null ? void 0 : _g.status)
  176. }, {
  177. k: common_vendor.f(activityList.value, (activity, k0, i0) => {
  178. var _a2, _b2;
  179. return common_vendor.e({
  180. a: common_vendor.t(activity.stock),
  181. b: common_vendor.t(activity.unitName),
  182. c: "de8354c5-2-" + i0 + "," + ("de8354c5-1-" + i0),
  183. d: common_vendor.p({
  184. percentage: activity.percent,
  185. strokeWidth: "10",
  186. textInside: true,
  187. isAnimate: true
  188. })
  189. }, ((_a2 = activeTimeConfig.value) == null ? void 0 : _a2.status) === common_vendor.unref(sheep_util_const.TimeStatusEnum).WAIT_START ? {} : ((_b2 = activeTimeConfig.value) == null ? void 0 : _b2.status) === common_vendor.unref(sheep_util_const.TimeStatusEnum).STARTED ? {} : {}, {
  190. e: common_vendor.o(($event) => common_vendor.unref(sheep_index.sheep).$router.go("/pages/goods/seckill", {
  191. id: activity.id
  192. }), activity.id),
  193. f: "de8354c5-1-" + i0 + ",de8354c5-0",
  194. g: common_vendor.p({
  195. size: "lg",
  196. data: {
  197. ...activity,
  198. price: activity.seckillPrice
  199. },
  200. goodsFields,
  201. seckillTag: true
  202. }),
  203. h: activity.id
  204. });
  205. }),
  206. l: ((_h = activeTimeConfig.value) == null ? void 0 : _h.status) === common_vendor.unref(sheep_util_const.TimeStatusEnum).WAIT_START,
  207. m: ((_i = activeTimeConfig.value) == null ? void 0 : _i.status) === common_vendor.unref(sheep_util_const.TimeStatusEnum).STARTED,
  208. n: common_vendor.n({
  209. disabled: activeTimeConfig.value.status === common_vendor.unref(sheep_util_const.TimeStatusEnum).END
  210. }),
  211. o: activityTotal.value > 0
  212. }, activityTotal.value > 0 ? {
  213. p: common_vendor.o(loadMore),
  214. q: common_vendor.p({
  215. status: loadStatus.value,
  216. ["content-text"]: {
  217. contentdown: "上拉加载更多"
  218. }
  219. })
  220. } : {}, {
  221. r: pageHeight + "rpx",
  222. s: common_vendor.s(_ctx.__cssVars()),
  223. t: common_vendor.p({
  224. navbar: "inner",
  225. bgStyle: {
  226. color: "rgb(245,28,19)"
  227. }
  228. })
  229. });
  230. };
  231. }
  232. };
  233. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-de8354c5"], ["__file", "D:/zx/mall-front-app/pages/activity/seckill/list.vue"]]);
  234. wx.createPage(MiniProgramPage);