收紧店务端验证码登录准入
This commit is contained in:
@@ -9,8 +9,8 @@
|
||||
|
||||
<section class="card auth-card">
|
||||
<div class="mode-tabs">
|
||||
<button type="button" :class="{ active: loginMode === 'password' }" @click="switchMode('password')">密码登录</button>
|
||||
<button type="button" :class="{ active: loginMode === 'phone' }" @click="switchMode('phone')">验证码登录</button>
|
||||
<button type="button" :class="{ active: loginMode === 'password' }" @click="switchMode('password')">密码登录</button>
|
||||
</div>
|
||||
|
||||
<div v-if="loginMode === 'password'" class="field">
|
||||
@@ -117,7 +117,7 @@ const session = useSessionStore()
|
||||
const toast = useToastStore()
|
||||
const appIconUrl = `${import.meta.env.BASE_URL}assets/images/app-icon.png`
|
||||
const preference = readJson<LoginPreference>(LOGIN_PREFERENCE_KEY, {})
|
||||
const loginMode = ref<LoginMode>(preference.loginMode || 'password')
|
||||
const loginMode = ref<LoginMode>(preference.loginMode || 'phone')
|
||||
const form = reactive({
|
||||
account: preference.account || '',
|
||||
password: '',
|
||||
@@ -213,6 +213,12 @@ const sendLoginCode = async (): Promise<void> => {
|
||||
}
|
||||
codeLoading.value = true
|
||||
try {
|
||||
const selection = await authApi.getManagerPhoneLoginShops(form.phone)
|
||||
const shops = Array.isArray(selection.shops) ? selection.shops : []
|
||||
if (!selection.allowShoplessLogin && shops.length === 0) {
|
||||
toast.error(selection.message || '仅店长或美甲师可登录店务端')
|
||||
return
|
||||
}
|
||||
await authApi.sendLoginCode(form.phone)
|
||||
toast.success('验证码已发送')
|
||||
startCountdown()
|
||||
@@ -259,8 +265,11 @@ const showLoginError = (error: unknown): void => {
|
||||
const openShopSelector = async (): Promise<boolean> => {
|
||||
const selection = loginMode.value === 'password'
|
||||
? await authApi.getPasswordLoginShops(form.account)
|
||||
: await authApi.getPhoneLoginShops(form.phone)
|
||||
: await authApi.getManagerPhoneLoginShops(form.phone)
|
||||
const shops = Array.isArray(selection.shops) ? selection.shops : []
|
||||
if (!selection.allowShoplessLogin && shops.length === 0) {
|
||||
throw new Error(selection.message || '仅店长或美甲师可登录店务端')
|
||||
}
|
||||
if (shops.length <= 1) {
|
||||
return false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user