Commit 8c92d3d8 by 张立顺

配置页面和组件导入IMG_URL

1 parent ae8ee0d6
// components/Tab/Tab.js // components/Tab/Tab.js
// behaviors: [LocationBehavior],
import { imgUrlMixin } from '~/mixins/index'
Component({ Component({
behaviors: [imgUrlMixin],
/** /**
* 组件的属性列表 * 组件的属性列表
*/ */
......
import { IMG_URL } from '~/utils/constantData'
module.exports = Behavior({
data: {
IMGURL: IMG_URL
}
})
import imgUrlMixin from './imgUrl'
module.exports = { module.exports = {
imgUrlMixin
} }
...@@ -7,6 +7,7 @@ Page({ ...@@ -7,6 +7,7 @@ Page({
*/ */
data: { data: {
navStyle, navStyle,
// IMG_URL
}, },
/** /**
......
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
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']
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!