commission-ranking.js 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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. const sheep_hooks_useGoods = require("../../sheep/hooks/useGoods.js");
  6. require("../../sheep/url/index.js");
  7. require("../../sheep/store/index.js");
  8. require("../../sheep/store/app.js");
  9. require("../../sheep/api/promotion/diy.js");
  10. require("../../sheep/request/index.js");
  11. require("../../sheep/config/index.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/platform/pay.js");
  28. require("../../sheep/api/pay/order.js");
  29. require("../../sheep/store/user.js");
  30. require("../../sheep/store/cart.js");
  31. require("../../sheep/api/trade/cart.js");
  32. require("../../sheep/api/pay/wallet.js");
  33. require("../../sheep/api/trade/order.js");
  34. require("../../sheep/api/promotion/coupon.js");
  35. require("../../sheep/store/sys.js");
  36. require("../../sheep/store/modal.js");
  37. require("../../sheep/config/zIndex.js");
  38. require("../../sheep/util/index.js");
  39. if (!Array) {
  40. const _component_emptyPage = common_vendor.resolveComponent("emptyPage");
  41. const _easycom_s_layout2 = common_vendor.resolveComponent("s-layout");
  42. (_component_emptyPage + _easycom_s_layout2)();
  43. }
  44. const _easycom_s_layout = () => "../../sheep/components/s-layout/s-layout.js";
  45. if (!Math) {
  46. _easycom_s_layout();
  47. }
  48. const _sfc_main = {
  49. __name: "commission-ranking",
  50. setup(__props) {
  51. const tabMaps = ["周排行", "月排行"];
  52. const state = common_vendor.reactive({
  53. currentTab: 0,
  54. position: 0,
  55. // 排名
  56. rankList: []
  57. });
  58. async function switchTap(index) {
  59. state.currentTab = index;
  60. state.rankList = [];
  61. calculateTimes();
  62. getBrokerageRankList();
  63. getBrokerageRankNumber();
  64. }
  65. async function getBrokerageRankList() {
  66. const {
  67. code,
  68. data
  69. } = await sheep_api_trade_brokerage.BrokerageApi.getBrokerageUserChildSummaryPageByPrice({
  70. pageNo: 1,
  71. pageSize: 10,
  72. "times[0]": state.times[0],
  73. "times[1]": state.times[1]
  74. });
  75. if (code !== 0) {
  76. return;
  77. }
  78. state.rankList = data.list;
  79. }
  80. async function getBrokerageRankNumber() {
  81. const {
  82. code,
  83. data
  84. } = await sheep_api_trade_brokerage.BrokerageApi.getRankByPrice({
  85. times: state.times
  86. });
  87. if (code !== 0) {
  88. return;
  89. }
  90. state.position = data;
  91. }
  92. function formatDate(date) {
  93. return sheep_index.sheep.$helper.timeFormat(date, "yyyy-mm-dd hh:MM:ss");
  94. }
  95. function calculateTimes() {
  96. let times;
  97. if (state.currentTab === 0) {
  98. times = getWeekTimes();
  99. } else {
  100. times = getMonthTimes();
  101. }
  102. state.times = [formatDate(times[0]), formatDate(times[1])];
  103. }
  104. common_vendor.onLoad(function() {
  105. calculateTimes();
  106. getBrokerageRankList();
  107. getBrokerageRankNumber();
  108. });
  109. function getWeekTimes() {
  110. const today = /* @__PURE__ */ new Date();
  111. const dayOfWeek = today.getDay();
  112. return [
  113. new Date(today.getFullYear(), today.getMonth(), today.getDate() - dayOfWeek, 0, 0, 0),
  114. new Date(
  115. today.getFullYear(),
  116. today.getMonth(),
  117. today.getDate() + (6 - dayOfWeek),
  118. 23,
  119. 59,
  120. 59
  121. )
  122. ];
  123. }
  124. function getMonthTimes() {
  125. const today = /* @__PURE__ */ new Date();
  126. const year = today.getFullYear();
  127. const month = today.getMonth();
  128. const startDate = new Date(year, month, 1, 0, 0, 0);
  129. const nextMonth = new Date(year, month + 1, 1);
  130. const endDate = new Date(nextMonth.getTime() - 1);
  131. return [startDate, endDate];
  132. }
  133. return (_ctx, _cache) => {
  134. return common_vendor.e({
  135. a: state.position
  136. }, state.position ? {
  137. b: common_vendor.t(state.position)
  138. } : {}, {
  139. c: common_vendor.f(tabMaps, (item, index, i0) => {
  140. return {
  141. a: common_vendor.t(item),
  142. b: common_vendor.n(state.currentTab === index ? "font-color" : ""),
  143. c: index,
  144. d: common_vendor.o(($event) => switchTap(index), index)
  145. };
  146. }),
  147. d: common_vendor.f(state.rankList, (item, index, i0) => {
  148. return common_vendor.e({
  149. a: index <= 2
  150. }, index <= 2 ? {
  151. b: "/static/images/medal0" + (index + 1) + ".png"
  152. } : {
  153. c: common_vendor.t(index + 1)
  154. }, {
  155. d: item.avatar,
  156. e: common_vendor.t(item.nickname),
  157. f: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(item.brokeragePrice)),
  158. g: index
  159. });
  160. }),
  161. e: state.rankList.length === 0 && (state.page !== 1 || state.active === 0)
  162. }, state.rankList.length === 0 && (state.page !== 1 || state.active === 0) ? {
  163. f: common_vendor.p({
  164. title: "暂无排行~"
  165. })
  166. } : {}, {
  167. g: common_vendor.p({
  168. title: "佣金排行榜"
  169. })
  170. });
  171. };
  172. }
  173. };
  174. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-4b4e4229"], ["__file", "D:/zx/mall-front-app/pages/commission/commission-ranking.vue"]]);
  175. wx.createPage(MiniProgramPage);