You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.3 KiB
44 lines
1.3 KiB
"use strict";
|
|
const common_vendor = require("../../common/vendor.js");
|
|
const _sfc_main = {
|
|
__name: "rank",
|
|
setup(__props) {
|
|
const rankData = common_vendor.ref([]);
|
|
const getStudents = async () => {
|
|
try {
|
|
let res = await common_vendor.index.request({
|
|
url: "http://10.133.60.255:3000/api/students",
|
|
method: "GET"
|
|
// 明确指定请求方法
|
|
});
|
|
if (res && res.data) {
|
|
rankData.value = res.data.map((student) => ({
|
|
name: student.name,
|
|
score: student.points
|
|
}));
|
|
rankData.value.sort((a, b) => b.score - a.score);
|
|
}
|
|
} catch (error) {
|
|
console.error("获取学生数据失败:", error);
|
|
}
|
|
};
|
|
common_vendor.onMounted(() => {
|
|
getStudents();
|
|
});
|
|
return (_ctx, _cache) => {
|
|
return {
|
|
a: common_vendor.f(rankData.value, (item, index, i0) => {
|
|
return {
|
|
a: common_vendor.t(item.name),
|
|
b: common_vendor.t(item.score),
|
|
c: common_vendor.t(index + 1),
|
|
d: index
|
|
};
|
|
})
|
|
};
|
|
};
|
|
}
|
|
};
|
|
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-716fbf2c"]]);
|
|
wx.createPage(MiniProgramPage);
|