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

91 lines
3.0 KiB
Vue

3 months ago
<template>
3 weeks ago
<web-view class="webview" @message="webLoad" style="flex: 1;" :src="config.h5Url"></web-view>
3 months ago
</template>
<script setup>
3 weeks ago
import { ref } from 'vue'
3 months ago
import config from "../../config";
1 month ago
import {onExit } from "@dcloudio/uni-app";
3 weeks ago
import { Communication } from '../../utils/communication.js';
const commun=new Communication()
4 weeks ago
/* import {
registerRequestPermissionTipsListener,
unregisterRequestPermissionTipsListener,
setRequestPermissionTips
} from "@/uni_modules/uni-registerRequestPermissionTips"
const PermissionTips = {
"android.permission.CAMERA": "<h4 style=\"font-size:40px;\">正在读取通讯录权限</h4><font color=#cccccc>通讯录权限不会获取任何信息,请注意</font>",
"android.permission.READ_PHONE_STATE": "<h4 style=\"font-size:40px;\">正在读取网络状态权限</h4><font color=#cccccc>通讯录权限不会获取任何信息,请注意通讯录权限不会获取任何信息,请注意通讯录权限不会获取任何信息,请注意</font>"
}
1 month ago
onExit(()=>{
4 weeks ago
unregisterRequestPermissionTipsListener()
1 month ago
})
4 weeks ago
const brand = uni.getSystemInfoSync().deviceBrand
setRequestPermissionTips(PermissionTips)
registerRequestPermissionTipsListener({
onRequest: (e) => {
3 weeks ago
console.log('onRequest',e)
4 weeks ago
},
onConfirm: (e) => {
commun.sendToH5('permission-application',{action:'open-permission',data:e});
},
onComplete: (e) => {
commun.sendToH5('permission-application',{action:'close-permission',data:e});
// 华为手机在权限禁止之后,再次申请权限不会出现权限申请框。此时应该引导用户去系统设置开启此权限,不应该频繁申请。
if (brand.toLowerCase() === "huawei") {
const tips = {}
let hasDeniedPermission = false
for (let k in PermissionTips) {
if (e[k] !== "denied") {
tips[k] = PermissionTips[k]
} else {
hasDeniedPermission = true
}
}
setRequestPermissionTips(tips) // 更新弹框提醒,防止华为手机不出现权限申请框时权限提醒框闪烁的情况
if (hasDeniedPermission)
uni.showModal({
content: "权限已经被拒绝,请前往设置中开启"
})
}
}
3 weeks ago
})*/
function initializeWebView() {
const currentWebview = getCurrentPages().pop().$getAppWebview()
commun.setWebView(currentWebview.children()[0])
}
//load-complete 注册函数
commun.registerHandler('load-complete',()=>{
initializeWebView()
const {statusBarHeight} = uni.getSystemInfoSync()
commun.webViewObj.setStyle({
top: statusBarHeight,
bottom: 0,
})
4 weeks ago
3 weeks ago
})
commun.registerHandler('getLocation',(data)=>{
uni.getLocation({
type:'gcj02',
geocode:true,
isHighAccuracy:true,
...data,
success: (res) => {
console.log('getLocation',res)
commun.sendToH5('getLocation',res);
},
})
})
const webLoad = (e) => {
const message = e.detail.data?.[0] || '';
commun.handleMessage(message);
};
3 months ago
</script>
<style>
</style>