<template>
  <view class="container">
    <up-icon size="20" class="close-icon" @click="handleClose" name="close-circle"></up-icon>
    <web-view :src="previewUrl"></web-view>
  </view>
</template>

<script setup lang="ts">
import { ref, onMounted, onUnmounted } from 'vue'
import CryptoJS from 'crypto-js'
import { getImgBaseUrl } from '@/defaultBaseUrl'
import { onLoad } from '@dcloudio/uni-app'

let previewUrl = ref('')
onLoad(option => {
  let url = encodeURIComponent(
    CryptoJS.enc.Utf8.parse(getImgBaseUrl() + option.documentUrl).toString(CryptoJS.enc.Base64)
  )
  previewUrl.value = getImgBaseUrl() + '/preview/onlinePreview?url=' + url
})
</script>

<style lang="scss" scoped>
.container {
  .close-icon {
    position: absolute;
    top: 20rpx;
    right: 20rpx;
    z-index: 999999;
  }
}
</style>
