commission-ranking.js 5.8 KB

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