<template>
  <div class="order-list">
    <div class="table">
      <el-table
        ref="orderTable"
        v-loading="listLoading"
        :data="dataList"
        element-loading-text="Loading"
      >
        <el-table-column align="center" label="订单编号" prop="id" min-width="180"></el-table-column>
        <el-table-column align="center" label="服务内容" prop="increContent" min-width="200" show-overflow-tooltip></el-table-column>
		<el-table-column align="center" label="服务金额" prop="amount" min-width="200" show-overflow-tooltip></el-table-column>
        <el-table-column align="center" label="支付状态" prop="">
			<template slot-scope="{row}">
			  {{row.payStatus == 'REFUND'?'已退款':row.payStatus == 'EXPIRE'?'过期':row.payStatus == 'CANCEL'?'取消':row.payStatus == 'PAID'?'已支付':row.payStatus == 'WAIT'?'待支付':''}}
			</template>
		</el-table-column>
		<el-table-column align="center" label="创建时间" prop="createTime" min-width="160"></el-table-column>
        <el-table-column align="center" label="操作" fixed="right">
          <template slot-scope="{row}">
            <el-button type="primary" @click="goOrderDetail(row)" size="mini">详情</el-button>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <div class="pagination clearfix">
      <div class="fr">
        <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="currentPage"
          :page-sizes="[10, 20, 30, 50]"
          :page-size="10"
          layout="total, sizes, prev, pager, next, jumper"
          :total="listTotal">
        </el-pagination>
      </div>
    </div>
  </div>
</template>

<script>
import request from '@/utils/request'

export default {
  name: 'MemberOrder',
  componentName: 'MemberOrder',
  props: ['user'],
  data() {
    return {
      dataList: [], // 数据列表
      listLoading: true, // 列表加载loading
      currentPage: 1, // 当前页码
      pageSize: 10, // 每页数量
      listTotal: 0 // 列表总数
    }
  },
  created() {
    this.getOrderList()
  },
  methods: {
    getOrderList() {
		let data = {
			pageNum: this.currentPage,
			pageSize: this.pageSize,
			params: [{param: "a.user_mobile", compare: "=", value: this.user.mobile}]
		}
		request({
		  url: `/incre/order/settle/list`,
		  method: 'post',
		  data
		}).then(res=>{
			this.dataList = res.data.records
			this.listTotal = res.data.total
			this.listLoading = false
		})
    },
    // 更改每页数量
    handleSizeChange(val) {
      this.pageSize = val
      this.currentPage = 1
      this.getOrderList()
    },
    // 更改当前页
    handleCurrentChange(val) {
      this.currentPage = val
      this.getOrderList()
    },
    goOrderDetail(row) {
		this.$router.push({
			name: 'orderSettleManag',
			params: {
				pageName: row.payNo,
				pageType: row.orderChannel,
				pageCode: row.payNo,
			},
		})
    }
  }
}
</script>

<style scoped>

</style>
