Commit 5d64a73a by chenwq

优化Dialog组件,新增禁用点击操作功能;调整退出登录逻辑,防止重复提交

1 parent 6d883a55
......@@ -38,6 +38,11 @@ Component({
statusIcon: {
type: String,
default: ""
},
// 是否禁用点击操作(用于防重复提交等场景,由外部传入控制)
disabled: {
type: Boolean,
value: false
}
},
......@@ -53,13 +58,18 @@ Component({
*/
methods: {
handleClick(e) {
// 通过外部传入的 disabled 属性判断是否禁止点击
if (this.data.disabled) return;
let {
index
} = e.currentTarget.dataset
const eventFn = this.data.buttons[index].eventFn || (index === 0 ? 'dialogCancel' : 'dialogConfirm')
const eventFn = this.data.buttons[index].eventFn || (index === 0 ? 'dialogCancel' : 'dialogConfirm')
this.triggerEvent(eventFn)
},
handleClose() {
if (this.data.disabled) return;
this.triggerEvent('dialogCancel')
}
}
......
......@@ -36,6 +36,7 @@ Page({
},
],
showLogoutDialog: false,
isLogouting: false,
logoutButtons: [
{ text: "取消", extClass: "btn_cancel", eventFn: "dialogCancel" },
{ text: "确认退出", extClass: "btn_primary", eventFn: "dialogConfirm" },
......@@ -86,11 +87,15 @@ Page({
},
onLogoutConfirm() {
this.toggleLogoutDialog();
if (this.data.isLogouting) return;
this.setData({ isLogouting: true });
wx.p.wxApi.showLoading("加载中...");
commonApi
.logout()
.then(() => {
this.setData({ showLogoutDialog: false }).then(() => {
this.setData({ isLogouting: false });
});
wx.hideLoading();
wx.p.storage.rm("token");
wx.p.isLogin = false;
......@@ -98,14 +103,15 @@ Page({
wx.p.router.redirectTo("/pages/Login/Login");
})
.catch(() => {
this.setData({ isLogouting: false });
wx.hideLoading();
});
},
async goToInspection() {
console.log(wx.p.api.systemApi)
const { report_webview } = await wx.p.api.systemApi.getFrontConfig()
console.log("获取的mock数据:", report_webview);
console.log(wx.p.api.systemApi);
const { report_webview } = await wx.p.api.systemApi.getFrontConfig();
console.log("获取的mock数据:", report_webview);
// TODO: 跳转到检测管理页面
const targetUrl = `/pages/webView/h5FullNoShare/h5FullNoShare?url=${encodeURIComponent(report_webview)}&openType=miniApp`;
wx.navigateTo({ url: targetUrl });
......
......@@ -210,10 +210,12 @@ page {
/* Footer */
.footer {
position: absolute;
bottom: 32rpx;
display: flex;
flex-direction: column;
align-items: center;
margin-top: 60rpx;
margin-top: 20rpx;
}
.version {
......
......@@ -84,6 +84,7 @@
show="{{showLogoutDialog}}"
title="退出登录"
buttons="{{logoutButtons}}"
disabled="{{isLogouting}}"
bind:dialogCancel="toggleLogoutDialog"
bind:dialogConfirm="onLogoutConfirm"
>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!