添加功能(用户申请提现)

This commit is contained in:
2025-06-10 12:18:44 +08:00
parent 4d40d86061
commit a20fbe81e3
8 changed files with 119 additions and 29 deletions

View File

@ -4,11 +4,10 @@
.page { .page {
background-color: #ffffff; background-color: #ffffff;
width: 100%; width: 100%;
overflow: hidden;
height: 100%; height: 100%;
} }
.section { .section {
padding: 88.46rpx 0 878.85rpx; padding: 88.46rpx 0 87.85rpx;
background-image: linear-gradient(180deg, #ffa74f -29.4%, #ffffff1a 115.7%); background-image: linear-gradient(180deg, #ffa74f -29.4%, #ffffff1a 115.7%);
} }
.section_2 { .section_2 {

View File

@ -47,7 +47,9 @@ Page({
title: '更新成功', title: '更新成功',
icon: 'success', icon: 'success',
}); });
setTimeout(() => {
wx.navigateBack({}); wx.navigateBack({});
}, 1000)
} }
}, },
fail(err) { fail(err) {

View File

@ -80,8 +80,8 @@
</view> </view>
<!-- 保存按钮 --> <!-- 保存按钮 -->
<view wx:if="{{ isUpdate }}" class="flex-col justify-start items-center self-center text-wrapper_3"> <view wx:if="{{ isUpdate }}" class="flex-col justify-start items-center self-center text-wrapper_3" bindtap="updateInfo">
<text class="font_2 text_8" bindtap="updateInfo" >更新</text> <text class="font_2 text_8">更新</text>
</view> </view>
<view wx:else="{{ isUpdate }}" class="flex-col justify-start items-center self-center text-wrapper_3"> <view wx:else="{{ isUpdate }}" class="flex-col justify-start items-center self-center text-wrapper_3">
<text class="font_2 text_8" bindtap="saveInfo" >保存</text> <text class="font_2 text_8" bindtap="saveInfo" >保存</text>

View File

@ -11,7 +11,7 @@
.font_2 { .font_2 {
font-size: 30.53rpx; font-size: 30.53rpx;
font-family: SourceHanSansCN; font-family: SourceHanSansCN;
line-height: 28.09rpx; line-height: 30.53rpx;
color: #000000; color: #000000;
} }
.text_2 { .text_2 {
@ -95,12 +95,11 @@
} }
.text-wrapper_3 { .text-wrapper_3 {
margin-top: 57.25rpx; margin-top: 57.25rpx;
padding: 25.84rpx 0 20.5rpx; padding: 26.25rpx 0;
background-color: #ff8d1a; background-color: #ff8d1a;
border-radius: 19.08rpx; border-radius: 19.08rpx;
width: 248.09rpx; width: 243.75rpx;
} }
.text_8 { .text_8 {
line-height: 100%;
color: #ffffff; color: #ffffff;
} }

View File

@ -6,13 +6,15 @@ Page({
* 页面的初始数据 * 页面的初始数据
*/ */
data: { data: {
withdrawalAccount: '', // 这里保存提现账户信息 currentBalance: 0, // 当前可提现余额
withdrawalAccount: '', // 提现账户信息
withdrawnAmount: '', // 用户输入的提现金额
}, },
// 获取当前账户信息 // 获取当前账户信息
getAccountInfo() { getAccountInfo() {
wx.request({ wx.request({
url: baseUrl + '/userAccount/queryById', // 替换为你的后端接口 url: baseUrl + '/withdrawalApply/query/condition', // 替换为你的后端接口
method: 'POST', method: 'POST',
header: { header: {
Authorization: wx.getStorageSync('token'), Authorization: wx.getStorageSync('token'),
@ -20,8 +22,10 @@ Page({
success: (res) => { success: (res) => {
console.log('当前账户是---->', res.data.data); console.log('当前账户是---->', res.data.data);
if (res.data.code === 1) { if (res.data.code === 1) {
let result = res.data.data;
this.setData({ this.setData({
withdrawalAccount: res.data.data.bankCardNumber, currentBalance: result.currentBalance.toFixed(2),
withdrawalAccount: result.bankCardNumber
}); });
} else { } else {
wx.showToast({ wx.showToast({
@ -39,11 +43,95 @@ Page({
}); });
}, },
// 输入框内容变化时更新数据
onInput(e) {
this.setData({
withdrawnAmount: e.detail.value, // 获取用户输入的金额
});
},
// 点击“全部提现”,填充当前可提现余额到输入框
onWithdrawAll() {
this.setData({
withdrawnAmount: this.data.currentBalance, // 将当前余额填入提现金额输入框
});
},
// 点击“立即提现”,发送请求
onSubmitWithdraw() {
const { withdrawnAmount, currentBalance } = this.data;
// 校验提现金额是否大于当前可提现余额
if (!withdrawnAmount) {
wx.showToast({
title: '请输入提现金额',
icon: 'none'
});
return;
}
// 校验提现金额是否大于当前可提现余额
if (parseFloat(withdrawnAmount) > parseFloat(currentBalance)) {
wx.showToast({
title: '提现金额不可大于余额',
icon: 'none'
});
return;
}
// 校验提现金额是否小于1元
if (parseFloat(withdrawnAmount) < 1) {
wx.showToast({
title: '最低提现金额为1元',
icon: 'none'
});
return;
}
// 发送提现请求
wx.request({
url: baseUrl + '/withdrawalApply/add', // 后端提现请求路径
method: 'POST',
header: {
Authorization: wx.getStorageSync('token'), // 请求头中加入token
},
data: {
withdrawnAmount: withdrawnAmount // 请求体携带提现金额
},
success: (res) => {
if (res.data.code === 1) {
wx.showToast({
title: '提现成功,等待后台审核',
icon: 'none',
});
// 1秒后跳转到账单详情页面
setTimeout(() => {
wx.redirectTo({
url: '/pages/personCenter/billingDetails/billingDetails',
});
}, 1000); // 延时1秒跳转
} else {
wx.showToast({
title: '提现失败,请重试',
icon: 'none'
});
}
},
fail: () => {
wx.showToast({
title: '请求失败,请稍后再试',
icon: 'none'
});
}
});
},
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad(options) { onLoad(options) {
this.getAccountInfo() this.getAccountInfo(); // 加载页面时获取账户信息
}, },
/** /**

View File

@ -22,14 +22,14 @@
class="shrink-0 image_2" class="shrink-0 image_2"
src="./images/money.png" src="./images/money.png"
/> />
<input class="font_2 text_3 ml-13" placeholder="请输入金额" /> <input class="font_2 text_3 ml-13" placeholder="请输入提现金额" bindinput="onInput" type="digit" value="{{withdrawnAmount}}"/>
</view> </view>
<text class="text_4">全部提现</text> <text class="text_4" bindtap="onWithdrawAll">全部提现</text>
</view> </view>
<text class="self-start font_2 text_5 mt-19">可提现:13.93元</text> <text class="self-start font_2 text_5 mt-19">可提现:{{ currentBalance }}元</text>
</view> </view>
</view> </view>
<view class="flex-col justify-start items-center self-center text-wrapper"> <view bindtap="onSubmitWithdraw" class="flex-col justify-start items-center self-center text-wrapper">
<text class="font text_6">立即提现</text> <text class="font text_6">立即提现</text>
</view> </view>
</view> </view>

View File

@ -41,10 +41,11 @@
font-size: 26.72rpx; font-size: 26.72rpx;
font-family: SourceHanSansCN; font-family: SourceHanSansCN;
line-height: 21.39rpx; line-height: 21.39rpx;
color: #000000; color: #323232;
} }
.text { .text {
line-height: 20.29rpx; font-size: 32.25rpx;
line-height: 32.25rpx;
} }
.section_3 { .section_3 {
margin-top: 40.08rpx; margin-top: 40.08rpx;
@ -65,18 +66,19 @@
height: 41.98rpx; height: 41.98rpx;
} }
.text_3 { .text_3 {
color: #b0b0b0; color: #323232;
line-height: 24.92rpx; line-height: 35.25rpx;
font-size: 35.25rpx;
} }
.text_4 { .text_4 {
color: #ff8d1a; color: #ff8d1a;
font-size: 22.9rpx; font-size: 30.25rpx;
font-family: SourceHanSansCN; font-family: SourceHanSansCN;
line-height: 21.39rpx; line-height: 30.25rpx;
} }
.text_5 { .text_5 {
font-size: 24.81rpx; font-size: 30.25rpx;
line-height: 22.88rpx; line-height: 30.25rpx;
} }
.text-wrapper { .text-wrapper {
margin-top: 64.89rpx; margin-top: 64.89rpx;

View File

@ -1,6 +1,6 @@
export const local='http://localhost:9091'; export const local='http://localhost:9091';
export const ip = 'http://27.30.77.229:9091'; export const ip = 'http://27.30.77.229:9091';
export const test = 'http://27.30.77.229:9092'; export const test = 'http://27.30.77.229:9092';
export const baseUrl = ip; export const baseUrl = local;
export const globalImgUrl = baseUrl + '/file/download/' export const globalImgUrl = baseUrl + '/file/download/'