mirror of
https://gitee.com/java110/WechatOwnerService.git
synced 2026-06-12 10:00:57 +08:00
引入打通
This commit is contained in:
parent
d545e6e352
commit
9a4e9525a9
@ -509,6 +509,15 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
,{
|
||||||
|
"path" : "pages/hcWebView/hcWebView",
|
||||||
|
"style" :
|
||||||
|
{
|
||||||
|
"navigationBarTitleText": "",
|
||||||
|
"enablePullDownRefresh": false
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
],
|
],
|
||||||
"tabBar": {
|
"tabBar": {
|
||||||
"color": "#272636",
|
"color": "#272636",
|
||||||
|
|||||||
32
pages/hcWebView/hcWebView.vue
Normal file
32
pages/hcWebView/hcWebView.vue
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
<template>
|
||||||
|
<view class="h5-html">
|
||||||
|
<web-view ref="webview" :src="url" @message="reciveMessage"></web-view>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import conf from '../../conf/config.js'
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
url: ''
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onLoad(options) {
|
||||||
|
this.url = options.url;
|
||||||
|
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
reciveMessage: function(event) {
|
||||||
|
console.log('商城回传的参数', event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.h5-html {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<view class="h5-html">
|
<view class="h5-html">
|
||||||
<web-view ref="webview" :src="url" @message="reciveMessage"></web-view>
|
<web-view ref="webview" :src="url" @onPostMessage="reciveMessage"></web-view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -12,36 +12,41 @@
|
|||||||
url: ''
|
url: ''
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
mounted() {
|
||||||
|
// #ifdef H5
|
||||||
|
window.addEventListener("message",this.reciveMessage);
|
||||||
|
// #endif
|
||||||
|
},
|
||||||
onLoad() {
|
onLoad() {
|
||||||
this.url = conf.mallUrl;
|
this.url = conf.mallUrl;
|
||||||
|
|
||||||
},
|
},
|
||||||
onReady() {
|
// onReady() {
|
||||||
var that = this;
|
// var that = this;
|
||||||
var height = 0; //定义动态的高度变量,如高度为定值,可以直接写
|
// var height = 0; //定义动态的高度变量,如高度为定值,可以直接写
|
||||||
var statusBarHeight = 0;
|
// var statusBarHeight = 0;
|
||||||
uni.getSystemInfo({
|
// uni.getSystemInfo({
|
||||||
//成功获取的回调函数,返回值为系统信息
|
// //成功获取的回调函数,返回值为系统信息
|
||||||
success: (sysinfo) => {
|
// success: (sysinfo) => {
|
||||||
height = sysinfo.windowHeight - that.$navHeight - sysinfo.statusBarHeight; //自行修改,自己需要的高度
|
// height = sysinfo.windowHeight - that.$navHeight - sysinfo.statusBarHeight; //自行修改,自己需要的高度
|
||||||
statusBarHeight = sysinfo.statusBarHeight;
|
// statusBarHeight = sysinfo.statusBarHeight;
|
||||||
},
|
// },
|
||||||
complete: () => {}
|
// complete: () => {}
|
||||||
});
|
// });
|
||||||
|
|
||||||
var pages = getCurrentPages();
|
// var pages = getCurrentPages();
|
||||||
var page = pages[pages.length - 1];
|
// var page = pages[pages.length - 1];
|
||||||
|
|
||||||
var currentWebview = page.$getAppWebview(); //页面栈最顶层就是当前webview
|
// var currentWebview = page.$getAppWebview(); //页面栈最顶层就是当前webview
|
||||||
|
|
||||||
setTimeout(function() {
|
// setTimeout(function() {
|
||||||
var wv = currentWebview.children()[0];
|
// var wv = currentWebview.children()[0];
|
||||||
wv.setStyle({ //设置web-view距离顶部的距离以及自己的高度,单位为px
|
// wv.setStyle({ //设置web-view距离顶部的距离以及自己的高度,单位为px
|
||||||
top: that.$navHeight + statusBarHeight,
|
// top: that.$navHeight + statusBarHeight,
|
||||||
height: height
|
// height: height
|
||||||
})
|
// })
|
||||||
}, 500); //如页面初始化调用需要写延迟
|
// }, 500); //如页面初始化调用需要写延迟
|
||||||
},
|
// },
|
||||||
methods: {
|
methods: {
|
||||||
reciveMessage: function(event) {
|
reciveMessage: function(event) {
|
||||||
console.log('商城回传的参数', event);
|
console.log('商城回传的参数', event);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user