promoter.js 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. const sheep_index = require("../../sheep/index.js");
  4. const sheep_api_trade_brokerage = require("../../sheep/api/trade/brokerage.js");
  5. require("../../sheep/url/index.js");
  6. require("../../sheep/store/index.js");
  7. require("../../sheep/store/app.js");
  8. require("../../sheep/api/promotion/diy.js");
  9. require("../../sheep/request/index.js");
  10. require("../../sheep/config/index.js");
  11. require("../../sheep/platform/index.js");
  12. require("../../sheep/platform/provider/wechat/index.js");
  13. require("../../sheep/platform/provider/wechat/miniProgram.js");
  14. require("../../sheep/api/member/auth.js");
  15. require("../../sheep/api/member/social.js");
  16. require("../../sheep/api/member/user.js");
  17. require("../../sheep/platform/provider/apple/index.js");
  18. require("../../sheep/platform/share.js");
  19. require("../../sheep/router/index.js");
  20. require("../../sheep/hooks/useModal.js");
  21. require("../../sheep/helper/index.js");
  22. require("../../sheep/helper/test.js");
  23. require("../../sheep/helper/digit.js");
  24. require("../../sheep/api/member/signin.js");
  25. require("../../sheep/helper/throttle.js");
  26. require("../../sheep/platform/pay.js");
  27. require("../../sheep/api/pay/order.js");
  28. require("../../sheep/store/user.js");
  29. require("../../sheep/store/cart.js");
  30. require("../../sheep/api/trade/cart.js");
  31. require("../../sheep/api/pay/wallet.js");
  32. require("../../sheep/api/trade/order.js");
  33. require("../../sheep/api/promotion/coupon.js");
  34. require("../../sheep/store/sys.js");
  35. require("../../sheep/store/modal.js");
  36. require("../../sheep/config/zIndex.js");
  37. if (!Array) {
  38. const _easycom_s_layout2 = common_vendor.resolveComponent("s-layout");
  39. _easycom_s_layout2();
  40. }
  41. const _easycom_s_layout = () => "../../sheep/components/s-layout/s-layout.js";
  42. if (!Math) {
  43. _easycom_s_layout();
  44. }
  45. const _sfc_main = {
  46. __name: "promoter",
  47. setup(__props) {
  48. const tabMaps = ["周排行", "月排行"];
  49. const state = common_vendor.reactive({
  50. currentTab: 0,
  51. rankList: [],
  52. times: [],
  53. one: {},
  54. // 排名第一
  55. two: {},
  56. // 排名第二
  57. three: {}
  58. // 排名第三
  59. });
  60. function switchTap(index) {
  61. if (state.currentTab === index) {
  62. return;
  63. }
  64. state.currentTab = index;
  65. calculateTimes();
  66. getRankList();
  67. }
  68. async function getRankList() {
  69. state.one = {};
  70. state.two = {};
  71. state.three = {};
  72. state.rankList = [];
  73. const { code, data } = await sheep_api_trade_brokerage.BrokerageApi.getBrokerageUserRankPageByUserCount({
  74. pageNo: 1,
  75. pageSize: 10,
  76. "times[0]": state.times[0],
  77. "times[1]": state.times[1]
  78. });
  79. if (code !== 0) {
  80. return;
  81. }
  82. state.rankList = data.list;
  83. state.one = state.rankList.shift() || {};
  84. state.two = state.rankList.shift() || {};
  85. state.trhee = state.rankList.shift() || {};
  86. }
  87. function calculateTimes() {
  88. let times;
  89. if (state.currentTab === 0) {
  90. times = getWeekTimes();
  91. } else {
  92. times = getMonthTimes();
  93. }
  94. state.times = [formatDate(times[0]), formatDate(times[1])];
  95. }
  96. common_vendor.onLoad(function() {
  97. calculateTimes();
  98. getRankList();
  99. });
  100. function formatDate(date) {
  101. return sheep_index.sheep.$helper.timeFormat(date, "yyyy-mm-dd hh:MM:ss");
  102. }
  103. function getWeekTimes() {
  104. const today = /* @__PURE__ */ new Date();
  105. const dayOfWeek = today.getDay();
  106. return [
  107. new Date(today.getFullYear(), today.getMonth(), today.getDate() - dayOfWeek, 0, 0, 0),
  108. new Date(today.getFullYear(), today.getMonth(), today.getDate() + (6 - dayOfWeek), 23, 59, 59)
  109. ];
  110. }
  111. function getMonthTimes() {
  112. const today = /* @__PURE__ */ new Date();
  113. const year = today.getFullYear();
  114. const month = today.getMonth();
  115. const startDate = new Date(year, month, 1, 0, 0, 0);
  116. const nextMonth = new Date(year, month + 1, 1);
  117. const endDate = new Date(nextMonth.getTime() - 1);
  118. return [startDate, endDate];
  119. }
  120. return (_ctx, _cache) => {
  121. return common_vendor.e({
  122. a: common_vendor.f(tabMaps, (item, index, i0) => {
  123. return {
  124. a: common_vendor.t(item),
  125. b: common_vendor.n(state.currentTab === index ? "font-color" : ""),
  126. c: index,
  127. d: common_vendor.o(($event) => switchTap(index), index)
  128. };
  129. }),
  130. b: state.two.avatar,
  131. c: common_vendor.t(state.two.nickname),
  132. d: common_vendor.t(state.two.brokerageUserCount),
  133. e: state.two.id,
  134. f: state.one.avatar,
  135. g: common_vendor.t(state.one.nickname),
  136. h: common_vendor.t(state.one.brokerageUserCount),
  137. i: state.one.id,
  138. j: state.three.avatar,
  139. k: common_vendor.t(state.three.nickname),
  140. l: common_vendor.t(state.three.brokerageUserCount),
  141. m: state.three.id,
  142. n: state.rankList.length
  143. }, state.rankList.length ? {
  144. o: common_vendor.f(state.rankList, (item, index, i0) => {
  145. return {
  146. a: common_vendor.t(index + 4),
  147. b: item.avatar,
  148. c: common_vendor.t(item.nickname),
  149. d: common_vendor.t(item.brokerageUserCount),
  150. e: index
  151. };
  152. })
  153. } : {}, {
  154. p: common_vendor.p({
  155. title: "推广人排行榜"
  156. })
  157. });
  158. };
  159. }
  160. };
  161. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-fe20a205"], ["__file", "D:/zx/mall-front-app/pages/commission/promoter.vue"]]);
  162. wx.createPage(MiniProgramPage);