Commit 0ce212e4 by 张立顺

IMGURL

1 parent c564c51b
...@@ -58,7 +58,7 @@ ...@@ -58,7 +58,7 @@
], ],
"include": [] "include": []
}, },
"appid": "wxe10067a63c1856ac", "appid": "wxfe82b8d65d07808f",
"projectname": "miniprogram-scrm-shopmall", "projectname": "miniprogram-scrm-shopmall",
"condition": {} "condition": {}
} }
\ No newline at end of file \ No newline at end of file
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}`
}) })
...@@ -183,4 +167,4 @@ class Router { ...@@ -183,4 +167,4 @@ class Router {
} }
} }
export default Router
\ No newline at end of file \ No newline at end of file
export default Router
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()
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!