Commit 55dfdcb6 by 李伟康

修改登录

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