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