根据提供的代码,可以将确认对话框逻辑添加到onResetPass
方法中。以下是一个可能的修改示例:
<button type="primary" class="data-v-723b7266" @click="showConfirmDialog">充值</button>
methods: {
showConfirmDialog() {
const self = this;
uni.showModal({
title: '确认充值',
content: '确定要进行充值吗?',
success(res) {
if (res.confirm) {
// 用户点击确定,执行充值操作
self.onResetPass();
} else if (res.cancel) {
// 用户点击取消,不进行充值操作
console.log('用户点击取消');
}
}
});
},
onResetPass() {
const table = uni.getStorageSync("nowTable");
if (this.newMoney <= 0) {
this.$utils.msg('请输入正确的充值数目');
return;
}
this.user.newMoney = parseFloat(this.user.newMoney) + parseFloat(this.newMoney);
this.$api.update(table, this.user).then((res) => {
this.changeSuccess = !this.changeSuccess;
});
},
// 其他页面逻辑...
}
在上述示例中,我们使用uni-app的uni.showModal()
方法来显示一个确认对话框。当用户点击确认时,res.confirm
为true
;当用户点击取消时,res.cancel
为true
。
在成功情况下,我们调用了原先的 onResetPass()
方法来执行相应的充值操作。
请注意,在实际项目中,请根据您的具体业务需求和uni-app框架进行相应修改,并确保已正确引入相关依赖库和配置了事件处理函数。
内容由零声教学AI助手提供,问题来源于学员提问