231
This commit is contained in:
parent
a58b4e431b
commit
316d1e2b5d
83
common/server/interface/earnings.js
Normal file
83
common/server/interface/earnings.js
Normal 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;
|
||||
|
|
@ -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() {
|
||||
|
||||
},
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user