使用uniapp 生成一个跟微信的零钱提现一样的页面代码 顶部一样显示到账银行卡 并且可以切换银行卡 中间是提现金额 再提现金额下方显示 当前余额 还有一个全部提现的蓝色字体 要美观一点 最下方就是键盘输入提现的金额 生成跟微信一样的提现页面代码
<template>
<view class="withdraw">
<view class="header">
<view class="bank-info">
<view class="bank-logo"></view>
<view class="bank-name">中国银行(尾号1234)</view>
</view>
<view class="switch-card">切换银行卡</view>
</view>
<view class="withdraw-amount">
<view class="amount-title">提现金额(元)</view>
<view class="amount-input">
<view class="amount-prefix">¥</view>
<input type="number" v-model="amount" placeholder="0.00" />
<view class="all-withdraw" @click="allWithdraw()">全部提现</view>
</view>
<view class="balance">当前余额:¥{{balance}}</view>
</view>
<view class="keyboard">
<view class="key-row">
<view class="key" @click="inputNumber(1)">1</view>
<view class="key" @click="inputNumber(2)">2</view>
<view class="key" @click="inputNumber(3)">3</view>
</view>
<view class="key-row">
<view class="key" @click="inputNumber(4)">4</view>
<view class="key" @click="inputNumber(5)">5</view>
<view class="key" @click="inputNumber(6)">6</view>
</view>
<view class="key-row">
<view class="key" @click="inputNumber(7)">7</view>
<view class="key" @click="inputNumber(8)">8</view>
<view class="key" @click="inputNumber(9)">9</view>
</view>
<view class="key-row">
<view class="key key-empty"></view>
<view class="key" @click="inputNumber(0)">0</view>
<view class="key key-delete" @click="deleteNumber()"></view>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
amount: '', // 提现金额
balance: 1000 // 当前余额
}
},
methods: {
inputNumber(num) {
if (this.amount.length < 10) {
// 限制输入金额长度不超过10位
this.amount += num
}
},
deleteNumber() {
if (this.amount) {
this.amount = this.amount.substring(0, this.amount.length - 1)
}
},
allWithdraw() {
this.amount = this.balance
}
}
}
</script>
<style scoped>
.withdraw {
display: flex;
flex-direction: column;
height: 100vh;
padding-top: 20px;
}
.header {
display: flex;
justify-content: space-between;
align-items: center;
margin: 0 15px;
}
.bank-info {
display: flex;
align-items: center;
}
.bank-logo {
width: 30px;
height: 30px;
background-color: #ccc;
border-radius: 50%;
margin-right: 10px;
}
.bank-name {
font-size: 16px;
font-weight: bold;
}
.switch-card {
font-size: 14px;
color: #4d7fff;
}
.withdraw-amount {
flex: 1;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.amount-title {
font-size: 16px;
}
.amount-input {
display: flex;
align-items: center;
margin: 20px 0;
}
.amount-prefix {
font-size: 20px;
font-weight: bold;
margin-right: 5px;
}
input {
font-size: 28px;
font-weight: bold;
text-align: center;
border: none;
outline: none;
width: 100%;
}
.all-withdraw {
font-size: 14px;
color: #4d7fff;
margin-left: 10px;
}
.balance {
font-size: 14px;
color: #999;
}
.keyboard {
display: flex;
flex-wrap: wrap;
padding: 10px;
background-color: #eee;
}
.key-row {
display: flex;
justify-content: space-between;
width: 100%;
margin-bottom: 10px;
}
.key {
display: flex;
justify-content: center;
align-items: center;
width: 30%;
height: 50px;
background-color: #fff;
border-radius: 5px;
font-size: 24px;
color: #333;
}
.key-empty {
visibility: hidden;
}
.key-delete::before {
content: '';
display: block;
width: 20px;
height: 20px;
background-image: url('https://img.icons8.com/material-outlined/24/000000/delete-sign.png');
background-repeat: no-repeat;
background-size: cover;
}
</style
原文地址: https://www.cveoy.top/t/topic/fHAI 著作权归作者所有。请勿转载和采集!