This commit is contained in:
HongRun Liu
2026-05-26 15:52:30 +08:00
commit b0744c8ab6
849 changed files with 130587 additions and 0 deletions
+242
View File
@@ -0,0 +1,242 @@
<template>
<s-layout title="充值" navbar="inner">
<view class="pages">
<image
class="w100 bg_img"
:src="$url + 'home/points_1.png'"
mode="widthFix"
:style="{ top: paddingTop + 'px' }"
/>
</view>
<view class="relative m-t-28">
<view class="head" :style="{ backgroundImage: `url(${$url + 'home/recharge_bg2.png'})` }">
<view class="size28 line40 m-b-2"> 余额 </view>
<view class="size68 line92">
{{ $fen2yuan(balance) }}
</view>
</view>
<view class="recharge-main">
<view class="head-line"> 余额充值 </view>
<view class="money-bar flex-wrap flex-between">
<view
class="item"
:class="i === money_cur ? 'active' : 'item'"
v-for="(v, i) in money_list"
@click="changeMoney(v, i)"
>
¥{{ Number($fen2yuan(v.payPrice)) }}
</view>
</view>
<view class="ipt-bar flex-between m-y-40 p-x-32">
<text class="icon m-r-20">¥</text>
<uni-easyinput
v-model="money_value"
type="number"
:inputBorder="false"
placeholder="请输入金额"
@blur="iptBlur"
/>
</view>
<view>
<view class="size28 line38 m-b-20">充值说明</view>
<view class="size24 line32 m-b-12"> 1、本次充值仅作为充值,无法提现。 </view>
<view class="size24 line32"> 2、若遇到充值未到账,请联系客服。 </view>
</view>
<view class="btn m-t-248" @click="submit()"> 充值 </view>
<view class="record size34 t-c m-y-36 line48"> </view>
<!-- <view class="record size34 t-c m-y-36 line48" @click="go()">
充值记录
</view> -->
</view>
</view>
</s-layout>
</template>
<script setup>
import { ref } from 'vue';
import { onLoad, onShow } from '@dcloudio/uni-app';
import sheep from '@/sheep';
import * as api from '@/sheep/api/home/pay';
import { fen2yuan } from '../../sheep/hooks/useGoods';
import { SYSCONST } from '@/sheep/helper/const';
import { toast } from '@/utils';
const money_value = ref();
const money_id = ref();
const money_cur = ref(-1);
const money_list = ref();
let balance = ref(0);
let marginTop = ref();
let height = ref(0);
let sysInfo = uni.getSystemInfoSync();
const windowHeight = sysInfo.windowHeight;
marginTop.value = sysInfo.statusBarHeight + uni.upx2px(88) + uni.upx2px(54);
height.value =
windowHeight -
sysInfo.statusBarHeight -
marginTop.value -
uni.upx2px(204) -
uni.upx2px(110) -
uni.upx2px(48) -
uni.upx2px(40);
let statusBarHeight = uni.getSystemInfoSync().statusBarHeight;
let paddingTop = ref();
paddingTop.value = -(statusBarHeight + 44);
onShow(async () => {
getList();
getBalance();
});
let iptBlur = () => {
money_id.value = '';
};
let getBalance = () => {
api.getWallet().then((res) => {
if (res.code === 0) {
balance.value = res.data.balance;
}
});
};
let getList = () => {
api.getWalletRechargeMoneyList({}).then((res) => {
if (res.code === 0) {
money_list.value = res.data;
}
});
};
const changeMoney = (e, i) => {
// console.log(e.id);
money_cur.value = i;
money_value.value = Number(fen2yuan(e.payPrice));
money_id.value = e.id;
};
const submit = () => {
if (!money_value.value) {
uni.showToast({
title: '请选择充值金额',
icon: 'none',
});
return;
} else if (Number(money_value.value) < fen2yuan(money_list.value[0].payPrice)) {
uni.showToast({
title: '充值金额不能少于' + fen2yuan(money_list.value[0].payPrice),
icon: 'none',
});
return;
} else {
// console.log(Number(money_value.value));
// console.log(money_id.value);
let data = {};
if (money_id.value) {
data.payPrice = Number(money_value.value);
data.packageId = money_id.value;
} else {
data.payPrice = Number(money_value.value);
}
if (
Number(money_value.value) > SYSCONST.MAX_PRICE / 100 ||
Number(money_value.value) === SYSCONST.MAX_PRICE / 100
) {
toast('充值金额要小于' + SYSCONST.MAX_PRICE / 100);
return;
}
api.walletRechargeCreate(data).then((res) => {
if (res.code === 0) {
sheep.$router.redirect('/pages/pay/index', {
id: res.data.payOrderId,
type: 'recharge', // 充值
});
}
});
}
};
const go = () => {
uni.navigateTo({
url: '/pages/home/rechargeRecord',
});
};
</script>
<style scoped lang="scss">
.pages {
position: relative;
.bg_img {
position: absolute;
}
}
.head {
min-height: 282rpx;
// background: #366DEE url('/static/home/recharge_bg.png');
background-size: 100% 282rpx;
margin: 0 32rpx;
border-radius: 12rpx;
padding: 40rpx 32rpx;
color: #fff;
}
.recharge-main {
background: #fff;
border-radius: 20rpx 20rpx 0 0;
padding: 46rpx 32rpx;
margin-top: -120rpx;
.head-line {
font-size: 28rpx;
// color: #FFFFFF;
line-height: 38rpx;
border-left: 6rpx solid #fe3b48;
padding-left: 18rpx;
}
.money-bar {
.item {
width: 214rpx;
height: 92rpx;
line-height: 92rpx;
text-align: center;
background: #ffefe5;
border-radius: 12rpx;
margin-top: 40rpx;
color: #fb4d32;
}
.active {
background: #fb4d32;
color: #fff;
}
}
.ipt-bar {
height: 134rpx;
background: #ffefe5;
border-radius: 12rpx;
.icon {
color: #fe3b48;
}
// ::v-deep .uni-input-input {
// color: #fff;
// }
}
.btn {
height: 100rpx;
background: linear-gradient(to right, #fa8735 0%, #fe3b48 100%);
border-radius: 20rpx;
font-size: 32rpx;
color: #ffffff;
line-height: 100rpx;
text-align: center;
}
.record {
text-align: center;
color: #366dee;
}
}
</style>