zhgdyunapp/pages/submit/submit.vue
2024-05-16 16:54:56 +08:00

83 lines
1.5 KiB
Vue

<template>
<view class="fullHeight">
<view>
<!-- :webview-styles="styles" -->
<web-view class="webView" :src="work_url" :fullscreen="false"
@onPostMessage="handlePostMessage"></web-view>
</view>
<footers class="footer" activeTab="submit"></footers>
</view>
</template>
<script>
import footers from '@/components/footers/footers.vue'
export default {
components: {
footers
},
data() {
return {
styles: {
height: '0',
screenHeight:''
}
}
},
onLoad() {
uni.getSystemInfo({
success: (res) => {
let screenHeight = res.screenHeight;
this.screenHeight = screenHeight;
}
})
},
onReady() {
try {
var currentWebview = this.$scope.$getAppWebview();
let userInfo = JSON.parse(uni.getStorageSync('userInfo'));
const _funName = 'msgFromUniapp'
const _data = {
token: userInfo.token,
loginUser: userInfo
};
setTimeout(function() {
let wv = currentWebview.children()[0]
wv.setStyle({
top: 50,
height: ((this.screenHeight - 300)),
bottom: uni.upx2px(110)
})
wv.evalJS(`${_funName}(${JSON.stringify(_data)})`);
}, 1000);
} catch (e) {
//TODO handle the exception
}
},
methods: {
handlePostMessage(data) {
console.log(data);
uni.showToast({
title: data
})
},
}
}
</script>
<style>
page {
background-color: #F4F5F7;
}
</style>
<style lang="less" scoped>
.fullHeight{
height: 100vh
}
.webView {
width: 100vw;
height: 80vh;
z-index: 10;
}
</style>