commission-ranking.js 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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/api/index.js");
  7. require("../../sheep/api/distri/score.js");
  8. require("../../sheep/request/index.js");
  9. require("../../sheep/config/index.js");
  10. require("../../sheep/store/index.js");
  11. require("../../sheep/store/app.js");
  12. require("../../sheep/api/promotion/diy.js");
  13. require("../../sheep/platform/index.js");
  14. require("../../sheep/platform/provider/wechat/index.js");
  15. require("../../sheep/platform/provider/wechat/miniProgram.js");
  16. require("../../sheep/api/member/auth.js");
  17. require("../../sheep/api/member/social.js");
  18. require("../../sheep/api/member/user.js");
  19. require("../../sheep/platform/provider/apple/index.js");
  20. require("../../sheep/platform/share.js");
  21. require("../../sheep/router/index.js");
  22. require("../../sheep/hooks/useModal.js");
  23. require("../../sheep/helper/index.js");
  24. require("../../sheep/helper/test.js");
  25. require("../../sheep/helper/digit.js");
  26. require("../../sheep/api/member/signin.js");
  27. require("../../sheep/helper/throttle.js");
  28. require("../../sheep/url/index.js");
  29. require("../../sheep/platform/pay.js");
  30. require("../../sheep/api/pay/order.js");
  31. require("../../sheep/store/user.js");
  32. require("../../sheep/store/cart.js");
  33. require("../../sheep/api/trade/cart.js");
  34. require("../../sheep/api/pay/wallet.js");
  35. require("../../sheep/api/trade/order.js");
  36. require("../../sheep/api/promotion/coupon.js");
  37. require("../../sheep/store/sys.js");
  38. require("../../sheep/store/modal.js");
  39. require("../../sheep/api/distri/share.js");
  40. require("../../sheep/api/distri/team.js");
  41. require("../../sheep/api/infra/file.js");
  42. require("../../sheep/api/member/address.js");
  43. require("../../sheep/api/member/point.js");
  44. require("../../sheep/api/migration/app.js");
  45. require("../../sheep/api/migration/chat.js");
  46. require("../../sheep/api/migration/index.js");
  47. require("../../sheep/api/migration/third.js");
  48. require("../../sheep/api/pay/channel.js");
  49. require("../../sheep/api/product/category.js");
  50. require("../../sheep/api/product/comment.js");
  51. require("../../sheep/api/product/favorite.js");
  52. require("../../sheep/api/product/history.js");
  53. require("../../sheep/api/product/spu.js");
  54. require("../../sheep/api/promotion/activity.js");
  55. require("../../sheep/api/promotion/article.js");
  56. require("../../sheep/api/promotion/bargain.js");
  57. require("../../sheep/api/promotion/combination.js");
  58. require("../../sheep/api/promotion/rewardActivity.js");
  59. require("../../sheep/api/promotion/seckill.js");
  60. require("../../sheep/api/system/area.js");
  61. require("../../sheep/api/system/voice.js");
  62. require("../../sheep/api/trade/afterSale.js");
  63. require("../../sheep/api/trade/config.js");
  64. require("../../sheep/api/trade/delivery.js");
  65. require("../../sheep/config/zIndex.js");
  66. require("../../sheep/util/index.js");
  67. if (!Array) {
  68. const _component_emptyPage = common_vendor.resolveComponent("emptyPage");
  69. const _easycom_s_layout2 = common_vendor.resolveComponent("s-layout");
  70. (_component_emptyPage + _easycom_s_layout2)();
  71. }
  72. const _easycom_s_layout = () => "../../sheep/components/s-layout/s-layout.js";
  73. if (!Math) {
  74. _easycom_s_layout();
  75. }
  76. const _sfc_main = {
  77. __name: "commission-ranking",
  78. setup(__props) {
  79. const tabMaps = ["周排行", "月排行"];
  80. const state = common_vendor.reactive({
  81. currentTab: 0,
  82. position: 0,
  83. // 排名
  84. rankList: []
  85. });
  86. async function switchTap(index) {
  87. state.currentTab = index;
  88. state.rankList = [];
  89. calculateTimes();
  90. getBrokerageRankList();
  91. getBrokerageRankNumber();
  92. }
  93. async function getBrokerageRankList() {
  94. const {
  95. code,
  96. data
  97. } = await sheep_api_trade_brokerage.BrokerageApi.getBrokerageUserChildSummaryPageByPrice({
  98. pageNo: 1,
  99. pageSize: 10,
  100. "times[0]": state.times[0],
  101. "times[1]": state.times[1]
  102. });
  103. if (code !== 0) {
  104. return;
  105. }
  106. state.rankList = data.list;
  107. }
  108. async function getBrokerageRankNumber() {
  109. const {
  110. code,
  111. data
  112. } = await sheep_api_trade_brokerage.BrokerageApi.getRankByPrice({
  113. times: state.times
  114. });
  115. if (code !== 0) {
  116. return;
  117. }
  118. state.position = data;
  119. }
  120. function formatDate(date) {
  121. return sheep_index.sheep.$helper.timeFormat(date, "yyyy-mm-dd hh:MM:ss");
  122. }
  123. function calculateTimes() {
  124. let times;
  125. if (state.currentTab === 0) {
  126. times = getWeekTimes();
  127. } else {
  128. times = getMonthTimes();
  129. }
  130. state.times = [formatDate(times[0]), formatDate(times[1])];
  131. }
  132. common_vendor.onLoad(function() {
  133. calculateTimes();
  134. getBrokerageRankList();
  135. getBrokerageRankNumber();
  136. });
  137. function getWeekTimes() {
  138. const today = /* @__PURE__ */ new Date();
  139. const dayOfWeek = today.getDay();
  140. return [
  141. new Date(today.getFullYear(), today.getMonth(), today.getDate() - dayOfWeek, 0, 0, 0),
  142. new Date(
  143. today.getFullYear(),
  144. today.getMonth(),
  145. today.getDate() + (6 - dayOfWeek),
  146. 23,
  147. 59,
  148. 59
  149. )
  150. ];
  151. }
  152. function getMonthTimes() {
  153. const today = /* @__PURE__ */ new Date();
  154. const year = today.getFullYear();
  155. const month = today.getMonth();
  156. const startDate = new Date(year, month, 1, 0, 0, 0);
  157. const nextMonth = new Date(year, month + 1, 1);
  158. const endDate = new Date(nextMonth.getTime() - 1);
  159. return [startDate, endDate];
  160. }
  161. return (_ctx, _cache) => {
  162. return common_vendor.e({
  163. a: state.position
  164. }, state.position ? {
  165. b: common_vendor.t(state.position)
  166. } : {}, {
  167. c: common_vendor.f(tabMaps, (item, index, i0) => {
  168. return {
  169. a: common_vendor.t(item),
  170. b: common_vendor.n(state.currentTab === index ? "font-color" : ""),
  171. c: index,
  172. d: common_vendor.o(($event) => switchTap(index), index)
  173. };
  174. }),
  175. d: common_vendor.f(state.rankList, (item, index, i0) => {
  176. return common_vendor.e({
  177. a: index <= 2
  178. }, index <= 2 ? {
  179. b: "/static/images/medal0" + (index + 1) + ".png"
  180. } : {
  181. c: common_vendor.t(index + 1)
  182. }, {
  183. d: item.avatar,
  184. e: common_vendor.t(item.nickname),
  185. f: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(item.brokeragePrice)),
  186. g: index
  187. });
  188. }),
  189. e: state.rankList.length === 0 && (state.page !== 1 || state.active === 0)
  190. }, state.rankList.length === 0 && (state.page !== 1 || state.active === 0) ? {
  191. f: common_vendor.p({
  192. title: "暂无排行~"
  193. })
  194. } : {}, {
  195. g: common_vendor.p({
  196. title: "佣金排行榜"
  197. })
  198. });
  199. };
  200. }
  201. };
  202. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-4b4e4229"], ["__file", "D:/zx/mall-front-app/pages/commission/commission-ranking.vue"]]);
  203. wx.createPage(MiniProgramPage);