zyejMAll-mobile/pages/pay/recharge.vue

276 lines
6.5 KiB
Vue
Raw Normal View History

2024-08-07 10:31:42 +08:00
<!-- 充值界面 -->
<template>
2024-08-07 21:40:27 +08:00
<s-layout title="充值" class="withdraw-wrap" navbar="inner">
<view
class="wallet-num-box ss-flex ss-col-center ss-row-between"
:style="[
{
marginTop: '-' + Number(statusBarHeight + 88) + 'rpx',
paddingTop: Number(statusBarHeight + 108) + 'rpx',
},
]"
>
<view class="">
<view class="num-title">当前余额</view>
<view class="wallet-num">{{ fen2yuan(userWallet.balance) }}</view>
</view>
<button class="ss-reset-button log-btn" @tap="sheep.$router.go('/pages/pay/recharge-log')">
2024-08-07 10:31:42 +08:00
充值记录
</button>
2024-08-07 21:40:27 +08:00
</view>
<view class="recharge-box">
<view class="recharge-card-box">
<view class="input-label ss-m-b-50">充值金额</view>
<view class="input-box ss-flex border-bottom ss-p-b-20">
<view class="unit"></view>
<uni-easyinput
v-model="state.recharge_money"
type="digit"
placeholder="请输入充值金额"
:inputBorder="false"
/>
</view>
<view class="face-value-box ss-flex ss-flex-wrap ss-m-y-40">
<button
class="ss-reset-button face-value-btn"
v-for="item in state.packageList"
:key="item.money"
:class="[{ 'btn-active': state.recharge_money === fen2yuan(item.payPrice) }]"
@tap="onCard(item.payPrice)"
>
<text class="face-value-title">{{ fen2yuan(item.payPrice) }}</text>
<view v-if="item.bonusPrice" class="face-value-tag">
{{ fen2yuan(item.bonusPrice) }}
2024-08-07 10:31:42 +08:00
</view>
2024-08-07 21:40:27 +08:00
</button>
</view>
<button
class="ss-reset-button save-btn ui-BG-Main-Gradient ss-m-t-60 ui-Shadow-Main"
@tap="onConfirm"
>
确认充值
</button>
</view>
</view>
</s-layout>
2024-08-07 10:31:42 +08:00
</template>
<script setup>
2024-08-07 21:40:27 +08:00
import { computed, reactive } from 'vue';
import sheep from '@/sheep';
import { onLoad } from '@dcloudio/uni-app';
2024-08-07 10:31:42 +08:00
import { fen2yuan } from '@/sheep/hooks/useGoods';
import PayWalletApi from '@/sheep/api/pay/wallet';
2024-08-07 21:40:27 +08:00
const userWallet = computed(() => sheep.$store('user').userWallet);
const statusBarHeight = sheep.$platform.device.statusBarHeight * 2;
const headerBg = sheep.$url.css('/static/img/shop/user/withdraw_bg.png');
2024-08-07 10:31:42 +08:00
2024-08-07 21:40:27 +08:00
const state = reactive({
recharge_money: '', // 输入的充值金额
2024-08-07 10:31:42 +08:00
packageList: [],
2024-08-07 21:40:27 +08:00
});
2024-08-07 10:31:42 +08:00
2024-08-07 21:40:27 +08:00
// 点击卡片,选择充值金额
function onCard(e) {
state.recharge_money = fen2yuan(e);
}
2024-08-07 10:31:42 +08:00
// 获得钱包充值套餐列表
2024-08-07 21:40:27 +08:00
async function getRechargeTabs() {
2024-08-07 10:31:42 +08:00
const { code, data } = await PayWalletApi.getWalletRechargePackageList();
if (code !== 0) {
return;
}
state.packageList = data;
2024-08-07 21:40:27 +08:00
}
2024-08-07 10:31:42 +08:00
// 发起支付
2024-08-07 21:40:27 +08:00
async function onConfirm() {
const { code, data } = await PayWalletApi.createWalletRecharge({
packageId: state.packageList.find((item) => fen2yuan(item.payPrice) === state.recharge_money)
?.id,
payPrice: state.recharge_money * 100,
});
if (code !== 0) {
return;
}
2024-08-07 10:31:42 +08:00
// #ifdef MP
sheep.$platform.useProvider('wechat').subscribeMessage('money_change');
// #endif
sheep.$router.go('/pages/pay/index', {
id: data.payOrderId,
2024-08-07 21:40:27 +08:00
orderType: 'recharge',
2024-10-30 18:49:19 +08:00
hideWalletPay:true
2024-08-07 10:31:42 +08:00
});
2024-08-07 21:40:27 +08:00
}
2024-08-07 10:31:42 +08:00
2024-08-07 21:40:27 +08:00
onLoad(() => {
getRechargeTabs();
});
2024-08-07 10:31:42 +08:00
</script>
<style lang="scss" scoped>
2024-08-07 21:40:27 +08:00
:deep() {
.uni-input-input {
font-family: OPPOSANS !important;
}
}
2024-08-07 10:31:42 +08:00
2024-08-07 21:40:27 +08:00
.wallet-num-box {
padding: 0 40rpx 80rpx;
background: var(--ui-BG-Main) v-bind(headerBg) center/750rpx 100% no-repeat;
border-radius: 0 0 5% 5%;
2024-08-07 10:31:42 +08:00
2024-08-07 21:40:27 +08:00
.num-title {
font-size: 26rpx;
font-weight: 500;
color: $white;
margin-bottom: 20rpx;
}
2024-08-07 10:31:42 +08:00
2024-08-07 21:40:27 +08:00
.wallet-num {
font-size: 60rpx;
font-weight: 500;
color: $white;
font-family: OPPOSANS;
}
2024-08-07 10:31:42 +08:00
2024-08-07 21:40:27 +08:00
.log-btn {
width: 170rpx;
height: 60rpx;
line-height: 60rpx;
border: 1rpx solid $white;
border-radius: 30rpx;
padding: 0;
font-size: 26rpx;
font-weight: 500;
color: $white;
}
}
2024-08-07 10:31:42 +08:00
2024-08-07 21:40:27 +08:00
.recharge-box {
position: relative;
padding: 0 30rpx;
margin-top: -60rpx;
}
2024-08-07 10:31:42 +08:00
2024-08-07 21:40:27 +08:00
.save-btn {
width: 620rpx;
height: 86rpx;
border-radius: 44rpx;
font-size: 30rpx;
}
2024-08-07 10:31:42 +08:00
2024-08-07 21:40:27 +08:00
.recharge-card-box {
width: 690rpx;
background: var(--ui-BG);
border-radius: 20rpx;
padding: 30rpx;
box-sizing: border-box;
2024-08-07 10:31:42 +08:00
2024-08-07 21:40:27 +08:00
.input-label {
font-size: 30rpx;
font-weight: 500;
color: #333;
}
2024-08-07 10:31:42 +08:00
2024-08-07 21:40:27 +08:00
.unit {
display: flex;
align-items: center;
font-size: 48rpx;
font-weight: 500;
}
2024-08-07 10:31:42 +08:00
2024-08-07 21:40:27 +08:00
.uni-easyinput__placeholder-class {
font-size: 30rpx;
height: 60rpx;
display: flex;
align-items: center;
}
2024-08-07 10:31:42 +08:00
2024-08-07 21:40:27 +08:00
:deep(.uni-easyinput__content-input) {
font-size: 48rpx;
}
2024-08-07 10:31:42 +08:00
2024-08-07 21:40:27 +08:00
.face-value-btn {
width: 200rpx;
height: 144rpx;
border: 1px solid var(--ui-BG-Main);
border-radius: 10rpx;
position: relative;
z-index: 1;
margin-bottom: 15rpx;
margin-right: 15rpx;
2024-08-07 10:31:42 +08:00
2024-08-07 21:40:27 +08:00
&:nth-of-type(3n) {
margin-right: 0;
}
2024-08-07 10:31:42 +08:00
2024-08-07 21:40:27 +08:00
.face-value-title {
font-size: 36rpx;
font-weight: 500;
color: var(--ui-BG-Main);
font-family: OPPOSANS;
2024-08-07 10:31:42 +08:00
2024-08-07 21:40:27 +08:00
&::after {
content: '元';
font-size: 24rpx;
margin-left: 6rpx;
}
}
2024-08-07 10:31:42 +08:00
2024-08-07 21:40:27 +08:00
.face-value-tag {
position: absolute;
z-index: 2;
height: 40rpx;
line-height: 40rpx;
background: var(--ui-BG-Main);
opacity: 0.8;
border-radius: 10rpx 0 20rpx 0;
top: 0;
left: -2rpx;
padding: 0 16rpx;
font-size: 22rpx;
color: $white;
font-family: OPPOSANS;
}
2024-08-07 10:31:42 +08:00
2024-08-07 21:40:27 +08:00
&::before {
position: absolute;
content: ' ';
width: 100%;
height: 100%;
background: var(--ui-BG-Main);
opacity: 0.1;
z-index: 0;
left: 0;
top: 0;
}
}
2024-08-07 10:31:42 +08:00
2024-08-07 21:40:27 +08:00
.btn-active {
z-index: 1;
2024-08-07 10:31:42 +08:00
2024-08-07 21:40:27 +08:00
&::before {
content: '';
background: var(--ui-BG-Main);
opacity: 1;
}
2024-08-07 10:31:42 +08:00
2024-08-07 21:40:27 +08:00
.face-value-title {
color: $white;
position: relative;
z-index: 1;
font-family: OPPOSANS;
}
2024-08-07 10:31:42 +08:00
2024-08-07 21:40:27 +08:00
.face-value-tag {
background: $white;
color: var(--ui-BG-Main);
font-family: OPPOSANS;
}
}
}
</style>