promoter.js 5.5 KB

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