This commit is contained in:
2026-04-29 11:39:05 +08:00
parent bb031d6a9f
commit 545f928f83
7 changed files with 442 additions and 322 deletions

2
src/components.d.ts vendored
View File

@@ -23,8 +23,8 @@ declare module 'vue' {
WdFormItem: typeof import('wot-design-uni/components/wd-form-item/wd-form-item.vue')['default']
WdIcon: typeof import('wot-design-uni/components/wd-icon/wd-icon.vue')['default']
WdInput: typeof import('wot-design-uni/components/wd-input/wd-input.vue')['default']
WdLoadmore: typeof import('wot-design-uni/components/wd-loadmore/wd-loadmore.vue')['default']
WdNavbar: typeof import('wot-design-uni/components/wd-navbar/wd-navbar.vue')['default']
WdPagination: typeof import('wot-design-uni/components/wd-pagination/wd-pagination.vue')['default']
WdPicker: typeof import('wot-design-uni/components/wd-picker/wd-picker.vue')['default']
WdPopup: typeof import('wot-design-uni/components/wd-popup/wd-popup.vue')['default']
WdTabbar: typeof import('wot-design-uni/components/wd-tabbar/wd-tabbar.vue')['default']

View File

@@ -1,10 +1,12 @@
<template>
<view class="min-h-screen bg-gray-50">
<!-- 收益列表 -->
<uni-list :loading="loading" :loadmore="loadMoreStatus" @loadmore="onLoadMore">
<EmptyState v-if="!loading && list.length === 0" text="暂无直推报告" />
<scroll-view
scroll-y
class="scroll-container"
@scrolltolower="onScrollToLower"
>
<EmptyState v-if="!loading && data.list.length === 0" text="暂无直推报告" />
<view v-for="(item, index) in list" :key="index" class="mx-4 my-2 bg-white rounded-lg p-4 shadow-sm">
<view v-for="(item, index) in data.list" :key="index" class="mx-4 my-2 bg-white rounded-lg p-4 shadow-sm">
<view class="flex justify-between items-center mb-2">
<text class="text-gray-500 text-sm">{{ item.create_time || '-' }}</text>
<text class="font-bold" :class="getAmountColor(item)">
@@ -27,17 +29,21 @@
</view>
</view>
<!-- 加载更多/加载完成提示 -->
<uni-load-more :status="loadMoreStatus" />
</uni-list>
<view v-if="loading" class="py-4 text-center text-sm text-gray-400">
加载中...
</view>
<view v-else-if="!data.list.length" class="py-4 text-center text-sm text-gray-400">
暂无记录
</view>
<wd-loadmore :state="loadMoreState" @reload="getData" />
</scroll-view>
</template>
<script setup>
import { ref, onMounted } from 'vue'
import { onPullDownRefresh } from '@dcloudio/uni-app'
import { getAgentCommission } from '@/apis/agent'
// 颜色配置(根据产品名称映射)
const typeColors = {
'老板企业报告': { bg: 'bg-blue-100', text: 'text-blue-800', dot: 'bg-blue-500' },
'人事背调': { bg: 'bg-green-100', text: 'text-green-800', dot: 'bg-green-500' },
@@ -46,24 +52,24 @@ const typeColors = {
'贷前背调': { bg: 'bg-orange-100', text: 'text-orange-800', dot: 'bg-orange-500' },
'租赁风险': { bg: 'bg-indigo-100', text: 'text-indigo-800', dot: 'bg-indigo-500' },
'个人风险': { bg: 'bg-red-100', text: 'text-red-800', dot: 'bg-red-500' },
// 默认类型
'default': { bg: 'bg-gray-100', text: 'text-gray-800', dot: 'bg-gray-500' }
}
const page = ref(1)
const pageSize = ref(10)
const total = ref(0)
const list = ref([])
const data = ref({
total: 0,
list: [],
})
const loading = ref(false)
const loadMoreStatus = ref('more') // 'more'|'loading'|'noMore'
const hasMore = ref(true)
const loadMoreState = ref('loading')
// 获取颜色样式
const getReportTypeStyle = (name) => {
const color = typeColors[name] || typeColors.default
return `${color.bg} ${color.text}`
}
// 获取小圆点颜色
const getDotColor = (name) => {
return (typeColors[name] || typeColors.default).dot
}
@@ -73,7 +79,6 @@ const toNumber = (value) => {
return Number.isFinite(n) ? n : 0
}
// 与 H5 对齐:优先显示 net_amount缺失时退化为 amount-refunded_amount
const getDisplayAmount = (item) => {
if (item && item.net_amount !== undefined && item.net_amount !== null)
return toNumber(item.net_amount)
@@ -119,77 +124,81 @@ const getStatusStyle = (item) => {
return 'bg-gray-100 text-gray-800'
}
// 加载更多数据
const onLoadMore = async () => {
if (loadMoreStatus.value === 'noMore') return
page.value++
await getData()
function mergeUniqueById(oldList, newList) {
const map = new Map()
const resolveKey = (item, index) => String(item?.id ?? item?.order_id ?? `${item?.create_time || ''}_${item?.product_name || ''}_${index}`)
oldList.forEach((item, index) => {
map.set(resolveKey(item, index), item)
})
newList.forEach((item, index) => {
map.set(resolveKey(item, oldList.length + index), item)
})
return Array.from(map.values())
}
// 获取数据
const getData = async () => {
async function getData(reset = false) {
try {
if (loading.value)
return
if (!reset && !hasMore.value)
return
loading.value = true
loadMoreStatus.value = 'loading'
if (reset) {
page.value = 1
hasMore.value = true
loadMoreState.value = 'loading'
data.value = { total: 0, list: [] }
}
const res = await getAgentCommission({
page: page.value,
page_size: pageSize.value
page_size: pageSize.value,
})
if (res.code === 200) {
// 首次加载
if (page.value === 1) {
list.value = res.data.list
total.value = res.data.total
} else {
// 分页加载
list.value.push(...res.data.list)
const incoming = res.data.list || []
data.value.total = res.data.total || 0
data.value.list = reset ? incoming : mergeUniqueById(data.value.list, incoming)
const isLastPage = incoming.length < pageSize.value || data.value.list.length >= data.value.total
hasMore.value = !isLastPage
loadMoreState.value = isLastPage ? 'finished' : 'loading'
if (!isLastPage)
page.value += 1
}
// 判断是否加载完成
if (list.value.length >= res.data.total || res.data.list.length < pageSize.value) {
loadMoreStatus.value = 'noMore'
} else {
loadMoreStatus.value = 'more'
else {
loadMoreState.value = 'error'
uni.showToast({ title: res.msg || '加载失败', icon: 'none' })
}
} else {
uni.showToast({
title: res.msg || '加载失败',
icon: 'none'
})
}
} catch (error) {
uni.showToast({
title: '网络错误',
icon: 'none'
})
} finally {
catch (error) {
loadMoreState.value = 'error'
uni.showToast({ title: '网络错误', icon: 'none' })
}
finally {
loading.value = false
}
}
// 页面加载
onMounted(() => {
function onScrollToLower() {
getData()
})
// 页面下拉刷新
const onPullDownRefresh = () => {
page.value = 1
loadMoreStatus.value = 'more'
getData().then(() => {
uni.stopPullDownRefresh()
})
}
// 导出页面生命周期方法
defineExpose({
onPullDownRefresh
onMounted(() => {
getData(true)
})
onPullDownRefresh(() => {
getData(true).then(() => {
uni.stopPullDownRefresh()
})
})
</script>
<style scoped>
.scroll-container {
height: 100vh;
}
</style>
<route type="page" lang="json">
{
"layout": "page",

View File

@@ -1,7 +1,9 @@
<template>
<view class="min-h-screen bg-gray-50">
<!-- 收益列表 -->
<uni-list :loading="loading" :loadmore="loadMoreStatus" @loadmore="onLoadMore">
<scroll-view
scroll-y
class="scroll-container"
@scrolltolower="onScrollToLower"
>
<EmptyState v-if="!loading && filteredList.length === 0" text="暂无收益记录" />
<view v-for="(item, index) in filteredList" :key="index" class="mx-4 my-2 bg-white rounded-lg p-4 shadow-sm">
@@ -18,17 +20,21 @@
</view>
</view>
<!-- 加载更多/加载完成提示 -->
<uni-load-more :status="loadMoreStatus" />
</uni-list>
<view v-if="loading" class="py-4 text-center text-sm text-gray-400">
加载中...
</view>
<view v-else-if="!data.list.length" class="py-4 text-center text-sm text-gray-400">
暂无记录
</view>
<wd-loadmore :state="loadMoreState" @reload="getData" />
</scroll-view>
</template>
<script setup>
import { ref, computed, reactive, onMounted } from 'vue'
import { ref, computed, onMounted } from 'vue'
import { onPullDownRefresh } from '@dcloudio/uni-app'
import { getAgentRewards } from '@/apis/agent'
// 类型映射配置
const typeConfig = {
descendant_promotion: {
chinese: '下级推广奖励',
@@ -54,102 +60,109 @@ const typeConfig = {
const page = ref(1)
const pageSize = ref(10)
const total = ref(0)
const list = ref([])
const data = ref({
total: 0,
list: [],
})
const loading = ref(false)
const loadMoreStatus = ref('more') // 'more'|'loading'|'noMore'
const hasMore = ref(true)
const loadMoreState = ref('loading')
const filteredList = computed(() => {
return (list.value || []).filter(item => {
return (data.value.list || []).filter(item => {
const type = item?.type
return type !== 'descendant_stay_activedescendant' && type !== 'new_active'
})
})
// 类型转中文
const typeToChinese = (type) => {
return typeConfig[type]?.chinese || typeConfig.default.chinese
}
// 获取颜色样式
const getReportTypeStyle = (type) => {
const config = typeConfig[type] || typeConfig.default
return `${config.color.bg} ${config.color.text}`
}
// 获取小圆点颜色
const getDotColor = (type) => {
return typeConfig[type]?.color.dot || typeConfig.default.color.dot
}
// 加载更多数据
const onLoadMore = async () => {
if (loadMoreStatus.value === 'noMore') return
page.value++
await getData()
function mergeUniqueById(oldList, newList) {
const map = new Map()
const resolveKey = (item, index) => String(item?.id ?? item?.order_id ?? `${item?.create_time || ''}_${item?.type || ''}_${index}`)
oldList.forEach((item, index) => {
map.set(resolveKey(item, index), item)
})
newList.forEach((item, index) => {
map.set(resolveKey(item, oldList.length + index), item)
})
return Array.from(map.values())
}
// 获取数据
const getData = async () => {
async function getData(reset = false) {
try {
if (loading.value)
return
if (!reset && !hasMore.value)
return
loading.value = true
loadMoreStatus.value = 'loading'
if (reset) {
page.value = 1
hasMore.value = true
loadMoreState.value = 'loading'
data.value = { total: 0, list: [] }
}
const res = await getAgentRewards({
page: page.value,
page_size: pageSize.value
page_size: pageSize.value,
})
if (res.code === 200) {
if (page.value === 1) {
list.value = res.data.list
total.value = res.data.total
} else {
list.value.push(...res.data.list)
const incoming = res.data.list || []
data.value.total = res.data.total || 0
data.value.list = reset ? incoming : mergeUniqueById(data.value.list, incoming)
const isLastPage = incoming.length < pageSize.value || data.value.list.length >= data.value.total
hasMore.value = !isLastPage
loadMoreState.value = isLastPage ? 'finished' : 'loading'
if (!isLastPage)
page.value += 1
}
if (list.value.length >= res.data.total || res.data.list.length < pageSize.value) {
loadMoreStatus.value = 'noMore'
} else {
loadMoreStatus.value = 'more'
else {
loadMoreState.value = 'error'
uni.showToast({ title: res.msg || '加载失败', icon: 'none' })
}
} else {
uni.showToast({
title: res.msg || '加载失败',
icon: 'none'
})
}
} catch (error) {
uni.showToast({
title: '网络错误',
icon: 'none'
})
} finally {
catch (error) {
loadMoreState.value = 'error'
uni.showToast({ title: '网络错误', icon: 'none' })
}
finally {
loading.value = false
}
}
// 页面加载
onMounted(() => {
function onScrollToLower() {
getData()
})
// 页面下拉刷新
const onPullDownRefresh = () => {
page.value = 1
loadMoreStatus.value = 'more'
getData().then(() => {
uni.stopPullDownRefresh()
})
}
// 导出页面生命周期方法
defineExpose({
onPullDownRefresh
onMounted(() => {
getData(true)
})
onPullDownRefresh(() => {
getData(true).then(() => {
uni.stopPullDownRefresh()
})
})
</script>
<style scoped>
.scroll-container {
height: 100vh;
}
</style>
<route type="page" lang="json">
{
"layout": "page",

View File

@@ -1,16 +1,22 @@
<script setup>
import { onMounted, ref } from 'vue'
import { onPullDownRefresh } from '@dcloudio/uni-app'
import { getAgentSubordinateContributionDetail } from '@/apis/agent'
const loading = ref(false)
const hasMore = ref(true)
const loadMoreState = ref('loading')
const page = ref(1)
const pageSize = 8
const total = ref(0)
const rewardDetails = ref([])
const pageSize = 10
const data = ref({
total: 0,
list: [],
})
const userInfo = ref({})
const summary = ref({})
const statistics = ref([])
const subordinateId = ref(0)
const initialized = ref(false)
function normalizeAgentLevel(value) {
const raw = String(value || '').trim()
@@ -72,11 +78,31 @@ function formatNumber(num) {
return Number(num).toFixed(2)
}
async function fetchRewardDetails() {
function mergeUniqueById(oldList, newList) {
const map = new Map()
const resolveKey = (item, index) => String(item?.id ?? `${item?.type || ''}_${item?.create_time || ''}_${index}`)
oldList.forEach((item, index) => {
map.set(resolveKey(item, index), item)
})
newList.forEach((item, index) => {
map.set(resolveKey(item, oldList.length + index), item)
})
return Array.from(map.values())
}
async function getData(reset = false) {
try {
if (loading.value || !subordinateId.value)
return
if (!reset && !hasMore.value)
return
loading.value = true
try {
if (reset) {
page.value = 1
hasMore.value = true
loadMoreState.value = 'loading'
data.value = { total: 0, list: [] }
}
const res = await getAgentSubordinateContributionDetail({
subordinate_id: subordinateId.value,
page: page.value,
@@ -118,19 +144,33 @@ async function fetchRewardDetails() {
item.amount = stats[keys[0]] || 0
item.count = stats[keys[1]] || 0
})
initialized.value = true
}
total.value = res.data.total || 0
rewardDetails.value = res.data.list || []
const incoming = res.data.list || []
data.value.total = res.data.total || 0
data.value.list = reset ? incoming : mergeUniqueById(data.value.list, incoming)
const isLastPage = incoming.length < pageSize || data.value.list.length >= data.value.total
hasMore.value = !isLastPage
loadMoreState.value = isLastPage ? 'finished' : 'loading'
if (!isLastPage)
page.value += 1
}
else {
loadMoreState.value = 'error'
uni.showToast({ title: res.msg || '加载失败', icon: 'none' })
}
}
catch (error) {
loadMoreState.value = 'error'
uni.showToast({ title: '网络错误', icon: 'none' })
}
finally {
loading.value = false
}
}
function onPageChange({ value }) {
page.value = value
fetchRewardDetails()
function onScrollToLower() {
getData()
}
onLoad((query) => {
@@ -144,12 +184,22 @@ onMounted(() => {
setTimeout(() => uni.navigateBack(), 800)
return
}
fetchRewardDetails()
getData(true)
})
onPullDownRefresh(() => {
getData(true).then(() => {
uni.stopPullDownRefresh()
})
})
</script>
<template>
<view class="reward-detail">
<scroll-view
scroll-y
class="scroll-container"
@scrolltolower="onScrollToLower"
>
<view class="p-4">
<view class="mb-4 rounded-xl bg-white p-5 shadow-sm">
<view class="mb-4 flex items-center justify-between">
@@ -221,15 +271,15 @@ onMounted(() => {
</view>
</view>
<view class="mb-4 rounded-xl bg-white p-4 shadow-sm">
<view class="rounded-xl bg-white p-4 shadow-sm">
<view class="text-base text-gray-800 font-medium">
贡献记录
</view>
<view class="detail-scroll p-4">
<view v-if="rewardDetails.length === 0" class="py-8 text-center text-gray-500">
<view>
<view v-if="!loading && data.list.length === 0" class="py-8 text-center text-gray-500">
暂无贡献记录
</view>
<view v-for="item in rewardDetails" v-else :key="item.id" class="reward-item">
<view v-for="item in data.list" v-else :key="item.id" class="reward-item">
<view class="mb-3 border-b border-gray-200 pb-3">
<view class="flex items-center justify-between">
<view>
@@ -252,24 +302,15 @@ onMounted(() => {
加载中...
</view>
</view>
<view class="px-4 pb-4">
<wd-pagination
v-model="page"
:total="total"
:page-size="pageSize"
show-icon
show-message
@change="onPageChange"
/>
</view>
</view>
<wd-loadmore :state="loadMoreState" @reload="getData" />
</view>
</view>
</scroll-view>
</template>
<style scoped>
.reward-detail {
min-height: 100vh;
.scroll-container {
height: 100vh;
background-color: #f5f5f5;
}
@@ -280,10 +321,6 @@ onMounted(() => {
.reward-item:active {
transform: scale(0.98);
}
.detail-scroll {
min-height: 50vh;
}
</style>
<route type="page" lang="json">

View File

@@ -1,14 +1,17 @@
<script setup>
import { onMounted, ref } from 'vue'
import { onPullDownRefresh } from '@dcloudio/uni-app'
import { getAgentSubordinateList } from '@/apis/agent'
const subordinates = ref([])
const loading = ref(false)
const page = ref(1)
const pageSize = 8
const statistics = ref({
totalSubordinates: 0,
const data = ref({
total: 0,
list: [],
})
const loading = ref(false)
const hasMore = ref(true)
const loadMoreState = ref('loading')
const page = ref(1)
const pageSize = 10
function normalizeLevel(value) {
const raw = String(value || '').trim()
@@ -51,28 +54,61 @@ function formatNumber(num) {
return Number(num).toFixed(2)
}
async function fetchSubordinates() {
function mergeUniqueById(oldList, newList) {
const map = new Map()
const resolveKey = (item, index) => String(item?.id ?? `${item?.mobile || ''}_${item?.create_time || ''}_${index}`)
oldList.forEach((item, index) => {
map.set(resolveKey(item, index), item)
})
newList.forEach((item, index) => {
map.set(resolveKey(item, oldList.length + index), item)
})
return Array.from(map.values())
}
async function getData(reset = false) {
try {
if (loading.value)
return
if (!reset && !hasMore.value)
return
loading.value = true
try {
if (reset) {
page.value = 1
hasMore.value = true
loadMoreState.value = 'loading'
data.value = { total: 0, list: [] }
}
const res = await getAgentSubordinateList({
page: page.value,
page_size: pageSize,
})
if (res.code === 200) {
statistics.value.totalSubordinates = res.data.total || 0
subordinates.value = res.data.list || []
const incoming = res.data.list || []
data.value.total = res.data.total || 0
data.value.list = reset ? incoming : mergeUniqueById(data.value.list, incoming)
const isLastPage = incoming.length < pageSize || data.value.list.length >= data.value.total
hasMore.value = !isLastPage
loadMoreState.value = isLastPage ? 'finished' : 'loading'
if (!isLastPage)
page.value += 1
}
else {
loadMoreState.value = 'error'
uni.showToast({ title: res.msg || '加载失败', icon: 'none' })
}
}
catch (error) {
loadMoreState.value = 'error'
uni.showToast({ title: '网络错误', icon: 'none' })
}
finally {
loading.value = false
}
}
function onPageChange({ value }) {
page.value = value
fetchSubordinates()
function onScrollToLower() {
getData()
}
function viewDetail(item) {
@@ -87,12 +123,22 @@ function viewDetail(item) {
}
onMounted(() => {
fetchSubordinates()
getData(true)
})
onPullDownRefresh(() => {
getData(true).then(() => {
uni.stopPullDownRefresh()
})
})
</script>
<template>
<view class="subordinate-list">
<scroll-view
scroll-y
class="scroll-container"
@scrolltolower="onScrollToLower"
>
<view class="p-4 pb-0">
<view class="rounded-xl bg-white p-4 shadow-sm">
<view class="flex items-center justify-center">
@@ -101,15 +147,15 @@ onMounted(() => {
下级总数
</view>
<view class="text-2xl text-blue-600 font-semibold">
{{ statistics.totalSubordinates }}
{{ data.total }}
</view>
</view>
</view>
</view>
</view>
<view class="subordinate-scroll p-4">
<view v-for="(item, index) in subordinates" :key="item.id" class="subordinate-item">
<view class="p-4">
<view v-for="(item, index) in data.list" :key="item.id" class="subordinate-item">
<view class="mb-4 flex flex-col rounded-xl bg-white p-5 shadow-sm">
<view class="mb-4 flex items-center justify-between">
<view class="flex items-center space-x-3">
@@ -169,33 +215,20 @@ onMounted(() => {
<view v-if="loading" class="py-4 text-center text-sm text-gray-400">
加载中...
</view>
<view v-else-if="!subordinates.length" class="py-4 text-center text-sm text-gray-400">
<view v-else-if="!data.list.length" class="py-4 text-center text-sm text-gray-400">
暂无下级代理
</view>
</view>
<view class="px-4 pb-4">
<wd-pagination
v-model="page"
:total="statistics.totalSubordinates"
:page-size="pageSize"
show-icon
show-message
@change="onPageChange"
/>
</view>
</view>
<wd-loadmore :state="loadMoreState" @reload="getData" />
</scroll-view>
</template>
<style scoped>
.subordinate-list {
min-height: 100vh;
.scroll-container {
height: 100vh;
background-color: #f5f5f5;
}
.subordinate-scroll {
height: calc(100vh - 180px);
}
.subordinate-item {
transition: transform 0.2s;
}

View File

@@ -1,10 +1,12 @@
<template>
<view class="min-h-screen bg-gray-50">
<!-- 提现记录列表 -->
<uni-list :loading="loading" :loadmore="loadMoreStatus" @loadmore="onLoadMore">
<EmptyState v-if="!loading && list.length === 0" text="暂无提现记录" />
<scroll-view
scroll-y
class="scroll-container"
@scrolltolower="onScrollToLower"
>
<EmptyState v-if="!loading && data.list.length === 0" text="暂无提现记录" />
<view v-for="(item, index) in list" :key="index" class="mx-4 my-2 bg-white rounded-lg p-4 shadow-sm">
<view v-for="(item, index) in data.list" :key="index" class="mx-4 my-2 bg-white rounded-lg p-4 shadow-sm">
<view class="flex justify-between items-center mb-2">
<text class="text-gray-500 text-sm">{{ item.create_time || '-' }}</text>
<text class="font-bold" :class="getAmountColor(item.status)">{{ item.amount.toFixed(2) }}</text>
@@ -22,18 +24,22 @@
</view>
</view>
<!-- 加载更多/加载完成提示 -->
<uni-load-more :status="loadMoreStatus" />
</uni-list>
<view v-if="loading" class="py-4 text-center text-sm text-gray-400">
加载中...
</view>
<view v-else-if="!data.list.length" class="py-10 text-center text-sm text-gray-400">
暂无提现记录
</view>
<wd-loadmore :state="loadMoreState" @reload="getData" />
</scroll-view>
</template>
<script setup>
import { ref, reactive, onMounted } from 'vue'
import { ref, onMounted } from 'vue'
import { onPullDownRefresh } from '@dcloudio/uni-app'
import { getWithdrawalRecords } from '@/apis/agent'
import { maskName } from '@/utils/format'
// 状态映射配置
const statusConfig = {
1: {
chinese: '处理中',
@@ -66,103 +72,106 @@ const statusConfig = {
const page = ref(1)
const pageSize = ref(10)
const total = ref(0)
const list = ref([])
const data = ref({
total: 0,
list: [],
})
const loading = ref(false)
const loadMoreStatus = ref('more') // 'more'|'loading'|'noMore'
const hasMore = ref(true)
const loadMoreState = ref('loading')
// 状态转中文
const statusToChinese = (status) => {
return statusConfig[status]?.chinese || '未知状态'
}
// 获取状态样式
const getStatusStyle = (status) => {
const config = statusConfig[status] || {}
return `${config.color?.bg || 'bg-gray-100'} ${config.color?.text || 'text-gray-800'}`
}
// 获取小圆点颜色
const getDotColor = (status) => {
return statusConfig[status]?.color.dot || 'bg-gray-500'
}
// 获取金额颜色
const getAmountColor = (status) => {
return statusConfig[status]?.color.amount || 'text-gray-500'
}
// 加载更多数据
const onLoadMore = async () => {
if (loadMoreStatus.value === 'noMore') return
page.value++
await getData()
function mergeUniqueById(oldList, newList) {
const map = new Map()
const resolveKey = (item, index) => String(item?.id ?? item?.withdraw_no ?? `${item?.create_time || ''}_${item?.amount || ''}_${index}`)
oldList.forEach((item, index) => {
map.set(resolveKey(item, index), item)
})
newList.forEach((item, index) => {
map.set(resolveKey(item, oldList.length + index), item)
})
return Array.from(map.values())
}
// 获取数据
const getData = async () => {
async function getData(reset = false) {
try {
if (loading.value)
return
if (!reset && !hasMore.value)
return
loading.value = true
loadMoreStatus.value = 'loading'
if (reset) {
page.value = 1
hasMore.value = true
loadMoreState.value = 'loading'
data.value = { total: 0, list: [] }
}
const res = await getWithdrawalRecords({
page: page.value,
page_size: pageSize.value
page_size: pageSize.value,
})
if (res.code === 200) {
if (page.value === 1) {
list.value = res.data.list
total.value = res.data.total
} else {
list.value.push(...res.data.list)
const incoming = res.data.list || []
data.value.total = res.data.total || 0
data.value.list = reset ? incoming : mergeUniqueById(data.value.list, incoming)
const isLastPage = incoming.length < pageSize.value || data.value.list.length >= data.value.total
hasMore.value = !isLastPage
loadMoreState.value = isLastPage ? 'finished' : 'loading'
if (!isLastPage)
page.value += 1
}
if (list.value.length >= res.data.total || res.data.list.length < pageSize.value) {
loadMoreStatus.value = 'noMore'
} else {
loadMoreStatus.value = 'more'
else {
loadMoreState.value = 'error'
uni.showToast({ title: res.msg || '加载失败', icon: 'none' })
}
} else {
uni.showToast({
title: res.msg || '加载失败',
icon: 'none'
})
}
} catch (error) {
uni.showToast({
title: '网络错误',
icon: 'none'
})
} finally {
catch (error) {
loadMoreState.value = 'error'
uni.showToast({ title: '网络错误', icon: 'none' })
}
finally {
loading.value = false
}
}
// 页面加载
onMounted(() => {
function onScrollToLower() {
getData()
})
// 页面下拉刷新
const onPullDownRefresh = () => {
page.value = 1
loadMoreStatus.value = 'more'
getData().then(() => {
uni.stopPullDownRefresh()
})
}
// 导出页面生命周期方法
defineExpose({
onPullDownRefresh
onMounted(() => {
getData(true)
})
onPullDownRefresh(() => {
getData(true).then(() => {
uni.stopPullDownRefresh()
})
})
</script>
<style>
/* 自定义样式 */
<style scoped>
.scroll-container {
height: 100vh;
}
</style>
<route type="page" lang="json">{
"layout": "page",
"title": "提现记录",

View File

@@ -99,6 +99,25 @@ function request(options) {
success: (res) => {
// 响应拦截器逻辑
if (res.statusCode === 200) {
// 检测会员过期响应头,自动刷新代理信息
const header = res.header || {}
if (header['X-Membership-Expired'] === 'true' || header['x-membership-expired'] === 'true') {
const { getAgentInfo } = require('@/apis/agent.js')
getAgentInfo().then(res => {
if (res.code === 200 && res.data) {
uni.setStorageSync('agentInfo', {
level: res.data.level,
isAgent: res.data.is_agent,
status: res.data.status,
agentID: res.data.agent_id,
mobile: res.data.mobile,
isRealName: res.data.is_real_name,
expiryTime: res.data.expiry_time
})
}
}).catch(() => {})
}
if (res.data?.code === USER_DISABLED_CODE || res.data?.code === USER_CANCELLED_CODE) {
forceLogoutToLogin()
reject(res.data)