|
@@ -17,26 +17,27 @@
|
|
|
</view>
|
|
</view>
|
|
|
</view>
|
|
</view>
|
|
|
|
|
|
|
|
- <!-- WEB模式:输入框界面 -->
|
|
|
|
|
|
|
+ <!-- WEB模式:确认界面 -->
|
|
|
<view v-else class="form-container">
|
|
<view v-else class="form-container">
|
|
|
<view class="status-bar-placeholder" :style="{ height: statusBarHeight + 'px' }" />
|
|
<view class="status-bar-placeholder" :style="{ height: statusBarHeight + 'px' }" />
|
|
|
<view class="form-content">
|
|
<view class="form-content">
|
|
|
- <text class="form-title">请输入登录信息</text>
|
|
|
|
|
|
|
+ <text class="form-title">确认登录信息</text>
|
|
|
<view class="input-group">
|
|
<view class="input-group">
|
|
|
- <text class="input-label">用户ID</text>
|
|
|
|
|
|
|
+ <text class="input-label">用户信息</text>
|
|
|
<input
|
|
<input
|
|
|
class="form-input"
|
|
class="form-input"
|
|
|
- v-model="inputUserId"
|
|
|
|
|
- placeholder="请输入用户ID"
|
|
|
|
|
|
|
+ v-model="inputUserInfo"
|
|
|
|
|
+ placeholder="请输入用户信息JSON"
|
|
|
placeholder-style="color: #bbb"
|
|
placeholder-style="color: #bbb"
|
|
|
/>
|
|
/>
|
|
|
</view>
|
|
</view>
|
|
|
<view class="input-group">
|
|
<view class="input-group">
|
|
|
- <text class="input-label">用户名</text>
|
|
|
|
|
|
|
+ <text class="input-label">密码</text>
|
|
|
<input
|
|
<input
|
|
|
class="form-input"
|
|
class="form-input"
|
|
|
- v-model="inputUsername"
|
|
|
|
|
- placeholder="请输入用户名"
|
|
|
|
|
|
|
+ v-model="inputPassword"
|
|
|
|
|
+ type="password"
|
|
|
|
|
+ placeholder="请输入密码"
|
|
|
placeholder-style="color: #bbb"
|
|
placeholder-style="color: #bbb"
|
|
|
/>
|
|
/>
|
|
|
</view>
|
|
</view>
|
|
@@ -57,17 +58,27 @@ defineOptions({
|
|
|
name: 'loading',
|
|
name: 'loading',
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
|
|
+interface PayloadData {
|
|
|
|
|
+ token?: string
|
|
|
|
|
+ userId?: string
|
|
|
|
|
+ username?: string
|
|
|
|
|
+ [key: string]: any
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
const statusText = ref('正在加载...')
|
|
const statusText = ref('正在加载...')
|
|
|
const fromType = ref('APP')
|
|
const fromType = ref('APP')
|
|
|
|
|
|
|
|
|
|
+// 解析后的payload
|
|
|
|
|
+const payload = ref<PayloadData>({})
|
|
|
|
|
+
|
|
|
// WEB模式表单
|
|
// WEB模式表单
|
|
|
-const inputUserId = ref('')
|
|
|
|
|
-const inputUsername = ref('')
|
|
|
|
|
|
|
+const inputUserInfo = ref('')
|
|
|
|
|
+const inputPassword = ref('')
|
|
|
|
|
|
|
|
-// URL参数(APP模式用)
|
|
|
|
|
-const urlToken = ref('')
|
|
|
|
|
-const urlUserId = ref('')
|
|
|
|
|
-const urlUsername = ref('')
|
|
|
|
|
|
|
+const loginAppToken = (params: { token: string; userId: string; username: string }) => {
|
|
|
|
|
+ doLogin(params.token, params.userId, params.username, '', 'APP')
|
|
|
|
|
+}
|
|
|
|
|
+window.loginAppToken = loginAppToken
|
|
|
|
|
|
|
|
// 状态栏高度
|
|
// 状态栏高度
|
|
|
const statusBarHeight = ref(20)
|
|
const statusBarHeight = ref(20)
|
|
@@ -76,51 +87,73 @@ statusBarHeight.value = systemInfo.statusBarHeight || 20
|
|
|
|
|
|
|
|
const userStore = useUserStore()
|
|
const userStore = useUserStore()
|
|
|
|
|
|
|
|
-onLoad((options) => {
|
|
|
|
|
|
|
+onLoad((options: any) => {
|
|
|
fromType.value = options?.from || 'WEB'
|
|
fromType.value = options?.from || 'WEB'
|
|
|
- urlToken.value = options?.token || ''
|
|
|
|
|
- urlUserId.value = options?.userId || ''
|
|
|
|
|
- urlUsername.value = options?.username || ''
|
|
|
|
|
-
|
|
|
|
|
- // WEB模式:预填URL参数到表单
|
|
|
|
|
- if (fromType.value !== 'APP') {
|
|
|
|
|
- inputUserId.value = urlUserId.value
|
|
|
|
|
- inputUsername.value = urlUsername.value
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // APP模式:直接登录
|
|
|
|
|
- if (fromType.value === 'APP') {
|
|
|
|
|
- if (!urlToken.value) {
|
|
|
|
|
- statusText.value = '缺少token参数'
|
|
|
|
|
- return
|
|
|
|
|
- }
|
|
|
|
|
- doLogin(urlToken.value)
|
|
|
|
|
- }
|
|
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
// WEB模式:点击继续
|
|
// WEB模式:点击继续
|
|
|
const handleWebSubmit = () => {
|
|
const handleWebSubmit = () => {
|
|
|
- if (!inputUserId.value.trim()) {
|
|
|
|
|
- statusText.value = '请输入用户ID'
|
|
|
|
|
|
|
+ if (!inputUserInfo.value.trim()) {
|
|
|
|
|
+ statusText.value = '请输入用户信息'
|
|
|
|
|
+ uni.showToast({ title: statusText.value, icon: 'none' })
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
- if (!inputUsername.value.trim()) {
|
|
|
|
|
- statusText.value = '请输入用户名'
|
|
|
|
|
|
|
+ let userInfo: any
|
|
|
|
|
+ try {
|
|
|
|
|
+ console.log('inputUserInfo.value.trim()', inputUserInfo.value.trim())
|
|
|
|
|
+ userInfo = JSON.parse(inputUserInfo.value.trim())
|
|
|
|
|
+ } catch {
|
|
|
|
|
+ statusText.value = '用户信息JSON格式错误'
|
|
|
|
|
+ uni.showToast({ title: statusText.value, icon: 'none' })
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ const userId = userInfo.userId || userInfo.user_id || ''
|
|
|
|
|
+ const username = userInfo.username || userInfo.user_name || ''
|
|
|
|
|
+ if (!userId) {
|
|
|
|
|
+ statusText.value = '用户信息中缺少userId'
|
|
|
|
|
+ uni.showToast({ title: statusText.value, icon: 'none' })
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!inputPassword.value.trim()) {
|
|
|
|
|
+ statusText.value = '请输入密码'
|
|
|
|
|
+ uni.showToast({ title: statusText.value, icon: 'none' })
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
statusText.value = ''
|
|
statusText.value = ''
|
|
|
- doLogin(urlToken.value, inputUserId.value.trim(), inputUsername.value.trim())
|
|
|
|
|
|
|
+ doLogin(
|
|
|
|
|
+ payload.value.token || '',
|
|
|
|
|
+ userId,
|
|
|
|
|
+ username,
|
|
|
|
|
+ inputPassword.value.trim(),
|
|
|
|
|
+ 'WEB',
|
|
|
|
|
+ )
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// appToken登录
|
|
// appToken登录
|
|
|
-const doLogin = async (appToken: string, extraUserId?: string, extraUsername?: string) => {
|
|
|
|
|
|
|
+const doLogin = async (
|
|
|
|
|
+ appToken: string,
|
|
|
|
|
+ extraUserId?: string,
|
|
|
|
|
+ extraUsername?: string,
|
|
|
|
|
+ password?: string,
|
|
|
|
|
+ mode?: 'APP' | 'WEB',
|
|
|
|
|
+) => {
|
|
|
try {
|
|
try {
|
|
|
|
|
+ if (fromType.value !== 'APP') {
|
|
|
|
|
+ uni.showLoading({ title: '加载中...', mask: true })
|
|
|
|
|
+ }
|
|
|
statusText.value = '正在加载...'
|
|
statusText.value = '正在加载...'
|
|
|
- const loginRes: any = await loginByAppToken({ appToken })
|
|
|
|
|
|
|
+ const loginRes: any = await loginByAppToken({
|
|
|
|
|
+ appToken,
|
|
|
|
|
+ userId: extraUserId,
|
|
|
|
|
+ username: extraUsername,
|
|
|
|
|
+ password: password,
|
|
|
|
|
+ mode: mode,
|
|
|
|
|
+ })
|
|
|
const loginData = loginRes?.data
|
|
const loginData = loginRes?.data
|
|
|
|
|
|
|
|
if (!loginRes || loginRes.code !== 0 || !loginData) {
|
|
if (!loginRes || loginRes.code !== 0 || !loginData) {
|
|
|
statusText.value = '加载失败: ' + (loginRes?.msg || '未知错误')
|
|
statusText.value = '加载失败: ' + (loginRes?.msg || '未知错误')
|
|
|
|
|
+ uni.showToast({ title: statusText.value, icon: 'none' })
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -144,6 +177,10 @@ const doLogin = async (appToken: string, extraUserId?: string, extraUsername?: s
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
|
console.error('[LoadingPage] 加载失败:', error)
|
|
console.error('[LoadingPage] 加载失败:', error)
|
|
|
statusText.value = '加载失败,请重试'
|
|
statusText.value = '加载失败,请重试'
|
|
|
|
|
+ } finally {
|
|
|
|
|
+ if (fromType.value !== 'APP') {
|
|
|
|
|
+ uni.hideLoading()
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -220,7 +257,6 @@ const fetchDeptMembers = async (deptId: string) => {
|
|
|
color: #333;
|
|
color: #333;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// WEB模式表单样式
|
|
|
|
|
.form-container {
|
|
.form-container {
|
|
|
min-height: 100vh;
|
|
min-height: 100vh;
|
|
|
background-color: #fff;
|
|
background-color: #fff;
|
|
@@ -275,11 +311,4 @@ const fetchDeptMembers = async (deptId: string) => {
|
|
|
font-size: 16px;
|
|
font-size: 16px;
|
|
|
color: #fff;
|
|
color: #fff;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
-.error-text {
|
|
|
|
|
- margin-top: 12px;
|
|
|
|
|
- font-size: 14px;
|
|
|
|
|
- color: #ff4d4f;
|
|
|
|
|
- text-align: center;
|
|
|
|
|
-}
|
|
|
|
|
</style>
|
|
</style>
|