<template>
  <div class="openPage">
    <img class="images" :src="picUrl" alt="">
  </div>
</template>

<script>
export default {
  name: "openPage",
  customNavigation: true,
  data() {
    return {
      picUrl: '',
      status: '',
    }
  },
  methods: {
    getStatus() {
      this.$instance.post('/app/appwechatguidepage/enableStatus',null, { withoutToken: true }).then(res=> {
        if(res?.data) {
          this.status = res.data
          if(this.status==0) {
            uni.switchTab({
              url: '/pages/AppHome/AppHome'
            })
          } else {
            this.getList()
            setTimeout(() => {
              uni.switchTab({
                url: '/pages/AppHome/AppHome'
              })
            }, 3000)
          }
        }
      })
    },
    getList() {
      this.$instance.post('/app/appwechatguidepage/listForXCX',null, {
        withoutToken: true,
        params: {
          current: 1,
          size: 100,
        }
      }).then(res=> {
        if(res?.data) {
          let nums = res.data.records
          let index = Math.floor(Math.random() * nums.length)
          this.picUrl = nums[index].picUrl
        }
      })
    }
  },
  onShow() {
    this.getStatus()
  },
}
</script>

<style scoped lang="scss">
.openPage {
  width: 100%;
  height: 100vh;
  box-sizing: border-box;

  .images {
    width: 100%;
    height: 100vh;
  }
}
</style>