acdr-ui/dist/dev/mp-weixin/modules/mall/commission/promoter.js

155 lines
4.9 KiB
JavaScript
Raw Normal View History

2024-09-19 07:20:14 +08:00
"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");
if (!Array) {
const _easycom_s_layout2 = common_vendor.resolveComponent("s-layout");
const _component_layout_default_uni = common_vendor.resolveComponent("layout-default-uni");
(_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: "promoter",
setup(__props) {
const tabMaps = ["周排行", "月排行"];
const state = common_vendor.reactive({
currentTab: 0,
rankList: [],
times: [],
one: {},
// 排名第一
two: {},
// 排名第二
three: {}
// 排名第三
});
function switchTap(index) {
if (state.currentTab === index) {
return;
}
state.currentTab = index;
calculateTimes();
getRankList();
}
function getRankList() {
return __async(this, null, function* () {
state.one = {};
state.two = {};
state.three = {};
state.rankList = [];
const { code, data } = yield sheep_api_trade_brokerage.BrokerageApi.getBrokerageUserRankPageByUserCount({
pageNo: 1,
pageSize: 10,
"times[0]": state.times[0],
"times[1]": state.times[1]
});
if (code !== 0) {
return;
}
state.rankList = data.list;
state.one = state.rankList.shift() || {};
state.two = state.rankList.shift() || {};
state.trhee = state.rankList.shift() || {};
});
}
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();
getRankList();
});
function formatDate(date) {
return sheep_index.sheep.$helper.timeFormat(date, "yyyy-mm-dd hh:MM:ss");
}
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: 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)
};
}),
b: state.two.avatar,
c: common_vendor.t(state.two.nickname),
d: common_vendor.t(state.two.brokerageUserCount),
e: state.two.id,
f: state.one.avatar,
g: common_vendor.t(state.one.nickname),
h: common_vendor.t(state.one.brokerageUserCount),
i: state.one.id,
j: state.three.avatar,
k: common_vendor.t(state.three.nickname),
l: common_vendor.t(state.three.brokerageUserCount),
m: state.three.id,
n: state.rankList.length
}, state.rankList.length ? {
o: common_vendor.f(state.rankList, (item, index, i0) => {
return {
a: common_vendor.t(index + 4),
b: item.avatar,
c: common_vendor.t(item.nickname),
d: common_vendor.t(item.brokerageUserCount),
e: index
};
})
} : {}, {
p: common_vendor.p({
title: "推广人排行榜"
})
});
};
}
};
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-7710ace8"]]);
wx.createPage(MiniProgramPage);
//# sourceMappingURL=promoter.js.map