初始化上传医疗项目到 medical-mall
This commit is contained in:
@@ -57,6 +57,7 @@
|
||||
type="text"
|
||||
placeholder="账号名/手机号/邮箱"
|
||||
v-model="account"
|
||||
autocomplete="off"
|
||||
/>
|
||||
</view>
|
||||
<view class="field password-field">
|
||||
@@ -65,6 +66,7 @@
|
||||
:type="isPasswordVisible ? 'text' : 'password'"
|
||||
placeholder="密码"
|
||||
v-model="password"
|
||||
autocomplete="new-password"
|
||||
/>
|
||||
<view class="eye-btn" @click="isPasswordVisible = !isPasswordVisible">
|
||||
<!-- 睁眼(猴子双手打开)表示可见, 闭眼(猴子捂眼)表示不可见 -->
|
||||
@@ -81,6 +83,7 @@
|
||||
placeholder="输入手机号码"
|
||||
maxlength="11"
|
||||
v-model="account"
|
||||
autocomplete="off"
|
||||
/>
|
||||
</view>
|
||||
|
||||
@@ -161,15 +164,22 @@ const cssVars = {
|
||||
const logoUrl = ref<string>('/static/logo.png')
|
||||
|
||||
const loginType = ref<number>(0)
|
||||
const account = ref<string>('')
|
||||
const password = ref<string>('')
|
||||
|
||||
// ─────────────────────────────────────────────
|
||||
// 默认账号密码(唯一来源,修改只改这里)
|
||||
// 必须在 account/password ref 之前声明,否则 ref 初始化时无法引用
|
||||
// ─────────────────────────────────────────────
|
||||
// const TEST_ACCOUNT = 'test@mall.com' // ← 旧账号(已停用)
|
||||
// const TEST_PASSWORD = 'Hf2152111' // ← 旧密码(已停用)
|
||||
const TEST_ACCOUNT = 'test19@163.com'
|
||||
const TEST_PASSWORD = 'huang123456'
|
||||
|
||||
// ✅ account/password 直接以常量作初始值,上线/刷新立即生效,不再依赖 onMounted 延迟赋值
|
||||
const account = ref<string>(TEST_ACCOUNT)
|
||||
const password = ref<string>(TEST_PASSWORD)
|
||||
const captcha = ref<string>('')
|
||||
const isPasswordVisible = ref<boolean>(false)
|
||||
|
||||
// 测试账号(开发测试用)
|
||||
const TEST_ACCOUNT = 'test@mall.com'
|
||||
const TEST_PASSWORD = 'Hf2152111'
|
||||
|
||||
const isLoading = ref<boolean>(false)
|
||||
|
||||
/**
|
||||
@@ -262,10 +272,36 @@ const checkLoginStatus = (): void => {
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
// ── 调试日志(开发阶段保留,上线前可删除)──
|
||||
console.log('[Login] ▶ onMounted 开始')
|
||||
console.log('[Login] 📝 form 初始值:', {
|
||||
account: account.value,
|
||||
password: account.value === TEST_ACCOUNT ? '(TEST_PASSWORD 默认)' : '(ref 已被其他逻辑覆盖)'
|
||||
})
|
||||
|
||||
// 检查是否存在旧版本 loginn.uvue 遗留的 rememberEmail 缓存
|
||||
try {
|
||||
const storedEmail = uni.getStorageSync('rememberEmail') as string | null
|
||||
console.log('[Login] 📦 读取 storage[rememberEmail]:', storedEmail ?? '(无)')
|
||||
if (storedEmail != null && storedEmail.trim() !== '') {
|
||||
// 如果存在之前的记住密码缓存,创建账号使用缓存,密码空留用户手动输入
|
||||
console.log('[Login] ℹ️ 发现 rememberEmail 缓存,使用缓存账号:', storedEmail)
|
||||
account.value = storedEmail
|
||||
password.value = '' // 密码不缓存,须用户手动输入
|
||||
} else {
|
||||
console.log('[Login] ℹ️ 无缓存,使用默认账号密码(已由 ref 初始化)')
|
||||
// account 和 password 已在 ref 声明时直接用 TEST_ACCOUNT/TEST_PASSWORD 初始化,无需重复赋值
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('[Login] ⚠️ 读取 rememberEmail 失败(已忽略):', e)
|
||||
}
|
||||
|
||||
console.log('[Login] 📝 onMounted 完成,最终 form 値:', {
|
||||
account: account.value,
|
||||
isDefault: account.value === TEST_ACCOUNT
|
||||
})
|
||||
|
||||
checkLoginStatus()
|
||||
// 自动填充测试账号密码
|
||||
account.value = TEST_ACCOUNT
|
||||
password.value = TEST_PASSWORD
|
||||
})
|
||||
|
||||
const validateAccount = (): boolean => {
|
||||
@@ -371,6 +407,42 @@ const handleLogin = async () => {
|
||||
return
|
||||
}
|
||||
|
||||
// 演示模式:测试账号直接走本地 bypass,不请求后端(WeChat MP 禁止 HTTP/裸 IP 请求)
|
||||
if (IS_TEST_MODE && account.value === TEST_ACCOUNT && password.value === TEST_PASSWORD) {
|
||||
setIsLoggedIn(true)
|
||||
const merchantProfile = {
|
||||
id: 'demo-merchant-001',
|
||||
username: '演示机构',
|
||||
email: TEST_ACCOUNT,
|
||||
gender: 'unknown',
|
||||
birthday: '',
|
||||
height_cm: 0,
|
||||
weight_kg: 0,
|
||||
bio: '医养服务演示机构',
|
||||
avatar_url: '/static/logo.png',
|
||||
preferred_language: 'zh-CN',
|
||||
role: 'merchant',
|
||||
school_id: '',
|
||||
grade_id: '',
|
||||
class_id: ''
|
||||
} as UserProfile
|
||||
setUserProfile(merchantProfile)
|
||||
uni.setStorageSync('user_id', 'demo-merchant-001')
|
||||
uni.showToast({ title: '登录成功', icon: 'success' })
|
||||
setTimeout(() => {
|
||||
// #ifdef H5
|
||||
uni.reLaunch({ url: '/pages/mall/admin/homePage/index' })
|
||||
// #endif
|
||||
// #ifdef MP-WEIXIN
|
||||
uni.reLaunch({ url: '/pages/mall/merchant/index' })
|
||||
// #endif
|
||||
// #ifndef H5 || MP-WEIXIN
|
||||
uni.reLaunch({ url: '/pages/mall/admin/homePage/index' })
|
||||
// #endif
|
||||
}, 500)
|
||||
return
|
||||
}
|
||||
|
||||
if (loginType.value === 0) {
|
||||
if (!validatePassword()) return
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user