158 lines
5.2 KiB
JavaScript
158 lines
5.2 KiB
JavaScript
|
"use strict";
|
||
|
var __async = (__this, __arguments, generator) => {
|
||
|
return new Promise((resolve, reject) => {
|
||
|
var fulfilled = (value) => {
|
||
|
try {
|
||
|
step(generator.next(value));
|
||
|
} catch (e) {
|
||
|
reject(e);
|
||
|
}
|
||
|
};
|
||
|
var rejected = (value) => {
|
||
|
try {
|
||
|
step(generator.throw(value));
|
||
|
} catch (e) {
|
||
|
reject(e);
|
||
|
}
|
||
|
};
|
||
|
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
||
|
step((generator = generator.apply(__this, __arguments)).next());
|
||
|
});
|
||
|
};
|
||
|
const common_vendor = require("../../../common/vendor.js");
|
||
|
const sheep_index = require("../../../sheep/index.js");
|
||
|
const sheep_api_trade_brokerage = require("../../../sheep/api/trade/brokerage.js");
|
||
|
const sheep_hooks_useGoods = require("../../../sheep/hooks/useGoods.js");
|
||
|
if (!Array) {
|
||
|
const _component_emptyPage = common_vendor.resolveComponent("emptyPage");
|
||
|
const _easycom_s_layout2 = common_vendor.resolveComponent("s-layout");
|
||
|
const _component_layout_default_uni = common_vendor.resolveComponent("layout-default-uni");
|
||
|
(_component_emptyPage + _easycom_s_layout2 + _component_layout_default_uni)();
|
||
|
}
|
||
|
const _easycom_s_layout = () => "../../../sheep/components/s-layout/s-layout.js";
|
||
|
if (!Math) {
|
||
|
_easycom_s_layout();
|
||
|
}
|
||
|
const _sfc_main = {
|
||
|
__name: "commission-ranking",
|
||
|
setup(__props) {
|
||
|
const tabMaps = ["周排行", "月排行"];
|
||
|
const state = common_vendor.reactive({
|
||
|
currentTab: 0,
|
||
|
position: 0,
|
||
|
// 排名
|
||
|
rankList: []
|
||
|
});
|
||
|
function switchTap(index) {
|
||
|
return __async(this, null, function* () {
|
||
|
state.currentTab = index;
|
||
|
state.rankList = [];
|
||
|
calculateTimes();
|
||
|
getBrokerageRankList();
|
||
|
getBrokerageRankNumber();
|
||
|
});
|
||
|
}
|
||
|
function getBrokerageRankList() {
|
||
|
return __async(this, null, function* () {
|
||
|
const { code, data } = yield sheep_api_trade_brokerage.BrokerageApi.getBrokerageUserChildSummaryPageByPrice({
|
||
|
pageNo: 1,
|
||
|
pageSize: 10,
|
||
|
"times[0]": state.times[0],
|
||
|
"times[1]": state.times[1]
|
||
|
});
|
||
|
if (code !== 0) {
|
||
|
return;
|
||
|
}
|
||
|
state.rankList = data.list;
|
||
|
});
|
||
|
}
|
||
|
function getBrokerageRankNumber() {
|
||
|
return __async(this, null, function* () {
|
||
|
const { code, data } = yield sheep_api_trade_brokerage.BrokerageApi.getRankByPrice({
|
||
|
times: state.times
|
||
|
});
|
||
|
if (code !== 0) {
|
||
|
return;
|
||
|
}
|
||
|
state.position = data;
|
||
|
});
|
||
|
}
|
||
|
function formatDate(date) {
|
||
|
return sheep_index.sheep.$helper.timeFormat(date, "yyyy-mm-dd hh:MM:ss");
|
||
|
}
|
||
|
function calculateTimes() {
|
||
|
let times;
|
||
|
if (state.currentTab === 0) {
|
||
|
times = getWeekTimes();
|
||
|
} else {
|
||
|
times = getMonthTimes();
|
||
|
}
|
||
|
state.times = [formatDate(times[0]), formatDate(times[1])];
|
||
|
}
|
||
|
common_vendor.onLoad(function() {
|
||
|
calculateTimes();
|
||
|
getBrokerageRankList();
|
||
|
getBrokerageRankNumber();
|
||
|
});
|
||
|
function getWeekTimes() {
|
||
|
const today = /* @__PURE__ */ new Date();
|
||
|
const dayOfWeek = today.getDay();
|
||
|
return [
|
||
|
new Date(today.getFullYear(), today.getMonth(), today.getDate() - dayOfWeek, 0, 0, 0),
|
||
|
new Date(today.getFullYear(), today.getMonth(), today.getDate() + (6 - dayOfWeek), 23, 59, 59)
|
||
|
];
|
||
|
}
|
||
|
function getMonthTimes() {
|
||
|
const today = /* @__PURE__ */ new Date();
|
||
|
const year = today.getFullYear();
|
||
|
const month = today.getMonth();
|
||
|
const startDate = new Date(year, month, 1, 0, 0, 0);
|
||
|
const nextMonth = new Date(year, month + 1, 1);
|
||
|
const endDate = new Date(nextMonth.getTime() - 1);
|
||
|
return [startDate, endDate];
|
||
|
}
|
||
|
return (_ctx, _cache) => {
|
||
|
return common_vendor.e({
|
||
|
a: state.position
|
||
|
}, state.position ? {
|
||
|
b: common_vendor.t(state.position)
|
||
|
} : {}, {
|
||
|
c: common_vendor.f(tabMaps, (item, index, i0) => {
|
||
|
return {
|
||
|
a: common_vendor.t(item),
|
||
|
b: common_vendor.n(state.currentTab === index ? "font-color" : ""),
|
||
|
c: index,
|
||
|
d: common_vendor.o(($event) => switchTap(index), index)
|
||
|
};
|
||
|
}),
|
||
|
d: common_vendor.f(state.rankList, (item, index, i0) => {
|
||
|
return common_vendor.e({
|
||
|
a: index <= 2
|
||
|
}, index <= 2 ? {
|
||
|
b: "/static/images/medal0" + (index + 1) + ".png"
|
||
|
} : {
|
||
|
c: common_vendor.t(index + 1)
|
||
|
}, {
|
||
|
d: item.avatar,
|
||
|
e: common_vendor.t(item.nickname),
|
||
|
f: common_vendor.t(common_vendor.unref(sheep_hooks_useGoods.fen2yuan)(item.brokeragePrice)),
|
||
|
g: index
|
||
|
});
|
||
|
}),
|
||
|
e: state.rankList.length === 0 && (state.page !== 1 || state.active === 0)
|
||
|
}, state.rankList.length === 0 && (state.page !== 1 || state.active === 0) ? {
|
||
|
f: common_vendor.p({
|
||
|
title: "暂无排行~"
|
||
|
})
|
||
|
} : {}, {
|
||
|
g: common_vendor.p({
|
||
|
title: "佣金排行榜"
|
||
|
})
|
||
|
});
|
||
|
};
|
||
|
}
|
||
|
};
|
||
|
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-26c7f737"]]);
|
||
|
wx.createPage(MiniProgramPage);
|
||
|
//# sourceMappingURL=commission-ranking.js.map
|