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.vue

88 lines
2.8 KiB
Vue

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<template>
<web-view class="webview" @message="webLoad" style="flex: 1;" ref="webViewRef" :src="config.h5Url"></web-view>
</template>
<script setup>
import { ref } from 'vue'
import config from "../../config";
import { onShow, onHide } from "@dcloudio/uni-app";
/* import {sendWebWiew,receiveWebView} from "@/utils/communicate"; */
/* import location from "../../utils/location"; */
/* import {
registerRequestPermissionTipsListener,
unregisterRequestPermissionTipsListener,
setRequestPermissionTips
} from "@/uni_modules/uni-registerRequestPermissionTips" */
/* plus.runtime.setBadgeNumber(999); */
/* const permissionListener = uni.createRequestPermissionListener();
permissionListener.onRequest((e)=>{
})
permissionListener.onConfirm((e) => {
sendWebWiew(webViewRef.value,{auth:e,open:true})
});
permissionListener.onComplete((e) => {
/* uni.showToast({
duration:1000000,
title:`${JSON.stringify(e)}1111${JSON.stringify(f)}`,
icon:'none'
}) */
/* sendWebWiew(webViewRef.value,{auth:e,open:false})
}); *!/*/
/* registerRequestPermissionTipsListener({
onRequest: (e) => {
console.log(e)
},
onConfirm: (e) => {
sendWebWiew(webViewRef.value,{auth:e,open:true})
},
onComplete: (e) => {
const arr=['android.permission.ACCESS_COARSE_LOCATION','android.permission.ACCESS_FINE_LOCATION','android.permission.ACCESS_LOCATION_EXTRA_COMMANDS','android.permission.ACCESS_MOCK_LOCATION']
const hasIntersection = Object.keys(e).some(item => new Set(arr).has(item));
uni.setSt
sendWebWiew(webViewRef.value,{auth:Object.keys(e),open:false})
}
})*/
//解决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)
})
const webLoad=(e)=>{
const h5SendString=e.detail.data?.[0]?.action
switch (h5SendString) {
//webview初始化加载完成
case 'load-complete':{
const {statusBarHeight} = uni.getSystemInfoSync()
const currentWebview = getCurrentPages().pop().$getAppWebview()
webViewObj.value=currentWebview.children()[0]
/* webViewObj.value.evalJS(`window.onReceive(${jsonString})`) */
webViewObj.value.setStyle({
top: statusBarHeight,
bottom: 0,
})
}
}
}
</script>
<style>
</style>