gree_leran/unpackage/dist/dev/mp-weixin/pages/intergral/intergral.js

67 lines
2.8 KiB
JavaScript

"use strict";
const common_vendor = require("../../common/vendor.js");
const apis_score = require("../../apis/score.js");
const pages_intergral_ut_dataTo = require("./ut/dataTo.js");
require("../../utils/http.js");
require("../../utils/Auth.js");
const _sfc_main = {
__name: "intergral",
setup(__props) {
const scoreList = common_vendor.ref([]);
const rankList = common_vendor.ref([]);
const totalScore = common_vendor.ref(0);
const averageScore = common_vendor.ref(0);
const nowTime = common_vendor.ref("");
const getRanking = async () => {
let res = await apis_score.getScoreList();
let list = pages_intergral_ut_dataTo.resToList(res.data);
scoreList.value = list.slice(0, 3);
rankList.value = list;
totalScore.value = list.reduce((sum, item) => sum + item.score, 0);
averageScore.value = totalScore.value / list.length;
console.log("转换结果", scoreList.value);
};
const getTime = () => {
const date = /* @__PURE__ */ new Date();
const year = date.getFullYear();
const month = date.getMonth() + 1;
const day = date.getDate();
const hour = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
const minute = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
const second = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
const timer = `${year}-${month >= 10 ? month : "0" + month}-${day >= 10 ? day : "0" + day} ${hour}:${minute}:${second}`;
nowTime.value = timer;
};
common_vendor.onMounted(() => {
getRanking();
getTime();
});
return (_ctx, _cache) => {
return {
a: scoreList.value[1].profilePicture,
b: common_vendor.t(scoreList.value[1].username),
c: common_vendor.t(scoreList.value[1].score),
d: scoreList.value[0].profilePicture,
e: common_vendor.t(scoreList.value[0].username),
f: common_vendor.t(scoreList.value[0].score),
g: scoreList.value[2].profilePicture,
h: common_vendor.t(scoreList.value[2].username),
i: common_vendor.t(scoreList.value[2].score),
j: common_vendor.t(averageScore.value.toFixed(2)),
k: common_vendor.t(totalScore.value),
l: common_vendor.f(rankList.value.slice(3), (item, index, i0) => {
return {
a: common_vendor.t(index + 4),
b: item.profilePicture ? item.profilePicture : "/static/hands.png",
c: common_vendor.t(item.username),
d: common_vendor.t(item.score),
e: index
};
})
};
};
}
};
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__file", "D:/uniapp1/gree_leran/pages/intergral/intergral.vue"]]);
wx.createPage(MiniProgramPage);