<template>
  <view class="">
    <u-modal v-model="show" :content="content" :show-cancel-button="true" @cancel="cancel" @confirm="confirm"></u-modal>
    <u-toast ref="uToast" />
  </view>
</template>

<script>
export default {
  name: 'judgeAuth',
  data() {
    return {
      show: false,
      content: '你还没有认证,该功能需要认证后才能使用!',
      auditStatus: null
    };
  },
  methods: {
    /**
     * @param {Object} bool
     */
    modalShow(url) {
      this.$u.api
        .getmemberinfo()
        .then((res) => {
          if (res.code === 200) {
            this.$u.vuex('vuex_memberInfo', res.data);
            if (res.data.auditStatus || res.data.auditStatus === 0) {
              this.auditStatus = Number(res.data.auditStatus);
            }
            switch (Number(res.data.auditStatus)) {
              case 0:
                this.content = '您的认证正在审核中,该功能需要认证后才能使用!';
                this.show = true;
                break;
              case 1:
                this.content = '您的认证未通过,,该功能需要认证后才能使用!';
                this.show = true;
                break;
              case 2:
                this.$emit('adoptAuth', url);
                break;
              case 3:
                this.content = '您的认证已被撤销,该功能需要认证后才能使用!';
                this.show = true;
                break;
              case 9:
                this.content = '您还未进行认证,该功能需要认证后才能使用!';
                this.show = true;
                break;
            }
          } else {
            this.$refs.uToast.show({
              title: res.msg,
              type: 'error'
            });
          }
        })
        .catch((err) => {
          this.$refs.uToast.show({
            title: err.msg,
            type: 'error'
          });
        });
    },
    /**
     * 取消
     */
    cancel() {},
    /**
     * 确认
     */
    confirm() {
      this.show = false;
      if (this.auditStatus === 1 || this.auditStatus === 3 || this.auditStatus === 9) {
        uni.navigateTo({
          url: '/pages/applyEducationCode/applyEducationCode'
        });
      }
    }
  }
};
</script>

<style></style>