<template>
  <div>
    <div id="mineTop">
      <img v-if="avatar" :src="avatar">
      <div id="mineTopRight">
        <div id="mineTopRightName">
          <span>{{userName}}</span>
          <img v-if="this.trophy[0]==1" src="../assets/21_complete.png">
          <img v-if="this.trophy[1]==1" src="../assets/60_complete.png">
          <img v-if="this.trophy[2]==1" src="../assets/150_complete.png">
        </div>
        <div>设备ID：{{seexSn}}</div>
      </div>
    </div>
    <ul id="mineBom">
      <li @click="toActivityHistory">
        <img src="../assets/icon_record1.png">
        <p>活动记录</p>
      </li>
      <li class="mineBomLine"></li>
      <li @click="toPosterHistory">
        <img src="../assets/icon_record2.png">
        <p>海报记录</p>
      </li>
      <li class="mineBomLine"></li>
      <li @click="toEquipment">
        <img src="../assets/icon_device.png">
        <p>设备管理</p>
      </li>
      <li class="mineBomLine"></li>
      <li @click="service">
        <img src="../assets/icon_contact.png">
        <p>联系客服</p>
      </li>
    </ul>
    <div id="service" v-show="serviceShow" @click.stop="serviceShow=false">
      <div id="serviceCon" @click.stop>
        <div>联系客服</div>
        <p>微信号：{{wxName}}</p>
        <img :src="wxUrl">
        <p>长按识别二维码</p>
        <img id="serviceClose" @click="serviceShow=false" src="../assets/icon_close.png">
      </div>
    </div>
    <navigation :is-x="isX" :apply-status="applyStatus" :tool-status="toolStatus" :mine-status="mineStatus"></navigation>
    <loading :loadingShow="loadingShow"></loading>
  </div>
</template>
<script>
import navigation from '../components/navigaton/navigation.vue'
import request from '../utils/request'
import loading from '../components/loading/loading.vue'
export default {
  data() {
    return{
      isX: false,
      applyStatus: false,
      toolStatus: false,
      mineStatus: true,
      loadingShow: false,//加载
      userName: '',
      avatar: '',
      seexSn: '',

      wxName: '',
      wxUrl: '',
      serviceShow: false,//客服
      trophy: [],
    }
  },
  components: {
    navigation, loading
  },
  mounted() {
    // var u = navigator.userAgent, app = navigator.appVersion;
    // var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
    // if (isiOS) {
    //   var w=window.screen.width * window.devicePixelRatio;
    //   var h=window.screen.height * window.devicePixelRatio;
    //   if(w==1125&&h==2436){
    //     this.isX = true;
    //   }
    // }
    this.loadingShow = true
    request({
      url: '/api/MarketingToolApi/Users/personalCenter',
      method: 'post',
      data: {
        token: localStorage.getItem("token")
      }
    }).then(response => {
      this.loadingShow = false
      this.userName = response.data.userName
      this.avatar = response.data.avatar
      this.seexSn = response.data.seexSn
      this.trophy = response.data.trophy
    })
    request({
      url: '/api/MarketingToolApi/Users/customer',
      method: 'post',
      data: {
        token: localStorage.getItem("token")
      }
    }).then(response => {
      this.loadingShow = false
      this.wxName = response.data.name
      this.wxUrl = response.data.url
    })
  },
  methods: {
    toActivityHistory() {
      this.$router.push({name: 'activityHistory'})
    },
    toPosterHistory() {
      this.$router.push({name: 'posterHistory'})
    },
    toEquipment() {
      this.$router.push({name: 'equipment'})
    },
    service() {
      this.serviceShow = true
    },
  }
}
</script>
<style lang="scss">
#mineTop{
  display: flex;
  align-items: center;
  background-color: #fff;
  padding: 10px 20px;
  margin-bottom: 10px;
  >img{
    display: block;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    margin-right: 10px;
  }
  #mineTopRight{
    font-size: 14px;
    color: #282B2F;
    #mineTopRightName{
      display: flex;
      align-items: center;
      span{
        margin-right: 10px;
      }
      >img{
        display: block;
        width: 21px;
        height: 21px;
        margin-right: 2px;
      }
    }
  }
}
#mineBom{
  display: flex;
  justify-content: space-around;
  background-color: #fff;
  padding: 15px 10px;
  li{
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 14px;
    color: #282B2F;
    img{
      display: block;
      width: 45px;
      height: 45px;
      margin-bottom: 6px;
    }
  }
  .mineBomLine{
    width: 1px;
    height: 47.5px;
    background-color: rgba(170,170,170,0.5);
  }
}
#service{
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10000;
  background-color: rgba( 0, 0, 0,0.6);
  #serviceCon{
    background: #fff;
    width: 240px;
    position: absolute;
    top: 50%;
    left: 50%;
    margin-left: -120px;
    margin-top: -128px;
    border-radius: 5px;
    color: #3F4041;
    font-weight: 500;
    text-align: center;
    padding: 20px 0;
    >div{
      font-size: 18px;
      margin-bottom: 10px;
    }
    >p{
      font-size: 14px;
      margin-top: 5px;
    }
    >img{
      display: block;
      width: 140px;
      height: 140px;
      margin: 3px auto 0;
    }
    #serviceClose{
      width: 37px;
      height: 37px;
      position: absolute;
      margin: 0;
      top: -37px;
      right: -37px;
    }
  }
}
</style>