Commit 81ad097b by 高淑倩

add: h5

parent 76e9b200
...@@ -19,7 +19,8 @@ ...@@ -19,7 +19,8 @@
{ {
"root": "subPackage/page", "root": "subPackage/page",
"pages": [ "pages": [
"pages/subPage/subPage" "pages/subPage/subPage",
"pages/h5/h5page"
] ]
} }
], ],
......
// subPackage/home/pages/h5/h5page.js
const wxService = require('../../../../utils/wxService')
wxService.page({
/**
* 页面的初始数据
*/
data: {
path: '',
h5WhitePages: [
'/wxhd/activity/lotteryActivity/main.do',
'/wxhd/weixin_loading.jsp'
]
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
const url = options.url
if (url) {
this.setData({
path: `${decodeURIComponent(url)}`
})
}
},
webviewOnload (e) {
if (e.type === 'load') {
const src = e.detail.src
console.log(src)
let pass = false
const whitePages = this.data.h5WhitePages
whitePages.map(item => {
const regex = new RegExp(`${item}`, 'gi')
if (!pass) {
pass = regex.test(src)
}
})
console.log(pass)
// 不在白名单页中统一返回到首页
if (!pass) {
wxService.router('/pages/userCenter/userCenter').back()
}
}
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})
{}
\ No newline at end of file
<!--subPackage/home/pages/h5/h5page.wxml-->
<web-view class='h5-body' src="{{path}}" bindload="webviewOnload">
</web-view>
/* subPackage/home/pages/h5/h5page.wxss */
\ No newline at end of file
...@@ -66,6 +66,14 @@ HandlerLink.prototype = { ...@@ -66,6 +66,14 @@ HandlerLink.prototype = {
// wxService.openCard() // wxService.openCard()
} }
} }
// else if(type == 6){
// // 跳转路径中包括http的跳转到h5页面中,用web-view去加载h5页面
// if (/http/gi.test(url)) {
// const enCodeUrl = encodeURIComponent(url)
// return `/subPackage/page/pages/h5/h5page?url=${enCodeUrl}`
// }
// return `/${url}`
// }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment