This commit is contained in:
zpc 2025-12-08 00:23:20 +08:00
parent a58b4e431b
commit 316d1e2b5d
3 changed files with 252 additions and 54 deletions

View File

@ -0,0 +1,83 @@
import request from '@/common/system/request';
/**
* 获取收益统计信息
* @returns {Promise<{pendingAmount: number, extractedAmount: number}>}
*/
export const getEarningsSummary = async () => {
const res = await request.getOrCache("sq/GetEarningsSummary", {}, 1);
if (res.code == 0) {
return res.data || { pendingAmount: 0, extractedAmount: 0 };
}
return { pendingAmount: 0, extractedAmount: 0 };
}
/**
* 获取收益规则说明
* @returns {Promise<string>}
*/
export const getEarningsRule = async () => {
const res = await request.getOrCache("sq/GetEarningsRule", {}, 300);
if (res.code == 0) {
return res.data?.content || '';
}
return '';
}
/**
* 获取收益记录列表
* @param {number} pageIndex 页码从1开始
* @param {number} pageSize 每页数量
* @returns {Promise<Array>}
*/
export const getEarningsRecordList = async (pageIndex = 1, pageSize = 20) => {
const res = await request.post(
"sq/GetEarningsRecordList",
{ pageIndex, pageSize }
);
if (res.code == 0) {
return res.data || [];
}
return [];
}
/**
* 获取提现记录列表
* @param {number} pageIndex 页码从1开始
* @param {number} pageSize 每页数量
* @returns {Promise<Array>}
*/
export const getWithdrawRecordList = async (pageIndex = 1, pageSize = 20) => {
const res = await request.post(
"sq/GetWithdrawRecordList",
{ pageIndex, pageSize }
);
if (res.code == 0) {
return res.data || [];
}
return [];
}
/**
* 申请提现
* @param {number} amount 提现金额
* @returns {Promise<{success: boolean, msg?: string}>}
*/
export const applyWithdraw = async (amount) => {
const res = await request.post("sq/ApplyWithdraw", { amount });
if (res.code == 0) {
return { success: true, msg: res.msg || '提现申请已提交' };
}
return { success: false, msg: res.msg || '提现申请失败' };
}
// 导出收益接口对象
export const earningsInterface = {
getEarningsSummary,
getEarningsRule,
getEarningsRecordList,
getWithdrawRecordList,
applyWithdraw
}
export default earningsInterface;

View File

