<template>
  <div class="abroad_evaluate">
    <div class="rate" @click="handleEvaluate">
        <div>
          <van-rate v-model="evaluationData.evaluationScore" color="#FFCC00" :size="16" readonly />
          <span>{{ evaluationData.evaluationScore }}</span>
        </div>
        <span>共{{evaluationData.evaluationCount}}个客户评价
          <van-icon name="arrow" />
        </span>
      </div>
  </div>
</template>
<script>
export default {
  props:['courseId'],
  data(){
    return{
      evaluationData: '',//评价
    }
  },
  mounted(){
    this.getEvaluationSummary()
  },
  methods:{
    // 获取评价
    getEvaluationSummary () {
      this.mgop({
        api: 'mgop.sz.hswsy.EvaluationSummary', // 必须
        host: 'https://mapi.zjzwfw.gov.cn/',
        dataType: 'JSON',
        type: 'GET',
        appKey: 'fuxgnukl+2001895516+edccpx', // 必须
        headers: {
          //   'isTestUrl': '1'
        },
        data: {
          "courseId": this.courseId,
        },
        onSuccess: res => {
          if (res.data.data) {
            this.evaluationData = res.data.data
          }
        },
        onFail: err => {
          console.log('err', err)
        }
      });
    },
    // 点击评价进入评价详情页
    handleEvaluate () {
      this.$router.push({ name: "ServiceAbroadEvaluate", query: { courseId: this.courseId } });
    },
  }
}
</script>