<template>
  <!-- 版本更新 -->
  <template v-if="globalData.type == 3">
    <version-update :id="appId" @close="close" @check="check" />
  </template>
  <template v-else>
    <view class="returnClass-root">
      <image src="https://image.jxc4.com/image/70143fcf48aefe74537533f35a0a8153.jpg" mode="scaleToFill" />
      <view @tap="closeReturn" class="returnClass">返回</view>
    </view>
  </template>
</template>

<script lang="ts" setup>
import { onBackPress, onLoad } from '@dcloudio/uni-app'
import versionUpdate from '@/components/jx-update/update-cel/version-update/varsion-update.nvue'
import configCms from '@/utils/configCms'
import { ref } from 'vue'
/*************************************************
 * 禁止返回
 */
onBackPress((options) => {
  if (options.from == 'backbutton') {
    return true
  } else if (options.from == 'navigateBack') {
    return false
  }
})

/*************************************************
 * 接收数据
 */
const globalData = ref<AnyObject>({
  type: 0,
})
onLoad((options) => {
  globalData.value = JSON.parse(options!.data) || globalData.value.type == 0
})

function close() {
  uni.navigateBack()
}
function check(res: AnyObject) {
  if (res.isTest == true) {
    globalData.value.type = 0
  }
  if (res.needUpdate == false) {
    globalData.value.type = 0
  }
}

function closeReturn() {
  uni.navigateBack()
}

const appId = ref<string>(configCms.appId)
</script>
<style>
page {
  background: transparent;
}
</style>
<style lang="scss" scoped>
.returnClass-root {
  position: fixed;
  flex-direction: column;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: rgba($color: #000000, $alpha: 0.8);
  .returnClass {
    width: 500rpx;
    background-color: $jx-primary;
    padding: 30rpx 0;
    border-radius: 50rpx;
    text-align: center;
    color: #fff;
  }

  image {
    width: 200rpx;
    height: 200rpx;
    border-radius: 15rpx;
    margin-bottom: 50rpx;
  }
}
</style>