list.js 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. const sheep_index = require("../../sheep/index.js");
  4. const sheep_util_index = require("../../sheep/util/index.js");
  5. const sheep_api_promotion_coupon = require("../../sheep/api/promotion/coupon.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/store/sys.js");
  37. require("../../sheep/store/modal.js");
  38. require("../../sheep/api/distri/share.js");
  39. require("../../sheep/api/distri/team.js");
  40. require("../../sheep/api/infra/file.js");
  41. require("../../sheep/api/member/address.js");
  42. require("../../sheep/api/member/point.js");
  43. require("../../sheep/api/migration/app.js");
  44. require("../../sheep/api/migration/chat.js");
  45. require("../../sheep/api/migration/index.js");
  46. require("../../sheep/api/migration/third.js");
  47. require("../../sheep/api/pay/channel.js");
  48. require("../../sheep/api/product/category.js");
  49. require("../../sheep/api/product/comment.js");
  50. require("../../sheep/api/product/favorite.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_su_tabs2 = common_vendor.resolveComponent("su-tabs");
  68. const _easycom_su_sticky2 = common_vendor.resolveComponent("su-sticky");
  69. const _easycom_s_empty2 = common_vendor.resolveComponent("s-empty");
  70. const _easycom_s_coupon_list2 = common_vendor.resolveComponent("s-coupon-list");
  71. const _easycom_uni_load_more2 = common_vendor.resolveComponent("uni-load-more");
  72. const _easycom_s_layout2 = common_vendor.resolveComponent("s-layout");
  73. (_easycom_su_tabs2 + _easycom_su_sticky2 + _easycom_s_empty2 + _easycom_s_coupon_list2 + _easycom_uni_load_more2 + _easycom_s_layout2)();
  74. }
  75. const _easycom_su_tabs = () => "../../sheep/ui/su-tabs/su-tabs.js";
  76. const _easycom_su_sticky = () => "../../sheep/ui/su-sticky/su-sticky.js";
  77. const _easycom_s_empty = () => "../../sheep/components/s-empty/s-empty.js";
  78. const _easycom_s_coupon_list = () => "../../sheep/components/s-coupon-list/s-coupon-list.js";
  79. const _easycom_uni_load_more = () => "../../uni_modules/uni-load-more/components/uni-load-more/uni-load-more.js";
  80. const _easycom_s_layout = () => "../../sheep/components/s-layout/s-layout.js";
  81. if (!Math) {
  82. (_easycom_su_tabs + _easycom_su_sticky + _easycom_s_empty + _easycom_s_coupon_list + _easycom_uni_load_more + _easycom_s_layout)();
  83. }
  84. const _sfc_main = {
  85. __name: "list",
  86. setup(__props) {
  87. const state = common_vendor.reactive({
  88. currentTab: 0,
  89. // 当前 tab
  90. type: "1",
  91. pagination: {
  92. list: [],
  93. total: 0,
  94. pageNo: 1,
  95. pageSize: 5
  96. },
  97. loadStatus: ""
  98. });
  99. const tabMaps = [
  100. {
  101. name: "领券中心",
  102. value: "all"
  103. },
  104. {
  105. name: "已领取",
  106. value: "1"
  107. },
  108. {
  109. name: "已使用",
  110. value: "2"
  111. },
  112. {
  113. name: "已失效",
  114. value: "3"
  115. }
  116. ];
  117. function onTabsChange(e) {
  118. state.currentTab = e.index;
  119. state.type = e.value;
  120. sheep_util_index.resetPagination(state.pagination);
  121. if (state.currentTab === 0) {
  122. getData();
  123. } else {
  124. getCoupon();
  125. }
  126. }
  127. async function getData() {
  128. state.loadStatus = "loading";
  129. const { data, code } = await sheep_api_promotion_coupon.CouponApi.getCouponTemplatePage({
  130. pageNo: state.pagination.pageNo,
  131. pageSize: state.pagination.pageSize
  132. });
  133. if (code !== 0) {
  134. return;
  135. }
  136. state.pagination.list = common_vendor._.concat(state.pagination.list, data.list);
  137. state.pagination.total = data.total;
  138. state.loadStatus = state.pagination.list.length < state.pagination.total ? "more" : "noMore";
  139. }
  140. async function getCoupon() {
  141. state.loadStatus = "loading";
  142. const { data, code } = await sheep_api_promotion_coupon.CouponApi.getCouponPage({
  143. pageNo: state.pagination.pageNo,
  144. pageSize: state.pagination.pageSize,
  145. status: state.type
  146. });
  147. if (code !== 0) {
  148. return;
  149. }
  150. state.pagination.list = common_vendor._.concat(state.pagination.list, data.list);
  151. state.pagination.total = data.total;
  152. state.loadStatus = state.pagination.list.length < state.pagination.total ? "more" : "noMore";
  153. }
  154. async function getBuy(id) {
  155. const { code } = await sheep_api_promotion_coupon.CouponApi.takeCoupon(id);
  156. if (code !== 0) {
  157. return;
  158. }
  159. common_vendor.index.showToast({
  160. title: "领取成功"
  161. });
  162. setTimeout(() => {
  163. sheep_util_index.resetPagination(state.pagination);
  164. getData();
  165. }, 1e3);
  166. }
  167. function loadMore() {
  168. if (state.loadStatus === "noMore") {
  169. return;
  170. }
  171. state.pagination.pageNo++;
  172. if (state.currentTab === 0) {
  173. getData();
  174. } else {
  175. getCoupon();
  176. }
  177. }
  178. common_vendor.onLoad((Option) => {
  179. if (Option.type === "all" || !Option.type) {
  180. getData();
  181. } else {
  182. Option.type === "geted" ? state.currentTab = 1 : Option.type === "used" ? state.currentTab = 2 : state.currentTab = 3;
  183. state.type = state.currentTab;
  184. getCoupon();
  185. }
  186. });
  187. common_vendor.onReachBottom(() => {
  188. loadMore();
  189. });
  190. return (_ctx, _cache) => {
  191. return common_vendor.e({
  192. a: common_vendor.o(onTabsChange),
  193. b: common_vendor.p({
  194. list: tabMaps,
  195. scrollable: false,
  196. current: state.currentTab
  197. }),
  198. c: common_vendor.p({
  199. bgColor: "#fff"
  200. }),
  201. d: state.pagination.total === 0
  202. }, state.pagination.total === 0 ? {
  203. e: common_vendor.p({
  204. icon: "/static/coupon-empty.png",
  205. text: "暂无优惠券"
  206. })
  207. } : {}, {
  208. f: state.currentTab === 0
  209. }, state.currentTab === 0 ? {
  210. g: common_vendor.f(state.pagination.list, (item, k0, i0) => {
  211. return {
  212. a: common_vendor.t(item.canTake ? "立即领取" : "已领取"),
  213. b: common_vendor.n(!item.canTake ? "border-btn" : ""),
  214. c: common_vendor.o(($event) => getBuy(item.id), item.id),
  215. d: !item.canTake,
  216. e: common_vendor.o(($event) => common_vendor.unref(sheep_index.sheep).$router.go("/pages/coupon/detail", {
  217. id: item.id
  218. }), item.id),
  219. f: "019d569f-4-" + i0 + ",019d569f-0",
  220. g: common_vendor.p({
  221. data: item
  222. }),
  223. h: item.id
  224. };
  225. })
  226. } : {
  227. h: common_vendor.f(state.pagination.list, (item, k0, i0) => {
  228. return {
  229. a: common_vendor.t(item.status === 1 ? "立即使用" : item.status === 2 ? "已使用" : "已过期"),
  230. b: common_vendor.n(item.status !== 1 ? "disabled-btn" : ""),
  231. c: item.status !== 1,
  232. d: common_vendor.o(($event) => common_vendor.unref(sheep_index.sheep).$router.go("/pages/coupon/detail", {
  233. couponId: item.id
  234. }), item.id),
  235. e: common_vendor.o(($event) => common_vendor.unref(sheep_index.sheep).$router.go("/pages/coupon/detail", {
  236. couponId: item.id
  237. }), item.id),
  238. f: "019d569f-5-" + i0 + ",019d569f-0",
  239. g: common_vendor.p({
  240. data: item,
  241. type: "user"
  242. }),
  243. h: item.id
  244. };
  245. })
  246. }, {
  247. i: state.pagination.total > 0
  248. }, state.pagination.total > 0 ? {
  249. j: common_vendor.o(loadMore),
  250. k: common_vendor.p({
  251. status: state.loadStatus,
  252. ["content-text"]: {
  253. contentdown: "上拉加载更多"
  254. }
  255. })
  256. } : {}, {
  257. l: common_vendor.p({
  258. title: "优惠券",
  259. bgStyle: {
  260. color: "#f2f2f2"
  261. }
  262. })
  263. });
  264. };
  265. }
  266. };
  267. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-019d569f"], ["__file", "D:/zx/mall-front-app/pages/coupon/list.vue"]]);
  268. wx.createPage(MiniProgramPage);