This commit is contained in:
@@ -95,11 +95,48 @@ export default {
|
||||
return
|
||||
}
|
||||
|
||||
// 假登录(演示用)
|
||||
if (this.username === 'admin' && this.password === 'admin') {
|
||||
const mockData = {
|
||||
token: 'mock-token-admin',
|
||||
userId: 'admin-001',
|
||||
role: 'admin'
|
||||
}
|
||||
uni.setStorageSync('token', mockData.token)
|
||||
uni.setStorageSync('userId', mockData.userId)
|
||||
uni.setStorageSync('role', mockData.role)
|
||||
|
||||
uni.showToast({ title: '登录成功', icon: 'success' })
|
||||
setTimeout(() => {
|
||||
uni.reLaunch({ url: '/pages/index/index' })
|
||||
}, 1000)
|
||||
return
|
||||
}
|
||||
|
||||
// 顾客登录
|
||||
if (this.username === 'customer' && this.password === 'customer') {
|
||||
const mockData = {
|
||||
token: 'mock-token-customer',
|
||||
userId: 'customer-001',
|
||||
role: 'customer'
|
||||
}
|
||||
uni.setStorageSync('token', mockData.token)
|
||||
uni.setStorageSync('userId', mockData.userId)
|
||||
uni.setStorageSync('role', mockData.role)
|
||||
|
||||
uni.showToast({ title: '登录成功', icon: 'success' })
|
||||
setTimeout(() => {
|
||||
uni.reLaunch({ url: '/pages/index/index' })
|
||||
}, 1000)
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
const data = await authApi.passwordLogin(this.username, this.password)
|
||||
uni.setStorageSync('token', data.token)
|
||||
uni.setStorageSync('refreshToken', data.refreshToken)
|
||||
uni.setStorageSync('userId', data.userId)
|
||||
uni.setStorageSync('role', data.role || 'customer')
|
||||
|
||||
uni.showToast({ title: '登录成功', icon: 'success' })
|
||||
setTimeout(() => {
|
||||
|
||||
Reference in New Issue
Block a user