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.
100 lines
2.8 KiB
100 lines
2.8 KiB
var file = require('../../utils/file.js');
|
|
var app = getApp();
|
|
|
|
Page({
|
|
data: {
|
|
vertIndex: 1,
|
|
horiIndex: 1,
|
|
operationName: '',
|
|
student_ID: "000000001",
|
|
name: "张三",
|
|
scoreOptions: [0.5, 1, 1.5, 2, 2.5, 3], // 分数选项
|
|
selectedScore: null, // 选中的分数
|
|
showScorePicker: false // 控制分数选择器的显示
|
|
},
|
|
|
|
onLoad() {
|
|
this._load();
|
|
},
|
|
|
|
vertPageChange: function (e) {
|
|
if ('touch' == e.detail.source) {
|
|
if (e.detail.current == 0) {
|
|
file.updatescore(-2);
|
|
wx.redirectTo({
|
|
url: '/pages/rollcall/rollcall',
|
|
})
|
|
} else if (e.detail.current == 2) {
|
|
// 停留在当前页面,显示分数选择器
|
|
this.setData({
|
|
showScorePicker: true // 显示分数选择器
|
|
});
|
|
}
|
|
|
|
this.setData({
|
|
vertIndex: 1,
|
|
});
|
|
}
|
|
},
|
|
|
|
horiPageChange: function (e) {
|
|
if ('touch' == e.detail.source) {
|
|
if (e.detail.current == 0) {
|
|
file.updatescore(1.5);
|
|
}
|
|
|
|
this.setData({
|
|
horiIndex: 1,
|
|
});
|
|
wx.redirectTo({
|
|
url: '/pages/rollcall/rollcall',
|
|
})
|
|
}
|
|
},
|
|
|
|
// 分数选择回调函数
|
|
scoreChange: function (e) {
|
|
const index = e.detail.value;
|
|
const selectedScore = this.data.scoreOptions[index];
|
|
this.setData({
|
|
selectedScore: selectedScore // 更新选中的分数
|
|
});
|
|
// console.log("Selected Score:", selectedScore); // 输出选中的分数用于调试
|
|
},
|
|
|
|
// 确认分数按钮的回调
|
|
confirmScore: function () {
|
|
if (this.data.selectedScore !== null) {
|
|
file.updatescore(this.data.selectedScore); // 更新分数
|
|
this.setData({
|
|
showScorePicker: false // 隐藏分数选择器
|
|
});
|
|
wx.showToast({
|
|
title: '分数更新成功',
|
|
icon: 'success',
|
|
duration: 2000
|
|
});
|
|
wx.redirectTo({
|
|
url: '/pages/rollcall/rollcall',
|
|
})
|
|
} else {
|
|
wx.showToast({
|
|
title: '请选择分数',
|
|
icon: 'none',
|
|
duration: 2000
|
|
});
|
|
}
|
|
},
|
|
|
|
_load: function (e) {
|
|
if (app.globalData.part === 0) {
|
|
const randomNumber = Math.floor(Math.random() * app.globalData.total);
|
|
app.globalData.currentId = randomNumber;
|
|
}
|
|
this.setData({
|
|
student_ID: app.globalData.array[app.globalData.currentId].student_ID,
|
|
name: app.globalData.array[app.globalData.currentId].name,
|
|
});
|
|
}
|
|
});
|