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

79 lines
1.9 KiB
Plaintext

5 months ago
<template>
<div class="content">
5 months ago
<web-view class="webview" @onPostMessage="webLoad" :style="{height:`${systemInfo.windowHeight}px`,width:`${systemInfo.windowWidth}`}" ref="webViewRef" :src="config.h5Url"></web-view>
5 months ago
</div>
</template>
<script setup>
3 months ago
import { ref} from 'vue'
5 months ago
import config from "../../config";
3 months ago
import { onShow, onHide } from "@dcloudio/uni-app";
5 months ago
import {sendWebWiew,receiveWebView} from "@/utils/communicate";
const webViewRef=ref(null)
3 months ago
5 months ago
const systemInfo = uni.getSystemInfoSync();
5 months ago
// #ifdef APP-ANDROID
3 months ago
/* const permissionListener = uni.createRequestPermissionListener();
5 months ago
permissionListener.onRequest((e)=>{
})
permissionListener.onConfirm((e) => {
sendWebWiew(webViewRef.value,{auth:e,open:true})
});
permissionListener.onComplete((e) => {
sendWebWiew(webViewRef.value,{auth:e,open:false})
3 months ago
}); */
5 months ago
// #endif
3 months ago
//解决ios的h5问题获取网络权限之后重新加载
const networkStatusChange=(res)=>{
if(res.isConnected) {
uni.redirectTo({
url: '/pages/index/index'
})
} else {
uni.showToast({
title: '网络无连接',
icon: 'none'
})
}
}
const webViewObj=ref(null)
onShow(()=>{
uni.onNetworkStatusChange(networkStatusChange);
})
onHide(()=>{
uni.offNetworkStatusChange(networkStatusChange)
})
5 months ago
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>