Commit 5d64a73a by chenwq

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

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