<template>
  <div class="home_user_info">
    <van-cell-group>
      <van-cell title="姓名" :value="nickName" />
      <!-- <van-popover v-model="showGenderPopover" trigger="click" :actions="actions" @select="onSelect">
      <template #reference>
        <van-cell title="性别">
        {{gender==1?'男':gender==2?'女':'-'}}
      </van-cell>
      </template>
    </van-popover> -->
      
      <van-cell title="身份证" :value="idCard" />
      <van-cell title="手机号" :value="phone" />
      <van-cell title="关注主学校" :value="schoolNamesChoose" />
    </van-cell-group>
    
  </div>
</template>
<script>
export default {
  data () {
    return {
      nickName: '',//姓名
      gender: '',//性别
      idCard: '',//身份证
      phone: '',//手机号
      schoolNamesChoose: '',//学校
      showGenderPopover:false,
      actions: [{ text: '选项一' }, { text: '选项二' }, { text: '选项三' }],
    }
  },
  mounted () {
    this.centerNo = localStorage.getItem('centerNo');
    const userInfo = JSON.parse(localStorage.getItem('userInfo'))
    this.nickName = userInfo.nickName
    this.gender = userInfo.gender
    this.idCard = userInfo.idCard || '-'
    this.phone = userInfo.phone
    let schoolNamesChoose = localStorage.getItem('schoolNamesChoose')
    if (schoolNamesChoose) {
      this.schoolNamesChoose = JSON.parse(schoolNamesChoose)
    }
  },
  methods: {
     onSelect(action) {
      Toast(action.text);
    },
    // 获取用户信息
    getUserInfo: function () {
      this.$toast.loading({
        message: '加载中...',
        duration: 0,
        forbidClick: true
      })
      this.mgop({
        api: 'mgop.sz.hswsy.getPortalUserByNum', // 必须
        host: 'https://mapi.zjzwfw.gov.cn/',
        dataType: 'JSON',
        type: 'GET',
        appKey: 'fuxgnukl+2001895516+edccpx', // 必须
        headers: {
          //   'isTestUrl': '1'
        },
        data: {
          "userNum": this.centerNo
        },
        onSuccess: res => {
        this.$toast.clear()
          if (res.data.code == 200) {
             const userInfo = res.data.data.userInfo
          localStorage.setItem('userInfo', JSON.stringify(userInfo))
          }
        },
        onFail: err => {
          console.log('err', err)
        }
      });
    },
  }
}
</script>
<style lang="scss">
.home_user_info {
  height: 100%;
  padding-top: 10px;
  box-sizing: border-box;
  background: rgb(247, 245, 251);
  .van-cell {
    padding: 30px 32px;
  }
}
</style>