init
This commit is contained in:
@@ -0,0 +1,661 @@
|
||||
<template>
|
||||
<s-pages title="我的收益">
|
||||
|
||||
<view class="pages">
|
||||
<!-- 1 -->
|
||||
<view class="section-1" :style="{ backgroundImage: 'url(' + $url + 'home/agency2.png' + ')' }">
|
||||
<view class="section1-content">
|
||||
<view class="date">{{ currentDate }}</view>
|
||||
<view class="title">今日收益(元)</view>
|
||||
<view class="num">{{ $fen2yuan(trendObj?.earnings || 0) }}</view>
|
||||
<view class="line" />
|
||||
<view class="flex align-center">
|
||||
<view class="title">未行权金额(元)</view>
|
||||
<view class="num2">{{ $fen2yuan(norelease || 0) }}</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 2 -->
|
||||
<view class="section-2">
|
||||
<view class="title">收益趋势<text>(近7天)</text></view>
|
||||
<view class="wrap">
|
||||
<card_echart :options="chartOption" />
|
||||
</view>
|
||||
</view>
|
||||
<!-- 3 -->
|
||||
<view class="section-3">
|
||||
<view class="item" v-for="(item, i) in navList" :key="i">
|
||||
<view class="title" :class="navCur === i ? 'active' : ''" @click="changeNav(item, i)">{{ item.text
|
||||
}}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 4 -->
|
||||
<view class="section-4">
|
||||
<view class="select-bar">
|
||||
<view class="left">
|
||||
<picker mode="date" fields="month" :value="date" @change="bindDateChange">
|
||||
<view class="selected-date">{{ currentMonth }} <text class="size18">▼</text></view>
|
||||
<view class="num">收益 ¥{{monthEarnings}}</view>
|
||||
</picker>
|
||||
</view>
|
||||
<view class="right">
|
||||
<view class="bar" @click="select_show = !select_show" v-if="navCur === 2">
|
||||
{{ select_value }}
|
||||
<text class="size18">▼</text>
|
||||
</view>
|
||||
<view class="select-content" v-if="select_show">
|
||||
<view class="select-item" v-for="(item, index) in range" :key="index"
|
||||
@click="changeSelect(item, index)">
|
||||
{{ item.text }}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<card_mescroll ref="cardPages" @upCallback="getList" :height="'540rpx'">
|
||||
<view class="item" v-for="(item, i) in infoArr" :key="i">
|
||||
<view class="left">
|
||||
<view class="title">
|
||||
{{ item.title }}
|
||||
</view>
|
||||
<view class="date">{{ item.time }}</view>
|
||||
</view>
|
||||
<view class="right">{{ item.money }}</view>
|
||||
</view>
|
||||
</card_mescroll>
|
||||
</view>
|
||||
</view>
|
||||
</s-pages>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {
|
||||
ref,
|
||||
reactive,
|
||||
onMounted,
|
||||
onUnmounted,
|
||||
getCurrentInstance,
|
||||
watch,
|
||||
nextTick
|
||||
} from 'vue';
|
||||
import card_mescroll from '@/components/card_pages/card_mescroll.vue';
|
||||
import * as echarts from 'echarts';
|
||||
let {
|
||||
proxy
|
||||
} = getCurrentInstance();
|
||||
import * as api from '@/sheep/api/home/index';
|
||||
import * as api2 from '@/sheep/api/home/pay';
|
||||
import {
|
||||
formatDate,
|
||||
sourceTypeObj
|
||||
} from '@/sheep/helper/utils';
|
||||
import card_echart from '@/components/card_echart/card_echart.vue';
|
||||
import {
|
||||
fen2yuan
|
||||
} from '@/sheep/hooks/useGoods';
|
||||
let list = ref([]);
|
||||
let obj = ref({});
|
||||
let infoArr = ref([]);
|
||||
const chartRef = ref(null);
|
||||
const currentDate = ref('');
|
||||
const currentMonth = ref('');
|
||||
const currentMonth2 = ref('');
|
||||
let cardPages = ref(null);
|
||||
let height = ref('20rpx');
|
||||
const norelease = ref(0)
|
||||
const monthEarnings = ref(0)
|
||||
const date = ref()
|
||||
//navbar
|
||||
const navCur = ref(0)
|
||||
const navList = ref([{
|
||||
value: 1,
|
||||
text: "全部",
|
||||
url: api2.getWalletTransactionPage,
|
||||
},
|
||||
{
|
||||
value: 2,
|
||||
text: "佣金",
|
||||
url: api2.commissionDetailPage,
|
||||
},
|
||||
{
|
||||
value: 3,
|
||||
text: "收益",
|
||||
url: api2.agentEarningsDetailPage,
|
||||
},
|
||||
{
|
||||
value: 4,
|
||||
text: "分红",
|
||||
url: api2.dividendDetailPage,
|
||||
},
|
||||
])
|
||||
//
|
||||
const select_show = ref(false);
|
||||
const select_value = ref();
|
||||
const select_cur = ref(0);
|
||||
const range = ref([{
|
||||
value: 0,
|
||||
text: "全部"
|
||||
}, {
|
||||
value: 1,
|
||||
text: "店长收益"
|
||||
},
|
||||
{
|
||||
value: 2,
|
||||
text: "权益收益"
|
||||
},
|
||||
{
|
||||
value: 3,
|
||||
text: "代理收益"
|
||||
},
|
||||
{
|
||||
value: 4,
|
||||
text: "其他"
|
||||
},
|
||||
]);
|
||||
const chartOption = ref({
|
||||
// 添加grid配置,实现间距自适应
|
||||
grid: {
|
||||
left: '3%',
|
||||
right: '4%',
|
||||
bottom: '3%',
|
||||
top: '0',
|
||||
height: 150,
|
||||
},
|
||||
// 简化全局坐标轴指示器配置
|
||||
axisPointer: {
|
||||
type: 'cross',
|
||||
snap: true, // 吸附到最近的数据点
|
||||
crossStyle: {
|
||||
color: '#EE0A24',
|
||||
},
|
||||
// 修正lineStyle缩进
|
||||
lineStyle: {
|
||||
color: '#EE0A24',
|
||||
type: 'dashed',
|
||||
width: 1,
|
||||
},
|
||||
},
|
||||
// 调整tooltip配置,确保点击时显示数据框
|
||||
tooltip: {
|
||||
trigger: 'axis',
|
||||
triggerOn: 'click', // 只在点击时触发
|
||||
backgroundColor: 'rgba(255, 255, 255, 0.9)',
|
||||
borderColor: '#EE0A24',
|
||||
borderWidth: 1,
|
||||
padding: 8,
|
||||
textStyle: {
|
||||
color: '#333',
|
||||
fontSize: 12,
|
||||
},
|
||||
formatter: function(params) {
|
||||
const data = params[0];
|
||||
return `日期: ${data.axisValue}<br/>收益: ${data.value.toFixed(2)}`;
|
||||
},
|
||||
extraCssText: 'border-radius: 4px; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);',
|
||||
// 修改position配置,使用默认位置
|
||||
position: 'top',
|
||||
axisPointer: {
|
||||
type: 'cross',
|
||||
crossStyle: {
|
||||
color: '#EE0A24',
|
||||
},
|
||||
},
|
||||
},
|
||||
xAxis: {
|
||||
type: 'category',
|
||||
data: [],
|
||||
axisLabel: {
|
||||
color: '#BBBBBB',
|
||||
},
|
||||
axisLine: {
|
||||
lineStyle: {
|
||||
color: '#D9D9D9',
|
||||
type: 'dashed',
|
||||
},
|
||||
},
|
||||
// x轴独立的axisPointer配置
|
||||
axisPointer: {
|
||||
type: 'shadow',
|
||||
snap: true,
|
||||
label: {
|
||||
show: true,
|
||||
backgroundColor: 'rgba(238, 10, 36, 0.8)',
|
||||
color: '#fff',
|
||||
padding: [3, 6],
|
||||
fontSize: 12,
|
||||
formatter: function(params) {
|
||||
return ``;
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
yAxis: {
|
||||
type: 'value',
|
||||
splitLine: {
|
||||
lineStyle: {
|
||||
color: '#D9D9D9',
|
||||
type: 'dashed',
|
||||
},
|
||||
},
|
||||
axisLabel: {
|
||||
color: '#BBBBBB',
|
||||
},
|
||||
// y轴独立的axisPointer配置
|
||||
axisPointer: {
|
||||
type: 'line',
|
||||
snap: true,
|
||||
label: {
|
||||
show: true,
|
||||
backgroundColor: 'rgba(238, 10, 36, 0.8)',
|
||||
color: '#fff',
|
||||
padding: [3, 6],
|
||||
fontSize: 12,
|
||||
formatter: function(params) {
|
||||
return `收益: ${params.value.toFixed(2)}`;
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
series: [{
|
||||
data: [],
|
||||
smooth: true,
|
||||
type: 'line',
|
||||
symbol: 'none', // 不显示数据点
|
||||
lineStyle: {
|
||||
color: '#EE0A24',
|
||||
},
|
||||
triggerEvent: true, // 确保事件可以被触发
|
||||
areaStyle: {
|
||||
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
|
||||
offset: 0,
|
||||
color: '#EE0A24'
|
||||
},
|
||||
{
|
||||
offset: 0.1,
|
||||
color: '#C1261F'
|
||||
},
|
||||
{
|
||||
offset: 1,
|
||||
color: 'rgba(235,110,57,0)'
|
||||
},
|
||||
]),
|
||||
},
|
||||
emphasis: {
|
||||
focus: 'series',
|
||||
itemStyle: {
|
||||
color: '#EE0A24',
|
||||
borderColor: '#fff',
|
||||
borderWidth: 2,
|
||||
},
|
||||
showSymbol: true, // 点击时显示数据点
|
||||
symbolSize: 10, // 数据点大小
|
||||
},
|
||||
// 移除重复的showSymbol设置
|
||||
}, ],
|
||||
// 移动端优化配置
|
||||
animation: false, // 禁用动画以提高性能
|
||||
touchMoveThreshold: 10, // 增加触摸移动阈值,避免误触
|
||||
roam: false, // 禁止缩放和平移
|
||||
});
|
||||
let trendObj = ref({});
|
||||
|
||||
|
||||
//navbar选择
|
||||
function changeNav(e, i) {
|
||||
navCur.value = i
|
||||
cardPages.value.mescrollTrigger();
|
||||
}
|
||||
//收益下拉框选择
|
||||
function changeSelect(e, i) {
|
||||
// console.log(e);
|
||||
select_value.value = e.text
|
||||
select_cur.value = e.value
|
||||
select_show.value = !select_show.value
|
||||
if (cardPages.value && cardPages.value.mescrollTrigger) {
|
||||
cardPages.value.mescrollTrigger();
|
||||
}
|
||||
}
|
||||
//获取未行权收益
|
||||
function getRelease() {
|
||||
api2.agentEarningsTrendNew().then((res) => {
|
||||
if (res.code === 0) {
|
||||
// norelease.value = res.data.remainingEarningAll
|
||||
}
|
||||
});
|
||||
}
|
||||
// 七天收益
|
||||
const getData = () => {
|
||||
api2.agentEarningsTrendNew({}).then((res) => {
|
||||
if (res.code === 0) {
|
||||
list.value = res.data.list || [];
|
||||
if (list.value.length) {
|
||||
trendObj.value = list.value[list.value.length - 1];
|
||||
|
||||
chartOption.value.xAxis.data = list.value.map((item) => {
|
||||
// 将日期从2023-09-01变为09/01格式
|
||||
item.date = item.date.split('-').slice(1).join('/');
|
||||
return item.date;
|
||||
});
|
||||
chartOption.value.series[0].data = list.value.map((item) => {
|
||||
return proxy.$fen2yuan(item.earnings);
|
||||
});
|
||||
}
|
||||
|
||||
norelease.value = res.data.remainingEarningAll
|
||||
}
|
||||
});
|
||||
};
|
||||
//列表
|
||||
const getList = (mescroll) => {
|
||||
const cfg = navList.value[navCur.value];
|
||||
if (!cfg || !cfg.url) {
|
||||
cardPages.value.getState(false);
|
||||
return;
|
||||
}
|
||||
const isAgentEarnings = navCur.value === 2;
|
||||
const params = {
|
||||
pageNo: mescroll.num,
|
||||
pageSize: mescroll.size,
|
||||
createMonth: currentMonth2.value,
|
||||
...(navCur.value === 0 ? {
|
||||
type: 1
|
||||
} :
|
||||
isAgentEarnings ? {
|
||||
transactionType: select_cur.value
|
||||
} : {
|
||||
transactionType: 1
|
||||
}),
|
||||
};
|
||||
cfg.url(params).then((res) => {
|
||||
if (res.code === 0) {
|
||||
// console.log(res.data.sum);
|
||||
monthEarnings.value = fen2yuan(res.data.sum)
|
||||
let list = res.data.list || [];
|
||||
if (mescroll.num == 1) infoArr.value = [];
|
||||
const idx = navCur.value;
|
||||
list = list.map((item) => {
|
||||
if (idx === 0) {
|
||||
item.time = formatDate(item.createTime).slice(0, 10);
|
||||
// item.remark = item.title;
|
||||
item.money = fen2yuan(item.price);
|
||||
} else if (idx === 1) {
|
||||
item.title = item.remark
|
||||
item.time = item.createTime;
|
||||
item.money = fen2yuan(item.amount);
|
||||
} else if (idx === 2) {
|
||||
item.title = item.remark
|
||||
item.time = formatDate(item.createTime).slice(0, 10);
|
||||
item.money = fen2yuan(item.totalEarnings);
|
||||
} else if (idx === 3) {
|
||||
item.title = item.remark
|
||||
item.time = formatDate(item.createTime).slice(0, 10);
|
||||
item.money = fen2yuan(item.amount);
|
||||
}
|
||||
return item;
|
||||
});
|
||||
infoArr.value = infoArr.value.concat(list);
|
||||
height.value = infoArr.value.length > 0 ? infoArr.value.length * 150 + 'rpx' : '540rpx';
|
||||
cardPages.value.getState(true, list.length);
|
||||
} else {
|
||||
cardPages.value.getState(false);
|
||||
}
|
||||
});
|
||||
};
|
||||
//选择日期
|
||||
function bindDateChange(e) {
|
||||
date.value = e.detail.value;
|
||||
const arr = e.detail.value.split('-');
|
||||
currentMonth.value = arr[0] + '.' + arr[1];
|
||||
currentMonth2.value = arr[0] + '-' + arr[1];
|
||||
if (cardPages.value && cardPages.value.mescrollTrigger) {
|
||||
cardPages.value.mescrollTrigger();
|
||||
}
|
||||
}
|
||||
//获取当前日期
|
||||
function getCurrentDate() {
|
||||
let date = new Date();
|
||||
let year = date.getFullYear();
|
||||
let month = date.getMonth() + 1;
|
||||
let day = date.getDate();
|
||||
month = month < 10 ? '0' + month : month;
|
||||
day = day < 10 ? '0' + day : day;
|
||||
currentDate.value = year + '-' + month + '-' + day;
|
||||
currentMonth.value = year + '.' + month;
|
||||
currentMonth2.value = year + '-' + month;
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
select_value.value = range.value[0].text
|
||||
select_cur.value = range.value[0].value
|
||||
getData();
|
||||
getCurrentDate()
|
||||
date.value = currentDate.value
|
||||
// getRelease()
|
||||
|
||||
});
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
.card {
|
||||
background-color: var(--color24);
|
||||
border-radius: 16rpx;
|
||||
}
|
||||
|
||||
.pages {
|
||||
padding: 32rpx 40rpx 0;
|
||||
|
||||
.section-1 {
|
||||
border-radius: 16rpx;
|
||||
height: 285rpx;
|
||||
max-height: 285rpx;
|
||||
background-size: 100% 100%;
|
||||
background-repeat: no-repeat;
|
||||
margin-bottom: 44rpx;
|
||||
|
||||
.section1-content {
|
||||
padding: 16rpx 28rpx;
|
||||
color: #fff;
|
||||
|
||||
.date {
|
||||
text-align: right;
|
||||
font-size: 24rpx;
|
||||
line-height: 44rpx;
|
||||
}
|
||||
|
||||
.title {
|
||||
font-size: 28rpx;
|
||||
color: rgba(255, 255, 255, 0.57);
|
||||
}
|
||||
|
||||
.num {
|
||||
font-weight: 700;
|
||||
font-size: 60rpx;
|
||||
line-height: 80rpx;
|
||||
margin: 8rpx 0;
|
||||
}
|
||||
|
||||
.num2 {
|
||||
font-size: 32rpx;
|
||||
margin-left: 40rpx;
|
||||
}
|
||||
|
||||
.line {
|
||||
width: 418rpx;
|
||||
height: 4rpx;
|
||||
background: rgba(255, 255, 255, 0.23);
|
||||
margin-bottom: 27rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.section-2 {
|
||||
@extend .card;
|
||||
padding: 16rpx 28rpx;
|
||||
margin-bottom: 32rpx;
|
||||
|
||||
.title {
|
||||
font-size: 32rpx;
|
||||
|
||||
text {
|
||||
font-size: 24rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.wrap {
|
||||
width: 100%;
|
||||
height: 350rpx;
|
||||
margin-top: 32rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.section-3 {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 34rpx;
|
||||
|
||||
.item {
|
||||
width: 146rpx;
|
||||
height: 62rpx;
|
||||
line-height: 62rpx;
|
||||
text-align: center;
|
||||
background: #fff;
|
||||
border-radius: 14rpx;
|
||||
overflow: hidden;
|
||||
font-weight: 400;
|
||||
font-size: 24rpx;
|
||||
// color: #FFFFFF;
|
||||
}
|
||||
|
||||
.active {
|
||||
color: #FB4D32;
|
||||
background: #FFEFE5;
|
||||
}
|
||||
}
|
||||
|
||||
.section-4 {
|
||||
background-color: var(--color24);
|
||||
border-radius: 50rpx 50rpx 0 0;
|
||||
margin: 32rpx -40rpx 0;
|
||||
padding: 28rpx 40rpx;
|
||||
|
||||
.select-bar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
|
||||
.left {
|
||||
font-weight: 500;
|
||||
line-height: 44rpx;
|
||||
|
||||
.selected-date {
|
||||
font-size: 32rpx;
|
||||
// color: #FFFFFF;
|
||||
}
|
||||
|
||||
.num {
|
||||
font-size: 28rpx;
|
||||
color: #969696;
|
||||
margin-top: 8rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.right {
|
||||
position: relative;
|
||||
|
||||
.bar {
|
||||
width: 146rpx;
|
||||
height: 50rpx;
|
||||
text-align: center;
|
||||
line-height: 50rpx;
|
||||
background: #F2F4F7;
|
||||
border-radius: 16rpx;
|
||||
font-weight: 400;
|
||||
font-size: 24rpx;
|
||||
// color: #FFFFFF;
|
||||
}
|
||||
|
||||
.select-content {
|
||||
width: 100%;
|
||||
border-radius: 10rpx;
|
||||
position: absolute;
|
||||
background: #F2F4F7;
|
||||
top: 60rpx;
|
||||
z-index: 10;
|
||||
|
||||
.select-item {
|
||||
padding: 0 10rpx;
|
||||
text-align: center;
|
||||
line-height: 70rpx;
|
||||
color: #000;
|
||||
font-weight: 400;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.item {
|
||||
// width: 100%;
|
||||
height: 144rpx;
|
||||
background: #F2F4F7;
|
||||
border-radius: 16rpx;
|
||||
overflow: hidden;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 0 24rpx;
|
||||
margin-top: 24rpx;
|
||||
|
||||
.left {
|
||||
font-weight: 400;
|
||||
|
||||
.title {
|
||||
font-size: 28rpx;
|
||||
// color: #FFFFFF;
|
||||
line-height: 40rpx;
|
||||
}
|
||||
|
||||
.date {
|
||||
font-size: 24rpx;
|
||||
color: #999999;
|
||||
line-height: 34rpx;
|
||||
margin-top: 10rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.right {
|
||||
font-weight: 500;
|
||||
font-size: 32rpx;
|
||||
color: #EE0A24;
|
||||
// line-height: 46rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
.select {
|
||||
width: 200rpx;
|
||||
|
||||
:deep(.uni-scroll-view-content) {
|
||||
color: #000;
|
||||
}
|
||||
|
||||
:deep(.uni-stat-box) {
|
||||
background-color: transparent;
|
||||
|
||||
.uni-select__input-box .padding-top-bottom {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.uni-select {
|
||||
border: none;
|
||||
}
|
||||
|
||||
.uni-icons {
|
||||
color: #fff !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user