<template>
  <view class="flex flex-col items-center">
    <img class="my-28 w-24 h-24" src="https://www.tall.wiki/staticrec/yanyuan/logo.png" />
    <view class="text-xl flex flex-col">
      <text class="mb-1">{{ content }}</text>
      <text>{{ time }}秒后跳转到首页...</text>
    </view>
  </view>
</template>

<script>
import toolMixin from '@/mixins/tool';
export default {
  mixins: [toolMixin],
  data() {
    return { content: '', time: 5, timer: null };
  },

  onLoad(options) {
    if (options.type === 'manyuan') {
      this.content = '工具箱已绑定';
    }
    if (options.type === 'jiashu') {
      this.openApplyModal(1, options.msg);
    }
    if (options.type === 'isjiashu') {
      this.openApplyModal(0);
    }
  },

  mounted() {
    this.$nextTick(() => {
      setTimeout(() => {
        uni.reLaunch({ url: `/pages/index/index?u=${this.userId}` });
      }, 5000);
    });
  },

  methods: {
    // 申请成为家属弹框
    async openApplyModal(type, msg) {
      if (type === 1) {
        this.content = msg;
      } else {
        this.content = '家属申请已提交，请等待审核';
      }
      this.timer = setInterval(() => {
        this.time--;
        if (this.time === 0) {
          clearInterval(this.timer);
        }
      }, 1000);
    },
  },
};
</script>

<style></style>
