<template>
  <section class="personal-rank-wrap rank-wrap">
    <h5header
      v-if="!isWeb"
      title="个人勤奋榜单"
      isGoHistory="1"
      :isOpacity="false"
      :shareObj="shareObj"/>
    <div class="rank-list" :class="{'padBott60': isWeb}" :style="{ marginTop: isWeb?0:`${44+statusBarHeight}Px`}">
      <div class="rank-item" v-for="(item, index) in personList" :key="index">
        <img v-if="index<=2" src="~/assets/img/stage3/rank-icon1.png" alt="" class="rank-icon">
        <p v-else class="rank-num">{{index+1}}</p>
        <div class="info">
          <img :src="item.avatarImageUrl" alt="" class="photo">
          <div class="details">
            <p class="name">{{item.name}}</p>
            <p class="awards">奖励: iPhone11、500云鹊豆</p>
          </div>
        </div>
        <div class="score">
          <p class="num">{{item.diligence}}</p>
          <p class="name">勤奋分</p>
        </div>
      </div>
      <div class="no-more" :style="{marginBottom: isWeb?0:`${50+homeIndicatorHeight}` + 'Px'}">
        <span class="line"></span>
        <span class="text">到底啦</span>
        <span class="line"></span>
      </div>
    </div>
    <div class="footer" v-if="!isWeb" :style="{height: `${50+homeIndicatorHeight}` + 'Px'}">
      <div class="content">
        <div class="left">
          <p class="score">我的勤奋分<span>{{personalData.diligence}}</span></p>
          <p class="rank">恭喜您上榜排名<span>第{{personalData.personRank}}</span></p>
        </div>
        <div class="right" @click="share">分享排名</div>
      </div>
    </div>
    <no-ssr v-if="isWeb">
      <pica-call-app
        :text="'高效学习 轻松行医'"
        path="https://test1-m-ws.yunqueyi.com/search"
      />
    </no-ssr>
  </section>
</template>

<script>
  import { getPersonScore,getPersonList } from '@/service/stage3Api';
  import { wxShare } from '@/configs/wxShare';
  import h5header from '@/components/h5header';
  export default {
    name: "personal-rank",
    components: {
      h5header
    },
    data() {
      return {
        personalData: {},
        isWeb: false,
        shareObj: wxShare,
      }
    },
    async asyncData( {query} ) {
      const { data } = await getPersonList();
      return {
        personList: data
      }
    },
    created() {
    },
    mounted() {
      this.$rocNative.appInit();
      this.isWeb = this.$rocNative.isWeb;
      this.shareObj.shareUrl = location.href; //微信分享链接
      if(!this.isWeb) {
        this.getPersonScore();
      };
    },
    methods: {
      getPersonScore() {
        getPersonScore().then(res => {
          this.personalData = res.data
        })
      },
      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/rank.less";
</style>