Showing
4 changed files
with
38 additions
and
8 deletions
| 1 | /* | 1 | /* |
| 2 | * @Date: 2022-09-19 14:11:05 | 2 | * @Date: 2022-09-19 14:11:05 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2022-11-01 11:49:42 | 4 | + * @LastEditTime: 2022-11-01 13:28:38 |
| 5 | * @FilePath: /swx/src/app.js | 5 | * @FilePath: /swx/src/app.js |
| 6 | * @Description: 文件描述 | 6 | * @Description: 文件描述 |
| 7 | */ | 7 | */ |
| ... | @@ -11,7 +11,7 @@ import './app.less' | ... | @@ -11,7 +11,7 @@ import './app.less' |
| 11 | import '@/components/vant-weapp/common/index.wxss' | 11 | import '@/components/vant-weapp/common/index.wxss' |
| 12 | import request from './utils/request'; | 12 | import request from './utils/request'; |
| 13 | import Taro from '@tarojs/taro' | 13 | import Taro from '@tarojs/taro' |
| 14 | -import { getCurrentPageUrl } from "@/utils/weapp"; | 14 | +import { routerStore } from '@/stores/router' |
| 15 | 15 | ||
| 16 | const App = createApp({ | 16 | const App = createApp({ |
| 17 | // 可以使用所有的 Vue 生命周期方法 | 17 | // 可以使用所有的 Vue 生命周期方法 |
| ... | @@ -22,6 +22,9 @@ const App = createApp({ | ... | @@ -22,6 +22,9 @@ const App = createApp({ |
| 22 | onLaunch(options) { | 22 | onLaunch(options) { |
| 23 | // 未授权状态跳转授权页面,首页不需要权限 | 23 | // 未授权状态跳转授权页面,首页不需要权限 |
| 24 | const path = options.path; | 24 | const path = options.path; |
| 25 | + // 缓存没有权限的地址 | ||
| 26 | + const router = routerStore(); | ||
| 27 | + router.add(path); | ||
| 25 | if (path !== 'pages/index/index' && !wx.getStorageSync("sessionid")) { | 28 | if (path !== 'pages/index/index' && !wx.getStorageSync("sessionid")) { |
| 26 | wx.navigateTo({ | 29 | wx.navigateTo({ |
| 27 | url: './pages/auth/index' | 30 | url: './pages/auth/index' | ... | ... |
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2022-09-19 14:11:06 | 2 | * @Date: 2022-09-19 14:11:06 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2022-10-21 17:24:06 | 4 | + * @LastEditTime: 2022-11-01 13:32:00 |
| 5 | * @FilePath: /swx/src/pages/auth/index.vue | 5 | * @FilePath: /swx/src/pages/auth/index.vue |
| 6 | * @Description: 文件描述 | 6 | * @Description: 文件描述 |
| 7 | --> | 7 | --> |
| ... | @@ -21,6 +21,8 @@ import request from '@/utils/request'; | ... | @@ -21,6 +21,8 @@ import request from '@/utils/request'; |
| 21 | 21 | ||
| 22 | <script> | 22 | <script> |
| 23 | import "./index.less"; | 23 | import "./index.less"; |
| 24 | +import { getCurrentPageParam } from "@/utils/weapp"; | ||
| 25 | + | ||
| 24 | export default { | 26 | export default { |
| 25 | name: "authPage", | 27 | name: "authPage", |
| 26 | mounted () { | 28 | mounted () { |
| ... | @@ -42,9 +44,9 @@ export default { | ... | @@ -42,9 +44,9 @@ export default { |
| 42 | // 修改请求头 | 44 | // 修改请求头 |
| 43 | request.defaults.headers.cookie = res.cookies[0]; | 45 | request.defaults.headers.cookie = res.cookies[0]; |
| 44 | if (res.data.data.avatar) { | 46 | if (res.data.data.avatar) { |
| 45 | - Taro.navigateBack({ | 47 | + Taro.redirectTo({ |
| 46 | - delta: 1 // 返回上一级页面。 | 48 | + url: '../../' + getCurrentPageParam().url |
| 47 | - }); | 49 | + }) |
| 48 | } else { // 头像没有设置跳转完善信息页面 | 50 | } else { // 头像没有设置跳转完善信息页面 |
| 49 | Taro.redirectTo({ | 51 | Taro.redirectTo({ |
| 50 | url: '../apxUserInfo/index' | 52 | url: '../apxUserInfo/index' | ... | ... |
src/stores/router.js
0 → 100755
| 1 | +/* | ||
| 2 | + * @Date: 2022-10-28 14:34:22 | ||
| 3 | + * @LastEditors: hookehuyr hookehuyr@gmail.com | ||
| 4 | + * @LastEditTime: 2022-11-01 13:27:09 | ||
| 5 | + * @FilePath: /swx/src/stores/router.js | ||
| 6 | + * @Description: 缓存路由信息 | ||
| 7 | + */ | ||
| 8 | +import { defineStore } from 'pinia' | ||
| 9 | + | ||
| 10 | +export const routerStore = defineStore('router', { | ||
| 11 | + state: () => { | ||
| 12 | + return { | ||
| 13 | + url: '', | ||
| 14 | + } | ||
| 15 | + }, | ||
| 16 | + actions: { | ||
| 17 | + add (path) { | ||
| 18 | + this.url = path | ||
| 19 | + }, | ||
| 20 | + remove () { | ||
| 21 | + this.url = '' | ||
| 22 | + }, | ||
| 23 | + }, | ||
| 24 | +}) |
| 1 | /* | 1 | /* |
| 2 | * @Date: 2022-09-19 14:11:06 | 2 | * @Date: 2022-09-19 14:11:06 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2022-10-18 15:02:01 | 4 | + * @LastEditTime: 2022-11-01 13:29:19 |
| 5 | * @FilePath: /swx/src/utils/request.js | 5 | * @FilePath: /swx/src/utils/request.js |
| 6 | * @Description: 简单axios封装,后续按实际处理 | 6 | * @Description: 简单axios封装,后续按实际处理 |
| 7 | */ | 7 | */ |
| ... | @@ -11,6 +11,7 @@ import Taro from '@tarojs/taro' | ... | @@ -11,6 +11,7 @@ import Taro from '@tarojs/taro' |
| 11 | import Toast from '../components/vant-weapp/toast/toast'; | 11 | import Toast from '../components/vant-weapp/toast/toast'; |
| 12 | import { strExist } from './tools' | 12 | import { strExist } from './tools' |
| 13 | import qs from 'Qs' | 13 | import qs from 'Qs' |
| 14 | +import { routerStore } from '@/stores/router' | ||
| 14 | 15 | ||
| 15 | // import { ProgressStart, ProgressEnd } from '@/components/axios-progress/progress'; | 16 | // import { ProgressStart, ProgressEnd } from '@/components/axios-progress/progress'; |
| 16 | // import store from '@/store' | 17 | // import store from '@/store' |
| ... | @@ -94,7 +95,7 @@ service.interceptors.response.use( | ... | @@ -94,7 +95,7 @@ service.interceptors.response.use( |
| 94 | * 授权完成后 返回当前页面 | 95 | * 授权完成后 返回当前页面 |
| 95 | */ | 96 | */ |
| 96 | Taro.navigateTo({ | 97 | Taro.navigateTo({ |
| 97 | - url: '../../pages/auth/index' | 98 | + url: '../../pages/auth/index?url=' + routerStore().url |
| 98 | }) | 99 | }) |
| 99 | } | 100 | } |
| 100 | return response | 101 | return response | ... | ... |
-
Please register or login to post a comment