引入打通

This commit is contained in:
java110 2021-06-04 02:04:47 +08:00
parent d545e6e352
commit 9a4e9525a9
3 changed files with 70 additions and 24 deletions

View File

@ -509,6 +509,15 @@
}
}
,{
"path" : "pages/hcWebView/hcWebView",
"style" :
{
"navigationBarTitleText": "",
"enablePullDownRefresh": false
}
}
],
"tabBar": {
"color": "#272636",

View 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>

View File

@ -1,6 +1,6 @@
<template>
<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>
</template>
@ -12,36 +12,41 @@
url: ''
}
},
mounted() {
// #ifdef H5
window.addEventListener("message",this.reciveMessage);
// #endif
},
onLoad() {
this.url = conf.mallUrl;
},
onReady() {
var that = this;
var height = 0; //
var statusBarHeight = 0;
uni.getSystemInfo({
//
success: (sysinfo) => {
height = sysinfo.windowHeight - that.$navHeight - sysinfo.statusBarHeight; //
statusBarHeight = sysinfo.statusBarHeight;
},
complete: () => {}
});
// onReady() {
// var that = this;
// var height = 0; //
// var statusBarHeight = 0;
// uni.getSystemInfo({
// //
// success: (sysinfo) => {
// height = sysinfo.windowHeight - that.$navHeight - sysinfo.statusBarHeight; //
// statusBarHeight = sysinfo.statusBarHeight;
// },
// complete: () => {}
// });
var pages = getCurrentPages();
var page = pages[pages.length - 1];
// var pages = getCurrentPages();
// var page = pages[pages.length - 1];
var currentWebview = page.$getAppWebview(); //webview
// var currentWebview = page.$getAppWebview(); //webview
setTimeout(function() {
var wv = currentWebview.children()[0];
wv.setStyle({ //web-viewpx
top: that.$navHeight + statusBarHeight,
height: height
})
}, 500); //
},
// setTimeout(function() {
// var wv = currentWebview.children()[0];
// wv.setStyle({ //web-viewpx
// top: that.$navHeight + statusBarHeight,
// height: height
// })
// }, 500); //
// },
methods: {
reciveMessage: function(event) {
console.log('商城回传的参数', event);