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 8c92d3d8
authored
Oct 12, 2022
by
张立顺
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
配置页面和组件导入IMG_URL
1 parent
ae8ee0d6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
39 additions
and
22 deletions
components/Tab/Tab.js
mixins/imgUrl.js
mixins/index.js
pages/tab/index/index.js
router/routerBefore.js
utils/constantData.js
components/Tab/Tab.js
View file @
8c92d3d
// components/Tab/Tab.js
// components/Tab/Tab.js
// behaviors: [LocationBehavior],
import
{
imgUrlMixin
}
from
'~/mixins/index'
Component
({
Component
({
behaviors
:
[
imgUrlMixin
],
/**
/**
* 组件的属性列表
* 组件的属性列表
*/
*/
...
...
mixins/imgUrl.js
0 → 100644
View file @
8c92d3d
import
{
IMG_URL
}
from
'~/utils/constantData'
module
.
exports
=
Behavior
({
data
:
{
IMGURL
:
IMG_URL
}
})
mixins/index.js
View file @
8c92d3d
import
imgUrlMixin
from
'./imgUrl'
module
.
exports
=
{
module
.
exports
=
{
}
\ No newline at end of file
\ No newline at end of file
imgUrlMixin
}
pages/tab/index/index.js
View file @
8c92d3d
...
@@ -7,6 +7,7 @@ Page({
...
@@ -7,6 +7,7 @@ Page({
*/
*/
data
:
{
data
:
{
navStyle
,
navStyle
,
// IMG_URL
},
},
/**
/**
...
...
router/routerBefore.js
View file @
8c92d3d
import
{
IMG_URL
}
from
'~/utils/constantData'
/**
/**
* 执行路由前的准备工作
* 执行路由前的准备工作
*/
*/
/**处理前置钩子逻辑 */
/**处理前置钩子逻辑 */
const
routerBefore
=
(
next
)
=>
{
const
routerBefore
=
next
=>
{
// console.log("处理前置钩子逻辑");
// console.log("处理前置钩子逻辑");
next
();
let
page
=
wx
.
$router
.
getPageInstance
()
};
page
&&
(
page
.
data
.
IMG_URL
=
IMG_URL
)
// page && page.setData({ IMG_URL })
// console.log()
// console.log(next)
next
()
}
/**处理后置钩子逻辑 */
/**处理后置钩子逻辑 */
const
routerAfter
=
(
next
)
=>
{
const
routerAfter
=
next
=>
{
// console.log("处理后置钩子逻辑");
// console.log("处理后置钩子逻辑");
next
()
;
next
()
}
;
}
// 重写Page方法
// 重写Page方法
const
OldPage
=
Page
;
const
OldPage
=
Page
Page
=
function
(
options
)
{
Page
=
function
(
options
)
{
const
oldShow
=
options
.
onShow
;
const
oldShow
=
options
.
onShow
const
oldHide
=
options
.
onHide
;
const
oldHide
=
options
.
onHide
options
.
onShow
=
function
()
{
options
.
onShow
=
function
()
{
routerBefore
(()
=>
{
routerBefore
(()
=>
{
oldShow
.
apply
(
this
,
arguments
)
;
oldShow
.
apply
(
this
,
arguments
)
})
;
})
}
;
}
options
.
onHide
=
function
()
{
options
.
onHide
=
function
()
{
routerAfter
(()
=>
{
routerAfter
(()
=>
{
oldHide
.
apply
(
this
,
arguments
)
;
oldHide
.
apply
(
this
,
arguments
)
})
;
})
}
;
}
OldPage
(
options
)
;
OldPage
(
options
)
}
;
}
export
default
routerBefore
;
\ No newline at end of file
\ No newline at end of file
export
default
routerBefore
utils/constantData.js
View file @
8c92d3d
export
const
IMG_URL
=
'https://img02.glsx.com.cn/weapp/resource/
miniprogram-test/cgacar
/'
export
const
IMG_URL
=
'https://img02.glsx.com.cn/weapp/resource/
saas/business-assistant
/'
// 缓存get方法为空的默认指定值
// 缓存get方法为空的默认指定值
export
const
DEFAULT_GET_STORAGEKEY
=
[
'sessionId'
,
'merchantId'
,
'userInfo'
]
export
const
DEFAULT_GET_STORAGEKEY
=
[
'sessionId'
,
'merchantId'
,
'userInfo'
]
...
...
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