<template>
  <section class="personal-grade-wrap">
    <h5header
      v-if="!isWeb"
      title="云鹊奖2019"
      isGoHistory="1"
      :isOpacity="false"
      :shareObj="shareObj"/>
    <div class="wrap-container" :class="{'marginBott60': isWeb}" :style="{ marginTop: isWeb?0:`${44+statusBarHeight}Px`}">
      <img src="~/assets/img/stage3/awards-title.png" alt="" class="title">
      <img :src="dealAwardsIcon()" alt="" class="awards-grade">
      <div class="personal-info">
        <img :src="myGrades.avatarImageUrl" alt="">
        <div class="right">
          <p class="name">{{myGrades.name}}</p>
          <p class="hospital">{{myGrades.hospitalName}}</p>
        </div>
      </div>
      <div class="join-num">活动总计参与人数:{{myGrades.count}}</div>
      <div class="grade-details">
        <div class="left">
          <p class="title">{{isWeb?'TA':'您'}}的成绩:</p>
          <div class="item">
            <div class="line"></div>
            <div class="content">
              <p class="label">累计获得勤奋分</p>
              <p class="grade">{{myGrades.diligence}}</p>
              <div class="trapezoid">
                <p class="detail-bg"></p>
                <p class="detail-text">超过{{myGrades.superCount||0}}%的医生</p>
              </div>
            </div>
          </div>
          <div class="item marginItem">
            <div class="line line168"></div>
            <div class="content">
              <p class="label">累计获得云鹊豆</p>
              <p class="grade">{{myGrades.bonus}}</p>
              <div class="detail">记得去云鹊豆中心进行兑换哦</div>
            </div>
          </div>
          <div class="item">
            <div class="line line168"></div>
            <div class="content">
              <p class="label">进每日TOP10</p>
              <p class="grade">{{myGrades.userDayTop10Count}}次</p>
              <div class="detail">拿奖拿到手发软 </div>
            </div>
          </div>
        </div>
        <div class="right">
          <p>{{rightText1}}</p>
          <p>{{rightText2}}</p>
        </div>
      </div>
      <div class="task-details">
        <div class="task-item">
          <img src="~/assets/img/stage3/task-icon1.png" alt="">
          <p class="num">{{myGrades.clockCount}}次</p>
          <p class="name">活动打卡</p>
        </div>
        <div class="task-item">
          <img src="~/assets/img/stage3/task-icon2.png" alt="">
          <p class="num">{{myGrades.courseCount}}门</p>
          <p class="name"> 学习课程</p>
        </div>
        <div class="task-item">
          <img src="~/assets/img/stage3/task-icon3.png" alt="">
          <p class="num">{{myGrades.inviteCount}}人</p>
          <p class="name">邀请好友</p>
        </div>
      </div>
      <div class="share-btn" @click="share" v-if="!isWeb">分享我的成绩</div>
      <p class="footer-text" v-if="!isWeb">共同推进医防融合 齐心聚力机构发展</p>
      <no-ssr v-if="isWeb">
        <pica-call-app
          :text="'高效学习 轻松行医'"
          path="https://test1-m-ws.yunqueyi.com/search"
        />
      </no-ssr>
    </div>
  </section>
</template>

<script>
  import { getMyGrades } from '@/service/stage3Api';
  import { wxShare } from '@/configs/wxShare';
  import h5header from '@/components/h5header';
  export default {
    name: "personal-grade",
    components: {
      h5header
    },
    data() {
      return {
        rightText1: '',//右侧文案
        rightText2: '',//右侧文案
        shareObj: wxShare,
        isWeb: false
      }
    },
    async asyncData({query}) {
      const { data } = await getMyGrades({id: query.encyptId});
      return {
        encyptId: query.encyptId,//加密doctorId
        myGrades: data
      }
    },
    created() {
    },
    mounted() {
      this.isWeb = this.$rocNative.isWeb;
      this.shareObj.shareUrl = location.href; //微信分享链接
      this.dealRightText();
    },
    methods: {
      dealRightText() {
        if(this.myGrades.superCount<=10) {
          this.rightText1 = '勤学不辍';
          this.rightText2 = '必有收获';
        } else if(this.myGrades.superCount>=11&&this.myGrades.superCount<=40) {
          this.rightText1 = '学无止境';
          this.rightText2 = '不知疲倦';
        } else if(this.myGrades.superCount>=41&&this.myGrades.superCount<=100) {
          this.rightText1 = '学而不倦';
          this.rightText2 = '可圈可点';
        }
      },
      dealAwardsIcon() {
        if(this.myGrades.superCount<=10) {
          return require('../../assets/img/stage3/awards-icon3.png');
        } else if(this.myGrades.superCount>=11&&this.myGrades.superCount<=40) {
          return require('../../assets/img/stage3/awards-icon2.png');
        } else if(this.myGrades.superCount>=41&&this.myGrades.superCount<=100) {
          return require('../../assets/img/stage3/awards-icon2.png');
        }
      },
      share() {
        this.$rocNative.shareWechat(this.shareObj);
      }
    }
  }
</script>
<style>
  @import '../../assets/style/pica-call-app.less';
</style>
<style scoped lang="less">
  @import '../../assets/style/awards-list/personal-grade.less';
</style>