Commit ed6d43b8 by 李伟康

增加loading页

1 parent be7cf529
......@@ -5,7 +5,8 @@
"pages/tab/equity/index",
"pages/tab/mall/index",
"pages/tab/mine/index",
"pages/webView/webView"
"pages/webView/webView",
"pages/Login/Login"
],
"requiredPrivateInfos": ["getLocation"],
"lazyCodeLoading": "requiredComponents",
......
......@@ -14,6 +14,9 @@ Page({
onLoad(options) {
console.log(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
{
"usingComponents": {}
}
\ No newline at end of file
/* pages/Login/Login.wxss */
\ No newline at end of file
<!--pages/Login/Login.wxml-->
<text>pages/Login/Login.wxml</text>
......@@ -12,55 +12,40 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad(options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
console.log(__wxConfig)
this.tabList = __wxConfig.tabBar.list
wx.p.wxApi.showLoading()
//scenc获取页面参数并跳转
if (options.scene) {
return
}
if (options.url) {
return this.jumpPage(options.url)
}
// 默认跳转到首页
wx.p.router.goHome()
},
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) {
let [url, query] = targetPath.split('?'),
events = {}
if (query) {
let arr = query.split('&')
arr.map(e => {
const [key, val] = e.split('=')
Object.assign(events, {
[key]: val
})
})
}
return {
url,
events
}
}
})
\ No newline at end of file
<!--pages/loading/loading.wxml-->
<text>pages/loading/loading.wxml</text>
......@@ -13,7 +13,7 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.setData(options)
},
jump(){
wx.p.router.go('/packageIndex/pages/index/index',{
......
......@@ -2,4 +2,6 @@
<view style="padding-top:200px">
<button bindtap="jump">点击跳转携带参数</button>
<view>{{a}}</view>
<view>{{b}}</view>
</view>
\ No newline at end of file
......@@ -27,6 +27,13 @@
"query": "merchantId=44205858",
"launchMode": "default",
"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 {
redirectTo(route, events = {}) {
this._to(route, events, 'redirectTo');
}
/**
* 跳转到switchTab
*/
switchTab(route,events = {}){
this._to(route, events, 'switchTab');
}
_to(route, events, to, success) {
getApp().globalData.ROUTE_QUERY = events
if (events.notIntercept) {
......
......@@ -7,11 +7,13 @@ class RouterBefore {
pageLeaveProxy(thisPage) {
let onLoad = thisPage.onLoad
thisPage.onLoad = function () {
const event = getApp().globalData.ROUTE_QUERY
let options = {
...getApp().globalData.ROUTE_QUERY,
...event,
...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!