<template>
  <el-tabs v-model="activeName" @tab-click="handleClick">
    <el-tab-pane label="活动参与记录" name="seventh">
      <div style="position: relative;display: inline-block;margin: 10px 0px;">
        <el-input style="width: 200px;" @keydown.enter.native="animeDat" placeholder="请输入活动标题"
          v-model="activyName">
        </el-input>&nbsp;&nbsp
      </div>
      <div style="position: relative;display: inline-block;margin: 10px 0px;">
        <el-input style="width: 200px;" @keydown.enter.native="animeDat" placeholder="请输入商户名称"
          v-model="shopName">
        </el-input>&nbsp;&nbsp
      </div>
      <!-- <div style="position: relative;display: inline-block;margin: 10px 0px;">
        <el-input style="width: 200px;" @keydown.enter.native="animeDat" placeholder="请输入订单id"
          v-model="orderId">
        </el-input>&nbsp;&nbsp
      </div> -->
      <div style="position: relative;display: inline-block;margin: 10px 0px;">
        <el-input style="width: 200px;" @keydown.enter.native="animeDat" placeholder="请输入用户手机号"
          v-model="phone">
        </el-input>&nbsp;&nbsp
      </div>
      <!-- <div style="position: relative;display: inline-block;margin: 10px 0px;">
        <span>状态：</span>
        <el-select v-model="state" style="width:150px;margin-left: 10px;" @change="animeDat(state)">
          <el-option v-for="item in typeList" :key="item.value" :label="item.label" :value="item.value"></el-option>
        </el-select>&nbsp;&nbsp;&nbsp;
      </div> -->
      <div style="position: relative;display: inline-block;margin: 10px 0px;">
        <span>活动类型：</span>
        <el-select v-model="huoType" style="width:150px;margin-left: 10px;" @change="animeDat(huoType)">
          <el-option v-for="item in huotype" :key="item.value" :label="item.label" :value="item.value"></el-option>
        </el-select>&nbsp;&nbsp;&nbsp;
      </div>

      <div style="position: relative;display: inline-block;margin-right:2%;">
        <el-button style="margin-left:15px;" size="mini" type="primary" icon="document" @click="animeDat">查询
        </el-button>
        <el-button style="margin-left:15px;" size="mini" type="primary" icon="document" @click="cleans">重置
        </el-button>
      </div>
      <el-table v-loading="tableDataLoading" :data="tableData.list">
        <el-table-column fixed prop="id" label="编号">
        </el-table-column>
        <el-table-column fixed prop="orderId" label="订单号">
        </el-table-column>
        <!-- <el-table-column fixed prop="nickName" label="昵称" width="150">
          <template slot-scope="scope">
            <span style="color: #f56c6c;cursor: pointer;" @click="updataDetails(scope.row)">{{scope.row.nickName ? scope.row.nickName : '未绑定'}}</span>
          </template>
        </el-table-column> -->
        <el-table-column label="头像" prop="userImg">
          <template slot-scope="scope">
            <img v-if="scope.row.avatar==null" src="~@/assets/img/avatar.png" alt="" width="40" height="40">
            <img v-else :src="scope.row.userImg" alt="" width="40" height="40">
          </template>
        </el-table-column>
        <el-table-column prop="userPhone" label="手机号">
        </el-table-column>
        <el-table-column prop="shopName" label="商户名称">
        </el-table-column>
        <el-table-column prop="activityTitle" label="活动名称">
        </el-table-column>
        <el-table-column prop="activityType" label="活动类型">
          <template slot-scope="scope">
            <span v-if="scope.row.activityType=='1'">普通活动</span>
            <span v-else-if="scope.row.activityType=='2'">时段优惠</span>
            <span v-else-if="scope.row.activityType=='3'">满额优惠</span>
            <span v-else-if="scope.row.activityType=='4'">全场优惠</span>
          </template>
        </el-table-column>
        <el-table-column prop="activityImg" label="图片">
          <template slot-scope="scope">
            <img :src="scope.row.activityImg" alt="" width="40" height="40">
          </template>
        </el-table-column>
        <el-table-column prop="activityContent" label="活动内容">
        </el-table-column>
        <el-table-column prop="createTime" label="下单时间">
        </el-table-column>
        <!-- <el-table-column prop="expirationTime" label="过期时间"> -->
        <!-- </el-table-column> -->
        <el-table-column label="状态">
          <template slot-scope="scope">已使用
          </template>
        </el-table-column>
      </el-table>
      <div style="text-align: center;margin-top: 10px;">
        <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
          :page-sizes="[10, 20, 30,50,100]" :page-size="limit" :current-page="page" layout="total,sizes, prev, pager, next"
          :total="tableData.totalCount">
        </el-pagination>
      </div>
    </el-tab-pane>
  </el-tabs>
</template>

<script>
  export default {
    data() {
      return {
        limit: 10,
        page: 1,
        state: '',
        huoType:'',
        title: '',
        id: '',
        content: '',
        activeName: 'seventh',
        tableDataLoading: false,
        dialogFormVisible1: false,
        dialogFormVisible2: false,
        dialogFormVisible: false,
        tableData: [],
        typeList:[
          {
            value:'',
            label:'全部'
          },
          {
            value:0,
            label:'未支付'
          },
          {
            value:1,
            label:'已支付'
          }
        ],
        huotype:[{
						value: '',
						label: '全部活动'
					},{
						value: 1,
						label: '普通活动'
					},
					{
						value: 2,
						label: '时段优惠'
					},
					{
						value: 3,
						label: '满额优惠'
					},{
						value: 4,
						label: '全场优惠'
					}
        ],
        phone:'',
		    shopName:'',
        activyName:'',
        orderId:'',
      }
    },
    methods: {
      // 详情跳转
      updataDetails(row) {
        this.$router.push({
          path: '/userDetail',
          query: {
            userId: row.userId
          }
        });
      },
      handleSizeChange(val) {
        this.limit = val;
        this.dataSelect()
      },
      handleCurrentChange(val) {
        this.page = val;
        this.dataSelect()
      },
      handleClick(tab, event) {
        this.page = 1
        this.limit = 10
        this.dataSelect()
      },
      // 获取数据列表
      dataSelect() {
        this.tableDataLoading = true
        this.$http({
          url: this.$http.adornUrl('admin/activity-part-record/page'),
          method: 'get',
          params: this.$http.adornParams({
            'page':this.page,
            'limit':this.limit,
            // 'orderId':this.orderId,
            'activityType':this.huoType,
            'userPhone':this.phone,
			      'orderPayStatus':this.state,
            'activityTitle':this.activyName,
            'shopName':this.shopName
          })
        }).then(({
          data
        }) => {
          if(data.msg=='success'){
						this.tableDataLoading = false
						let returnData = data.data
						this.tableData = returnData
					}else{
						this.$message({
							message: data.msg,
							type: 'warning',
							duration: 1500,
							onClose: () => {}
						})
          }
        })
      },
      animeDat(){
        this.page = 1
        this.dataSelect()
      },
      cleans(){
        this.page = 1
        this.phone = ''
        this.state = ''
        this.orderId=''
		    this.shopName = ''
        this.activyName=''
        this.huoType=''
        this.dataSelect()
      }
    },
    mounted() {
      this.dataSelect()
    }
  };
</script>

<style>

</style>
