<template>
  <view class="errpr_page">
    <!-- <image src="@/common/assets/network-error.svg" style="width: 100%" /> -->
    <view class="des">网络可能发生错误</view>
    <up-button type="warning" text="点击重试" @click="refreshPage"></up-button>
  </view>
</template>

<script setup lang="ts">
import { useWeAppAuthStore } from '@/common/store/useWeAppAuthStore'
import { onLoad } from '@dcloudio/uni-app'
import { ref } from 'vue'

const auth = useWeAppAuthStore()
const query = ref()

onLoad(options => {
  query.value = options
})

function refreshPage() {
  // 获取当前页面的实例
  const pages = getCurrentPages()
  const currentPage: any = pages[pages.length - 1]
  console.log('currentPage', currentPage)
  const path = currentPage.$page.fullPath
  if (currentPage.$page.options) {
    const options = currentPage.$page.options
    const fullPath = `${path}?${Object.keys(options)
      .map(key => `${key}=${encodeURIComponent(options[key])}`)
      .join('&')}`
    uni.reLaunch({
      url: fullPath
    })
    console.log(fullPath)
  } else {
    uni.reLaunch({
      url: path
    })
  }
}
</script>
<style lang="scss" scoped>
.errpr_page {
  padding: 0 40rpx;
  text-align: center;
  .des {
    padding: 40rpx 0;
  }
}
</style>
