<template>
  <view style="background-color: rgb(246, 247, 250); height: 100%">
	  <u-navbar  title="官方认证" ></u-navbar>
    <view class="flex-col group">
      <view class="flex-col list">
        <view
          class="list-item flex-col"
          :key="i"
          v-for="(item, i) in list"
          @click="toAuthentication(i)"
        >
          <text class="text_1">{{ item.name }}</text>
          <view class="center-group justify-between">
            <text class="text_3">{{ item.title }}</text>
            <image :src="item.imgUrl" class="image_2" />
          </view>
          <view class="bottom-section"> </view> </view
      ></view>
    </view>
    <!-- 修改密码 -->
    <u-mask :show="Alert">
      <view class="Alert">
        <view class="form">
          <text class="text">正在进行资质审核，请耐性等待~</text>
          <view class="btns">
            <u-button class="btn" @click="Alert = false" type="primary"
              >确认</u-button
            >
          </view>
        </view>
      </view>
    </u-mask>
	  <u-top-tips :z-index="999" ref="uTips" :navbar-height="0"></u-top-tips>
    <u-toast ref="uToast" />
  </view>
</template>

<script>
export default {
  data() {
    return {
	  schoolId:'',
      Alert: false,
	  isZXS:false,
      list: [
        {
          name: "企业认证",
          title: "针对企业公司或其他经济组织的认证",
          imgUrl: require("../../../static/common/img/enterprise.png"),
        },
        {
          name: "管理员认证",
          title: "针对学校工作管理人员和学生管理人员的认证",
          imgUrl: require("../../../static/common/img/admin.png"),
        },
		// {
		//   name: "教职工认证",
		//   title: "针对在校教职工与其他在校工作人员认证",
		//   imgUrl: require("../../../static/common/img/Faculty.png"),
		// },
      ],
    };
  },
  onLoad() {
	  this.getschoolId()
  },
  methods: {
    getschoolId(){
	  	this.$u.apiList.GetUserSchool().then(res=>{
      console.log(res,'res-----')  
      // 学生时
      if([0,2].includes(this.vuex_user.userType)){
        this.schoolId = res.items.schoolId
      }
      // 教师时
      if(this.vuex_user.userType === 1){
        this.schoolId = res.jzgItems.schoolId
      }
      // this.schoolId = res.items.schoolId
			this.isZXS = res.isAttestationZXS
	  	})
    },
    toAuthentication(id) {
    console.log(id,'id---')
		if(id == 0 || id == 2){
			if(this.isZXS&&id==2){
				// this.$tips("在校生无法认证教职工!", "warning");
        this.$refs.uToast.show({
						title: '在校生无法认证教职工!',
						type: "warning",
					});

			}else{
				if(id==0){
					// if(this.vuex_user.isAttestationJZG){
					// 	this.$tips("已认证教职工,无法再认证企业！", "warning");
					// }else{
						this.getUserApproval(id)
					// }
          
				}else if(id==2){
					if(this.vuex_user.isAttestationQY){
						// this.$tips("已认证企业,无法再认证教职工！", "warning");
            this.$refs.uToast.show({
              title: '已认证企业,无法再认证教职工！',
              type: "warning",
            });
					}else{
						this.getUserApproval(id)
					}
				}else{
					this.getUserApproval(id)
				}
			}
		}
    if(id === 1){
      if([0,1].includes(this.vuex_glyType)){
        // this.$tips('已经是管理员无需认证', "warning");
        this.$refs.uToast.show({
						title: '已经是管理员无需认证',
						type: "error",
					});
        return 
      }
			this.getUserApproval(id)
		}
    },
	//验证该学校是否已经认证
	getUserApproval(id){
		const data = {
			schoolId:this.schoolId,
			type:id
		}
		this.$u.apiList.GetUserApproval(data).then((res)=>{
			this.$u.route({
			  url: "/pages/my/certificationDetails/certificationDetails",
			  params: { id: id },
			});
		})
		.catch((err)=>{
			// this.$tips(err.error, "warning");
      this.$refs.uToast.show({
						title: err.error,
						type: "error",
					});
		})
	},
	//返回上一级
	router(){
		this.$u.route({
			url: 'pages/my/mySeting/mySeting'
		});
	}
  },
};
</script>

<style lang="scss" scoped>
.Alert {
  .form {
    width: 80%;
    background-color: #ffffff;
    border-radius: 0.14rem;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 0.3rem;
    .text {
      line-height: 0.3rem;
      color: #494c57;
      display: inline-block;
      padding: 0.4rem 0;
      font-size: 0.16rem;
    }
    .input {
      background-color: #f6f7fa;
      border-radius: 0.07rem;
      font-size: 0.22rem;
      color: #b4b6bd;
      margin-bottom: 0.2rem;
      padding: 0.05rem 0.1rem;
    }
    .codeInput {
      display: flex;
      justify-content: space-between;
      margin-bottom: 0.2rem;
      ::v-deep .u-input {
        background-color: #f6f7fa;
        border-radius: 0.07rem;
        font-size: 0.22rem;
        color: #b4b6bd;
        padding: 0.05rem 0.1rem !important;
      }
      .codeBtn {
        width: 0.5rem;
        height: 0.5rem;
        background-color: #eaf5ff;
        border-radius: 0.07rem;
        font-size: 0.26rem;
        line-height: 0.23rem;
        color: #2e9bff;
        margin-left: 0.12rem;
      }
    }
    .btns {
      display: flex;
      justify-content: space-between;
      .btn {
        width: 40%;
      }
    }
  }
}

.group {
  padding: 0.17rem 0 0.76rem;
  flex: 1 1 auto;
  overflow-y: auto;
  .list {
    padding-left: 0.21rem;
    padding-right: 0.19rem;
    .list-item {
      padding: 0.27rem 0.17rem 0.21rem;
      border-radius: 0.05rem;
      background-size: 100% 100%;
      background-repeat: no-repeat;
      &:not(:first-of-type) {
        margin-top: 0.13rem;
      }
      .text_1 {
        color: rgb(255, 255, 255);
        font-size: 0.24rem;
        font-weight: 700;
        line-height: 0.23rem;
        white-space: nowrap;
      }
      .center-group {
        margin-top: 0.14rem;
        padding: 0 0.015rem;
        color: rgb(255, 255, 255);
        font-size: 0.12rem;
        font-weight: 700;
        line-height: 0.12rem;
        white-space: nowrap;
        .text_3 {
          opacity: 0.49;
        }
        .image_2 {
          margin-right: 0.1rem;
          margin-top: 0.06rem;
          width: 0.37rem;
          height: 0.45rem;
        }
      }
      .bottom-section {
        margin-left: 0.015rem;
        margin-top: 0.23rem;
        background-color: rgb(255, 255, 255);
        border-radius: 0.02rem;
        width: 0.27rem;
        height: 0.04rem;
      }
    }
    .list-item:nth-child(3n-2) {
      background-image: url("~@/static/common/img/enterpriseBj.png");
    }
    .list-item:nth-child(3n-1) {
      background-image: url("~@/static/common/img/FacultyBj.png");
    }
    .list-item:nth-child(3n) {
      background-image: url("~@/static/common/img/adminBj.png");
    }
  }
}
</style>
