<template>
  <ContentWrap>
    <el-table v-loading="loading" :data="tableData" :stripe="true">
      <el-table-column label="商品名称" align="center" prop="spuName" />
      <el-table-column label="点数" align="center" prop="price" />
      <el-table-column label="是否已支付" align="center" prop="payStatus">
        <template #default="scope">
          {{ scope.row.payStatus ? "已支付" : "未支付"}}
        </template>
      </el-table-column>
      <el-table-column label="支付订单编号" align="center" prop="payOrderId" />
      <el-table-column
        label="订单支付时间"
        align="center"
        prop="payTime"
        :formatter="dateFormatter"
        width="180px"
      />
    </el-table>

    <Pagination
      :total="total"
      v-model:page="queryParams.pageNo"
      v-model:limit="queryParams.pageSize"
      @pagination="getList"
    />
  </ContentWrap>
</template>

<script setup>
/* 交易订单 */
defineOptions({ name: 'EnterpriseUserTradeOrderList'})
import { EnterpriseUserBindApi } from '@/api/menduner/system/enterprise/userBind'
import { DICT_TYPE } from '@/utils/dict'
import { dateFormatter } from '@/utils/formatTime'

const props = defineProps({
  userId: String,
  enterpriseId: String
})

const loading = ref(false)
const tableData = ref([])
const total = ref(0)
const queryParams = reactive({
  pageNo: 1,
  pageSize: 10,
  userId: props.userId,
  enterpriseId: props.enterpriseId
})

const getList = async () => {
  loading.value = true
  try {
    const data = await EnterpriseUserBindApi.getEnterpriseUserTradeOrderPage(queryParams)
    tableData.value = data.list
    total.value = data.total
  } finally {
    loading.value = false
  }
}
getList()
</script>
