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