45 lines
1.4 KiB
Vue
45 lines
1.4 KiB
Vue
<template>
|
|
<web-view class="webview" @message="webLoad" style="flex: 1;" :src="config.h5Url"></web-view>
|
|
</template>
|
|
<script setup>
|
|
import { ref } from 'vue'
|
|
import config from "../../config";
|
|
import {onExit } from "@dcloudio/uni-app";
|
|
import { Communication } from '../../utils/communication.js';
|
|
const commun=new Communication()
|
|
const permissionListener = uni.createRequestPermissionListener();
|
|
onExit(()=>{
|
|
permissionListener.stop()
|
|
})
|
|
function initializeWebView() {
|
|
const currentWebview = getCurrentPages().pop().$getAppWebview()
|
|
commun.setWebView(currentWebview.children()[0])
|
|
}
|
|
commun.registerHandler('load-complete',()=>{
|
|
initializeWebView()
|
|
const {statusBarHeight} = uni.getSystemInfoSync()
|
|
commun.webViewObj.setStyle({
|
|
top: statusBarHeight,
|
|
bottom: 0,
|
|
})
|
|
permissionListener.onRequest((e)=>{
|
|
commun.sendToH5('permission-application',e);
|
|
})
|
|
permissionListener.onConfirm((e) => {
|
|
});
|
|
permissionListener.onComplete((e) => {
|
|
console.log('APP执行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']
|
|
commun.sendToH5('permission-complete',e);
|
|
})
|
|
})
|
|
const webLoad = (e) => {
|
|
const message = e.detail.data?.[0] || '';
|
|
commun.handleMessage(message);
|
|
};
|
|
</script>
|
|
|
|
<style>
|
|
|
|
</style>
|