<route lang="json5" type="page">
{
  layout: 'default',
  needLogin: true,
  style: {
    navigationBarTitleText: '%wallet.frozenRecord.title%',
    navigationBarBackgroundColor: '#fff',
  },
}
</route>

<script lang="ts" setup>
// 必须导入需要用到的页面生命周期（即使在当前页面上没有直接使用到）
// eslint-disable-next-line unused-imports/no-unused-imports
import { onPageScroll, onReachBottom } from '@dcloudio/uni-app'
import useZPaging from 'z-paging/components/z-paging/js/hooks/useZPaging.js'
import { withdrawFreedList } from '@/api/wallet'
import { formatNumber } from '@/utils'

defineOptions({
  name: 'FrozenRecord', // 冻结记录
})
// z-paging
const paging = ref(null)
// 类似mixins，如果是页面滚动务必要写这一行，并传入当前ref绑定的paging，注意此处是paging，而非paging.value
useZPaging(paging)
const queryParams = ref<any>({})
// 搜索结果
const dataList = ref([])

async function queryList(pageNo: number, pageSize: number) {
  try {
    const res = await withdrawFreedList({
      page: pageNo,
      size: pageSize,
    })
    console.log(res)
    paging.value.complete(res.data.list)
  }
  catch {
    paging.value.complete(false)
  }
}
onLoad((options) => {
  queryParams.value = options
})
</script>

<template>
  <z-paging ref="paging" v-model="dataList" use-page-scroll @query="queryList">
    <view class="py-20rpx">
      <view v-for="item in dataList" :key="item.id" class="bg-white px-22rpx py-18rpx">
        <view class="mb-8rpx flex items-center justify-between">
          <view>{{ $t('myOrders.order.id') }}: {{ item.bizNo }}</view>
          <view>{{ formatNumber(item.freezeAmount) }}</view>
        </view>
        <view class="flex items-center justify-between text-22rpx text-#3A444C">
          <view>{{ item.createTime }}</view>
          <wd-text type="primary" bold :text="item.status === 1 ? $t('wallet.frozenRecord.type.withdraw') : $t('wallet.frozenRecord.type.refund')" />
        </view>
      </view>
    </view>
  </z-paging>
</template>

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