@ -16,15 +16,15 @@
<view class="row">
<view class="column" style="margin-top: 20rpx; margin-left: 24rpx;">
<text style="font-size: 28rpx;">待提取收益</text>
<text style="font-size: 48rpx;">0.00</text>
<text style="font-size: 48rpx;">{{ pendingAmount.toFixed(2) }}</text>
</view>
<view class="column" style="margin-top: 20rpx; margin-left: auto; margin-right: 22rpx;">
<text style="font-size: 28rpx;">已提取收益</text>
<text style="font-size: 48rpx;">0.00</text>
<text style="font-size: 48rpx;">{{ extractedAmount.toFixed(2) }}</text>
</view>
</view>
<view class="center" @click="reflectShow = true"
<view class="center" @click="openWithdrawPopup"
style="width: 640rpx; height: 76rpx; background-color: #00AC4E; border-radius: 48rpx; margin: 44rpx auto 0; font-size: 30rpx; color: #FFFFFF;">
去提现
</view>
@ -32,7 +32,7 @@
</view>
<view class="center" style="color: #00A2FF; font-size: 24rpx; margin: 20rpx;" @click="show = true">
<view class="center" style="color: #00A2FF; font-size: 24rpx; margin: 20rpx;" @click="openRulePopup">
<text>点击查看收益规则</text>
</view>
@ -63,54 +63,59 @@
</view>
<view class="" v-if="currentIndex == 0" style="width: 100%; flex: 1; margin-top: 16rpx;">
<view class="row" v-for="(item,index) in dataList"
<view v-if="dataList.length === 0" class="center" style="margin-top: 100rpx; color: #999999; font-size: 28rpx;">
暂无收益记录
</view>
<view class="row" v-for="item in dataList" :key="item.id"
style="font-size: 28rpx; color: #555555; margin-bottom: 20rpx;">
<view class="center" style="flex: 1;">2025/1/1</view>
<view class="center" style="flex: 1;">305大包</view>
<view class="center" style="flex: 1;">12</view>
<view class="center" style="flex: 1;">0.12</view>
<view class="center" style="flex: 1;">{{ item.date }}</view>
<view class="center" style="flex: 1;">{{ item.roomName }}</view>
<view class="center" style="flex: 1;">{{ item.roomFee.toFixed(2) }}</view>
<view class="center" style="flex: 1;">{{ item.earnings.toFixed(2) }}</view>
</view>
</view>
<view class="" v-else style="width: 100%; flex: 1; margin-top: 16rpx;">
<view class="row" v-for="(item,index) in dataList"
<view v-if="dataList.length === 0" class="center" style="margin-top: 100rpx; color: #999999; font-size: 28rpx;">
暂无提现记录
</view>
<view class="row" v-for="item in dataList" :key="item.id"
style="font-size: 28rpx; color: #555555; margin-bottom: 20rpx;">
<view class="center" style="flex: 1;">2025/1/1</view>
<view class="center" style="flex: 1;">12</view>
<view class="center" style="flex: 1;">提现中</view>
<view class="center" style="flex: 1;">{{ item.date }}</view>
<view class="center" style="flex: 1;">{{ item.amount.toFixed(2) }}</view>
<view class="center" style="flex: 1;">{{ item.status }}</view>
</view>
</view>
</view>
<up-popup v-model:show="show" @close="close" @open="open" :round="10" mode="center" :closeable="true">
<up-popup v-model:show="show" @close="close" @open="openRulePopup" :round="10" mode="center" :closeable="true">
<view style="width: 656rpx;">
<view class="center" style="margin-top: 28rpx;">规则说明</view>
<view class="center" style="width: 80%; margin: 44rpx auto 20rpx;">
正文正文正文正文正文正文正文正文正文正文正文正
文正文正文正文正文正文正文正文正文正文正文正文
正文正文正文正文正文正文正文
<view class="center" style="width: 80%; margin: 44rpx auto 20rpx; white-space: pre-wrap; text-align: left;">
{{ ruleContent || '加载中...' }}
</view>
</view>
</up-popup>
<up-popup v-model:show="reflectShow" @close="close" @open="open" :round="10" mode="center" :closeable="true">
<up-popup v-model:show="reflectShow" @close="close" @open="openWithdrawPopup" :round="10" mode="center" :closeable="true">
<view style="width: 656rpx;">
<view class="center" style="margin-top: 28rpx;">提现申请</view>
<view class="center"
style="width: 90%; height: 114rpx; margin: 26rpx auto 20rpx; background-color: rgba(0,172,78,0.37); border-radius: 30rpx;">
<up-input placeholder="请输入要提现的金额" placeholderStyle="color:'#818181'" border="none"
inputAlign="center" fontSize="32rpx" v-model="value"></up-input>
inputAlign="center" fontSize="32rpx" v-model="value" type="digit"></up-input>
</view>
<view class="row" style="width: 90%; margin: 0 auto 0;">
<text style="font-size: 28rpx; color: #818181;">最高可提现0.00</text>
<text style="font-size: 28rpx; color: #00A2FF; margin-left: auto;">全部提现</text>
<text style="font-size: 28rpx; color: #818181;">最高可提现{{ maxWithdrawAmount.toFixed(2) }}</text>
<text style="font-size: 28rpx; color: #00A2FF; margin-left: auto;" @click="allWithdraw">全部提现</text>
</view>
<view class="center"
style="width: 304rpx; height: 90rpx; background-color: #00AC4E; color: #FFFFFF; margin: 30rpx auto 0; font-size: 32rpx;">
style="width: 304rpx; height: 90rpx; background-color: #00AC4E; color: #FFFFFF; margin: 30rpx auto 0; font-size: 32rpx;"
@click="submitWithdraw">
申请提现
</view>
@ -123,16 +128,32 @@
</template>
<script>
import {
getEarningsSummary,
getEarningsRule,
getEarningsRecordList,
getWithdrawRecordList,
applyWithdraw
} from '@/common/server/interface/earnings.js'
export default {
data() {
return {
currentIndex: 0,
show: false,
reflectShow: false,
dataList: [1, 2, 3, 4, 5, 6],
value: ''
dataList: [],
value: '',
pendingAmount: 0.00,
extractedAmount: 0.00,
maxWithdrawAmount: 0.00,
ruleContent: ''
}
},
onLoad() {
this.loadEarningsSummary();
this.loadDataList();
},
methods: {
//
goBack() {
@ -155,7 +176,117 @@
clickTab(index) {
this.currentIndex = index;
this.loadDataList();
},
//
async loadEarningsSummary() {
try {
const data = await getEarningsSummary();
if (data) {
this.pendingAmount = data.pendingAmount || 0.00;
this.extractedAmount = data.extractedAmount || 0.00;
this.maxWithdrawAmount = data.pendingAmount || 0.00;
}
} catch (error) {
console.error('加载收益统计失败:', error);
}
},
//
async loadRuleContent() {
try {
this.ruleContent = await getEarningsRule();
} catch (error) {
console.error('加载规则内容失败:', error);
this.ruleContent = '加载失败,请稍后重试';
}
},
//
async loadDataList() {
try {
if (this.currentIndex === 0) {
//
this.dataList = await getEarningsRecordList(1, 20);
} else {
//
this.dataList = await getWithdrawRecordList(1, 20);
}
} catch (error) {
console.error('加载列表数据失败:', error);
this.dataList = [];
}
},
//
async openRulePopup() {
this.show = true;
if (!this.ruleContent) {
await this.loadRuleContent();
}
},
//
async openWithdrawPopup() {
this.reflectShow = true;
//
await this.loadEarningsSummary();
},
//
allWithdraw() {
this.value = this.maxWithdrawAmount.toFixed(2);
},
//
async submitWithdraw() {
const amount = parseFloat(this.value);
if (!amount || amount <= 0) {
uni.showToast({
title: '请输入正确的提现金额',
icon: 'none'
});
return;
}
if (amount > this.maxWithdrawAmount) {
uni.showToast({
title: '提现金额不能超过待提取收益',
icon: 'none'
});
return;
}
try {
const result = await applyWithdraw(amount);
if (result.success) {
uni.showToast({
title: result.msg || '提现申请已提交',
icon: 'success'
});
this.reflectShow = false;
this.value = '';
//
await this.loadEarningsSummary();
if (this.currentIndex === 1) {
await this.loadDataList();
}
} else {
uni.showToast({
title: result.msg || '提现申请失败',
icon: 'none'
});
}
} catch (error) {
console.error('提现申请失败:', error);
uni.showToast({
title: '提现申请失败,请稍后重试',
icon: 'none'
});
}
},
open() {
},

View File

@ -18,7 +18,7 @@
### 接口1获取收益统计信息
#### 基本信息
- **接口路径**:建议 `GET /api/user/GetEarningsSummary` 或 `POST /api/user/GetEarningsSummary`
- **接口路径**:建议 `GET /api/sq/GetEarningsSummary`
- **调用时机**
- 页面初始化时
- 提现成功后刷新
@ -62,7 +62,7 @@ interface Response {
### 接口2获取收益规则说明
#### 基本信息
- **接口路径**:建议 `GET /api/user/GetEarningsRule``POST /api/user/GetEarningsRule`
- **接口路径**:建议 `GET /api/user/GetEarningsRule`
- **调用时机**
- 点击"点击查看收益规则"时第35-37行
- 打开规则弹窗时第86-96行
@ -103,7 +103,7 @@ interface Response {
### 接口3获取收益记录列表
#### 基本信息
- **接口路径**建议 `GET /api/user/GetEarningsRecordList``POST /api/user/GetEarningsRecordList`
- **接口路径** `POST /api/sq/GetEarningsRecordList`
- **调用时机**
- 页面初始化时currentIndex = 0
- 切换到"收益记录"标签时
@ -179,7 +179,7 @@ interface EarningsRecordItem {
### 接口4获取提现记录列表
#### 基本信息
- **接口路径**建议 `GET /api/user/GetWithdrawRecordList``POST /api/user/GetWithdrawRecordList`
- **接口路径**`POST /api/user/GetWithdrawRecordList`
- **调用时机**
- 切换到"提现记录"标签时currentIndex = 1
- 下拉刷新时
@ -254,7 +254,7 @@ interface WithdrawRecordItem {
### 接口5申请提现
#### 基本信息
- **接口路径**建议 `POST /api/user/ApplyWithdraw`
- **接口路径** `POST /api/sq/ApplyWithdraw`
- **调用时机**
- 点击"申请提现"按钮时第114行
- **是否需要登录**需要Token
@ -302,23 +302,7 @@ interface Response {
}
```
---
### 接口6获取最高可提现金额可选
#### 基本信息
- **接口路径**:建议 `GET /api/user/GetMaxWithdrawAmount` 或使用接口1的 `pendingAmount`
- **调用时机**
- 打开提现弹窗时第98-118行
- 用于显示"最高可提现0.00元"第108行
- **是否需要登录**需要Token
#### 说明
此接口可以复用**接口1获取收益统计信息**中的 `pendingAmount` 字段,无需单独接口。
如果后端需要单独接口可参考接口1的返回结构只返回 `pendingAmount`
---
## 📝 页面数据映射总览
@ -359,7 +343,7 @@ interface Response {
### 1. 接口定义位置
建议在 `common/server/interface/user.js` 中添加:
建议在 `common/server/interface/earnings.js` 中添加:
```javascript
/**
@ -367,7 +351,7 @@ interface Response {
* @returns {Promise<{pendingAmount: number, extractedAmount: number}>}
*/
export const getEarningsSummary = async () => {
const res = await request.getOrCache("user/GetEarningsSummary", {}, 1);
const res = await request.getOrCache("sq/GetEarningsSummary", {}, 1);
if (res.code == 0) {
return res.data;
}
@ -379,7 +363,7 @@ export const getEarningsSummary = async () => {
* @returns {Promise<string>}
*/
export const getEarningsRule = async () => {
const res = await request.getOrCache("user/GetEarningsRule", {}, 300);
const res = await request.getOrCache("sq/GetEarningsRule", {}, 300);
if (res.code == 0) {
return res.data.content;
}
@ -394,7 +378,7 @@ export const getEarningsRule = async () => {
*/
export const getEarningsRecordList = async (pageIndex = 1, pageSize = 20) => {
const res = await request.getOrCache(
"user/GetEarningsRecordList",
"sq/GetEarningsRecordList",
{ pageIndex, pageSize },
1
);
@ -412,7 +396,7 @@ export const getEarningsRecordList = async (pageIndex = 1, pageSize = 20) => {
*/
export const getWithdrawRecordList = async (pageIndex = 1, pageSize = 20) => {
const res = await request.getOrCache(
"user/GetWithdrawRecordList",
"sq/GetWithdrawRecordList",
{ pageIndex, pageSize },
1
);
@ -428,7 +412,7 @@ export const getWithdrawRecordList = async (pageIndex = 1, pageSize = 20) => {
* @returns {Promise<boolean>}
*/
export const applyWithdraw = async (amount) => {
const res = await request.post("user/ApplyWithdraw", { amount });
const res = await request.post("sq/ApplyWithdraw", { amount });
if (res.code == 0) {
return true;
}
@ -445,7 +429,7 @@ import {
getEarningsRecordList,
getWithdrawRecordList,
applyWithdraw
} from '@/common/server/interface/user.js'
} from '@/common/server/interface/earnings.js'
export default {
data() {