zhgdyunapp/pages/submit/submit.vue

83 lines
1.5 KiB
Vue
Raw Normal View History

2024-04-17 22:11:05 +08:00
<template>
2024-05-16 16:54:56 +08:00
<view class="fullHeight">
<view>
<!-- :webview-styles="styles" -->
<web-view class="webView" :src="work_url" :fullscreen="false"
@onPostMessage="handlePostMessage"></web-view>
</view>
2024-04-17 22:11:05 +08:00
<footers class="footer" activeTab="submit"></footers>
</view>
</template>
<script>
import footers from '@/components/footers/footers.vue'
export default {
components: {
footers
},
2024-04-21 09:44:03 +08:00
data() {
return {
styles: {
height: '0',
screenHeight:''
}
}
},
onLoad() {
uni.getSystemInfo({
success: (res) => {
let screenHeight = res.screenHeight;
this.screenHeight = screenHeight;
}
})
},
2024-04-17 22:11:05 +08:00
onReady() {
2024-04-21 09:44:03 +08:00
try {
2024-04-18 23:10:52 +08:00
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,
2024-04-21 09:44:03 +08:00
height: ((this.screenHeight - 300)),
2024-04-18 23:10:52 +08:00
bottom: uni.upx2px(110)
})
wv.evalJS(`${_funName}(${JSON.stringify(_data)})`);
}, 1000);
2024-04-21 09:44:03 +08:00
} catch (e) {
2024-04-18 23:10:52 +08:00
//TODO handle the exception
}
2024-04-21 09:44:03 +08:00
2024-04-17 22:11:05 +08:00
},
methods: {
2024-04-21 09:44:03 +08:00
handlePostMessage(data) {
console.log(data);
uni.showToast({
title: data
})
2024-04-17 22:11:05 +08:00
},
}
}
</script>
<style>
page {
background-color: #F4F5F7;
}
</style>
<style lang="less" scoped>
2024-05-16 16:54:56 +08:00
.fullHeight{
height: 100vh
}
2024-04-17 22:11:05 +08:00
.webView {
width: 100vw;
height: 80vh;
z-index: 10;
}
</style>