@ -0,0 +1 @@
|
||||
{"containers":[],"config":{}}
|
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Eslint config file
|
||||
* Documentation: https://eslint.org/docs/user-guide/configuring/
|
||||
* Install the Eslint extension before using this feature.
|
||||
*/
|
||||
module.exports = {
|
||||
env: {
|
||||
es6: true,
|
||||
browser: true,
|
||||
node: true,
|
||||
},
|
||||
ecmaFeatures: {
|
||||
modules: true,
|
||||
},
|
||||
parserOptions: {
|
||||
ecmaVersion: 2018,
|
||||
sourceType: 'module',
|
||||
},
|
||||
globals: {
|
||||
wx: true,
|
||||
App: true,
|
||||
Page: true,
|
||||
getCurrentPages: true,
|
||||
getApp: true,
|
||||
Component: true,
|
||||
requirePlugin: true,
|
||||
requireMiniProgram: true,
|
||||
},
|
||||
// extends: 'eslint:recommended',
|
||||
rules: {},
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
// app.js
|
||||
App({
|
||||
onLaunch() {
|
||||
// 展示本地存储能力
|
||||
const logs = wx.getStorageSync('logs') || []
|
||||
logs.unshift(Date.now())
|
||||
wx.setStorageSync('logs', logs)
|
||||
|
||||
// 登录
|
||||
wx.login({
|
||||
success: res => {
|
||||
// 发送 res.code 到后台换取 openId, sessionKey, unionId
|
||||
}
|
||||
})
|
||||
},
|
||||
globalData: {
|
||||
userInfo: null
|
||||
}
|
||||
})
|
@ -0,0 +1,28 @@
|
||||
{
|
||||
"pages": [
|
||||
"pages/index/index",
|
||||
"pages/student/rules/rule2/rule2",
|
||||
"pages/student/rules/rule1/rule1",
|
||||
"pages/student/diandang/dd-yes/dd-yes",
|
||||
"pages/student/diandang/dd-not/dd-not",
|
||||
"pages/student/rank/rank",
|
||||
"pages/student/dm/dm",
|
||||
"pages/student/student",
|
||||
"pages/teacher/Mode-arrive/Mode-arrive",
|
||||
"pages/teacher/mode2/mode2",
|
||||
"pages/teacher/Mode-quiz/Mode-quiz",
|
||||
"pages/teacher/Trank/rank-Mode1/rank-Mode1",
|
||||
"pages/teacher/Trank/rank-Mode2/rank-Mode2",
|
||||
"pages/teacher/Mode-quiz_2/Mode-quiz_2",
|
||||
"pages/teacher/teacher"
|
||||
],
|
||||
"window": {
|
||||
"navigationBarTextStyle": "black",
|
||||
"navigationBarTitleText": "Weixin",
|
||||
"navigationBarBackgroundColor": "#ffffff"
|
||||
},
|
||||
"style": "v2",
|
||||
"componentFramework": "glass-easel",
|
||||
"sitemapLocation": "sitemap.json",
|
||||
"lazyCodeLoading": "requiredComponents"
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
/**app.wxss**/
|
||||
.container {
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 200rpx 0;
|
||||
box-sizing: border-box;
|
||||
}
|
After Width: | Height: | Size: 4.3 KiB |
After Width: | Height: | Size: 2.8 KiB |
After Width: | Height: | Size: 3.4 KiB |
After Width: | Height: | Size: 3.4 KiB |
After Width: | Height: | Size: 3.1 KiB |
After Width: | Height: | Size: 3.6 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 4.1 KiB |
After Width: | Height: | Size: 163 KiB |
After Width: | Height: | Size: 102 KiB |
After Width: | Height: | Size: 96 KiB |
After Width: | Height: | Size: 138 KiB |
After Width: | Height: | Size: 53 KiB |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 127 KiB |
After Width: | Height: | Size: 15 KiB |
After Width: | Height: | Size: 51 KiB |
After Width: | Height: | Size: 10 KiB |
After Width: | Height: | Size: 451 B |
After Width: | Height: | Size: 423 B |
After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 100 KiB |
After Width: | Height: | Size: 111 KiB |
After Width: | Height: | Size: 4.3 KiB |
After Width: | Height: | Size: 552 B |
After Width: | Height: | Size: 48 KiB |
After Width: | Height: | Size: 12 KiB |
After Width: | Height: | Size: 88 KiB |
After Width: | Height: | Size: 219 KiB |
After Width: | Height: | Size: 2.9 KiB |
After Width: | Height: | Size: 107 KiB |
After Width: | Height: | Size: 34 KiB |
After Width: | Height: | Size: 48 KiB |
After Width: | Height: | Size: 4.3 KiB |
After Width: | Height: | Size: 52 KiB |
After Width: | Height: | Size: 346 KiB |
After Width: | Height: | Size: 21 KiB |
After Width: | Height: | Size: 66 KiB |
After Width: | Height: | Size: 438 KiB |
After Width: | Height: | Size: 22 KiB |
After Width: | Height: | Size: 17 KiB |
After Width: | Height: | Size: 80 KiB |
After Width: | Height: | Size: 32 KiB |
After Width: | Height: | Size: 229 KiB |
After Width: | Height: | Size: 72 KiB |
After Width: | Height: | Size: 3.3 KiB |
After Width: | Height: | Size: 130 KiB |
After Width: | Height: | Size: 15 KiB |
After Width: | Height: | Size: 16 KiB |
@ -0,0 +1,9 @@
|
||||
{
|
||||
"treeData": [
|
||||
{
|
||||
"title": "minitest-1",
|
||||
"caseId": "85b100f1-fc91-4825-af29-698a75e0bc35",
|
||||
"rootPath": ""
|
||||
}
|
||||
]
|
||||
}
|
After Width: | Height: | Size: 2.8 KiB |
@ -0,0 +1,12 @@
|
||||
Page({
|
||||
goToStudent() {
|
||||
wx.navigateTo({
|
||||
url: '../student/student?fromIndex=true'
|
||||
});
|
||||
},
|
||||
goToTeacher() {
|
||||
wx.navigateTo({
|
||||
url: '../teacher/teacher'
|
||||
});
|
||||
}
|
||||
});
|
@ -0,0 +1,4 @@
|
||||
{
|
||||
"usingComponents": {
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
<view class="container" style="background-image: url('/image/index背景.png');"></view>
|
||||
<image class="teacher-image" src="/image/teacher.png" mode="widthFix"></image>
|
||||
<text class="text1">"简单"一点</text>
|
||||
<image class="green1-image" src="/image/green1.png" mode="widthFix"></image>
|
||||
<image class="green2-image" src="/image/green2.png" mode="widthFix"></image>
|
||||
<image class="music-image" src="/image/music.png" mode="widthFix"></image>
|
||||
<image class="home-image" src="/image/home.png" mode="widthFix"></image>
|
||||
<view class="rectangle1"></view>
|
||||
<view class="rectangle2"></view>
|
||||
<view class="rectangle3"></view>
|
||||
<text class="text2" bindtap="goToTeacher">我是老师</text>
|
||||
<text class="text3" bindtap="goToStudent">我是学生</text>
|
@ -0,0 +1,13 @@
|
||||
// pages/student/diandang/dd-not/dd-not.js
|
||||
Page({
|
||||
goyes() {
|
||||
wx.navigateTo({
|
||||
url: '/pages/student/diandang/dd-yes/dd-yes',
|
||||
});
|
||||
},
|
||||
goback() {
|
||||
wx.navigateTo({
|
||||
url: '/pages/student/student',
|
||||
});
|
||||
},
|
||||
})
|
@ -0,0 +1,3 @@
|
||||
{
|
||||
"usingComponents": {}
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
Page({
|
||||
data: {
|
||||
studentName: '',
|
||||
studentId: '',
|
||||
showInputModal: false, // 控制输入框的显示
|
||||
pledgeScore: 0, // 典当积分
|
||||
},
|
||||
|
||||
onLoad(options) {
|
||||
// 从前一个页面获取学生信息
|
||||
this.setData({
|
||||
studentId: options.studentId,
|
||||
studentName: options.studentName,
|
||||
});
|
||||
},
|
||||
|
||||
goback() {
|
||||
wx.navigateTo({
|
||||
url: '/pages/student/student',
|
||||
});
|
||||
},
|
||||
|
||||
confirmPledge() {
|
||||
// 显示输入框
|
||||
this.setData({ showInputModal: true });
|
||||
},
|
||||
|
||||
cancelPledge() {
|
||||
wx.navigateTo({
|
||||
url: '/pages/student/diandang/dd-not/dd-not',
|
||||
});
|
||||
},
|
||||
|
||||
closeInputModal() {
|
||||
this.setData({ showInputModal: false });
|
||||
// wx.navigateTo({
|
||||
// url: '/pages/student/student',
|
||||
// });
|
||||
},
|
||||
|
||||
handlePledgeInput(e) {
|
||||
this.setData({ pledgeScore: e.detail.value });
|
||||
},
|
||||
|
||||
submitPledge() {
|
||||
const { studentId, studentName, pledgeScore } = this.data;
|
||||
|
||||
// 发送请求保存典当信息
|
||||
wx.request({
|
||||
url: 'http://127.0.0.1:8000/api/create_pledge/',
|
||||
method: 'POST',
|
||||
data: {
|
||||
studentId: studentId,
|
||||
studentName: studentName,
|
||||
pledgeScore: pledgeScore,
|
||||
},
|
||||
success: (res) => {
|
||||
if (res.statusCode === 201) {
|
||||
wx.showToast({ title: '典当信息已保存', icon: 'success' });
|
||||
this.closeInputModal(); // 关闭输入框
|
||||
wx.navigateBack(); // 返回上一页
|
||||
} else {
|
||||
wx.showToast({ title: '典当失败', icon: 'none' });
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
wx.showToast({ title: '请求失败,请检查网络', icon: 'none' });
|
||||
}
|
||||
});
|
||||
},
|
||||
});
|
@ -0,0 +1,3 @@
|
||||
{
|
||||
"usingComponents": {}
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
{
|
||||
"enablePullDownRefresh": true
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
<!--pages/student/dm/dm.wxml-->
|
||||
<view class="container" style="background-image: url('/image/student背景.png');">
|
||||
</view>
|
||||
<image class="card-image" bindtap="useExemptionCard" src="/image/card.png" mode="widthFix"></image>
|
||||
<image class="green-image1" src="/image/green.png" mode="widthFix"></image>
|
||||
<image class="green-image2" src="/image/green.png" mode="widthFix"></image>
|
||||
<text class="name" style="white-space: pre;"> 姓名:{{mystudentName}}
|
||||
|
||||
当前积分: {{myscore}}</text>
|
||||
|
||||
<view class="circle1"></view>
|
||||
<image class="hu-image" src="/image/hu.png" mode="widthFix"></image>
|
||||
<image class="hu-image2" src="/image/hu.png" mode="widthFix"></image>
|
||||
<text class="dm-text" style="white-space: pre;" > 要点名啦</text>
|
||||
<text class="card-text" style="white-space: pre;" bindtap="useExemptionCard"> 点名豁免卡</text>
|
||||
<image class="fanhui-image" bindtap="goBack" src="/image/fanhui2.png" mode="widthFix"></image>
|
@ -0,0 +1,39 @@
|
||||
Page({
|
||||
data: {
|
||||
leaderboard: [], // 存储排行榜数据
|
||||
},
|
||||
|
||||
onLoad() {
|
||||
this.fetchLeaderboard();
|
||||
},
|
||||
goback() {
|
||||
wx.navigateTo({
|
||||
url: '/pages/student/student',
|
||||
});
|
||||
},
|
||||
|
||||
fetchLeaderboard() {
|
||||
wx.request({
|
||||
url: 'http://127.0.0.1:8000/api/leaderboard/', // 获取排行榜的 API
|
||||
method: 'GET',
|
||||
success: (res) => {
|
||||
if (res.statusCode === 200) {
|
||||
this.setData({
|
||||
leaderboard: res.data, // 设置排行榜数据
|
||||
});
|
||||
} else {
|
||||
wx.showToast({
|
||||
title: '获取排行榜失败',
|
||||
icon: 'none',
|
||||
});
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
wx.showToast({
|
||||
title: '请求失败,请检查网络',
|
||||
icon: 'none',
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
});
|
@ -0,0 +1,3 @@
|
||||
{
|
||||
"enablePullDownRefresh": true
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
<!--pages/student/rank/rank.wxml-->
|
||||
<view class="container" style="background-image: url('/image/rank背景.png');">
|
||||
|
||||
|
||||
<image class="p1-image" src="/image/p1.png" mode="widthFix"></image>
|
||||
<image class="p2-image" src="/image/p2.png" mode="widthFix"></image>
|
||||
<image class="vs-image" src="/image/vs.png" mode="widthFix"></image>
|
||||
<image class="rank1-image" src="/image/rank1.png" mode="widthFix"></image>
|
||||
<view class="rectangle"></view>
|
||||
<view class="rectangle-00"></view>
|
||||
<view class="rectangle-01"></view>
|
||||
<view class="rectangle-02"></view>
|
||||
<view class="rectangle-03"></view>
|
||||
<view class="rectangle-04"></view>
|
||||
<view class="rectangle-05"></view>
|
||||
<text class="rank-text" style="white-space: pre;"> 学生 积分 排行</text>
|
||||
<view class="circle1"></view>
|
||||
<view class="circle2"></view>
|
||||
<view class="circle3"></view>
|
||||
<view class="circle4"></view>
|
||||
<view class="circle5"></view>
|
||||
<image class="image1" src="/image/5.png" mode="widthFix"></image>
|
||||
<image class="image2" src="/image/4.png" mode="widthFix"></image>
|
||||
<image class="image3" src="/image/1.png" mode="widthFix"></image>
|
||||
<image class="image4" src="/image/2.png" mode="widthFix"></image>
|
||||
<image class="image5" src="/image/3.png" mode="widthFix"></image>
|
||||
<image class="image6" src="/image/6.png" mode="widthFix"></image>
|
||||
<block wx:for="{{leaderboard}}" wx:key="index">
|
||||
<view>
|
||||
<text class="text{{index + 1}}" style="white-space: pre;">
|
||||
{{item.name}}</text>
|
||||
<text class="text{{index + 6}}" style="white-space: pre;">
|
||||
{{item.score}} {{index + 1}} </text>
|
||||
</view>
|
||||
</block>
|
||||
|
||||
|
||||
<image class="fanhui-image" bindtap="goback" src="/image/fanhui.png" mode="widthFix"></image>
|
||||
</view>
|
@ -0,0 +1,18 @@
|
||||
|
||||
Page({
|
||||
data: {},
|
||||
onLoad() {
|
||||
console.log('规则页面加载');
|
||||
},
|
||||
goBack() {
|
||||
wx.navigateTo({
|
||||
url: '/pages/student/student',
|
||||
});
|
||||
},
|
||||
goTorule2() {
|
||||
console.log('点击了rule2按钮'); // 添加调试信息
|
||||
wx.navigateTo({
|
||||
url: `/pages/student/rules/rule2/rule2`,
|
||||
});
|
||||
},
|
||||
});
|
@ -0,0 +1,3 @@
|
||||
{
|
||||
"navigationBarTitleText": "游戏规则"
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
|
||||
Page({
|
||||
|
||||
goBack() {
|
||||
wx.navigateTo({
|
||||
url: '/pages/student/student',
|
||||
});
|
||||
},
|
||||
goTorule1() {
|
||||
console.log('点击了rule1按钮'); // 添加调试信息
|
||||
wx.navigateTo({
|
||||
url: `/pages/student/rules/rule1/rule1`,
|
||||
});
|
||||
},
|
||||
})
|
@ -0,0 +1,3 @@
|
||||
{
|
||||
"usingComponents": {}
|
||||
}
|
@ -0,0 +1,173 @@
|
||||
Page({
|
||||
data: {
|
||||
studentName: '',
|
||||
studentId: '',
|
||||
avatar: '/image/4.png', // 默认头像
|
||||
showModal: false, // 控制模态框显示
|
||||
score: 0, // 学生积分
|
||||
refreshing: false // 控制下拉刷新的状态
|
||||
},
|
||||
|
||||
onLoad(options) {
|
||||
const app = getApp();
|
||||
const { fromIndex } = options; // 获取参数
|
||||
|
||||
if (fromIndex) {
|
||||
// 清空全局变量和数据
|
||||
app.globalData.studentInfo = null;
|
||||
this.setData({
|
||||
studentName: '',
|
||||
studentId: '',
|
||||
score: 0,
|
||||
avatar: '/image/4.png'
|
||||
});
|
||||
} else if (app.globalData.studentInfo) {
|
||||
const { studentName, studentId, score, avatar } = app.globalData.studentInfo;
|
||||
this.setData({ studentName, studentId, score, avatar });
|
||||
}
|
||||
},
|
||||
|
||||
onShow() {
|
||||
// 页面显示时只更新积分
|
||||
this.updateScore();
|
||||
},
|
||||
|
||||
showLoginModal() {
|
||||
this.setData({ showModal: true });
|
||||
},
|
||||
|
||||
handleInput(e) {
|
||||
const { field } = e.currentTarget.dataset;
|
||||
const value = e.detail.value;
|
||||
this.setData({ [field]: value });
|
||||
},
|
||||
|
||||
confirmInput() {
|
||||
const { studentName, studentId } = this.data;
|
||||
|
||||
if (!studentName || !studentId) {
|
||||
wx.showToast({ title: '请填写完整信息', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
|
||||
this.setData({ showModal: false });
|
||||
|
||||
wx.request({
|
||||
url: `http://127.0.0.1:8000/api/get_student_info/${studentId}/`,
|
||||
method: 'GET',
|
||||
success: (res) => {
|
||||
if (res.statusCode === 200) {
|
||||
this.setData({
|
||||
score: res.data.score,
|
||||
avatar: res.data.avatar || this.data.avatar // 更新头像
|
||||
});
|
||||
|
||||
// 将学生信息存入全局变量
|
||||
const app = getApp();
|
||||
app.globalData.studentInfo = {
|
||||
studentName,
|
||||
studentId,
|
||||
score: res.data.score,
|
||||
avatar: this.data.avatar,
|
||||
};
|
||||
} else {
|
||||
wx.showToast({ title: '信息错误,请重试', icon: 'none' });
|
||||
}
|
||||
},
|
||||
fail: (error) => {
|
||||
wx.showToast({ title: '无法获取学生信息,请检查网络连接', icon: 'none' });
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
cancelInput() {
|
||||
this.setData({ showModal: false });
|
||||
},
|
||||
|
||||
// 下拉刷新功能
|
||||
onRefresh() {
|
||||
this.setData({ refreshing: true }); // 开始刷新
|
||||
this.updateScore(); // 更新积分
|
||||
},
|
||||
|
||||
updateScore() {
|
||||
const { studentId } = this.data;
|
||||
if (!studentId) {
|
||||
// wx.showToast({ title: '学生 ID 丢失', icon: 'none' });
|
||||
this.setData({ refreshing: false }); // 刷新结束
|
||||
return;
|
||||
}
|
||||
wx.request({
|
||||
url: `http://127.0.0.1:8000/api/get_student_info/${studentId}/`,
|
||||
method: 'GET',
|
||||
success: (res) => {
|
||||
console.log(res.data); // 打印 API 返回的数据
|
||||
if (res.statusCode === 200) {
|
||||
this.setData({
|
||||
score: res.data.score,
|
||||
refreshing: false // 刷新结束
|
||||
});
|
||||
} else {
|
||||
wx.showToast({ title: '更新失败', icon: 'none' });
|
||||
this.setData({ refreshing: false }); // 刷新结束
|
||||
}
|
||||
},
|
||||
fail: (error) => {
|
||||
wx.showToast({ title: '请求失败,请检查网络', icon: 'none' });
|
||||
this.setData({ refreshing: false }); // 刷新结束
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 上传头像
|
||||
uploadAvatar() {
|
||||
wx.chooseImage({
|
||||
count: 1,
|
||||
sizeType: ['compressed'],
|
||||
sourceType: ['album', 'camera'],
|
||||
success: (res) => {
|
||||
const tempFilePath = res.tempFilePaths[0];
|
||||
this.setData({ avatar: tempFilePath });
|
||||
},
|
||||
fail: (error) => {
|
||||
wx.showToast({ title: '上传失败,请重试', icon: 'none' });
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
// 跳转到点名功能
|
||||
rollCall() {
|
||||
wx.navigateTo({
|
||||
// url: '/pages/student/dm/dm?studentId=' + this.data.studentId,
|
||||
url: `/pages/student/dm/dm?studentId=${this.data.studentId}&studentName=${this.data.studentName}&score=${this.data.score}`,
|
||||
});
|
||||
},
|
||||
|
||||
goBack() {
|
||||
wx.navigateTo({
|
||||
url: '/pages/index/index',
|
||||
});
|
||||
},
|
||||
|
||||
// 跳转到排行榜
|
||||
goTorank() {
|
||||
console.log('点击了排行榜按钮'); // 添加调试信息
|
||||
wx.navigateTo({
|
||||
url: '/pages/student/rank/rank',
|
||||
});
|
||||
},
|
||||
// 跳转到典当页面
|
||||
goToPledge() {
|
||||
console.log('点击了典当按钮'); // 添加调试信息
|
||||
wx.navigateTo({
|
||||
url: `/pages/student/diandang/dd-yes/dd-yes?studentId=${this.data.studentId}&studentName=${this.data.studentName}`,
|
||||
});
|
||||
},
|
||||
goToguize() {
|
||||
console.log('点击了规则按钮'); // 添加调试信息
|
||||
wx.navigateTo({
|
||||
url: `/pages/student/rules/rule1/rule1`,
|
||||
});
|
||||
},
|
||||
});
|
@ -0,0 +1,3 @@
|
||||
{
|
||||
"enablePullDownRefresh": true
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
<!--pages/student/student.wxml-->
|
||||
<!-- 自定义模态框 -->
|
||||
<view wx:if="{{showModal}}" class="modal">
|
||||
<view class="modal-content">
|
||||
<view class="input-container">
|
||||
<text class="label">学号:</text>
|
||||
<input class="input-field" type="text" placeholder="请输入学号" bindinput="handleInput" data-field="studentId" />
|
||||
</view>
|
||||
<view class="input-container">
|
||||
<text class="label">姓名:</text>
|
||||
<input class="input-field" type="text" placeholder="请输入姓名" bindinput="handleInput" data-field="studentName" />
|
||||
</view>
|
||||
<view class="input-container">
|
||||
<text class="label">上传头像:</text>
|
||||
<button class="upload-button" bindtap="uploadAvatar">选择图片</button>
|
||||
</view>
|
||||
<button class="confirm-button" bindtap="confirmInput">确定</button>
|
||||
<button class="cancel-button" bindtap="cancelInput">取消</button>
|
||||
</view>
|
||||
</view>
|
||||
<scroll-view
|
||||
class="scroll-view"
|
||||
scroll-y="true"
|
||||
enable-back-to-top
|
||||
bindrefresh="onRefresh"
|
||||
refreshing="{{refreshing}}">
|
||||
<!-- 其他内容 -->
|
||||
</scroll-view>
|
||||
<view class="container" style="background-image: url('/image/学生背景.png');"></view>
|
||||
<image class="lanren-image" src="/image/lanren.png" mode="widthFix"></image>
|
||||
<image class="zi-image" src="/image/zi.png" mode="widthFix"></image>
|
||||
<image class="dd-image" bindtap="goToPledge" src="/image/dd.png" mode="widthFix"></image>
|
||||
<view class="circle1"></view>
|
||||
<image class="guize-image" bindtap="goToguize" src="/image/guize.png" mode="widthFix"></image>
|
||||
<text class="text1" bindtap="goToguize">规则</text>
|
||||
<image class="paihang-image" bindtap="goTorank" src="/image/排行.png" mode="widthFix"></image>
|
||||
<image class="yu-image" bindtap="rollCall" src="/image/yu.png" mode="widthFix"></image>
|
||||
<view class="rectangle1"></view>
|
||||
<view class="rectangle2"></view>
|
||||
<image class="bao-image" src="{{avatar}}" mode="widthFix"></image>
|
||||
<view class="rectangle3"></view>
|
||||
<view class="rectangle4"></view>
|
||||
<text class="text2"> {{studentName}}</text>
|
||||
<text class="text3" bindtap="rollCall">点
|
||||
|
||||
名</text>
|
||||
<text class="text4">当前积分: {{score}}</text>
|
||||
<image class="fanhui-image" bindtap="goBack" src="/image/fanhui.png" mode="widthFix"></image>
|
||||
<button class="submit-text" bindtap="showLoginModal">登录</button>
|
||||
|
@ -0,0 +1,99 @@
|
||||
Page({
|
||||
data: {
|
||||
studentId: '',
|
||||
studentName: '',
|
||||
score: 0.0,
|
||||
},
|
||||
|
||||
onLoad(options) {
|
||||
this.setData({
|
||||
studentId: options.studentId,
|
||||
});
|
||||
this.fetchStudentInfo();
|
||||
},
|
||||
|
||||
// 获取学生姓名和积分
|
||||
fetchStudentInfo() {
|
||||
console.log("Student ID:", this.data.studentId); // 检查 studentId 的值
|
||||
wx.request({
|
||||
url: `http://127.0.0.1:8000/api/get_student_info/${this.data.studentId}/`, // 拼接 student_id
|
||||
method: 'GET',
|
||||
success: (res) => {
|
||||
if (res.statusCode === 200 && res.data) {
|
||||
this.setData({
|
||||
studentName: res.data.name,
|
||||
score: res.data.score,
|
||||
});
|
||||
} else if (res.data.error) {
|
||||
wx.showToast({
|
||||
title: res.data.error,
|
||||
icon: 'none',
|
||||
});
|
||||
}
|
||||
},
|
||||
fail: (error) => {
|
||||
console.error('获取学生信息失败:', error);
|
||||
wx.showToast({
|
||||
title: '获取学生信息失败',
|
||||
icon: 'none',
|
||||
});
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
// 加分
|
||||
addScore() {
|
||||
this.updateScore(1);
|
||||
},
|
||||
|
||||
// 减分
|
||||
reduceScore() {
|
||||
this.updateScore(-1);
|
||||
},
|
||||
|
||||
// 更新分数到数据库
|
||||
updateScore(change) {
|
||||
const currentScore = parseFloat(this.data.score); // 转换为数字
|
||||
const newScore = (currentScore + change).toFixed(1); // 保留一位小数
|
||||
|
||||
wx.request({
|
||||
url: 'http://127.0.0.1:8000/api/update_student_score/',
|
||||
method: 'POST',
|
||||
data: {
|
||||
student_id: this.data.studentId,
|
||||
score: parseFloat(newScore), // 确保发送为浮点数
|
||||
},
|
||||
success: (res) => {
|
||||
if (res.data.success) {
|
||||
this.setData({ score: parseFloat(newScore) }); // 更新状态
|
||||
wx.showToast({
|
||||
title: change > 0 ? '加分成功' : '扣分成功',
|
||||
icon: 'success',
|
||||
});
|
||||
} else {
|
||||
wx.showToast({
|
||||
title: '更新失败',
|
||||
icon: 'none',
|
||||
});
|
||||
}
|
||||
},
|
||||
fail: (error) => {
|
||||
console.error('更新分数失败:', error);
|
||||
},
|
||||
});
|
||||
},
|
||||
// 跳转到排行榜
|
||||
goTorank() {
|
||||
console.log('点击了排行榜按钮'); // 添加调试信息
|
||||
wx.navigateTo({
|
||||
url: '/pages/teacher/Trank/rank-Mode1/rank-Mode1',
|
||||
});
|
||||
},
|
||||
goBack() {
|
||||
wx.navigateTo({
|
||||
url: '/pages/teacher/teacher',
|
||||
});
|
||||
},
|
||||
|
||||
});
|
||||
|
@ -0,0 +1,3 @@
|
||||
{
|
||||
"usingComponents": {}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
<!--pages/teacher/Mode-arrive/Mode-arrive.wxml-->
|
||||
<view class="container" style="background-image: url('/image/Mode1.png');">
|
||||
</view>
|
||||
<image class="ball-image" src="/image/ball.png" mode="widthFix"></image>
|
||||
<image class="back-image" bindtap="goBack" src="/image/back.png" mode="widthFix"></image>
|
||||
<view class="circle"></view>
|
||||
<image class="rank-image" bindtap="goTorank" src="/image/rank.png" mode="widthFix"></image>
|
||||
<view class="rectangle">
|
||||
<text class="text1" >
|
||||
学生姓名: {{studentName}}
|
||||
当前分数: {{score}}
|
||||
该同学是否在教室并答到</text>
|
||||
<label class="radio-label">
|
||||
<input type="radio" name="choice" value="yes" class="radio-input" />
|
||||
<view class="radio-custom" bindtap="addScore"></view>
|
||||
<text class="radio-text" bindtap="addScore">是</text>
|
||||
</label>
|
||||
<label class="radio-label">
|
||||
<input type="radio" name="choice" value="no" class="radio-input" />
|
||||
<view class="radio-custom" bindtap="reduceScore"></view>
|
||||
<text class="radio-text" bindtap="reduceScore">否</text>
|
||||
</label>
|
||||
</view>
|
@ -0,0 +1,125 @@
|
||||
Page({
|
||||
data: {
|
||||
showModal:false,
|
||||
showModalNoPledge: false, // 控制无典当信息弹窗的显示
|
||||
studentId: '',
|
||||
studentName: '',
|
||||
questionScore: 0,// 教师输入的分数
|
||||
currentScore: 0,
|
||||
pledgeScore: 0,
|
||||
pledgeStatus: 0,
|
||||
updatedScore: 0, // 更新后的分数
|
||||
},
|
||||
|
||||
|
||||
onLoad(options) {
|
||||
console.log('Received studentId:', options.studentId); // 检查参数传递是否成功
|
||||
this.setData({
|
||||
studentId: options.studentId,
|
||||
});
|
||||
},
|
||||
|
||||
// 处理输入的分数
|
||||
handleInputScore(e) {
|
||||
const value = e.detail.value;
|
||||
const numericValue = Number(value);
|
||||
|
||||
// 验证输入是否为有效的数字
|
||||
if (!isNaN(numericValue)) {
|
||||
this.setData({
|
||||
questionScore: numericValue, // 使用 Number 转换为数字
|
||||
});
|
||||
} else {
|
||||
this.setData({
|
||||
questionScore: 0, // 如果不是数字,重置为 0
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
submitScore() {
|
||||
const { studentId, questionScore } = this.data;
|
||||
console.log('请求数据:', { studentId, questionScore }); // 打印请求数据
|
||||
// 积分必须是一个数字
|
||||
if (isNaN(questionScore)) {
|
||||
wx.showToast({
|
||||
title: '请输入有效的积分',
|
||||
icon: 'none',
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// 更新学生积分并处理典当
|
||||
wx.request({
|
||||
url: 'http://127.0.0.1:8000/api/update_question_score', // 你的后端 API 地址
|
||||
method: 'POST',
|
||||
data: {
|
||||
studentId: this.data.studentId,
|
||||
questionScore: this.data.questionScore,
|
||||
},
|
||||
success: (res) => {
|
||||
if (res.statusCode === 200) {
|
||||
wx.showToast({
|
||||
title: '积分更新成功',
|
||||
icon: 'success',
|
||||
});
|
||||
// 判断返回的数据中是否有典当信息
|
||||
const { current_score, pledge_score, pledge_status, updated_score} = res.data;
|
||||
|
||||
if (pledge_score && pledge_status === 1) {
|
||||
// 设置数据并弹出典当信息的弹窗
|
||||
this.setData({
|
||||
currentScore: current_score,
|
||||
pledgeScore: pledge_score,
|
||||
showModal: true, // 显示典当信息弹窗
|
||||
});
|
||||
} else {
|
||||
this.setData({
|
||||
updatedScore: updated_score,
|
||||
showModalNoPledge: true, // 显示无典当信息弹窗
|
||||
});
|
||||
}
|
||||
} else {
|
||||
wx.showToast({
|
||||
title: res.data.error || '更新失败',
|
||||
icon: 'none',
|
||||
});
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
wx.showToast({
|
||||
title: '请求失败,请检查网络',
|
||||
icon: 'none',
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 关闭典当信息弹窗
|
||||
closeModal() {
|
||||
this.setData({
|
||||
showModal: false,
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
// 关闭无典当信息弹窗
|
||||
closeModalNoPledge() {
|
||||
this.setData({
|
||||
showModalNoPledge: false,
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
goTorank() {
|
||||
console.log('点击了排行榜按钮'); // 添加调试信息
|
||||
wx.navigateTo({
|
||||
url: '/pages/teacher/Trank/rank-Mode2/rank-Mode2',
|
||||
});
|
||||
},
|
||||
goBack() {
|
||||
wx.navigateTo({
|
||||
url: '/pages/teacher/teacher',
|
||||
});
|
||||
},
|
||||
});
|
||||
|
@ -0,0 +1,3 @@
|
||||
{
|
||||
"usingComponents": {}
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
// pages/teacher/Mode-quiz_2/Mode-quiz_2.js
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad(options) {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面初次渲染完成
|
||||
*/
|
||||
onReady() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面隐藏
|
||||
*/
|
||||
onHide() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面卸载
|
||||
*/
|
||||
onUnload() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 用户点击右上角分享
|
||||
*/
|
||||
onShareAppMessage() {
|
||||
|
||||
}
|
||||
})
|
@ -0,0 +1,3 @@
|
||||
{
|
||||
"usingComponents": {}
|
||||
}
|