2024-04-11 06:31:44 +00:00
|
|
|
|
<template>
|
|
|
|
|
<div class="content">
|
2024-04-12 08:30:22 +00:00
|
|
|
|
<web-view class="webview" @onPostMessage="webLoad" :style="{height:`${systemInfo.windowHeight}px`,width:`${systemInfo.windowWidth}`}" ref="webViewRef" :src="config.h5Url"></web-view>
|
2024-04-11 06:31:44 +00:00
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
<script setup>
|
2024-06-18 12:02:33 +00:00
|
|
|
|
import { ref,onShow ,onHide} from 'vue'
|
2024-04-12 08:30:22 +00:00
|
|
|
|
import config from "../../config";
|
2024-04-11 06:31:44 +00:00
|
|
|
|
import {sendWebWiew,receiveWebView} from "@/utils/communicate";
|
|
|
|
|
const webViewRef=ref(null)
|
|
|
|
|
const systemInfo = uni.getSystemInfoSync();
|
2024-04-12 08:30:22 +00:00
|
|
|
|
// #ifdef APP-ANDROID
|
2024-06-18 08:54:37 +00:00
|
|
|
|
/* const permissionListener = uni.createRequestPermissionListener();
|
2024-04-11 06:31:44 +00:00
|
|
|
|
permissionListener.onRequest((e)=>{
|
|
|
|
|
})
|
|
|
|
|
permissionListener.onConfirm((e) => {
|
|
|
|
|
sendWebWiew(webViewRef.value,{auth:e,open:true})
|
|
|
|
|
});
|
|
|
|
|
permissionListener.onComplete((e) => {
|
|
|
|
|
sendWebWiew(webViewRef.value,{auth:e,open:false})
|
2024-06-18 08:54:37 +00:00
|
|
|
|
}); */
|
2024-04-12 08:30:22 +00:00
|
|
|
|
// #endif
|
2024-06-18 12:02:33 +00:00
|
|
|
|
//解决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)
|
|
|
|
|
})
|
2024-04-11 06:31:44 +00:00
|
|
|
|
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>
|