<script setup>
const webviewStyles = ref({
  top: `${uni.getSystemInfoSync().statusBarHeight + 44}px`, // 距离顶部的距离
  height: `${uni.getSystemInfoSync().windowHeight - uni.getSystemInfoSync().statusBarHeight - 44}px`, // 高度
  position: 'absolute', // 绝对定位
  dock: 'bottom', // 停靠在底部
  bounce: 'vertical', // 垂直方向的回弹效果
})
const feature = ref(null)
const token = ref(null)
const webviewSrc = ref('')

onLoad((option) => {
  if (option.feature) {
    feature.value = option.feature
  }

  token.value = uni.getStorageSync('token') || ''

  const baseUrl = 'https://app.quannengcha.com/example'
  webviewSrc.value = `${baseUrl}?feature=${encodeURIComponent(feature.value)}&token=${encodeURIComponent(token.value)}`
})
</script>

<template>
  <view>
    <!-- 使用动态构造的 WebView src -->
    <web-view :webview-styles="webviewStyles" :src="webviewSrc" />
  </view>
</template>

<style lang="scss" scoped>

</style>

<route lang="json">
  {
    "layout": "page",
    "title": "示例报告"
  }
</route>
