<!-- 积分兑换记录 -->
<template>
  <div>
    <CtTable
      class="mt-3"
      :items="dataList"
      :headers="headers"
      :loading="false"
      :elevation="0"
      :isTools="false"
      :showPage="true"
      :total="total"
      :page-info="queryParams"
      itemKey="id"
      @pageHandleChange="handleChangePage"
    >
    </CtTable>
  </div>
</template>

<script setup>
defineOptions({name: 'mall-exchangeRecords'})
import { ref } from 'vue'
import { getRedeemPage } from '@/api/mall1'
import { getToken } from '@/utils/auth'

const total = ref(0)
const headers = [
  { title: '商品名称', key: 'name', sortable: false },
  { title: '消耗积分', key: 'point', sortable: false },
  { title: '收货人姓名', key: 'contactName', sortable: false },
  { title: '联系电话/收货人电话', key: 'contactPhone', sortable: false },
  { title: '收货详细地址', key: 'contactAddress', sortable: false },
  { title: '订单编号', key: 'orderNo', sortable: false }
]
const queryParams = ref({
  pageNo: 1,
  pageSize: 10,
})

// 数据
const dataList = ref([])
const getData = async () => {
  const res  = await getRedeemPage(queryParams.value)
  dataList.value = res.list
  total.value = res.total
}
if (getToken()) getData()

const handleChangePage = (e) => {
  queryParams.value.pageNo = e
  getData()
}
</script>

<style lang="scss" scoped>
</style>