feat: 添加去变现功能

This commit is contained in:
2026-06-01 16:12:25 +08:00
parent c2388e1396
commit d2f77335d1
5 changed files with 403 additions and 2 deletions
+14
View File
@@ -837,6 +837,20 @@
{ {
"navigationBarTitleText" : "钱包" "navigationBarTitleText" : "钱包"
} }
},
{
"path": "liquidation",
"style": {
"navigationBarTitleText": "去变现",
"enablePullDownRefresh": false
}
},
{
"path": "liquidationRecord",
"style": {
"navigationBarTitleText": "变现记录",
"enablePullDownRefresh": false
}
} }
] ]
}, },
+279
View File
@@ -0,0 +1,279 @@
<template>
<s-pages title="去变现">
<view class="liquidation">
<view class="top_bar">
<view class="record_link" @click="goRecord">变现记录</view>
</view>
<view class="container">
<view class="card balance-card">
<view class="balance-label">当前钱包余额</view>
<view class="balance-value">{{ $fen2yuan(walletBalanceCents || 0) }}</view>
</view>
<view class="section-row">
<view class="section-title">转出资产</view>
</view>
<view class="card input-card">
<view class="amount-row">
<view class="amount-prefix">¥</view>
<uni-easyinput
v-model="amountInput"
type="digit"
placeholder="00.00"
placeholder-style="font-size: 64rpx;color:#C6C6C6;"
:inputBorder="false"
:min="0"
:clearSize="50"
@blur="onAmountBlur"
@confirm="submit"
/>
</view>
<view class="tip-text">请输入去变现数量</view>
</view>
<view class="card tip-card">
<view class="tip-header">
<view class="tip-title">兑换提示</view>
<uni-icons type="info" color="#C6C6C6" size="22" />
</view>
<view class="tip-text">请慎重考虑,一经兑换,不可撤销</view>
</view>
</view>
<view class="bottom-bar">
<view class="confirm-btn" @click="submit">确定</view>
</view>
</view>
</s-pages>
</template>
<script setup>
import { computed, ref } from 'vue';
import { onShow } from '@dcloudio/uni-app';
import * as payApi from '@/sheep/api/home/pay';
import * as incrementApi from '@/sheep/api/increment';
import sheep from '@/sheep';
const walletBalanceCents = ref(0);
const amount = ref('');
const sanitizeAmountInput = (val) => {
let next = String(val ?? '').replace(/[^\d.]/g, '');
const firstDot = next.indexOf('.');
if (firstDot !== -1) {
next = next.slice(0, firstDot + 1) + next.slice(firstDot + 1).replace(/\./g, '');
const [a, b = ''] = next.split('.');
next = `${a}.${b.slice(0, 2)}`;
}
return next;
};
const amountInput = computed({
get: () => String(amount.value ?? ''),
set: (v) => {
amount.value = sanitizeAmountInput(v);
},
});
const amountNumber = computed(() => {
const n = Number(amount.value);
return Number.isFinite(n) ? n : 0;
});
const availableYuan = computed(() => Number(walletBalanceCents.value || 0) / 100);
const refreshWallet = async () => {
const res = await payApi.getWallet().catch(() => ({ code: -1 }));
if (res?.code === 0) walletBalanceCents.value = res?.data?.balance ?? 0;
};
const onAmountBlur = () => {
if (amountNumber.value < 0) {
sheep.$helper.toast('请输入正确金额');
amount.value = '0';
return;
}
if (amountNumber.value > availableYuan.value) {
sheep.$helper.toast('变现金额不能大于钱包余额');
amount.value = availableYuan.value > 0 ? String(availableYuan.value.toFixed(2)) : '0';
}
};
const submit = async () => {
const amt = amountNumber.value;
if (!amt) {
sheep.$helper.toast('请输入去变现数量');
return;
}
if (amt > availableYuan.value) {
sheep.$helper.toast('变现金额不能大于钱包余额');
amount.value = availableYuan.value > 0 ? String(availableYuan.value.toFixed(2)) : '0';
return;
}
const money = Math.round(amt * 100);
const res = await incrementApi.walletLiquidation({ money }).catch(() => ({ code: -1 }));
if (res?.code === 0) {
sheep.$helper.toast('提交成功');
amount.value = '';
refreshWallet();
}
};
const goRecord = () => {
uni.navigateTo({
url: '/pages/home/liquidationRecord',
});
};
onShow(() => {
refreshWallet();
});
</script>
<style lang="scss" scoped>
.liquidation {
min-height: 100vh;
}
.top_bar {
padding: 22rpx 40rpx 0;
display: flex;
justify-content: flex-end;
}
.record_link {
height: 60rpx;
padding: 0 22rpx;
border-radius: 30rpx;
border: 2rpx solid rgba(0, 0, 0, 0.08);
background: rgba(255, 255, 255, 0.75);
color: #333333;
font-size: 26rpx;
display: flex;
align-items: center;
justify-content: center;
box-sizing: border-box;
}
.container {
padding: 32rpx 40rpx 200rpx;
}
.card {
background: #f4f8f2;
border-radius: 24rpx;
padding: 28rpx;
}
.balance-card {
margin-bottom: 28rpx;
}
.balance-label {
color: #333333;
font-size: 26rpx;
line-height: 36rpx;
}
.balance-value {
margin-top: 12rpx;
color: #111111;
font-size: 72rpx;
font-weight: 700;
line-height: 84rpx;
}
.section-row {
display: flex;
align-items: center;
justify-content: space-between;
padding: 4rpx 4rpx 18rpx;
}
.section-title {
font-size: 28rpx;
color: #111111;
font-weight: 600;
}
.input-card {
padding: 24rpx 28rpx;
}
.amount-row {
display: flex;
align-items: center;
}
.amount-prefix {
color: #111111;
font-size: 40rpx;
font-weight: 600;
margin-right: 14rpx;
}
:deep(.uni-easyinput__content) {
background: transparent !important;
border: none !important;
}
:deep(.uni-easyinput__content-input) {
height: 84rpx !important;
font-size: 64rpx !important;
color: #9a9a9a !important;
font-weight: 600;
}
:deep(.uni-input-input) {
color: #111111 !important;
font-weight: 700;
}
.tip-card {
margin-top: 20rpx;
padding: 28rpx;
}
.tip-header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 14rpx;
}
.tip-title {
font-size: 26rpx;
color: #111111;
font-weight: 600;
}
.tip-text {
color: #8b8b8b;
font-size: 22rpx;
line-height: 32rpx;
}
.bottom-bar {
position: fixed;
left: 0;
right: 0;
bottom: 0;
padding: 22rpx 32rpx calc(22rpx + env(safe-area-inset-bottom));
background: #ffffff;
}
.confirm-btn {
height: 96rpx;
border-radius: 20rpx;
background: linear-gradient(90deg, #00a87a 0%, #02b06c 100%);
color: #ffffff;
font-size: 34rpx;
font-weight: 700;
display: flex;
align-items: center;
justify-content: center;
}
</style>
+73
View File
@@ -0,0 +1,73 @@
<template>
<s-pages title="变现记录">
<card_mescroll ref="cardPages" @upCallback="getList" :height="height">
<view class="bg24 radius12 m-x-42 p-y-28 p-x-40" v-if="detailList.length">
<view
class="flex-between border-bottom"
style="height: 150rpx"
v-for="(v, i) in detailList"
:key="i"
>
<view class="c0">
<view class="size28"> 发起变现 </view>
<view class="c_999 size24 m-t-10">
{{ sheep.$helper.timeFormat(v.createTime, 'yyyy-mm-dd hh:MM:ss') }}
</view>
</view>
<view class="c0">
<view class="size28 price">
{{ fen2yuan(v.liquidationAmount) }}
</view>
<view class="status size24 m-t-10">
{{ v.statusDescription }}
</view>
</view>
</view>
</view>
</card_mescroll>
</s-pages>
</template>
<script setup>
import sheep from '@/sheep';
import { ref } from 'vue';
import { onLoad } from '@dcloudio/uni-app';
import card_mescroll from '@/components/card_pages/card_mescroll.vue';
import { fen2yuan } from '@/sheep/hooks/useGoods';
import * as api from '@/sheep/api/increment';
let detailList = ref([]);
let height = ref('100%');
let sysInfo = uni.getSystemInfoSync();
height.value = sysInfo.windowHeight - sysInfo.statusBarHeight - uni.upx2px(88) + 'px';
let cardPages = ref(null);
const getList = async (mescroll) => {
const res = await api.walletLiquidationRecordPage({
pageNo: mescroll.num,
pageSize: mescroll.size,
});
if (res.code === 0) {
const data = res.data?.list || [];
if (mescroll.num == 1) detailList.value = [];
detailList.value = detailList.value.concat(data);
cardPages.value.getState(true, data.length);
} else {
cardPages.value.getState(false);
}
};
onLoad(() => {});
</script>
<style scoped lang="scss">
.price {
text-align: right;
}
.status {
text-align: right;
color: #366eee;
}
</style>
+21 -2
View File
@@ -10,11 +10,12 @@
{{ $fen2yuan(money_obj?.balance || 0) }} {{ $fen2yuan(money_obj?.balance || 0) }}
</view> </view>
<view class="line" /> <view class="line" />
<view class="flex m-t-22"> <view class="flex m-t-22 withdraw_row">
<view class="title"> 可提现金额 </view> <view class="title"> 可提现金额 </view>
<view class="num m-l-34" @click="jumpPage('提现', '/pages/home/pay/withdraw')"> <view class="num m-l-34" @click="jumpPage('提现', '/pages/home/pay/withdraw')">
{{ $fen2yuan(money_obj?.withdrawAmount || 0) }} {{ $fen2yuan(money_obj?.withdrawAmount || 0) }}
</view> </view>
<view class="withdraw_btn" @click="jumpPage('变现', '/pages/home/liquidation')">去变现</view>
</view> </view>
</view> </view>
</view> </view>
@@ -35,7 +36,7 @@
<script setup> <script setup>
import { ref } from 'vue'; import { ref } from 'vue';
import { onLoad, onShow } from '@dcloudio/uni-app'; import { onLoad } from '@dcloudio/uni-app';
import * as api from '@/sheep/api/home/pay'; import * as api from '@/sheep/api/home/pay';
import * as apiIndex from '@/sheep/api/index/index'; import * as apiIndex from '@/sheep/api/index/index';
import goods from '@/components/goods/goods.vue'; import goods from '@/components/goods/goods.vue';
@@ -116,6 +117,24 @@
rgba(255, 255, 255, 0) 100% rgba(255, 255, 255, 0) 100%
); );
} }
.withdraw_row {
align-items: center;
}
.withdraw_btn {
margin-left: auto;
height: 44rpx;
padding: 0 18rpx;
line-height: 44rpx;
font-size: 24rpx;
font-weight: 500;
color: #ffffff;
border: 2rpx solid rgba(255, 255, 255, 0.55);
border-radius: 22rpx;
background: rgba(255, 255, 255, 0.16);
box-sizing: border-box;
}
} }
} }
+16
View File
@@ -133,3 +133,19 @@ export function automaticGroupBuy(data: any) {
}, },
}) })
} }
export function walletLiquidation(data: any) {
return request({
url: '/trade/wallet-liquidation-record/apply',
method: 'post',
data,
})
}
export const walletLiquidationRecordPage = (params: any) => {
return request({
url: '/trade/wallet-liquidation-record/page',
method: 'get',
params,
})
}