|
@@ -21,6 +21,13 @@ const defaultAccountInfo = {
|
|
|
userId: ''
|
|
|
}
|
|
|
|
|
|
+const tabUrl = [
|
|
|
+ 'pages/index/index',
|
|
|
+ 'pages/index/position',
|
|
|
+ 'pages/index/communicate',
|
|
|
+ 'pages/index/my'
|
|
|
+]
|
|
|
+
|
|
|
export const userStore = defineStore({
|
|
|
id: 'user',
|
|
|
state: () => ({
|
|
@@ -32,7 +39,7 @@ export const userStore = defineStore({
|
|
|
|
|
|
actions: {
|
|
|
// 登录
|
|
|
- async handleSmsLogin (query, type) {
|
|
|
+ async handleSmsLogin (query, type, route) {
|
|
|
const api = type ? smsLogin : passwordLogin
|
|
|
const { data, code } = await api(query)
|
|
|
if (code === 0) {
|
|
@@ -42,9 +49,17 @@ export const userStore = defineStore({
|
|
|
}
|
|
|
this.accountInfo = data
|
|
|
this.getInfo()
|
|
|
- uni.switchTab({
|
|
|
- url: '/pages/index/my'
|
|
|
- })
|
|
|
+
|
|
|
+ // 登录成功后的跳转地址
|
|
|
+ if (tabUrl.includes(route)) {
|
|
|
+ uni.switchTab({
|
|
|
+ url: '/' + route
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ uni.navigateTo({
|
|
|
+ url: '/' + route
|
|
|
+ })
|
|
|
+ }
|
|
|
},
|
|
|
// 获取用户信息
|
|
|
async getInfo() {
|