From 794b3cce89d4b2031654b2666e470de234d820e6 Mon Sep 17 00:00:00 2001 From: p9bwcp862 <2234458131@qq.com> Date: Thu, 10 Oct 2024 00:54:56 +0800 Subject: [PATCH] ADD file via upload --- suanfa.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 suanfa.js diff --git a/suanfa.js b/suanfa.js new file mode 100644 index 0000000..dd031a9 --- /dev/null +++ b/suanfa.js @@ -0,0 +1,25 @@ +Page({ + data: { + students: [], // 存储学生信息的数组 + }, + + // 从后端获取学生数据并排序 + loadStudents: function() { + const that = this; + wx.request({ + url: 'https://wx.fzu.edu.cn/info/1010/2092.htm', // 后端API地址 + method: 'GET', + success: function(res) { + const studentsData = res.data; // 后端返回按JSON格式组织好的数据 + const students = studentsData.map(student => new Student(student.name, student.id, student.points)); + // 按积分从小到大排序 + that.setData({ + students: students.sort((a, b) => a.points - b.points) + }); + }, + fail: function(err) { + console.error('Failed to load students:', err); + } + }); + }, +}) \ No newline at end of file