<template>
  <section class="dm-wrap" v-loading="loading">
    <div class="pb22 clearfix">
      <el-input v-model="listParams.search" class="w300" placeholder="请输入会员信息" clearable @change="refresh"><i slot="prefix" class="el-input__icon el-icon-search"></i></el-input>
      <!-- <el-input v-model="listParams.receiveCode" class="w300" placeholder="请输入投放渠道" clearable @change="refresh"><i slot="prefix" class="el-input__icon el-icon-search"></i></el-input> -->
    </div>
    <el-table tooltipEffect="light" :data="tableList" style="width: 100%">
      <el-table-column :show-overflow-tooltip="true" min-width="100" align="left" prop="receiveTime" label="领取时间">
        <template slot-scope="scope">
          <p class="cell-time">
            {{ formatDateTimeByType(scope.row.receiveTime, 'yyyy-MM-dd-HH-mm', true).y }}<br />
            <span>{{ formatDateTimeByType(scope.row.receiveTime, 'yyyy-MM-dd-HH-mm', true).h }}</span>
          </p>
        </template>
      </el-table-column>
      <el-table-column :show-overflow-tooltip="true" min-width="120" header-align="left" align="left" prop="memberId" label="会员信息">
        <template slot-scope="scope">
          <a :href="'/member/#/wechatmemberDetail?memberId=' + scope.row.memberId" target="_blank">
            <img class="vertical-middle table__avatar--40" :src="scope.row.imageUrl || defaultAvatar" width="60" height="60" />
            <div class="inline-block vertical-middle">
              <p class="table-name--ellipsis">{{ scope.row.memberName || '--' }}</p>
              <p class="fz13 gray">{{ scope.row.phoneNumber || '--' }}</p>
            </div>
          </a>
        </template>
      </el-table-column>
      <el-table-column :show-overflow-tooltip="true" min-width="120" align="left" prop="cardPackageName" label="卡券包名称"></el-table-column>
      <el-table-column :show-overflow-tooltip="true" min-width="120" align="left" prop="receivePositionName" label="领取位置"></el-table-column>
      <el-table-column :show-overflow-tooltip="true" min-width="120" align="left" prop="receiveName" label="投放渠道"></el-table-column>
      <!-- <el-table-column :show-overflow-tooltip="true" min-width="120" align="left" prop="marketingActivityName" label="数据对话">
        <template slot-scope="scope">{{ scope.row.marketingActivityName || '--' }}</template>
      </el-table-column> -->
    </el-table>
    <dm-pagination v-show="tableList.length" background class="dm-pagination" @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="listParams.currentPage" :page-sizes="[20, 40, 60, 80]" :page-size="listParams.pageSize" layout="total, sizes, prev, pager, next" :total="total"></dm-pagination>
  </section>
</template>
<script>
import { pageCoupPackageLog } from '@/service/api/cardApi.js';
import { formatDateTimeByType } from '@/utils/index.js';
import talbeMethods from '@/mixins/tableMethods.js';
import filterAvater from '@/mixins/filterAvater.js';

export default {
  name: 'destory-list',
  mixins: [talbeMethods, filterAvater],
  data() {
    return {
      formatDateTimeByType,
      visible: false,
      listParams: {
        cardPackageId: '',
        search: '',
        marketingActivityId: '',
        receiveCode: '',
        sceneSettingId: '',
        currentPage: 1,
        pageSize: 20
      },
      total: 0,
      loading: false,
      tableList: [],
      projectName: 'marketing', // 当前项目名
      dialogVisible: false,
      excelUrl: '', // 下载数据的地址
      params: {} // 传递的参数
    };
  },
  created() {
    this.listParams.cardPackageId = this.$route.query.cardPackageId;
    this.getTableList();
    this.$store.commit('mutations_breadcrumb', [{ name: '营销管理', path: '' }, { name: '卡券营销', path: '' }, { name: '卡券包', path: '' }, { name: `${this.$route.query.name || ''}-卡券包领取记录`, path: '' }]); // eslint-disable-line
  },
  methods: {
    // 加载列表
    async getTableList() {
      this.loading = true;
      try {
        let res = await pageCoupPackageLog(this.listParams);
        this.tableList = res.result.result || [];
        this.total = res.result.totalCount || 0;
      } catch (err) {
        this.$tips({ type: 'error', message: '加载列表失败' });
      }
      this.loading = false;
    }
  }
};
</script>
