优化提现界面的小数展示

This commit is contained in:
gyq
2025-08-20 16:23:23 +08:00
parent 855a884c4c
commit efce59d822
2 changed files with 598 additions and 603 deletions

View File

@@ -146,6 +146,7 @@ function commonsProcess(showLoading, httpReqCallback, isreturm, url) {
}
if (res.code == 401) {
uni.clearStorageSync()
uni.redirectTo({
url: "/pages/login/login",
});

View File

@@ -1,9 +1,8 @@
<template>
<view class="container">
<up-navbar title="申请提现" :autoBack="true" bgColor="rgb(255, 117, 129)" leftIconColor="#FFF"
:titleStyle="{color:'#FFF'}">
<up-navbar title="申请提现" :autoBack="true" bgColor="rgb(255, 117, 129)" leftIconColor="#FFF" :titleStyle="{ color: '#FFF' }">
<template #right>
<view class="u-p-r-30 u-flex u-col-center" style="color: #fff;">
<view class="u-p-r-30 u-flex u-col-center" style="color: #fff">
<text class="rule-btn" @click="showRule">规则</text>
</view>
</template>
@@ -13,26 +12,25 @@
<view class="title">可提现总额</view>
<view class="mayMoney">¥ {{ data.mayMoney }}</view>
<view class="val" style="">
<view style="display: flex;flex-direction: row;padding: 20upx;">
<view style="font-size: 32upx;color: #333333;">提现金额</view>
<view style="display: flex; flex-direction: row; padding: 20upx">
<view style="font-size: 32upx; color: #333333">提现金额</view>
</view>
<view class="input" style="">
<view style="display: flex;align-items: center;">
<view style="font-size: 40upx;color: #333333;">¥</view>
<input type="digit" v-model="data.money" placeholder="请输入金额" @input="moneyInput"
style="font-size: 32rpx;color: #333333;text-align: left;margin-left: 10rpx;width: 80%;" />
<view style="display: flex; align-items: center">
<view style="font-size: 40upx; color: #333333">¥</view>
<input
type="digit"
v-model="data.money"
placeholder="请输入金额"
@input="moneyInput"
style="font-size: 32rpx; color: #333333; text-align: left; margin-left: 10rpx; width: 80%"
/>
</view>
<view class="allbtn" @click="setAllMoney">
全部
<view class="allbtn" @click="setAllMoney">全部</view>
</view>
</view>
</view>
<view class="witBtn" @click="goWithdraw">{{ data.isWithdraw ? '立即提现' : '观看广告提现' }}</view>
<view style="color: #666;" @click="WithdrawalAlipay">
提现到支付宝
</view>
<view style="color: #666" @click="WithdrawalAlipay">提现到支付宝</view>
<view class="tab" style="">
<view @click="linkTo('/pages/me/withdraw/realName')">实名认证</view>
<!-- <view @click="linkTo('/pages/me/withdraw/alipay')">提现账号</view> -->
@@ -42,60 +40,64 @@
<view class="moneyList u-p-b-30">
<view v-if="data.list.length" v-for="(item, index) in data.list" :key="index" class="item">
<view>
<view style="margin-bottom: 8upx;text-align: right;">
<view style="margin-bottom: 8upx; text-align: right">
<text style="margin-bottom: 8upx; color: green" v-if="item.state === 1">提现成功</text>
<text style="margin-bottom: 8upx;color: green" v-if="item.state===0||item.state==3">
提现</text>
<text style="margin-bottom: 8upx;color: #FD6416" v-if="item.state===-1||item.state===2">
提现失败
</text>
<text style="margin-bottom: 8upx; color: green" v-if="item.state === 0 || item.state == 3">提现中</text>
<text style="margin-bottom: 8upx; color: #fd6416" v-if="item.state === -1 || item.state === 2">提现失败</text>
</view>
<view style="color: #999999;font-size: 28upx;">
<view style="color: #999999; font-size: 28upx">
<view style="margin-bottom: 8upx">收款人账号{{ item.zhifubao }}</view>
<view style="margin-bottom: 8upx">收款人姓名{{ item.zhifubaoName }}</view>
<view style="margin-bottom: 8upx">发起时间{{ item.createAt }}</view>
<view style="margin-bottom: 8upx" v-if="item.state === 1">成功时间 {{ item.outAt }}</view>
<view style="margin-bottom: 8upx;color: #FD6416" v-if="item.state===-1||item.state===2">
失败原因{{ item.refund }}
</view>
<view style="margin-bottom: 8upx; color: #fd6416" v-if="item.state === -1 || item.state === 2">失败原因{{ item.refund }}</view>
<view style="margin-bottom: 8upx;text-align: right;">
<view style="margin-bottom: 8upx; text-align: right">
<!-- 提现金额 -->
<text style="color: #FD6416;font-size: 32upx;font-weight: 600"> {{ item.money }}</text>
<text style="color: #fd6416; font-size: 32upx; font-weight: 600">{{ item.money }}</text>
</view>
</view>
</view>
</view>
<emprty-card v-if="!data.list.length" />
</view>
</view>
<up-modal :show="data.ruleShow" confirm-text="知道了" title="规则说明" :title="data.rule_title"
:title-style="{fontWeight:'700'}" @confirm="ruleConfirm" confirm-color="rgb(255, 117, 129)">
<up-modal
:show="data.ruleShow"
confirm-text="知道了"
title="规则说明"
:title="data.rule_title"
:title-style="{ fontWeight: '700' }"
@confirm="ruleConfirm"
confirm-color="rgb(255, 117, 129)"
>
<view class="u-p-30 u-text-left" v-if="data.ruleShow">
<scroll-view scroll-y="true" style="max-height: 50vh;">
<rich-text style="text-align: justify;font-size: 18px;color: #666;"
:nodes="data.rule_content"></rich-text>
<scroll-view scroll-y="true" style="max-height: 50vh">
<rich-text style="text-align: justify; font-size: 18px; color: #666" :nodes="data.rule_content"></rich-text>
</scroll-view>
</view>
</up-modal>
<view style="width: 0;height: 0;overflow: hidden;">
<view style="width: 0; height: 0; overflow: hidden">
<!-- 激励视频广告 -->
<ad-rewarded-video ref="adRewardedw" :adpid="data.adpid" :loadnext="true" :url-callback="data.urlCallback"
@load="onadload" @close="onadclose" @error="onaderror">
</ad-rewarded-video>
<ad-rewarded-video
ref="adRewardedw"
:adpid="data.adpid"
:loadnext="true"
:url-callback="data.urlCallback"
@load="onadload"
@close="onadclose"
@error="onaderror"
></ad-rewarded-video>
</view>
</view>
</template>
<script setup>
import { reactive, nextTick, ref } from 'vue';
import { onReady,onLoad,onShow,onLaunch,onPullDownRefresh, onReachBottom } from '@dcloudio/uni-app'
import { onReady, onLoad, onShow, onLaunch, onPullDownRefresh, onReachBottom } from '@dcloudio/uni-app';
import { selectUserMoney, selectPayDetails, canCash, state, withdraw } from '@/api/me/withdraw.js';
import { selectUserById } from '@/api/user/user.js';
import { announcement } from '@/api/index/index.js';
@@ -104,8 +106,8 @@
const data = reactive({
ruleShow: false,
rule_title: "",
rule_content: "",
rule_title: '',
rule_content: '',
money: '',
mayMoney: '0',
list: [],
@@ -122,7 +124,7 @@
userInfo: null,
ruleIndex: 0,
ruleList: []
})
});
const adRewardedw = ref(null);
onLoad(() => {
@@ -130,47 +132,46 @@
// data.adpid = 1531580352
// }
// if ( uni.getSystemInfoSync().platform == 'ios' ) {
data.adpid = 1373604770
data.adpid = 1373604770;
// }
getExtractFei();
getMoneyDetail();
getCanCash()
getCanCash();
announcement({
type: 1
}).then(res => {
data.ruleList = res
}).then((res) => {
data.ruleList = res;
ruleInit()
})
})
ruleInit();
});
});
onShow(() => {
getcashMoney()
getcashMoney();
getUserInfo();
})
});
onReady(() => {
nextTick(() => {
data.adRewardedVideoloadNum = 0
data.adRewardedVideoloadNum = 0;
adRewardedw.value.load();
data.ruleShow = true
})
})
data.ruleShow = true;
});
});
onReachBottom(() => {
if (data.page * data.limit < data.totalCount) {
data.page = data.page + 1;
getMoneyDetail();
}
})
});
onPullDownRefresh(() => {
data.page = 1;
data.list = []
data.list = [];
getMoneyDetail();
})
});
function ruleInit() {
data.rule_content = ""
data.rule_title = data.ruleList[data.ruleIndex].title
data.rule_content = data.ruleList[data.ruleIndex].content
data.rule_content = '';
data.rule_title = data.ruleList[data.ruleIndex].title;
data.rule_content = data.ruleList[data.ruleIndex].content;
}
/**
* 规则弹窗打开
@@ -178,35 +179,35 @@
function showRule() {
if (data.ruleList.length <= 0) {
uni.showToast({
title: "暂未配置规则",
title: '暂未配置规则',
icon: 'none'
})
});
return false;
}
ruleInit()
data.ruleShow = true
ruleInit();
data.ruleShow = true;
}
/**
* 规则确认
*/
function ruleConfirm() {
console.log(1)
data.ruleShow = false
data.ruleIndex++
console.log(1);
data.ruleShow = false;
data.ruleIndex++;
if (data.ruleIndex >= data.ruleList.length) {
data.ruleIndex = 0
return
data.ruleIndex = 0;
return;
}
setTimeout(res => {
ruleInit()
data.ruleShow = true
}, 300)
setTimeout((res) => {
ruleInit();
data.ruleShow = true;
}, 300);
}
function getUserInfo() {
selectUserById().then(res => {
selectUserById().then((res) => {
data.userInfo = res;
})
});
}
function WithdrawalAlipay() {
@@ -215,53 +216,52 @@
withdraw({
amount: data.money,
isAlipay: 1
}).then(res => {
data.money = ''
uni.setStorageSync('adRewardedNum', 0)
}).then((res) => {
data.money = '';
uni.setStorageSync('adRewardedNum', 0);
setTimeout(function () {
getcashMoney()
}, 1500)
getcashMoney();
}, 1500);
uni.showToast({
title: res.msg,
icon: 'none'
})
})
});
});
} else {
uni.showToast({
title: "请输入金额",
icon: 'none',
})
title: '请输入金额',
icon: 'none'
});
}
} else {
uni.showToast({
title: "请绑定支付宝",
icon: 'none',
})
title: '请绑定支付宝',
icon: 'none'
});
setTimeout(() => {
// 未绑定信息
linkTo('/pages/me/withdraw/alipay')
}, 1500)
linkTo('/pages/me/withdraw/alipay');
}, 1500);
}
}
function back() {
uni.navigateBack()
uni.navigateBack();
}
/**
* 获取看广告状态
*/
async function getCanCash() {
canCash().then(res => {
canCash().then((res) => {
data.isWithdraw = res;
console.log(res)
console.log(res);
if (uni.getStorageSync('adRewardedNum') >= 3) {
data.isWithdraw = true;
// uni.setStorageSync('adRewardedNum',0)
} else {
uni.setStorageSync('adRewardedNum', ((uni.getStorageSync('adRewardedNum') || 0) + 1))
uni.setStorageSync('adRewardedNum', (uni.getStorageSync('adRewardedNum') || 0) + 1);
}
})
});
}
/**
* 广告数据加载成功回调
@@ -269,7 +269,7 @@
*/
function onadload(e) {
data.adRewardedShow = true;
uni.setStorageSync('adRewardedNum', 0)
uni.setStorageSync('adRewardedNum', 0);
console.log('广告数据加载成功');
}
@@ -279,13 +279,13 @@
*/
function onaderror(e) {
if (data.adRewardedVideoloadNum >= 3) {
return
return;
}
data.adRewardedVideoloadNum++
data.adRewardedVideoloadNum++;
setTimeout(() => {
adRewardedw.value.load();
}, 1000); // 10
console.log("广告加载失败", e)
console.log('广告加载失败', e);
}
/**
@@ -293,24 +293,24 @@
* @param {Object} e
*/
async function onadclose(e) {
const detail = e.detail
const detail = e.detail;
if (detail && detail.isEnded) {
// 正常播放结束
console.log(data.urlCallback.extra)
console.log(data.urlCallback.extra);
let res = await state({
extraKey: data.urlCallback.extra
})
console.log(res)
uni.setStorageSync('adRewardedNum', 0)
getCanCash()
});
console.log(res);
uni.setStorageSync('adRewardedNum', 0);
getCanCash();
} else {
// 播放中途退出
}
}
function onNavigationBarButtonTap() {
console.log(1)
data.ruleShow = true
console.log(1);
data.ruleShow = true;
}
/**
@@ -323,17 +323,16 @@
icon: 'none',
title: '广告加载失败,请稍后重试'
});
return
return;
}
data.urlCallback = {
userId: uni.getStorageSync('userInfo').userId,
extra: 'cash:' + uni.getStorageSync('userInfo').userId + "" + new Date().getTime(),
}
extra: 'cash:' + uni.getStorageSync('userInfo').userId + '' + new Date().getTime()
};
adRewardedw.value.show();
} else {
getOut()
getOut();
}
}
function moneyInput(e) {
@@ -344,7 +343,7 @@
* 全部提现赋值
*/
function setAllMoney() {
data.money = getMoneys(data.mayMoney)
data.money = getMoneys(data.mayMoney);
}
/**
@@ -353,28 +352,21 @@
* money:金额
* 保留两位小数&不四舍五入
*/
function getMoneys(money) {
if (!money || isNaN(money)) return "0.00";
let num = parseFloat(money + '') + '';
num = parseInt(money * 100 + '') / 100 + ''
let reg = /(-?\d+)(\d{4})/;
while (reg.test(num)) {
num = num.replace(reg, "$1,$2");
function getMoneys(num, decimal = 2, isInt = false) {
num = +num;
num = num.toFixed(3).toString();
const index = num.indexOf('.');
if (index !== -1) {
num = num.substring(0, decimal + index + 1);
} else {
num = num.substring(0);
}
let idx = num.indexOf('.')
if (idx === -1) {
num = num + '.00'
//截取后保留两位小数
if (isInt) {
return parseFloat(num);
} else {
return parseFloat(num).toFixed(decimal);
}
if (idx > 0) {
let num_per = num.substring(0, idx) + '.'
let num_next = num.substring(idx + 1).padEnd(2, '0')
num = num_per + num_next
}
return num;
}
/**
@@ -384,7 +376,7 @@
selectPayDetails({
page: data.page,
limit: data.limit
}).then(res => {
}).then((res) => {
data.totalCount = res.totalCount;
if (res.list.length > 0) {
data.list = [...data.list, ...res.list];
@@ -392,14 +384,14 @@
setTimeout(() => {
uni.stopPullDownRefresh();
}, 500);
})
});
}
/**
* 获取最低提现金额
*/
function getExtractFei() {
commonType(112).then(res => {
commonType(112).then((res) => {
if (res && res.value) {
data.cashMoney = res.value;
}
@@ -409,12 +401,12 @@
/**
* 可提现金额
*/
const totalMoney=ref(0)
const totalMoney = ref(0);
function getcashMoney() {
selectUserMoney().then(res => {
data.mayMoney = getMoneys(res.amount) || 0
totalMoney.value=res.amount||0
})
selectUserMoney().then((res) => {
data.mayMoney = getMoneys(res.amount) || 0;
totalMoney.value = res.amount || 0;
});
}
/**
@@ -433,34 +425,34 @@
});
withdraw({
amount: data.money
}).then(res => {
console.log(res)
data.money = ''
uni.setStorageSync('adRewardedNum', 0)
})
.then((res) => {
console.log(res);
data.money = '';
uni.setStorageSync('adRewardedNum', 0);
setTimeout(function () {
getcashMoney()
}, 1500)
getcashMoney();
}, 1500);
uni.showToast({
title: res.msg,
icon: 'none'
});
})
}).catch(res => {
.catch((res) => {
if (res.code == 9991) {
uni.showToast({
title: res.msg,
icon: 'none'
})
});
setTimeout(function () {
linkTo('/pages/me/withdraw/alipay')
}, 1500)
linkTo('/pages/me/withdraw/alipay');
}, 1500);
} else {
}
})
});
}
function getOut() {
if (!/^\d+(\.\d{1,2})?$/.test(data.money)) {
uni.showToast({
icon: 'none',
@@ -471,11 +463,11 @@
if (!data.userInfo.accountNo) {
uni.showToast({
icon: 'none',
title: "请先实名认证"
title: '请先实名认证'
});
setTimeout(() => {
linkTo('/pages/me/withdraw/realName')
}, 1500)
linkTo('/pages/me/withdraw/realName');
}, 1500);
return;
}
console.log(data.mayMoney);
@@ -483,41 +475,44 @@
if (totalMoney.value * 1 >= parseFloat(data.money)) {
if (parseFloat(data.money).toFixed(2) >= parseFloat(data.cashMoney)) {
uni.showModal({
title: "提现申请提示",
title: '提现申请提示',
content: '每日只可提现一次',
success: (e) => {
if (e.confirm) {
setTimeout(() => {
uni.showModal({
title: "提现申请提示",
content: '请仔细确认收款人信息\n\n收款人姓名:' + data.userInfo.certName +
'\n\n提现金额:' + data
.money + '元\n\n收款人账号' + data.userInfo.accountNo + '',
title: '提现申请提示',
content:
'请仔细确认收款人信息\n\n收款人姓名:' +
data.userInfo.certName +
'\n\n提现金额:' +
data.money +
'元\n\n收款人账号' +
data.userInfo.accountNo +
'',
success: (e) => {
if (e.confirm) {
console.log(data.money)
console.log(data.money);
getMoney();
getMoneyDetail();
}
}
});
}, 200)
}, 200);
}
}
});
} else {
uni.showToast({
icon: 'none',
title: "提现金额必须大于或等于" + data.cashMoney + "元才可提现"
title: '提现金额必须大于或等于' + data.cashMoney + '元才可提现'
});
}
} else {
uni.showToast({
icon: 'none',
title: "您的余额不足"
title: '您的余额不足'
});
}
}
@@ -562,13 +557,13 @@
.title {
font-size: 32rpx;
color: #FFFFFF;
color: #ffffff;
padding-top: 230rpx;
}
.mayMoney {
font-size: 40rpx;
color: #FFFFFF;
color: #ffffff;
padding-top: 20rpx;
}
@@ -576,7 +571,7 @@
width: 90%;
height: max-content;
margin-left: 40rpx;
background-color: #FFFFFF;
background-color: #ffffff;
box-shadow: rgba(183, 183, 183, 0.3) 0px 1px 10px;
margin-top: 50rpx;
border-radius: 20rpx;
@@ -624,14 +619,14 @@
}
.moneyList {
text-align: left
text-align: left;
}
}
.cash-top {
padding: 32upx 32upx 50upx 32upx;
/* border-bottom: 1px solid gainsboro; */
background: #5074FF;
background: #5074ff;
}
.leiji {
@@ -676,7 +671,6 @@
}
}
.centre {
text-align: center;
padding: 200rpx 0;