Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
saas_plus
/
business-assistant
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 55dfdcb6
authored
Oct 11, 2022
by
李伟康
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
修改登录
1 parent
960cd8e3
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
50 additions
and
34 deletions
login/index/index.js
login/loading/loading.js
project.private.config.json
router/router.js
router/wxOnAppRoute.js
login/index/index.js
View file @
55dfdcb
...
...
@@ -8,7 +8,9 @@ Page({
loginType
:
0
,
disabled
:
true
},
onRoute
(
options
){
console
.
log
(
options
)
},
/**
* 生命周期函数--监听页面加载
*/
...
...
login/loading/loading.js
View file @
55dfdcb
...
...
@@ -30,16 +30,19 @@ Page({
sessionId
,
}
=
wx
.
$storage
.
get
(),
{
url
,
p
ath
=
decodeURIComponent
(
url
)
targetP
ath
=
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
})
}
})
},
/**
...
...
project.private.config.json
View file @
55dfdcb
...
...
@@ -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
}
...
...
router/router.js
View file @
55dfdcb
...
...
@@ -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
)
...
...
router/wxOnAppRoute.js
View file @
55dfdcb
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
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment