fix: 登录时保存username,修复订单列表无数据

This commit is contained in:
Agent
2026-03-25 16:33:52 +00:00
parent d834188c08
commit e32758ecc5
2 changed files with 11 additions and 3 deletions

View File

@@ -101,10 +101,12 @@ export default {
const mockData = {
token: 'mock-token-admin',
userId: 'admin-001',
username: 'admin',
role: 'admin'
}
uni.setStorageSync('token', mockData.token)
uni.setStorageSync('userId', mockData.userId)
uni.setStorageSync('username', mockData.username)
uni.setStorageSync('role', mockData.role)
uni.showToast({ title: '管理员登录成功', icon: 'success' })
@@ -119,10 +121,12 @@ export default {
const mockData = {
token: 'mock-token-sales',
userId: 'sales-001',
username: '张三',
role: 'sales'
}
uni.setStorageSync('token', mockData.token)
uni.setStorageSync('userId', mockData.userId)
uni.setStorageSync('username', mockData.username)
uni.setStorageSync('role', mockData.role)
uni.showToast({ title: '销售人员登录成功', icon: 'success' })
@@ -137,10 +141,12 @@ export default {
const mockData = {
token: 'mock-token-customer',
userId: 'customer-001',
username: '顾客',
role: 'customer'
}
uni.setStorageSync('token', mockData.token)
uni.setStorageSync('userId', mockData.userId)
uni.setStorageSync('username', mockData.username)
uni.setStorageSync('role', mockData.role)
uni.showToast({ title: '登录成功', icon: 'success' })
@@ -155,6 +161,7 @@ export default {
uni.setStorageSync('token', data.token)
uni.setStorageSync('refreshToken', data.refreshToken)
uni.setStorageSync('userId', data.userId)
uni.setStorageSync('username', data.username || this.username)
uni.setStorageSync('role', data.role || 'customer')
uni.showToast({ title: '登录成功', icon: 'success' })