promoter.js 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  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/api/index.js");
  6. require("../../sheep/api/distri/score.js");
  7. require("../../sheep/request/index.js");
  8. require("../../sheep/config/index.js");
  9. require("../../sheep/store/index.js");
  10. require("../../sheep/store/app.js");
  11. require("../../sheep/api/promotion/diy.js");
  12. require("../../sheep/platform/index.js");
  13. require("../../sheep/platform/provider/wechat/index.js");
  14. require("../../sheep/platform/provider/wechat/miniProgram.js");
  15. require("../../sheep/api/member/auth.js");
  16. require("../../sheep/api/member/social.js");
  17. require("../../sheep/api/member/user.js");
  18. require("../../sheep/platform/provider/apple/index.js");
  19. require("../../sheep/platform/share.js");
  20. require("../../sheep/router/index.js");
  21. require("../../sheep/hooks/useModal.js");
  22. require("../../sheep/helper/index.js");
  23. require("../../sheep/helper/test.js");
  24. require("../../sheep/helper/digit.js");
  25. require("../../sheep/api/member/signin.js");
  26. require("../../sheep/helper/throttle.js");
  27. require("../../sheep/url/index.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/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/config.js");
  63. require("../../sheep/api/trade/delivery.js");
  64. require("../../sheep/config/zIndex.js");
  65. if (!Array) {
  66. const _easycom_s_layout2 = common_vendor.resolveComponent("s-layout");
  67. _easycom_s_layout2();
  68. }
  69. const _easycom_s_layout = () => "../../sheep/components/s-layout/s-layout.js";
  70. if (!Math) {
  71. _easycom_s_layout();
  72. }
  73. const _sfc_main = {
  74. __name: "promoter",
  75. setup(__props) {
  76. const tabMaps = ["周排行", "月排行"];
  77. const state = common_vendor.reactive({
  78. currentTab: 0,
  79. rankList: [],
  80. times: [],
  81. one: {},
  82. // 排名第一
  83. two: {},
  84. // 排名第二
  85. three: {}
  86. // 排名第三
  87. });
  88. function switchTap(index) {
  89. if (state.currentTab === index) {
  90. return;
  91. }
  92. state.currentTab = index;
  93. calculateTimes();
  94. getRankList();
  95. }
  96. async function getRankList() {
  97. state.one = {};
  98. state.two = {};
  99. state.three = {};
  100. state.rankList = [];
  101. const { code, data } = await sheep_api_trade_brokerage.BrokerageApi.getBrokerageUserRankPageByUserCount({
  102. pageNo: 1,
  103. pageSize: 10,
  104. "times[0]": state.times[0],
  105. "times[1]": state.times[1]
  106. });
  107. if (code !== 0) {
  108. return;
  109. }
  110. state.rankList = data.list;
  111. state.one = state.rankList.shift() || {};
  112. state.two = state.rankList.shift() || {};
  113. state.trhee = state.rankList.shift() || {};
  114. }
  115. function calculateTimes() {
  116. let times;
  117. if (state.currentTab === 0) {
  118. times = getWeekTimes();
  119. } else {
  120. times = getMonthTimes();
  121. }
  122. state.times = [formatDate(times[0]), formatDate(times[1])];
  123. }
  124. common_vendor.onLoad(function() {
  125. calculateTimes();
  126. getRankList();
  127. });
  128. function formatDate(date) {
  129. return sheep_index.sheep.$helper.timeFormat(date, "yyyy-mm-dd hh:MM:ss");
  130. }
  131. function getWeekTimes() {
  132. const today = /* @__PURE__ */ new Date();
  133. const dayOfWeek = today.getDay();
  134. return [
  135. new Date(today.getFullYear(), today.getMonth(), today.getDate() - dayOfWeek, 0, 0, 0),
  136. new Date(today.getFullYear(), today.getMonth(), today.getDate() + (6 - dayOfWeek), 23, 59, 59)
  137. ];
  138. }
  139. function getMonthTimes() {
  140. const today = /* @__PURE__ */ new Date();
  141. const year = today.getFullYear();
  142. const month = today.getMonth();
  143. const startDate = new Date(year, month, 1, 0, 0, 0);
  144. const nextMonth = new Date(year, month + 1, 1);
  145. const endDate = new Date(nextMonth.getTime() - 1);
  146. return [startDate, endDate];
  147. }
  148. return (_ctx, _cache) => {
  149. return common_vendor.e({
  150. a: common_vendor.f(tabMaps, (item, index, i0) => {
  151. return {
  152. a: common_vendor.t(item),
  153. b: common_vendor.n(state.currentTab === index ? "font-color" : ""),
  154. c: index,
  155. d: common_vendor.o(($event) => switchTap(index), index)
  156. };
  157. }),
  158. b: state.two.avatar,
  159. c: common_vendor.t(state.two.nickname),
  160. d: common_vendor.t(state.two.brokerageUserCount),
  161. e: state.two.id,
  162. f: state.one.avatar,
  163. g: common_vendor.t(state.one.nickname),
  164. h: common_vendor.t(state.one.brokerageUserCount),
  165. i: state.one.id,
  166. j: state.three.avatar,
  167. k: common_vendor.t(state.three.nickname),
  168. l: common_vendor.t(state.three.brokerageUserCount),
  169. m: state.three.id,
  170. n: state.rankList.length
  171. }, state.rankList.length ? {
  172. o: common_vendor.f(state.rankList, (item, index, i0) => {
  173. return {
  174. a: common_vendor.t(index + 4),
  175. b: item.avatar,
  176. c: common_vendor.t(item.nickname),
  177. d: common_vendor.t(item.brokerageUserCount),
  178. e: index
  179. };
  180. })
  181. } : {}, {
  182. p: common_vendor.p({
  183. title: "推广人排行榜"
  184. })
  185. });
  186. };
  187. }
  188. };
  189. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-fe20a205"], ["__file", "D:/zx/mall-front-app/pages/commission/promoter.vue"]]);
  190. wx.createPage(MiniProgramPage);