<template>
|
<div class="personal-points">
|
<!-- 积分统计卡片 -->
|
<div class="stats-section">
|
<div class="stats-cards">
|
<div class="stats-card balance">
|
<div class="card-icon">
|
<!-- <el-icon><Money /></el-icon> -->
|
<svg-icon name="local-jifen" color="#007CEE"
|
size="50"></svg-icon>
|
</div>
|
<div class="card-content">
|
<div class="card-title">积分余额</div>
|
<div class="card-value">{{ formatNumber(stats.balance) }}</div>
|
</div>
|
</div>
|
<div class="stats-card earned">
|
<div class="card-icon">
|
<!-- <el-icon><Plus /></el-icon> -->
|
<svg-icon name="local-jifenjia" color="#007CEE"
|
size="50"></svg-icon>
|
</div>
|
<div class="card-content">
|
<div class="card-title">累计获取</div>
|
<div class="card-value">{{ formatNumber(stats.totalEarned) }}</div>
|
</div>
|
</div>
|
<div class="stats-card consumed">
|
<div class="card-icon">
|
<!-- <el-icon><Minus /></el-icon> -->
|
<svg-icon name="local-jifenjian" color="#007CEE"
|
size="50"></svg-icon>
|
</div>
|
<div class="card-content">
|
<div class="card-title">累计消耗</div>
|
<div class="card-value">{{ formatNumber(stats.totalConsumed) }}</div>
|
</div>
|
</div>
|
</div>
|
<div class="stats-background">
|
<div class="coins-bg"></div>
|
</div>
|
</div>
|
|
<!-- 积分流水 -->
|
<div class="flow-section">
|
<el-card shadow="never">
|
<template #header>
|
<div class="section-header">
|
<span class="section-title">积分流水</span>
|
</div>
|
</template>
|
|
<!-- 筛选条件 -->
|
<div class="filter-section">
|
<div class="filter-row">
|
<div class="filter-item">
|
<span class="filter-label">数据类目:</span>
|
<el-select v-model="queryParams.dataCategory" placeholder="全部" clearable>
|
<el-option label="全部" value="" />
|
<el-option
|
v-for="category in categoryList"
|
:key="category"
|
:label="getCategoryLabel(category)"
|
:value="category"
|
/>
|
</el-select>
|
</div>
|
<div class="filter-item">
|
<span class="filter-label">时间:</span>
|
<el-date-picker
|
v-model="dateRange"
|
type="datetimerange"
|
range-separator="至"
|
start-placeholder="开始日期"
|
end-placeholder="结束日期"
|
format="YYYY-MM-DD HH:mm:ss"
|
date-format="YYYY-MM-DD"
|
time-format="HH:mm:ss"
|
@change="handleDateChange"
|
/>
|
</div>
|
<div class="filter-item">
|
<span class="filter-label">数据类型:</span>
|
<el-select v-model="queryParams.dataType" placeholder="全部" clearable>
|
<el-option label="全部" value="" />
|
<el-option label="获取" value="0" />
|
<el-option label="消耗" value="1" />
|
</el-select>
|
</div>
|
</div>
|
<div class="filter-actions">
|
<el-button type="primary" @click="queryData">
|
<el-icon><Search /></el-icon>
|
查询
|
</el-button>
|
<el-button @click="resetQuery">
|
<el-icon><Refresh /></el-icon>
|
重置
|
</el-button>
|
</div>
|
</div>
|
|
<!-- 流水表格 -->
|
<div class="table-section">
|
<el-table :data="flowList" stripe style="width: 100%">
|
<el-table-column prop="id" label="序号" width="80" align="center" />
|
<el-table-column prop="dataCategory" label="数据类目" width="120">
|
<template #default="{ row }">
|
<span>{{ getCategoryLabel(row.dataCategory) }}</span>
|
</template>
|
</el-table-column>
|
<el-table-column prop="name" label="名称" show-overflow-tooltip />
|
<el-table-column prop="flowTime" label="时间" align="center" />
|
<el-table-column prop="points" label="积分" align="center">
|
<template #default="{ row }">
|
<span :class="row.points > 0 ? 'points-earned' : 'points-consumed'">
|
{{ row.points > 0 ? '+' : '' }}{{ row.points }}
|
</span>
|
</template>
|
</el-table-column>
|
</el-table>
|
|
<!-- 分页 -->
|
<div class="pagination-section">
|
<div class="pagination-info">
|
共{{ total }}条
|
</div>
|
<el-pagination
|
v-model:current-page="queryParams.pageNum"
|
v-model:page-size="queryParams.pageSize"
|
:page-sizes="[10, 20, 50, 100]"
|
:total="total"
|
layout="sizes, prev, pager, next, jumper"
|
@size-change="handleSizeChange"
|
@current-change="handleCurrentChange"
|
/>
|
</div>
|
</div>
|
</el-card>
|
</div>
|
</div>
|
</template>
|
|
<script setup lang="ts">
|
import { ref, reactive, onMounted, computed } from 'vue'
|
import { dayjs, ElMessage } from 'element-plus'
|
import {
|
ArrowLeft,
|
Refresh,
|
Setting,
|
Close,
|
Money,
|
Plus,
|
Minus,
|
Search
|
} from '@element-plus/icons-vue'
|
import pointsApi from '@/api/pointsApi'
|
import type { PointsStats, PointsFlow, PointsQueryParams } from '@/types/points'
|
|
// 积分统计
|
const stats = ref<PointsStats>({
|
balance: 0,
|
totalEarned: 0,
|
totalConsumed: 0,
|
totalConverted: 0,
|
})
|
|
// 查询参数
|
const queryParams = reactive<PointsQueryParams>({
|
userId: '1',
|
dataCategory: '',
|
dataType: '',
|
pageNum: 1,
|
pageSize: 10,
|
})
|
|
// 日期范围
|
const dateRange = ref<[string, string] | null>(null)
|
|
// 流水列表
|
const flowList = ref<PointsFlow[]>([])
|
|
// 总数
|
const total = ref(0)
|
|
// 数据类目列表
|
const categoryList = ref<string[]>([])
|
|
// 格式化数字
|
const formatNumber = (num: number) => {
|
return num.toLocaleString()
|
}
|
|
// 获取分类标签
|
const getCategoryLabel = (category: string) => {
|
const categoryMap: Record<string, string> = {
|
resource_contribution: '资源贡献',
|
resource_transaction: '资源交易',
|
resource_dissemination: '资源传播',
|
user_participation: '用户参与',
|
points_conversion: '积分转换',
|
other: '其他',
|
}
|
return categoryMap[category] || category
|
}
|
|
// 获取积分统计
|
const getPointsStats = async () => {
|
try {
|
const userId = 1;
|
const res = await pointsApi.getPersonalPointsStats(userId)
|
if (res.code === 200 && res.data) {
|
stats.value = res.data
|
}
|
} catch (error) {
|
console.error('获取积分统计失败:', error)
|
}
|
}
|
|
// 获取数据类目列表
|
const getCategoryList = async () => {
|
try {
|
const res = await pointsApi.getPointsFlowCategories()
|
if (res.code === 200 && res.data) {
|
categoryList.value = res.data
|
}
|
} catch (error) {
|
console.error('获取数据类目失败:', error)
|
}
|
}
|
|
// 获取积分流水
|
const getPointsFlow = async () => {
|
try {
|
const res = await pointsApi.getPersonalPointsFlow(queryParams)
|
if (res.code === 200) {
|
flowList.value = res.data.list || []
|
total.value = res.data.total || 0
|
}
|
} catch (error) {
|
console.error('获取积分流水失败:', error)
|
}
|
}
|
|
// 查询数据
|
const queryData = () => {
|
queryParams.pageNum = 1
|
getPointsFlow()
|
}
|
|
// 重置查询
|
const resetQuery = () => {
|
queryParams.dataCategory = ''
|
queryParams.dataType = ''
|
queryParams.flowStartTime = ''
|
queryParams.flowEndTime = ''
|
dateRange.value = null
|
queryParams.pageNum = 1
|
queryData()
|
}
|
|
// 处理日期变化
|
const handleDateChange = (dates: [string, string] | null) => {
|
if (dates) {
|
queryParams.flowStartTime = dayjs(dates[0]).format('YYYY-MM-DD HH:mm:ss');
|
queryParams.flowEndTime = dayjs(dates[1]).format('YYYY-MM-DD HH:mm:ss');
|
} else {
|
queryParams.flowStartTime = ''
|
queryParams.flowEndTime = ''
|
}
|
}
|
|
// 处理分页大小变化
|
const handleSizeChange = (size: number) => {
|
queryParams.pageSize = size
|
queryParams.pageNum = 1
|
getPointsFlow()
|
}
|
|
// 处理当前页变化
|
const handleCurrentChange = (page: number) => {
|
queryParams.pageNum = page
|
getPointsFlow()
|
}
|
|
// 刷新数据
|
const refreshData = () => {
|
getPointsStats()
|
getPointsFlow()
|
}
|
|
// 返回上一页
|
const goBack = () => {
|
history.back()
|
}
|
|
// 关闭全部
|
const closeAll = () => {
|
ElMessage.info('关闭全部功能')
|
}
|
|
onMounted(() => {
|
getPointsStats()
|
getPointsFlow()
|
getCategoryList()
|
})
|
</script>
|
|
<style scoped lang="scss">
|
.personal-points {
|
padding: 20px;
|
background-color: #f5f5f5;
|
min-height: 100vh;
|
|
.page-header {
|
display: flex;
|
justify-content: space-between;
|
align-items: center;
|
margin-bottom: 20px;
|
padding: 16px 20px;
|
background: white;
|
border-radius: 8px;
|
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
|
.breadcrumb {
|
display: flex;
|
align-items: center;
|
gap: 8px;
|
|
.back-arrow {
|
cursor: pointer;
|
color: #409eff;
|
font-size: 18px;
|
|
&:hover {
|
color: #66b1ff;
|
}
|
}
|
|
.title {
|
font-size: 16px;
|
font-weight: 500;
|
color: #303133;
|
}
|
|
.header-actions {
|
display: flex;
|
gap: 12px;
|
margin-left: 16px;
|
|
.refresh-icon,
|
.settings-icon {
|
cursor: pointer;
|
color: #909399;
|
font-size: 16px;
|
|
&:hover {
|
color: #409eff;
|
}
|
}
|
}
|
}
|
|
.global-actions {
|
display: flex;
|
gap: 12px;
|
}
|
}
|
|
.stats-section {
|
position: relative;
|
margin-bottom: 20px;
|
padding: 24px;
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
border-radius: 12px;
|
overflow: hidden;
|
|
.stats-cards {
|
display: flex;
|
gap: 24px;
|
position: relative;
|
z-index: 2;
|
}
|
|
.stats-card {
|
flex: 1;
|
display: flex;
|
align-items: center;
|
gap: 16px;
|
padding: 20px;
|
background: rgba(255, 255, 255, 0.95);
|
border-radius: 8px;
|
backdrop-filter: blur(10px);
|
|
.card-icon {
|
width: 48px;
|
height: 48px;
|
border-radius: 50%;
|
display: flex;
|
align-items: center;
|
justify-content: center;
|
font-size: 24px;
|
color: white;
|
|
&.balance {
|
background: linear-gradient(135deg, #409eff, #66b1ff);
|
}
|
|
&.earned {
|
background: linear-gradient(135deg, #67c23a, #85ce61);
|
}
|
|
&.consumed {
|
background: linear-gradient(135deg, #f56c6c, #f78989);
|
}
|
}
|
|
.card-content {
|
flex: 1;
|
|
.card-title {
|
font-size: 14px;
|
color: #909399;
|
margin-bottom: 4px;
|
}
|
|
.card-value {
|
font-size: 24px;
|
font-weight: 600;
|
color: #303133;
|
}
|
}
|
}
|
|
.stats-background {
|
position: absolute;
|
top: 0;
|
right: 0;
|
width: 200px;
|
height: 100%;
|
opacity: 0.1;
|
|
.coins-bg {
|
width: 100%;
|
height: 100%;
|
background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%23ffffff"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"/></svg>');
|
background-repeat: repeat;
|
background-size: 24px 24px;
|
}
|
}
|
}
|
|
.flow-section {
|
.section-header {
|
.section-title {
|
font-size: 16px;
|
font-weight: 600;
|
color: #303133;
|
}
|
}
|
|
.filter-section {
|
margin-bottom: 20px;
|
padding: 16px;
|
background: #fafafa;
|
border-radius: 6px;
|
display: flex;
|
flex-direction: column;
|
gap: 16px;
|
|
@media (min-width: 768px) {
|
flex-direction: row;
|
align-items: center;
|
gap: 20px;
|
}
|
|
.filter-row {
|
display: flex;
|
flex-direction: column;
|
gap: 8px;
|
flex: 1;
|
min-width: 0;
|
|
@media (min-width: 768px) {
|
flex-direction: row;
|
gap: 20px;
|
flex-wrap: wrap;
|
flex: 0 0 80%;
|
}
|
|
@media (min-width: 1200px) {
|
flex-wrap: nowrap;
|
}
|
}
|
|
.filter-actions {
|
display: flex;
|
gap: 12px;
|
flex-shrink: 0;
|
justify-content: flex-start;
|
|
@media (min-width: 768px) {
|
justify-content: flex-end;
|
flex: 0 0 20%;
|
}
|
}
|
|
.filter-item {
|
display: flex;
|
flex-direction: column;
|
gap: 8px;
|
min-width: 0;
|
|
@media (min-width: 768px) {
|
flex-direction: row;
|
align-items: center;
|
}
|
|
// 第一个控件(数据类目)- 30%
|
&:nth-child(1) {
|
@media (min-width: 768px) {
|
flex: 0 0 30%;
|
}
|
}
|
|
// 第二个控件(时间)- 40%
|
&:nth-child(2) {
|
@media (min-width: 768px) {
|
flex: 0 0 40%;
|
}
|
}
|
|
// 第三个控件(数据类型)- 30%
|
&:nth-child(3) {
|
@media (min-width: 768px) {
|
flex: 0 0 30%;
|
}
|
}
|
|
.filter-label {
|
font-size: 14px;
|
color: #606266;
|
white-space: nowrap;
|
flex-shrink: 0;
|
}
|
|
:deep(.el-select),
|
:deep(.el-date-picker) {
|
width: 100%;
|
|
@media (min-width: 768px) {
|
width: auto;
|
min-width: 120px;
|
}
|
}
|
}
|
}
|
|
.table-section {
|
.points-earned {
|
color: #67c23a;
|
font-weight: 500;
|
}
|
|
.points-consumed {
|
color: #f56c6c;
|
font-weight: 500;
|
}
|
}
|
|
.pagination-section {
|
display: flex;
|
justify-content: space-between;
|
align-items: center;
|
margin-top: 20px;
|
padding-top: 16px;
|
border-top: 1px solid #ebeef5;
|
|
.pagination-info {
|
font-size: 14px;
|
color: #909399;
|
}
|
}
|
}
|
}
|
</style>
|