feat: web通讯的处理
This commit is contained in:
27
src/pages-bridge/UploadImage.vue
Normal file
27
src/pages-bridge/UploadImage.vue
Normal file
@@ -0,0 +1,27 @@
|
||||
<template>
|
||||
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { onLoad } from '@dcloudio/uni-app'
|
||||
import { chooseAndUploadImage } from '@/pages/webview/bridge.js'
|
||||
|
||||
onLoad(() => {
|
||||
handleChoose()
|
||||
})
|
||||
|
||||
const sendResult = (imageUrl) => {
|
||||
// 触发全局事件
|
||||
uni.$emit('UPLOAD_RESULT', imageUrl)
|
||||
}
|
||||
const handleChoose = async () => {
|
||||
try {
|
||||
const imageUrl = await chooseAndUploadImage()
|
||||
sendResult(imageUrl)
|
||||
} catch (e) {
|
||||
sendResult('error')
|
||||
}
|
||||
|
||||
uni.navigateBack()
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user