<template>
  <div>
    <el-dialog
      :title="marketingData.title"
      width="1000px"
      :visible.sync="dialogVisible"
      :before-close="close"
    >
      <div class="dialog-search">
        <div>参与用户数量：{{marketingData.realNum}}</div>
        <div class="ge"></div>
        <div>新用户数（助力用户数）：{{marketingData.newUserCount}}</div>
        <div class="ge"></div>
        <div>抽奖码数量：{{marketingData.codeCount}}</div>
      </div>
      <el-table
        v-loading="loading"
        :data="marketingList"
        class="el-table"
      >
        <el-table-column label="用户编号" prop="userId" min-width="80" />
        <el-table-column label="用户昵称" prop="nickName" min-width="80" />
        <el-table-column label="抽奖码" prop="code" min-width="80" />
        <el-table-column label="抽奖码获取时间" prop="createdTime" min-width="85">
          <template slot-scope="scope">
            <div>{{ parseTime(scope.row.createdTime) }}</div>
          </template>
        </el-table-column>
        <el-table-column label="奖级" prop="awardsName" min-width="50" >
          <template slot-scope="scope">
            <div v-if="scope.row.prizeName != ''">{{ scope.row.awardsName }}</div>
            <div v-else> -- </div>
          </template>
        </el-table-column>
        <el-table-column label="奖品名称" prop="prizeName" min-width="85" >
          <template slot-scope="scope">
            <div v-if="scope.row.prizeType == 'COIN'">盲豆 x{{scope.row.value}}</div>
            <div v-else-if="scope.row.prizeName != ''">{{ scope.row.prizeName }}</div>
            <div v-else> -- </div>
          </template>
        </el-table-column>
      </el-table>
      <pagination
        v-show="marketingTotal > 0"
        :total="marketingTotal"
        :page.sync="pageParams.pageNum"
        :limit.sync="pageParams.pageSize"
        @pagination="getMarketingData"
      />
      <div class="dialog-btn">
        <el-button size="small" @click="close"> 关 闭 </el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
import { getMarketingData, getMarketingDataCodeList } from '@/api/business/marketing'
export default {
  name: "CouponAdd",
  props: {
    dialogVisible: {
      type: Boolean,
      default: false,
    },
    ids: {
      type: Object,
      default: () => []
    }
  },
  data() {
    return {
      loading: false,
      marketingList: [], // 列表
      marketingTotal: 0, // 总数
      pageParams: {
        pageNum: 1,
        pageSize: 10,
      },
      marketingData: {},//
    };
  },
  created() {
    this.getMarketingData();
  },
  methods: {
    // 列表
    getMarketingData() {
      this.loading = true;
      getMarketingDataCodeList('pageNum='+this.pageParams.pageNum + '&pageSize='+this.pageParams.pageSize+'&',this.ids.id ).then((res) => {
        this.marketingList = res.rows
        this.marketingTotal = res.total;
        this.loading = false;
      });
      getMarketingData(this.ids.id ).then((res) => {
        if(res.code == 0){
          this.marketingData = res.data
        }
      });

    },

    close() {
      this.$emit("close");
    },
  },
};
</script>
<style lang="scss" scoped>
.dialog-search {
  display: flex;
  line-height: 32px;
  margin-bottom: 20px;
  .ge {
    width: 40px;
  }
}
.dialog-btn {
  display: flex;
  align-content: center;
  justify-content: flex-end;
  padding: 40px 0 0;
  .ge {
    width: 40px;
  }
}
</style>
