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.

71 lines
1.8 KiB

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://10.133.64.210: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' });
}
});
},
});