Commit 55dfdcb6 by 李伟康

修改登录

1 parent 960cd8e3
...@@ -8,7 +8,9 @@ Page({ ...@@ -8,7 +8,9 @@ Page({
loginType: 0, loginType: 0,
disabled: true disabled: true
}, },
onRoute(options){
console.log(options)
},
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
......
...@@ -30,16 +30,19 @@ Page({ ...@@ -30,16 +30,19 @@ Page({
sessionId, sessionId,
} = wx.$storage.get(), { } = wx.$storage.get(), {
url, url,
path = decodeURIComponent(url) targetPath = decodeURIComponent(url)
} = this.options } = this.options
console.log(path) console.log(targetPath)
wx.nextTick(() => {
if (sessionId) { if (sessionId) {
wx.$router.reLaunch('login.index') // wx.$router.reLaunch('login.index')
console.log(sessionId)
} else { } else {
wx.$router.reLaunch('login.index') wx.$router.reLaunch('login.index', {
targetPath
})
} }
})
}, },
/** /**
......
...@@ -15,9 +15,9 @@ ...@@ -15,9 +15,9 @@
"scene": null "scene": null
}, },
{ {
"name": "", "name": "携带目标页面",
"pathName": "login/index/index", "pathName": "login/loading/loading",
"query": "", "query": "url=pages%2Ftab%2Findex%2Findex%3Fid%3D123",
"launchMode": "default", "launchMode": "default",
"scene": null "scene": null
} }
......
...@@ -2,8 +2,8 @@ const _routeHooks = Symbol('_routeHooks') ...@@ -2,8 +2,8 @@ const _routeHooks = Symbol('_routeHooks')
const _query = Symbol('_query') const _query = Symbol('_query')
const _routerList = Symbol('_routerList') const _routerList = Symbol('_routerList')
import { import {
wxOnAppRouteFn, generateRoutList,
generateRoutList wxOnAppRouteFn
} from './wxOnAppRoute.js' } from './wxOnAppRoute.js'
import { import {
getNavigationBarTitleText getNavigationBarTitleText
...@@ -17,15 +17,23 @@ class Router { ...@@ -17,15 +17,23 @@ class Router {
[_routerList] = [] [_routerList] = []
constructor(router) { constructor(router) {
this[_routerList] = generateRoutList(router) this[_routerList] = generateRoutList(router)
let obj = { wx.onAppRoute &&
query: this[_query], wx.onAppRoute(e => {
routeHooks: this[_routeHooks], let thisPage = this.getPageInstance()
routerList: this[_routerList], if (thisPage) {
getPageInstance: this.getPageInstance, this.setNavigationBarTitleText(thisPage)
setNavigationBarTitleText: this.setNavigationBarTitleText, let onRoute = thisPage.onRoute
getRouterList: this.getRouterList typeof onRoute === 'function' && onRoute(this[_query])
}
this[_routeHooks].forEach(fn => {
try {
typeof fn === 'function' && fn(e, this[_query], this[_routerList])
} catch (err) {
console.log(err)
} }
wxOnAppRouteFn(obj) })
this[_query] = {}
})
} }
/**设置标题栏 */ /**设置标题栏 */
setNavigationBarTitleText = thisPage => { setNavigationBarTitleText = thisPage => {
...@@ -164,6 +172,7 @@ class Router { ...@@ -164,6 +172,7 @@ class Router {
if (Object.keys(data).length !== 0) data.on('getData', res => callBack(res)) if (Object.keys(data).length !== 0) data.on('getData', res => callBack(res))
} }
onRoute(fn) { onRoute(fn) {
console.log(fn)
this[_routeHooks].push(fn) this[_routeHooks].push(fn)
return () => { return () => {
const i = list.indexOf(fn) const i = list.indexOf(fn)
......
import util from '../utils/util.js' import util from '../utils/util.js'
import { getUserInfo } from '~/utils/cache/userInfo' import {
import { IMG_URL } from '~/utils/constantData' getUserInfo
} from '~/utils/cache/userInfo'
import {
IMG_URL
} from '~/utils/constantData'
/** /**
* wx.onAppRoute钩子方法, * wx.onAppRoute钩子方法,
...@@ -13,7 +17,8 @@ import { IMG_URL } from '~/utils/constantData' ...@@ -13,7 +17,8 @@ import { IMG_URL } from '~/utils/constantData'
* @param {*} obj.setNavigationBarTitleText * @param {*} obj.setNavigationBarTitleText
* @param {*} obj.getRouterList * @param {*} obj.getRouterList
*/ */
export const wxOnAppRouteFn = obj => { /**有问题,query一直为空 */
export const wxOnAppRouteFn = (obj,a) => {
wx.onAppRoute && wx.onAppRoute &&
wx.onAppRoute(e => { wx.onAppRoute(e => {
let thisPage = obj.getPageInstance() let thisPage = obj.getPageInstance()
...@@ -50,7 +55,9 @@ export const generateRoutList = routerList => { ...@@ -50,7 +55,9 @@ export const generateRoutList = routerList => {
if (item.parent != '__plugin__') { if (item.parent != '__plugin__') {
obj = { obj = {
...item, ...item,
isTab: __wxConfig.tabBar.list.some(({ pagePath }) => item.url.includes(pagePath.replace('.html', ''))) isTab: __wxConfig.tabBar.list.some(({
pagePath
}) => item.url.includes(pagePath.replace('.html', '')))
} }
if (item.parent !== 'pages') { if (item.parent !== 'pages') {
let parentList = item.url.split(`/`) let parentList = item.url.split(`/`)
...@@ -59,11 +66,6 @@ export const generateRoutList = routerList => { ...@@ -59,11 +66,6 @@ export const generateRoutList = routerList => {
obj.subPages = item.url.split(`/${item.parent}/pages/`)[1].split('/')[0] obj.subPages = item.url.split(`/${item.parent}/pages/`)[1].split('/')[0]
} }
} }
if (obj.isTab) {
__wxConfig.tabBar.list.map(e => {
if (obj.url === `/${e.pagePath.replace('.html', '')}`) obj.rootName = e.rootName
})
}
} }
return obj return obj
})) }))
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!