55 lines
1.2 KiB
Vue
55 lines
1.2 KiB
Vue
<template>
|
|
<view>
|
|
<web-view class="webView" :webview-styles="webviewStyles" src="http://192.168.34.139:5173/" :fullscreen="false"
|
|
@onPostMessage="handlePostMessage"></web-view>
|
|
<footers class="footer" activeTab="submit"></footers>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
import footers from '@/components/footers/footers.vue'
|
|
export default {
|
|
components: {
|
|
footers
|
|
},
|
|
onReady() {
|
|
var currentWebview = this.$scope.$getAppWebview();
|
|
let userInfo = JSON.parse(uni.getStorageSync('userInfo'));
|
|
let str = "需要发送的信息"
|
|
const _funName = 'msgFromUniapp'
|
|
const _data = {
|
|
token: userInfo.token,
|
|
loginUser: userInfo
|
|
};
|
|
setTimeout(function() {
|
|
let wv = currentWebview.children()[0]
|
|
console.log(wv, "wv");
|
|
// height:(windowHeight - uni.upx2px(110) - 22)
|
|
wv.setStyle({
|
|
top: 50,
|
|
bottom: uni.upx2px(110)
|
|
})
|
|
wv.evalJS(`${_funName}(${JSON.stringify(_data)})`);
|
|
}, 1000);
|
|
},
|
|
methods: {
|
|
handlePostMessage: function(data) {
|
|
console.log("接收到消息:" + JSON.stringify(data.detail));
|
|
},
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style>
|
|
page {
|
|
background-color: #F4F5F7;
|
|
}
|
|
</style>
|
|
|
|
<style lang="less" scoped>
|
|
.webView {
|
|
width: 100vw;
|
|
height: 80vh;
|
|
z-index: 10;
|
|
}
|
|
</style> |