This commit is contained in:
@@ -47,17 +47,25 @@
|
||||
</div>
|
||||
</ElFormItem>
|
||||
|
||||
<ElFormItem label="密码" prop="password">
|
||||
<ElFormItem label="密码" prop="password" class="password-form-item">
|
||||
<ElInput
|
||||
v-model="form.password"
|
||||
type="password"
|
||||
show-password
|
||||
placeholder="请输入密码(8-32 位)"
|
||||
maxlength="32"
|
||||
placeholder="请输入密码(8~12位)"
|
||||
maxlength="12"
|
||||
autocomplete="new-password"
|
||||
aria-describedby="registration-password-rule"
|
||||
/>
|
||||
<div class="strength-bar" :class="strengthClass">
|
||||
<p id="registration-password-rule" class="password-hint">
|
||||
{{ NEW_LOGIN_PASSWORD_HINT }}
|
||||
</p>
|
||||
<div class="strength-bar" :class="strengthClass" aria-hidden="true">
|
||||
<i v-for="n in 3" :key="n" :class="{ active: passwordStrength >= n }" />
|
||||
</div>
|
||||
<span v-if="form.password" class="password-status" aria-live="polite">
|
||||
{{ passwordStrength === 3 ? '密码符合规则' : '密码尚未符合规则' }}
|
||||
</span>
|
||||
</ElFormItem>
|
||||
|
||||
<div class="form-grid">
|
||||
@@ -129,6 +137,12 @@
|
||||
type AgentDistributionRegistrationParams
|
||||
} from '@/api/modules/agentDistribution'
|
||||
import { regionData } from '@/utils/constants/regionData'
|
||||
import { getAgentRegistrationFailureMessage } from '@/utils/business/agentRegistrationError'
|
||||
import {
|
||||
createNewLoginPasswordRule,
|
||||
getNewLoginPasswordError,
|
||||
NEW_LOGIN_PASSWORD_HINT
|
||||
} from '@/utils/validation/loginPassword'
|
||||
|
||||
const route = useRoute()
|
||||
|
||||
@@ -180,7 +194,7 @@
|
||||
code: [{ required: true, message: '请输入短信验证码', trigger: 'blur' }],
|
||||
password: [
|
||||
{ required: true, message: '请输入密码', trigger: 'blur' },
|
||||
{ min: 8, max: 32, message: '密码长度为 8-32 位', trigger: 'blur' }
|
||||
createNewLoginPasswordRule()
|
||||
],
|
||||
shop_name: [{ required: true, message: '请输入店铺名称', trigger: 'blur' }],
|
||||
username: [
|
||||
@@ -234,14 +248,7 @@
|
||||
const passwordStrength = computed(() => {
|
||||
const pwd = form.password
|
||||
if (!pwd) return 0
|
||||
let score = 0
|
||||
if (pwd.length >= 8) score += 1
|
||||
if (/[a-z]/.test(pwd) && /[A-Z]/.test(pwd)) score += 1
|
||||
if (/\d/.test(pwd)) score += 1
|
||||
if (/[^A-Za-z0-9]/.test(pwd)) score += 1
|
||||
if (score >= 4) return 3
|
||||
if (score >= 2) return 2
|
||||
return 1
|
||||
return getNewLoginPasswordError(pwd) ? 1 : 3
|
||||
})
|
||||
|
||||
const strengthClass = computed(() => {
|
||||
@@ -267,9 +274,9 @@
|
||||
}
|
||||
|
||||
const handleSubmit = () => {
|
||||
if (!formRef.value) return
|
||||
if (!formRef.value || submitting.value) return
|
||||
formRef.value.validate(async (valid) => {
|
||||
if (!valid) return
|
||||
if (!valid || submitting.value) return
|
||||
submitting.value = true
|
||||
try {
|
||||
const params: AgentDistributionRegistrationParams = {
|
||||
@@ -291,10 +298,10 @@
|
||||
if (res.code === 0) {
|
||||
submitted.value = true
|
||||
} else {
|
||||
ElMessage.error('分销码不可用')
|
||||
ElMessage.error(getAgentRegistrationFailureMessage(res))
|
||||
}
|
||||
} catch {
|
||||
ElMessage.error('分销码不可用')
|
||||
} catch (error) {
|
||||
ElMessage.error(getAgentRegistrationFailureMessage(error))
|
||||
} finally {
|
||||
submitting.value = false
|
||||
}
|
||||
@@ -315,19 +322,19 @@
|
||||
|
||||
<style scoped lang="scss">
|
||||
.agent-registration-page {
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: center;
|
||||
min-height: 100vh;
|
||||
padding: 48px 16px 64px;
|
||||
box-sizing: border-box;
|
||||
background: linear-gradient(160deg, #eef3fb 0%, #f7f9fd 40%, #eef3fb 100%);
|
||||
|
||||
.register-card {
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
max-width: 520px;
|
||||
padding: 36px 36px 28px;
|
||||
box-sizing: border-box;
|
||||
background: #fff;
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 8px 30px rgb(93 135 255 / 12%);
|
||||
@@ -375,13 +382,14 @@
|
||||
.strength-bar {
|
||||
display: flex;
|
||||
gap: 6px;
|
||||
width: 100%;
|
||||
margin-top: 8px;
|
||||
|
||||
i {
|
||||
flex: 1;
|
||||
height: 4px;
|
||||
border-radius: 2px;
|
||||
background: var(--el-border-color-lighter);
|
||||
border-radius: 2px;
|
||||
transition: background-color 0.2s ease;
|
||||
|
||||
&.active {
|
||||
@@ -398,6 +406,21 @@
|
||||
}
|
||||
}
|
||||
|
||||
.password-hint,
|
||||
.password-status {
|
||||
width: 100%;
|
||||
margin: 8px 0 0;
|
||||
font-size: 13px;
|
||||
line-height: 1.5;
|
||||
color: var(--el-text-color-regular);
|
||||
}
|
||||
|
||||
.password-form-item :deep(.el-form-item__error) {
|
||||
position: static;
|
||||
width: 100%;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.region-cascader {
|
||||
width: 100%;
|
||||
}
|
||||
@@ -411,7 +434,7 @@
|
||||
padding: 8px 0;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
@media (width <= 768px) {
|
||||
padding: 24px 12px 40px;
|
||||
|
||||
.register-card {
|
||||
@@ -429,7 +452,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 600px) {
|
||||
@media (width <= 600px) {
|
||||
:global(.agent-registration-cascader-popper) {
|
||||
width: calc(100vw - 24px) !important;
|
||||
max-width: calc(100vw - 24px) !important;
|
||||
@@ -441,10 +464,10 @@
|
||||
}
|
||||
|
||||
:global(.agent-registration-cascader-popper .el-cascader-menu) {
|
||||
box-sizing: border-box;
|
||||
flex: 1 1 0;
|
||||
width: 0;
|
||||
min-width: 0 !important;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
:global(.agent-registration-cascader-popper .el-cascader-node__label) {
|
||||
|
||||
Reference in New Issue
Block a user