<template>
  <PageLayout>
    <template #header-right>
      <q-btn flat dense :to="{path:'/customer/wallet/draw/history',query:{t:Date.now()}}">历史记录</q-btn>
    </template>
    <infinite-scroll :load="load" :list="list" ref="scrollRef">
      <template #prepend>
        <q-tabs
          v-model="tab"
          no-caps
          dense
          active-color="primary"
          indicator-color="primary"
          class="bg-white"
        >
          <q-tab v-for="item in tabs" :name="item.id" :key="item.id">
            {{ item.name }}
            <!-- DELAY 暂时隐藏 -->
            <!-- （{{ formatMoney(item.money||0) }}） -->
          </q-tab>
        </q-tabs>
        <WarnTip class="text-left">用户提现由店主进行打款处理，请知悉。</WarnTip>
      </template>
      <template v-slot="{ item }">
        <DrawMoneyItem :item="item" />
      </template>
    </infinite-scroll>
  </PageLayout>
</template>
<script setup>
import { ref, onMounted, reactive,watch,onActivated } from "vue";
import { onBeforeRouteUpdate, useRoute, useRouter } from "vue-router";
import { useSelfStore } from "stores/self";
import { api } from "boot/axios";
import { useQuasar } from "quasar";
import { useInfiniteScroll } from 'src/composables/infiniteScroll';
import DrawMoneyItem from "./components/DrawMoneyItem.vue";
import { formatMoney } from 'src/utils/tools'
import { PAY_TYPES } from "src/utils/const";
const $q = useQuasar();
const route = useRoute();
const router = useRouter();
const store = useSelfStore();

const tabs = ref(JSON.parse(JSON.stringify(PAY_TYPES)))
const tab = ref(Object.values(PAY_TYPES)[0].id)
const { list, refresh, load,scrollRef } = useInfiniteScroll((page)=>{
  return api.getCustomerWithdrawList({
    page,
    state:1,
    type: tab.value,
    // customer_id:''
  }).then((res) => {
    // !tabs.value.length && res.tabs && (tabs.value = res.tabs)
    return res
  });
})
watch(tab,refresh)

let enterTime = route.query.t
onActivated(()=>{
  if(route.query.t!=enterTime){
    enterTime = route.query.t
    refresh()
  }
})
</script>
<style lang="scss" scoped></style>
