Commit 9dadecd3 by liimin

Merge branch 'v1.0.0' of http://192.168.3.233:8090/saas/mini-program/hmd into v1.0.0

2 parents 5ca511bf ed6d43b8
...@@ -5,7 +5,8 @@ ...@@ -5,7 +5,8 @@
"pages/tab/equity/index", "pages/tab/equity/index",
"pages/tab/mall/index", "pages/tab/mall/index",
"pages/tab/mine/index", "pages/tab/mine/index",
"pages/webView/webView" "pages/webView/webView",
"pages/Login/Login"
], ],
"requiredPrivateInfos": ["getLocation"], "requiredPrivateInfos": ["getLocation"],
"lazyCodeLoading": "requiredComponents", "lazyCodeLoading": "requiredComponents",
......
...@@ -14,6 +14,9 @@ Page({ ...@@ -14,6 +14,9 @@ Page({
onLoad(options) { onLoad(options) {
console.log(options) console.log(options)
this.setData(options) this.setData(options)
setTimeout(() => {
console.log(this.options, 'this.options')
}, 2e3)
}, },
/** /**
......
// pages/Login/Login.js
Page({
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})
\ No newline at end of file \ No newline at end of file
{
"usingComponents": {}
}
\ No newline at end of file \ No newline at end of file
/* pages/Login/Login.wxss */
\ No newline at end of file \ No newline at end of file
<!--pages/Login/Login.wxml-->
<text>pages/Login/Login.wxml</text>
...@@ -12,55 +12,40 @@ Page({ ...@@ -12,55 +12,40 @@ Page({
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad(options) { onLoad(options) {
console.log(__wxConfig)
}, this.tabList = __wxConfig.tabBar.list
wx.p.wxApi.showLoading()
/** //scenc获取页面参数并跳转
* 生命周期函数--监听页面初次渲染完成 if (options.scene) {
*/ return
onReady() { }
if (options.url) {
}, return this.jumpPage(options.url)
}
/** // 默认跳转到首页
* 生命周期函数--监听页面显示 wx.p.router.goHome()
*/ },
onShow() { jumpPage(val){
const targetPath = decodeURIComponent(val),
}, {url, events} = this.setRouteData(targetPath),
routeName = this.tabList.findIndex(e => `/${e.pagePath}` == `${url}.html`) > -1 ? 'switchTab' : 'redirectTo'
/** wx.p.router[routeName](url,events)
* 生命周期函数--监听页面隐藏 },
*/ setRouteData(targetPath) {
onHide() { let [url, query] = targetPath.split('?'),
events = {}
}, if (query) {
let arr = query.split('&')
/** arr.map(e => {
* 生命周期函数--监听页面卸载 const [key, val] = e.split('=')
*/ Object.assign(events, {
onUnload() { [key]: val
})
}, })
}
/** return {
* 页面相关事件处理函数--监听用户下拉动作 url,
*/ events
onPullDownRefresh() { }
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
} }
}) })
\ No newline at end of file \ No newline at end of file
<!--pages/loading/loading.wxml-->
<text>pages/loading/loading.wxml</text>
...@@ -13,7 +13,7 @@ Page({ ...@@ -13,7 +13,7 @@ Page({
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad: function (options) { onLoad: function (options) {
this.setData(options)
}, },
jump(){ jump(){
wx.p.router.go('/packageIndex/pages/index/index',{ wx.p.router.go('/packageIndex/pages/index/index',{
......
...@@ -2,4 +2,6 @@ ...@@ -2,4 +2,6 @@
<view style="padding-top:200px"> <view style="padding-top:200px">
<button bindtap="jump">点击跳转携带参数</button> <button bindtap="jump">点击跳转携带参数</button>
<view>{{a}}</view>
<view>{{b}}</view>
</view> </view>
\ No newline at end of file \ No newline at end of file
...@@ -27,6 +27,13 @@ ...@@ -27,6 +27,13 @@
"query": "merchantId=44205858", "query": "merchantId=44205858",
"launchMode": "default", "launchMode": "default",
"scene": null "scene": null
},
{
"name": "测试loading",
"pathName": "pages/loading/loading",
"query": "url=%2Fpages%2Ftab%2Findex%2Findex%3Fa%3D123%26b%3D456",
"launchMode": "default",
"scene": null
} }
] ]
} }
......
...@@ -37,6 +37,12 @@ class Router { ...@@ -37,6 +37,12 @@ class Router {
redirectTo(route, events = {}) { redirectTo(route, events = {}) {
this._to(route, events, 'redirectTo'); this._to(route, events, 'redirectTo');
} }
/**
* 跳转到switchTab
*/
switchTab(route,events = {}){
this._to(route, events, 'switchTab');
}
_to(route, events, to, success) { _to(route, events, to, success) {
getApp().globalData.ROUTE_QUERY = events getApp().globalData.ROUTE_QUERY = events
if (events.notIntercept) { if (events.notIntercept) {
......
...@@ -7,11 +7,13 @@ class RouterBefore { ...@@ -7,11 +7,13 @@ class RouterBefore {
pageLeaveProxy(thisPage) { pageLeaveProxy(thisPage) {
let onLoad = thisPage.onLoad let onLoad = thisPage.onLoad
thisPage.onLoad = function () { thisPage.onLoad = function () {
const event = getApp().globalData.ROUTE_QUERY
let options = { let options = {
...getApp().globalData.ROUTE_QUERY, ...event,
...arguments[0] ...arguments[0]
} }
onLoad && onLoad.apply(this, [options]),(getApp().globalData.ROUTE_QUERY = {}) getApp().globalData.ROUTE_QUERY = {}
onLoad && onLoad.apply(this, [options]),(this.options = options)
} }
} }
/**全局注册事件 */ /**全局注册事件 */
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!