适配鸿蒙

main
yanzai 1 year ago
parent 07c6223869
commit 84ab848bdc

@ -1,5 +1,6 @@
const isAndroid = navigator.userAgent.indexOf('Android') > -1 || navigator.userAgent.indexOf('Adr') > -1 const isAndroid = navigator.userAgent.indexOf('Android') > -1 || navigator.userAgent.indexOf('Adr') > -1
const isiOS = !!navigator.userAgent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/) const isiOS = !!navigator.userAgent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/)
const isHM = navigator.userAgent.toLowerCase().indexOf('harmonyos_healthdaxing') > -1
// 这是必须要写的,用来创建一些设置 // 这是必须要写的,用来创建一些设置
function setupWebViewJavascriptBridge(callback) { function setupWebViewJavascriptBridge(callback) {
// Android使用 // Android使用

@ -11,7 +11,7 @@
<van-step>预约完成</van-step> <van-step>预约完成</van-step>
</van-steps> </van-steps>
<div class="head"> <div class="head">
请上传"{{needinfo.label}}"相关证件 请上传"{{needinfo.label}}"相关证件.
</div> </div>
<!-- <div><van-button type="primary" round @click="callAPP()">4</van-button></div> --> <!-- <div><van-button type="primary" round @click="callAPP()">4</van-button></div> -->
<div v-for="(item,index) in needinfo.fileList"> <div v-for="(item,index) in needinfo.fileList">
@ -33,6 +33,7 @@
<van-button type="primary" class="button" round @click="to()"></van-button> <van-button type="primary" class="button" round @click="to()"></van-button>
</div> </div>
</template> </template>
<script setup> <script setup>
import { import {
onMounted, onMounted,
@ -54,6 +55,10 @@
} from '@/stores/index.js' } from '@/stores/index.js'
import Bridge from '@/jsBridge/Bridge.js' import Bridge from '@/jsBridge/Bridge.js'
let Info=ref('');
let isHM=ref(false)
let uploadFuncName=ref('upLoadAjax');
let selectedNum = ref(null); // let selectedNum = ref(null); //
let backImageList = ref([ let backImageList = ref([
[], [],
@ -67,25 +72,36 @@
// JSAPP // JSAPP
const param = { const param = {
type: 'photoLibrary', type: 'photoLibrary',
callBackMethod: 'upLoadAjax', callBackMethod: uploadFuncName.value,
params: { params: {
maxCount: '1', maxCount: '1',
maxBytes: '2097152', maxBytes: '2097152',
} }
} }
if(isHM.value){
window.WDHarmony.nativePermission(JSON.stringify(param))
}else{
Bridge.callHandler('nativePermission', param, (res) => { Bridge.callHandler('nativePermission', param, (res) => {
}) })
} }
}
const zhuce = () => { const zhuce = () => {
Bridge.registerHandler('upLoadAjax', (datas, responseCallback) => {
Bridge.registerHandler(uploadFuncName.value, (datas, responseCallback) => {
let dd = JSON.parse(datas) let dd = JSON.parse(datas)
upLoadFile(dd['avatar'])
})
}
const upLoadAjaxHM=(param)=>{
upLoadFile(param.avatar)
}
const upLoadFile=(datas)=>{
try {
// //
loading.value = true loading.value = true
UpFileBase64({ UpFileBase64({
base64file: dd['avatar'] base64file: datas
}).then(res => { }).then(res => {
loading.value = false loading.value = false
if (res.status == true) { if (res.status == true) {
@ -110,12 +126,12 @@
showToast(res.msg); showToast(res.msg);
} }
}) })
}catch(e){
Info.value=e.message
}
// this.msg = `appjs${datas}`
// console.log(`appjs${datas}`)
// console.log(`responseCallback:${responseCallback}`)
})
} }
window.upLoadAjaxHM = upLoadAjaxHM;
const DelImage = (index,img_index) => { const DelImage = (index,img_index) => {
showConfirmDialog({ showConfirmDialog({
title: '提示', title: '提示',
@ -166,9 +182,14 @@
let username=ref(''); let username=ref('');
let orgname=ref(''); let orgname=ref('');
onMounted(() => { onMounted(() => {
isHM.value = navigator.userAgent.toLowerCase().indexOf('harmonyos_healthdaxing') > -1
if(isHM.value){
uploadFuncName.value='upLoadAjaxHM'
}
username.value=sessionStorage.getItem('name') username.value=sessionStorage.getItem('name')
orgname.value=pinia.yuyue_info.org_name orgname.value=pinia.yuyue_info.org_name
zhuce() zhuce()
//upLoadAjaxHM({avatar:'d'})
if (pinia.yuyue_info.doc_id) { if (pinia.yuyue_info.doc_id) {
needinfo.value = pinia.hangyeInfo[pinia.yuyue_info.doc_id - 1] needinfo.value = pinia.hangyeInfo[pinia.yuyue_info.doc_id - 1]
} }

Loading…
Cancel
Save