Files
kangyuan-mobile/pages/home/noReleaseAmount.vue
T

274 lines
6.0 KiB
Vue

<template>
<s-pages title="收支明细" :blue_bg="true" navPreset="float">
<view class="page" @click="filterOpen = false">
<view class="hero-card">
<view class="hero-left">
<view class="hero-title">未行权金额</view>
<view class="hero-amount">{{ $fen2yuan(totalAmount) }}</view>
</view>
<image class="hero-illustration" src="/static/icon/mingxi.svg" mode="aspectFit" />
</view>
<view class="detail-card">
<view class="detail-header">
<view class="detail-title">收支明细</view>
<view class="detail-filter" @click.stop="filterOpen = !filterOpen">
{{ filterOptions[filterIndex]?.text || '全部' }}
<text class="detail-arrow">▼</text>
</view>
<view class="detail-filter-menu" v-if="filterOpen" @click.stop>
<view
class="detail-filter-item"
v-for="(opt, i) in filterOptions"
:key="opt.value"
@click.stop="onFilterChange(i)"
>
{{ opt.text }}
</view>
</view>
</view>
<card_mescroll ref="cardPages" @upCallback="getList" :height="listHeight">
<view class="detail-item" v-for="(item, index) in detailList" :key="index">
<view class="detail-main">
<view class="detail-name">{{ getItemTitle(item) }}</view>
<view class="detail-time">{{ formatDate(item.createTime) }}</view>
</view>
<view class="detail-amount">
{{ getItemAmount(item) > 0 ? '+' : '' }}{{ $fen2yuan(getItemAmount(item)) }}
</view>
</view>
</card_mescroll>
</view>
</view>
</s-pages>
</template>
<script setup>
import { ref } from 'vue';
import { onShow } from '@dcloudio/uni-app';
import card_mescroll from '@/components/card_pages/card_mescroll.vue';
import * as api from '@/sheep/api/home/pay';
import { formatDate, sourceTypeObj } from '@/sheep/helper/utils';
const totalAmount = ref(0);
const detailList = ref([]);
const cardPages = ref(null);
const filterOpen = ref(false);
const filterIndex = ref(0);
const filterOptions = [
// {
// value: 0,
// text: '全部',
// },
{
value: 1,
text: '佣金',
},
{
value: 2,
text: '收益',
},
{
value: 3,
text: '分红',
},
{
value: 4,
text: '其他',
},
];
const sysInfo = uni.getSystemInfoSync();
const listHeight =
sysInfo.windowHeight -
sysInfo.statusBarHeight -
uni.upx2px(88) -
uni.upx2px(280) -
uni.upx2px(32) -
uni.upx2px(40) +
'px';
const getHeaderData = async () => {
const res = await api.agentEarningsTrendNew({}).catch(() => ({ code: -1 }));
if (res.code === 0) {
totalAmount.value = res.data?.remainingEarningAll || 0;
}
};
const getList = async (mescroll) => {
const opt = filterOptions[filterIndex.value] || filterOptions[0];
const res = await api
.agentEarningsIncomeDetailsPage({
pageNo: mescroll.num,
pageSize: mescroll.size,
...(opt.value ? { transactionType: opt.value } : {}),
})
.catch(() => ({ code: -1 }));
if (res.code === 0) {
const list = res.data?.list || [];
if (mescroll.num === 1) detailList.value = [];
detailList.value = detailList.value.concat(list);
cardPages.value?.getState(true, list.length);
return;
}
cardPages.value?.getState(false);
};
const getItemTitle = (item) => {
return item?.remark || item?.title || sourceTypeObj[Number(item?.sourceType) || 1] || '未行权金额';
};
const getItemAmount = (item) => {
const raw = item?.totalEarnings ?? item?.amount ?? item?.price ?? item?.remainingEarning ?? 0;
const n = Number(raw);
return Number.isFinite(n) ? n : 0;
};
const onFilterChange = (i) => {
filterIndex.value = i;
filterOpen.value = false;
cardPages.value?.mescrollTrigger();
};
onShow(() => {
getHeaderData();
cardPages.value?.mescrollTrigger();
});
</script>
<style lang="scss" scoped>
.page {
padding: 32rpx 40rpx 0;
}
.hero-card {
height: 220rpx;
border-radius: 16rpx;
padding: 36rpx 32rpx;
display: flex;
align-items: center;
justify-content: space-between;
// background: url("https://sycbuck.oss-cn-hangzhou.aliyuncs.com/app/home/agency2.png")
// center / 100% 100% no-repeat;
background: linear-gradient(135deg, #ffc6e6 0%, #fb7f33 100%);
margin-bottom: 32rpx;
}
.hero-left {
color: #ffffff;
}
.hero-title {
font-size: 36rpx;
line-height: 50rpx;
font-weight: 500;
// opacity: 0.75;
}
.hero-amount {
margin-top: 18rpx;
font-size: 68rpx;
line-height: 82rpx;
font-weight: 700;
}
.hero-illustration {
width: 220rpx;
height: 136rpx;
flex-shrink: 0;
filter: brightness(0) invert(1);
}
.detail-card {
background: rgba(255, 255, 255, 0.98);
border-radius: 24rpx 24rpx 0 0;
padding: 0 24rpx;
}
.detail-title {
font-size: 32rpx;
line-height: 110rpx;
color: #111111;
font-weight: 500;
}
.detail-header {
position: relative;
display: flex;
align-items: center;
justify-content: space-between;
height: 110rpx;
}
.detail-filter {
height: 52rpx;
line-height: 52rpx;
padding: 0 18rpx;
background: #f2f4f7;
border-radius: 16rpx;
font-size: 24rpx;
color: #111111;
display: flex;
align-items: center;
}
.detail-arrow {
margin-left: 10rpx;
font-size: 22rpx;
}
.detail-filter-menu {
position: absolute;
right: 0;
top: 110rpx;
width: 160rpx;
background: #f2f4f7;
border-radius: 16rpx;
z-index: 10;
overflow: hidden;
}
.detail-filter-item {
text-align: center;
line-height: 72rpx;
font-size: 26rpx;
color: #111111;
}
.detail-item {
display: flex;
align-items: center;
justify-content: space-between;
padding: 32rpx 0;
border-bottom: 2rpx solid #f1f2f5;
}
.detail-main {
flex: 1;
padding-right: 24rpx;
}
.detail-name {
font-size: 28rpx;
line-height: 40rpx;
color: #111111;
}
.detail-time {
margin-top: 10rpx;
font-size: 24rpx;
line-height: 34rpx;
color: #999999;
}
.detail-amount {
flex-shrink: 0;
font-size: 32rpx;
line-height: 46rpx;
color: #ee0a24;
font-weight: 500;
}
</style>