Dining_Hall/pages/remainingSum/index.vue

337 lines
8.5 KiB
Vue
Raw Normal View History

2025-01-02 19:39:21 +08:00
<template>
<view>
2025-01-03 12:15:58 +08:00
<Navbar title="余额/充值" :showRightText="true" :isBack="false" :text="'充值记录'" @clickIcon="handleRightText" />
2025-01-02 19:39:21 +08:00
<div class="content">
<div class="top-cont">
<div>总余额()</div>
<div class="acc-bal">{{ balance.accBal }}</div>
<div class="money">
<div class="money-item">
<div>个人钱包</div>
<div class="item">
<span style="font-size: 11px"></span>
{{ balance.walletBal }}
</div>
</div>
<div class="money-item">
<div>补贴钱包</div>
<div class="item">
<span style="font-size: 11px"></span>
{{ balance.subsidyBal }}
</div>
</div>
</div>
</div>
<div class="up">快捷充值</div>
<div class="box">
<div class="box-item" :class="{ active: active == 1 }" @click="handleRecharge(1)">
2025-01-02 19:39:21 +08:00
<span></span>
<span>50.00</span>
<u-icon v-if="active == 1" class="icon" name="../../static/images/active.png" size="12" />
</div>
<div class="box-item" :class="{ active: active == 2 }" @click="handleRecharge(2)">
<span></span>
<span>100.00</span>
<u-icon v-if="active == 2" class="icon" name="../../static/images/active.png" size="12" />
</div>
<div class="box-item" :class="{ active: active == 3 }" @click="handleRecharge(3)">
<span></span>
<span>200.00</span>
<u-icon v-if="active == 3" class="icon" name="../../static/images/active.png" size="12" />
</div>
<div class="box-item" :class="{ active: active == 4 }" @click="handleRecharge(4)">
<span></span>
<span>300.00</span>
<u-icon v-if="active == 4" class="icon" name="../../static/images/active.png" size="12" />
</div>
<div class="box-item" :class="{ active: active == 5 }" @click="handleRecharge(5)">
<span></span>
<span>500.00</span>
<u-icon v-if="active == 5" class="icon" name="../../static/images/active.png" size="12" />
</div>
<div class="box-item" :class="{ active: active == 6 }" @click="handleRecharge(6)">
<span v-if="amount === ''" style="font-size: 18px">自定义</span>
<span v-else><span style="font-size: 18px;">{{amount}}.00</span></span>
2025-01-02 19:39:21 +08:00
<u-icon v-if="active == 6" class="icon" name="../../static/images/active.png" size="12" />
</div>
</div>
<!-- 充值 -->
<u-button shape="circle" color="#FF6816" @click="" style="height: 32px; margin-top: 100px">立即充值</u-button>
<u-popup
:show="localShow"
@close="closePopup"
mode="center"
round="12"
:closeOnClickOverlay="false"
>
<view class="amount-popup">
<view class="popup-title">自定义金额</view>
<view class="input-box">
<u--input
v-model="amount"
placeholder="输入金额"
prefixIcon="¥"
:prefixIconStyle="{
color: '#333',
fontSize: '32rpx',
fontWeight: 'bold'
}"
border="surround"
clearable
></u--input>
</view>
<view class="button-group">
<u-button
text="取消"
:customStyle="{
width: '240rpx',
height: '80rpx',
border: 'none',
background: '#f5f5f5',
color: '#666666'
}"
@click="closePopup"
></u-button>
<u-button
type="warning"
text="确认"
:customStyle="{
width: '240rpx',
height: '80rpx',
background: '#ff6633',
border: 'none'
}"
@click="confirm"
></u-button>
</view>
</view>
</u-popup>
2025-01-02 19:39:21 +08:00
</div>
</view>
</template>
<script>
import { getAccountBalance } from '@/api/dining-hall'
import uIcon from '../../uni_modules/uview-ui/components/u-icon/u-icon.vue'
import UUpload from '../../uni_modules/uview-ui/components/u-upload/u-upload.vue'
2025-01-02 19:39:21 +08:00
export default {
components: { UUpload },
2025-01-02 19:39:21 +08:00
data() {
return {
// 余额
balance: {
accBal: '1.23', // 账户总余额
walletBal: '1.23', // 个人钱包
subsidyBal: '1.23' // 补贴钱包
},
custId: '', // 用户id
custThirdId: '', // 用户第三方id
active: 1,
accTradeType: 8, // 交易类型 8微信扫码充值 9支付宝扫码充值 10现金充值
accType: 1, // 钱包类型 1个人钱包 2补贴钱包
rechargeAmount: 0, // 充值金额
payChannel: '', // 支付渠道
payType: '', // 支付方式
thirdRechargeNum: '', // 第三方充值流水号
localShow: false, // 自定义充值弹窗
amount: ''
2025-01-02 19:39:21 +08:00
}
},
onLoad() {
},
2025-01-02 19:39:21 +08:00
methods: {
handleRightText() {
console.log('🚀 ~ handleRightText ~ ')
uni.navigateTo({
url: '/pages/remainingSum/rechargeRecord'
})
2025-01-02 19:39:21 +08:00
},
// 获取余额
async getBalance() {
const params = {
custId: this.custId,
custThirdId: this.custThirdId
}
const res = await getAccountBalance(params)
console.log('🚀 ~ getBalance ~ res', res)
},
// 充值
handleRecharge(index) {
this.active = index
if (index == 1) {
this.rechargeAmount = 50
} else if (index == 2) {
this.rechargeAmount = 100
} else if (index == 3) {
this.rechargeAmount = 200
} else if (index == 4) {
this.rechargeAmount = 300
} else if (index == 5) {
this.rechargeAmount = 500
} else if (index == 6) {
2025-01-03 10:25:10 +08:00
this.rechargeAmount = 0
this.openPopup()
}
},
openPopup() {
this.localShow = true
},
closePopup() {
this.localShow = false
},
confirm() {
if (!this.amount) {
uni.$u.toast('请输入金额')
return
}else if (!/^\d+$/.test(this.amount)) {
this.amount = ''
this.rechargeAmount = 0
uni.$u.toast('金额必须为整数')
return
2025-01-02 19:39:21 +08:00
}
this.$emit('confirm', this.rechargeAmount)
this.closePopup()
2025-01-02 19:39:21 +08:00
}
}
}
</script>
2025-01-03 10:25:10 +08:00
<style lang="scss" scoped>
page {
background: #fff;
}
2025-01-02 19:39:21 +08:00
.content {
padding: 16px;
2025-01-02 19:39:21 +08:00
.top-cont {
padding: 16px;
height: 190px;
color: #fff;
font-size: 14px;
background: linear-gradient(134deg, #ff6816 0%, rgba(255, 104, 22, 0.2) 99%), rgba(255, 104, 22, 0.6);
border-radius: 12px 12px 12px 12px;
position: relative;
.acc-bal {
margin-top: 15px;
font-weight: 500;
font-size: 48px;
}
.money {
display: flex;
position: absolute;
bottom: 16px;
2025-01-02 19:39:21 +08:00
.money-item {
margin-right: 60px;
display: flex;
flex-direction: column;
justify-content: flex-start;
align-items: center;
2025-01-02 19:39:21 +08:00
.item {
margin-top: 10px;
font-size: 14px;
}
}
}
}
.up {
margin: 20px 0 10px;
font-weight: 500;
font-size: 14px;
color: #0f274b;
line-height: 16px;
}
2025-01-02 19:39:21 +08:00
.box {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
2025-01-02 19:39:21 +08:00
.box-item {
margin-bottom: 12px;
2025-01-03 10:20:58 +08:00
width: 30%;
2025-01-02 19:39:21 +08:00
height: 66px;
border-radius: 4px 4px 4px 4px;
border: 1px solid rgba(15, 39, 75, 0.4);
font-weight: 500;
font-size: 18px;
color: #0f274b;
display: flex;
justify-content: center;
align-items: center;
position: relative;
2025-01-02 19:39:21 +08:00
:first-child {
font-size: 12px;
}
2025-01-02 19:39:21 +08:00
.icon {
position: absolute;
right: 0;
bottom: 0;
}
}
2025-01-02 19:39:21 +08:00
.active {
background: rgba(255, 104, 22, 0.1);
border: 1px solid #ff6816;
}
}
}
.amount-popup {
width: 600rpx;
background-color: #ffffff;
border-radius: 24rpx;
padding: 40rpx 30rpx;
.popup-title {
text-align: center;
font-size: 32rpx;
color: #333333;
font-weight: 500;
margin-bottom: 30rpx;
}
.input-box {
margin-bottom: 40rpx;
}
.button-group {
display: flex;
justify-content: space-between;
}
}
::v-deep .u-input {
&__content {
height: 80rpx;
background-color: #ffffff;
&__prefix-icon {
margin-right: 10rpx;
padding-left: 10rpx;
}
&__field-wrapper {
&__field {
font-size: 28rpx;
}
}
}
}
2025-01-02 19:39:21 +08:00
</style>