You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
oa-base/pages/index/index.nvue

55 lines
1.4 KiB
Plaintext

<template>
<div class="content">
<web-view class="webview" @onPostMessage="webLoad" :style="{height:`${systemInfo.windowHeight}px`,width:`${systemInfo.windowWidth}`}" ref="webViewRef" :src="config.h5Url"></web-view>
</div>
</template>
<script setup>
import { ref } from 'vue'
import config from "../../config";
import {sendWebWiew,receiveWebView} from "@/utils/communicate";
const webViewRef=ref(null)
const systemInfo = uni.getSystemInfoSync();
// #ifdef APP-ANDROID
/*const permissionListener = uni.createRequestPermissionListener();
permissionListener.onRequest((e)=>{
})
permissionListener.onConfirm((e) => {
sendWebWiew(webViewRef.value,{auth:e,open:true})
});
permissionListener.onComplete((e) => {
sendWebWiew(webViewRef.value,{auth:e,open:false})
});*/
// #endif
const webLoad=(e)=>{
const m=receiveWebView(e)
switch (m.action) {
//webview初始化加载完成
case 'load-complete':{
const systemInfo= uni.getSystemInfoSync()
uni.getLocation({
type: 'gcj02',
geocode: false,
isHighAccuracy: false,
success:async (res) => {
sendWebWiew(webViewRef.value,{...res,systemInfo})
},
fail: (e) => {
console.log(e);
}
})
}
}
}
</script>
<style>
.content {
display: flex;
flex: 1;
}
</style>