修复前端登录提示和店铺表单移动端交互
This commit is contained in:
@@ -366,6 +366,10 @@ onUnmounted(() => {
|
||||
.jayu-cloud-time-panel .ant-picker-time-panel-column {
|
||||
width: 76px;
|
||||
padding: 8px 6px;
|
||||
overflow-y: auto;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
overscroll-behavior: contain;
|
||||
touch-action: pan-y;
|
||||
}
|
||||
|
||||
.jayu-cloud-date-time-panel .ant-picker-time-panel-cell-inner,
|
||||
|
||||
@@ -114,11 +114,17 @@ const mergedBodyStyle = computed(() => (
|
||||
|
||||
/** handleOpenChange is a local helper used by this page script. */
|
||||
const handleOpenChange = (value: boolean) => {
|
||||
if (!value && typeof document !== 'undefined' && document.visibilityState === 'hidden') {
|
||||
return
|
||||
}
|
||||
emit('update:open', value)
|
||||
}
|
||||
|
||||
/** handleCancel is a local helper used by this page script. */
|
||||
const handleCancel = (event?: unknown) => {
|
||||
if (typeof document !== 'undefined' && document.visibilityState === 'hidden') {
|
||||
return
|
||||
}
|
||||
emit('update:open', false)
|
||||
emit('cancel', event)
|
||||
}
|
||||
|
||||
@@ -601,7 +601,7 @@
|
||||
* ShopsView page script.
|
||||
* Call guide: the template binds the reactive state below, and the methods are triggered by button clicks, lifecycle hooks, or router events.
|
||||
*/
|
||||
import { computed, ref, reactive, onMounted } from 'vue'
|
||||
import { computed, ref, reactive, onBeforeUnmount, onMounted } from 'vue'
|
||||
import { message } from 'ant-design-vue'
|
||||
import type { FormInstance, UploadProps } from 'ant-design-vue'
|
||||
import { PlusOutlined } from '@ant-design/icons-vue'
|
||||
@@ -2177,6 +2177,21 @@ const handleSaveDraft = () => {
|
||||
message.success('已暂存到本地')
|
||||
}
|
||||
|
||||
const saveDraftSilently = () => {
|
||||
if (!modalVisible.value || isUploadPending.value) {
|
||||
return
|
||||
}
|
||||
syncBusinessHoursValue()
|
||||
const draft = saveDraftRecord(getDraftKey(), buildDraftPayload())
|
||||
draftSavedAt.value = draft.savedAt
|
||||
}
|
||||
|
||||
const handleDocumentVisibilityChange = () => {
|
||||
if (document.visibilityState === 'hidden') {
|
||||
saveDraftSilently()
|
||||
}
|
||||
}
|
||||
|
||||
/** handleClearDraft is a local helper used by this page script. */
|
||||
const handleClearDraft = (showMessage = true) => {
|
||||
clearDraftRecord(getDraftKey())
|
||||
@@ -2382,10 +2397,15 @@ const handleStatusChange = async (record: Shop | Record<string, any>, enabled: b
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
document.addEventListener('visibilitychange', handleDocumentVisibilityChange)
|
||||
loadCustomThemeTemplates()
|
||||
await loadUserPermissions()
|
||||
fetchShopList()
|
||||
})
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
document.removeEventListener('visibilitychange', handleDocumentVisibilityChange)
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
@@ -216,6 +216,8 @@ const sendLoginCode = async (): Promise<void> => {
|
||||
await authApi.sendLoginCode(form.phone)
|
||||
toast.success('验证码已发送')
|
||||
startCountdown()
|
||||
} catch (error) {
|
||||
showLoginError(error)
|
||||
} finally {
|
||||
codeLoading.value = false
|
||||
}
|
||||
@@ -246,6 +248,14 @@ const resolveLoginResponse = async (shopId?: IdType): Promise<LoginResponse> =>
|
||||
return authApi.phoneLogin(buildPhoneRequest(shopId))
|
||||
}
|
||||
|
||||
const showLoginError = (error: unknown): void => {
|
||||
const message = error instanceof Error && error.message ? error.message : '登录失败,请稍后再试'
|
||||
if (toast.visible && toast.message === message) {
|
||||
return
|
||||
}
|
||||
toast.error(message)
|
||||
}
|
||||
|
||||
const openShopSelector = async (): Promise<boolean> => {
|
||||
const selection = loginMode.value === 'password'
|
||||
? await authApi.getPasswordLoginShops(form.account)
|
||||
@@ -267,6 +277,8 @@ const loginWithShop = async (shopId: IdType): Promise<void> => {
|
||||
savePreference()
|
||||
toast.success('登录成功')
|
||||
await router.replace('/planning')
|
||||
} catch (error) {
|
||||
showLoginError(error)
|
||||
} finally {
|
||||
switchingShop.value = false
|
||||
}
|
||||
@@ -295,6 +307,8 @@ const submit = async (): Promise<void> => {
|
||||
savePreference()
|
||||
toast.success('登录成功')
|
||||
await router.replace('/planning')
|
||||
} catch (error) {
|
||||
showLoginError(error)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user