Files
shanxia2.0/miniprogram/pages/bx/advance/list.vue
T
2026-07-18 09:14:02 +08:00

89 lines
2.9 KiB
Vue

<script setup>
import { ref } from 'vue'
import { onShow, onReachBottom } from '@dcloudio/uni-app'
import { listMyAdvance } from '@/api/bx'
import { bxStatusLabel, formatMoney, dash } from '@/utils/bxLabels'
import { PAGE_PATHS } from '@/config/api'
const list = ref([])
const page = ref(1)
const total = ref(0)
const loading = ref(false)
const finished = ref(false)
const pageSize = 20
const goBack = () => {
uni.navigateBack({
fail: () => uni.switchTab({ url: PAGE_PATHS.workbench })
})
}
const goForm = () => uni.navigateTo({ url: PAGE_PATHS.bxAdvanceForm })
const goDetail = (row) =>
uni.navigateTo({ url: `${PAGE_PATHS.bxAdvanceDetail}?id=${row.id}` })
const loadList = async (reset = false) => {
if (loading.value) return
if (reset) {
page.value = 1
finished.value = false
list.value = []
}
if (finished.value) return
loading.value = true
try {
const res = await listMyAdvance({ page: page.value, pageSize })
const rows = res.rows || []
list.value = reset ? rows : list.value.concat(rows)
total.value = res.total || 0
if (list.value.length >= total.value || rows.length < pageSize) finished.value = true
else page.value += 1
} catch (e) {
uni.showToast({ title: e.message || '加载失败', icon: 'none' })
} finally {
loading.value = false
}
}
onShow(() => loadList(true))
onReachBottom(() => loadList(false))
</script>
<template>
<view class="mp-page mp-page--sub">
<view class="mp-header mp-header--bx">
<view class="mp-header__row">
<text class="mp-subpage-back" @click="goBack">← 工作台</text>
<view class="mp-header__action" @click="goForm">+ 申请</view>
</view>
<text class="mp-header__title" style="margin-top: 16rpx">借款申请</text>
</view>
<view class="mp-section">
<mp-empty v-if="!list.length && !loading" title="暂无借款单" />
<view v-else class="mp-list">
<view v-for="row in list" :key="row.id" class="mp-card" @click="goDetail(row)">
<view class="mp-card__head">
<view>
<text class="mp-card__title">{{ dash(row.applyCode) }}</text>
<text class="mp-card__sub">{{ dash(row.reason) }}</text>
</view>
<text class="mp-tag" :class="'mp-tag--' + bxStatusLabel(row.status).tag">
{{ bxStatusLabel(row.status).text }}
</text>
</view>
<view class="mp-card__row">
<text>申请时间</text>
<text class="mp-card__row-val">{{ dash(row.applyTime) }}</text>
</view>
<view class="mp-card__foot">
<text class="mp-card__amount">{{ formatMoney(row.amount) }}</text>
</view>
</view>
</view>
<view v-if="loading" class="mp-list-loading">加载中…</view>
<view v-else-if="finished && list.length" class="mp-list-end">已加载全部</view>
</view>
</view>
</template>