<template>
  <el-dialog
    title="分销排行榜"
    :close-on-click-modal="false"
    :visible.sync="visible">
    <div class="table-con distribution-msg-table">
      <el-table
        ref="distributionMsgTable"
        height="600"
        border
        :data="dataList"
        header-cell-class-name="table-header"
        row-class-name="table-row-low"
        style="width: 100%"
      >
        <el-table-column
          prop="nickName"
          label="用户昵称"
          align="center">
          <template slot-scope="scope">
            {{scope.row.nickName}}
          </template>
        </el-table-column>
        <el-table-column
          prop="pic"
          label="用户头像"
          align="center">
          <template slot-scope="scope">
            <img :src="scope.row.pic " height="50px"/>
          </template>
        </el-table-column>
        <el-table-column
          prop="rank"
          label="排名"
          align="center">
          <template slot-scope="scope">
            {{scope.row.rank}}
          </template>
        </el-table-column>
        <el-table-column
          prop="score"
          label="积分"
          align="center">
          <template slot-scope="scope">
            {{scope.row.score}}
          </template>
        </el-table-column>

      </el-table>
    </div>
  </el-dialog>
</template>

<script>
// import PicUpload from '@/components/pic-upload'
import ImgUpload from './distribution-activity-img-upload.vue'
import TinyMce from '@/components/tiny-mce'
import { isHtmlNull } from '@/utils/index.js'

export default {
  components: {
    ImgUpload,
    TinyMce
  },
  created () {
    // this.getData()
  },
  data () {
    return {
      visible: false,
      tinymceFlag: new Date() + 1,
      dataList: []
    }
  },
  methods: {
    init (activityId) {
      console.log('activityId',activityId)
      this.visible = true
      this.$nextTick(() => {
        this.$http({
          url: this.$http.adornUrl('/distribution/distributionActivity/getActivityRank?activityId=' + activityId),
          method: 'get',
          params: this.$http.adornParams()
        }).then(({data}) => {
          console.log('data',data)
          this.dataList = data.rankList
        })
      })
    },
    // 提交表单
    dataFormSubmit () {
      this.$refs['dataForm'].validate((valid) => {
        if (valid) {
          this.$http({
            url: this.$http.adornUrl(`/distribution/distributionActivity`),
            method: this.dataForm.activityId ? 'put' : 'post',
            data: this.$http.adornData(this.dataForm)
          }).then(({ data }) => {
            this.$message({
              message: this.$i18n.t('publics.operation'),
              type: 'success',
            })
            this.visible = false
            this.$emit("refreshDataList")
          }).catch(() => {

          })
        }
      })
    }
  },
  activated () {
    this.tinymceFlag = new Date() + 1
  }
}
</script>

