101 lines
2.2 KiB
Vue
101 lines
2.2 KiB
Vue
<template>
|
|
<view class="fullHeight">
|
|
<!-- <levitatedsphere id="levitatedsphere" :x="100" :y="80"></levitatedsphere> -->
|
|
<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() {
|
|
console.log(JSON.stringify(currentWebview.children()[0]));
|
|
let wv = currentWebview.children()[0]
|
|
wv.setStyle({
|
|
top: 50,
|
|
height: ((this.screenHeight - 300)),
|
|
bottom: uni.upx2px(110)
|
|
})
|
|
// let query=uni.createSelectorQuery();
|
|
// let dom = query.select("#levitatedsphere");
|
|
// console.log(dom);
|
|
// currentWebview.appendChild(dom)
|
|
wv.evalJS(`${_funName}(${JSON.stringify(_data)})`);
|
|
console.log(1111111111,currentWebview);
|
|
}, 1000);
|
|
} catch (e) {
|
|
//TODO handle the exception
|
|
}
|
|
},
|
|
methods: {
|
|
handleLoad(data){
|
|
console.log(11111,data);
|
|
let query=uni.createSelectorQuery();
|
|
let dom = query.select("#levitatedsphere");
|
|
console.log(dom);
|
|
console.log(uni.createSelectorQuery().select("#app"));
|
|
console.log(document.body);
|
|
uni.createSelectorQuery().select("#app").appendChild(dom);
|
|
},
|
|
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> |