接口更改
This commit is contained in:
@@ -29,9 +29,9 @@
|
|||||||
<el-icon><List /></el-icon>
|
<el-icon><List /></el-icon>
|
||||||
<template #title>订单管理</template>
|
<template #title>订单管理</template>
|
||||||
</el-menu-item>
|
</el-menu-item>
|
||||||
<el-menu-item v-if="userStore.isAdmin" index="/income">
|
<el-menu-item v-if="userStore.isAdmin" index="/withdrawals">
|
||||||
<el-icon><Money /></el-icon>
|
<el-icon><Money /></el-icon>
|
||||||
<template #title>提现管理</template>
|
<template #title>提现审批</template>
|
||||||
</el-menu-item>
|
</el-menu-item>
|
||||||
<el-menu-item index="/profile">
|
<el-menu-item index="/profile">
|
||||||
<el-icon><UserFilled /></el-icon>
|
<el-icon><UserFilled /></el-icon>
|
||||||
|
|||||||
@@ -83,9 +83,9 @@ const routes = [
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'income',
|
path: 'withdrawals',
|
||||||
name: 'Income',
|
name: 'Withdrawals',
|
||||||
component: () => import('@/views/Income.vue'),
|
component: () => import('@/views/WithdrawalApproval.vue'),
|
||||||
meta: {
|
meta: {
|
||||||
title: '提现管理',
|
title: '提现管理',
|
||||||
icon: 'Money',
|
icon: 'Money',
|
||||||
|
|||||||
@@ -247,9 +247,9 @@ const api = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
// 提现管理
|
// 提现管理
|
||||||
income: {
|
withdraw: {
|
||||||
getIncomeList: (params) => apiRequest.get('/income', {params}),
|
getWithdrawList: (params) => apiRequest.get('/withdrawals', {params}),
|
||||||
createIncome: (data) => apiRequest.post('/income', data),
|
createWithdraw: (data) => apiRequest.post('/withdrawals', data),
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
type="primary"
|
type="primary"
|
||||||
size="large"
|
size="large"
|
||||||
class="withdraw-btn"
|
class="withdraw-btn"
|
||||||
@click="getIncome"
|
@click="getWithdraw"
|
||||||
>
|
>
|
||||||
<el-icon><Plus /></el-icon>
|
<el-icon><Plus /></el-icon>
|
||||||
申请提现
|
申请提现
|
||||||
@@ -21,20 +21,20 @@
|
|||||||
<!-- 数据表格 -->
|
<!-- 数据表格 -->
|
||||||
<div class="table-container">
|
<div class="table-container">
|
||||||
<el-table
|
<el-table
|
||||||
:data="incomeList"
|
:data="withdrawList"
|
||||||
v-loading="loading"
|
v-loading="loading"
|
||||||
stripe
|
stripe
|
||||||
class="income-table"
|
class="income-table"
|
||||||
header-row-class-name="table-header"
|
header-row-class-name="table-header"
|
||||||
>
|
>
|
||||||
<el-table-column prop="id" label="ID" align="center" />
|
<el-table-column prop="id" label="ID" />
|
||||||
<el-table-column prop="user.name" label="用户" />
|
<el-table-column prop="user_id" label="用户" />
|
||||||
<el-table-column prop="amount" label="金额">
|
<el-table-column prop="amount" label="金额">
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
<span class="amount-text">¥{{ row.amount }}</span>
|
<span class="amount-text">¥{{ row.amount }}</span>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column prop="status" label="状态" align="center">
|
<el-table-column prop="status" label="状态">
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
<el-tag
|
<el-tag
|
||||||
:type="getStatusType(row.status)"
|
:type="getStatusType(row.status)"
|
||||||
@@ -45,9 +45,9 @@
|
|||||||
</el-tag>
|
</el-tag>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column prop="createdAt" label="创建时间">
|
<el-table-column prop="time" label="创建时间">
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
<span class="time-text">{{ formatTime(row.createdAt) }}</span>
|
<span class="time-text">{{ formatTime(row.time) }}</span>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
@@ -61,8 +61,8 @@
|
|||||||
:page-sizes="[10, 20, 50, 100]"
|
:page-sizes="[10, 20, 50, 100]"
|
||||||
:total="pagination.total"
|
:total="pagination.total"
|
||||||
layout="total, sizes, prev, pager, next, jumper"
|
layout="total, sizes, prev, pager, next, jumper"
|
||||||
@size-change="loadIncomeList"
|
@size-change="loadWithdrawList"
|
||||||
@current-change="loadIncomeList"
|
@current-change="loadWithdrawList"
|
||||||
class="custom-pagination"
|
class="custom-pagination"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -83,7 +83,7 @@
|
|||||||
>
|
>
|
||||||
<el-form-item label="提现金额" prop="amount">
|
<el-form-item label="提现金额" prop="amount">
|
||||||
<el-input
|
<el-input
|
||||||
v-model="form.amount"
|
v-model.number="form.amount"
|
||||||
type="number"
|
type="number"
|
||||||
placeholder="请输入提现金额"
|
placeholder="请输入提现金额"
|
||||||
>
|
>
|
||||||
@@ -120,7 +120,7 @@ import { ElForm, ElFormItem, ElInput, ElMessage } from 'element-plus'
|
|||||||
import { Money, Plus, Check } from '@element-plus/icons-vue'
|
import { Money, Plus, Check } from '@element-plus/icons-vue'
|
||||||
|
|
||||||
const userStore = useUserStore()
|
const userStore = useUserStore()
|
||||||
const incomeList = ref([])
|
const withdrawList = ref([])
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
const drawerVisible = ref(false)
|
const drawerVisible = ref(false)
|
||||||
const formRef = ref(null)
|
const formRef = ref(null)
|
||||||
@@ -143,11 +143,9 @@ const pagination = reactive({
|
|||||||
// 状态类型映射
|
// 状态类型映射
|
||||||
const getStatusType = (status) => {
|
const getStatusType = (status) => {
|
||||||
const statusMap = {
|
const statusMap = {
|
||||||
'pending': 'warning',
|
'pending': 'info',
|
||||||
'processing': 'primary',
|
'success': 'success',
|
||||||
'completed': 'success',
|
'canceled': 'danger'
|
||||||
'failed': 'danger',
|
|
||||||
'cancelled': 'info'
|
|
||||||
}
|
}
|
||||||
return statusMap[status] || 'info'
|
return statusMap[status] || 'info'
|
||||||
}
|
}
|
||||||
@@ -156,10 +154,8 @@ const getStatusType = (status) => {
|
|||||||
const getStatusText = (status) => {
|
const getStatusText = (status) => {
|
||||||
const statusMap = {
|
const statusMap = {
|
||||||
'pending': '待处理',
|
'pending': '待处理',
|
||||||
'processing': '处理中',
|
'success': '已通过',
|
||||||
'completed': '已完成',
|
'canceled': '已取消'
|
||||||
'failed': '失败',
|
|
||||||
'cancelled': '已取消'
|
|
||||||
}
|
}
|
||||||
return statusMap[status] || status
|
return statusMap[status] || status
|
||||||
}
|
}
|
||||||
@@ -177,15 +173,15 @@ const formatTime = (time) => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const loadIncomeList = async () => {
|
const loadWithdrawList = async () => {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
try {
|
try {
|
||||||
const { data } = await api.income.getIncomeList({
|
const { data } = await api.withdraw.getWithdrawList({
|
||||||
page: pagination.page,
|
page: pagination.page,
|
||||||
limit: pagination.limit
|
limit: pagination.limit
|
||||||
})
|
})
|
||||||
incomeList.value = data
|
withdrawList.value = data.data.withdrawals || []
|
||||||
pagination.total = data.total
|
pagination.total = data.data.pagination.total || 0
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('获取提现列表失败:', error)
|
console.error('获取提现列表失败:', error)
|
||||||
ElMessage.error('获取提现列表失败')
|
ElMessage.error('获取提现列表失败')
|
||||||
@@ -194,7 +190,7 @@ const loadIncomeList = async () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const getIncome = async () => {
|
const getWithdraw = async () => {
|
||||||
drawerVisible.value = true
|
drawerVisible.value = true
|
||||||
// 重置表单
|
// 重置表单
|
||||||
form.amount = 0
|
form.amount = 0
|
||||||
@@ -210,14 +206,14 @@ const submitForm = async () => {
|
|||||||
const valid = await formRef.value.validate()
|
const valid = await formRef.value.validate()
|
||||||
if (!valid) return
|
if (!valid) return
|
||||||
|
|
||||||
const response = await api.income.createIncome({
|
const response = await api.withdraw.createWithdraw({
|
||||||
amount: Number(form.amount),
|
amount: Number(form.amount),
|
||||||
userId: userStore.user.id
|
userId: userStore.user.id
|
||||||
})
|
})
|
||||||
|
|
||||||
if (response.data) {
|
if (response.data) {
|
||||||
ElMessage.success('提现申请提交成功')
|
ElMessage.success('提现申请提交成功')
|
||||||
loadIncomeList()
|
loadWithdrawList()
|
||||||
drawerVisible.value = false
|
drawerVisible.value = false
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -227,13 +223,13 @@ const submitForm = async () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
loadIncomeList()
|
loadWithdrawList()
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
/* 页面容器 */
|
/* 页面容器 */
|
||||||
.income-container {
|
.withdraw-container {
|
||||||
padding: 24px;
|
padding: 24px;
|
||||||
min-height: 100vh;
|
min-height: 100vh;
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user