Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
saas_plus
/
store-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 0ce212e4
authored
Oct 12, 2022
by
张立顺
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
IMGURL
1 parent
c564c51b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
30 deletions
project.config.json
router/router.js
router/routerBefore.js
project.config.json
View file @
0ce212e
...
...
@@ -58,7 +58,7 @@
],
"include"
:
[]
},
"appid"
:
"wx
e10067a63c1856ac
"
,
"appid"
:
"wx
fe82b8d65d07808f
"
,
"projectname"
:
"miniprogram-scrm-shopmall"
,
"condition"
:
{}
}
\ No newline at end of file
router/router.js
View file @
0ce212e
const
_routeHooks
=
Symbol
(
'_routeHooks'
)
const
_query
=
Symbol
(
'_query'
)
const
_routerList
=
Symbol
(
'_routerList'
)
import
{
generateRoutList
}
from
'./wxOnAppRoute.js'
import
{
getNavigationBarTitleText
}
from
'~/utils/cache/storageApi'
import
{
getUserInfo
}
from
'~/utils/cache/userInfo'
import
{
IMG_URL
}
from
'~/utils/constantData'
import
{
generateRoutList
}
from
'./wxOnAppRoute.js'
import
{
getNavigationBarTitleText
}
from
'~/utils/cache/storageApi'
import
{
getUserInfo
}
from
'~/utils/cache/userInfo'
class
Router
{
[
_query
]
=
{};
[
_routeHooks
]
=
[];
...
...
@@ -21,6 +16,7 @@ class Router {
let
thisPage
=
this
.
getPageInstance
()
if
(
thisPage
)
{
thisPage
.
options
=
this
[
_query
]
thisPage
.
setData
({
IMGURL
:
IMG_URL
})
this
.
setNavigationBarTitleText
(
thisPage
)
let
onRoute
=
thisPage
.
onRoute
typeof
onRoute
===
'function'
&&
onRoute
(
this
[
_query
])
...
...
@@ -41,10 +37,7 @@ class Router {
if
(
getUserInfo
())
title
=
getUserInfo
().
merchantName
const
router
=
`
${
thisPage
.
__route__
}
.html`
if
(
__wxConfig
&&
__wxConfig
.
page
&&
__wxConfig
.
page
[
router
])
{
let
{
navigationBarTitleText
,
navigationStyle
}
=
__wxConfig
.
page
[
router
].
window
let
{
navigationBarTitleText
,
navigationStyle
}
=
__wxConfig
.
page
[
router
].
window
if
(
!
title
)
title
=
'生意助手'
if
(
!
navigationBarTitleText
&&
!
navigationStyle
)
wx
.
setNavigationBarTitle
({
...
...
@@ -116,10 +109,7 @@ class Router {
* 保留当前页面,跳转到应用内的某个页面。但是不能跳到 tabbar 页面。使用 $router.back() 可以返回到原页面。小程序中页面栈最多十层
*/
go
(
route
,
events
)
{
let
{
routerMapItem
,
query
}
=
this
.
checkRouter
(
route
,
events
)
let
{
routerMapItem
,
query
}
=
this
.
checkRouter
(
route
,
events
)
if
(
routerMapItem
.
isTab
)
{
wx
.
switchTab
({
url
:
routerMapItem
.
url
...
...
@@ -133,20 +123,14 @@ class Router {
}
/**关闭所有页面,打开到应用内的某个页面 */
reLaunch
(
route
,
events
)
{
let
{
routerMapItem
,
query
}
=
this
.
checkRouter
(
route
,
events
)
let
{
routerMapItem
,
query
}
=
this
.
checkRouter
(
route
,
events
)
wx
.
reLaunch
({
url
:
`
${
routerMapItem
.
url
}${
query
}
`
})
}
/**关闭当前页面,跳转到应用内的某个页面。但是不允许跳转到 tabbar 页面。 */
redirectTo
(
route
,
events
)
{
let
{
routerMapItem
,
query
}
=
this
.
checkRouter
(
route
,
events
)
let
{
routerMapItem
,
query
}
=
this
.
checkRouter
(
route
,
events
)
wx
.
redirectTo
({
url
:
`
${
routerMapItem
.
url
}${
query
}
`
})
...
...
@@ -183,4 +167,4 @@ class Router {
}
}
export
default
Router
\ No newline at end of file
export
default
Router
router/routerBefore.js
View file @
0ce212e
import
{
IMG_URL
}
from
'~/utils/constantData'
//
import { IMG_URL } from '~/utils/constantData'
/**
* 执行路由前的准备工作
*/
...
...
@@ -7,8 +7,8 @@ import { IMG_URL } from '~/utils/constantData'
const
routerBefore
=
next
=>
{
// console.log("处理前置钩子逻辑");
// 配置图片全局路径
let
page
=
wx
.
$router
.
getPageInstance
()
page
&&
(
page
.
data
.
IMG_URL
=
IMG_URL
)
//
let page = wx.$router.getPageInstance()
//
page && (page.data.IMG_URL = IMG_URL)
// page && page.setData({ IMG_URL })
// console.log()
...
...
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