完善添加银行卡功能
This commit is contained in:
63
pages/my-index/wallet/bank-card/card-details.vue
Normal file
63
pages/my-index/wallet/bank-card/card-details.vue
Normal file
@@ -0,0 +1,63 @@
|
||||
<script setup>
|
||||
import { onLoad } from '@dcloudio/uni-app'
|
||||
import { reactive } from 'vue'
|
||||
import CardInput from '../../components/card-input.vue'
|
||||
|
||||
const stateData = reactive({
|
||||
title: '',
|
||||
state: '0'
|
||||
})
|
||||
|
||||
const formData = reactive({
|
||||
// 银行卡名称
|
||||
name: '',
|
||||
// 开户行名称
|
||||
khName: '',
|
||||
// 银行卡号
|
||||
cardNum: '',
|
||||
// 微信/支付宝号
|
||||
codeName: '',
|
||||
// 图片链接
|
||||
img: ''
|
||||
})
|
||||
onLoad(e => {
|
||||
const titltData = {
|
||||
0: '添加银行卡',
|
||||
101: '添加支付宝账户',
|
||||
102: '添加微信账户'
|
||||
}[e.key]
|
||||
stateData.title = titltData
|
||||
stateData.state = e.key
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<view>
|
||||
<nav-bar isTopBg isPlaceholder :title="stateData.title"></nav-bar>
|
||||
|
||||
<view
|
||||
v-if="!['101', '102'].includes(stateData.state)"
|
||||
class="card-details"
|
||||
>
|
||||
<CardInput v-model="formData.name" title="银行名称"></CardInput>
|
||||
<CardInput v-model="formData.khName" title="开户行"></CardInput>
|
||||
<CardInput v-model="formData.cardNum" title="银行卡号"></CardInput>
|
||||
</view>
|
||||
|
||||
<view v-else class="card-details">
|
||||
<CardInput
|
||||
v-model="formData.codeName"
|
||||
:title="`${
|
||||
stateData.state === '101' ? '支付宝账号' : '微信账号'
|
||||
}`"
|
||||
></CardInput>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@import '../../styles/index.scss';
|
||||
.card-details {
|
||||
padding: 32rpx 24rpx;
|
||||
}
|
||||
</style>
|
||||
56
pages/my-index/wallet/bank-card/index.vue
Normal file
56
pages/my-index/wallet/bank-card/index.vue
Normal file
@@ -0,0 +1,56 @@
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
import { navigateTo } from '@/utils/router'
|
||||
|
||||
const itemList = ref([
|
||||
{
|
||||
title: '支付宝',
|
||||
key: '101',
|
||||
icon: '/static/images/my-index/zfb.png'
|
||||
},
|
||||
{ title: '微信', key: '102', icon: '/static/images/my-index/wx.png' }
|
||||
])
|
||||
|
||||
const onAddCard = key => {
|
||||
navigateTo('/pages/my-index/wallet/bank-card/card-details', { key })
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<view class="bank-card">
|
||||
<view
|
||||
v-for="(item, index) in itemList"
|
||||
:key="index"
|
||||
class="public-card"
|
||||
@click="onAddCard(item.key)"
|
||||
>
|
||||
<view class="left-img">
|
||||
<image
|
||||
:src="
|
||||
item.icon
|
||||
? item.icon
|
||||
: 'https://nimg.ws.126.net/?url=http%3A%2F%2Fdingyue.ws.126.net%2F2024%2F1227%2F842e0e65j00sp543n001fd000i700iim.jpg&thumbnail=660x2147483647&quality=80&type=jpg'
|
||||
"
|
||||
mode="aspectFill"
|
||||
class="card"
|
||||
></image>
|
||||
<text>{{ item.title }}</text>
|
||||
</view>
|
||||
<view class="right-box">
|
||||
<uni-icons type="right" size="16" color="#999999"></uni-icons>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 底部按钮 -->
|
||||
<bottom-view>
|
||||
<cb-button @click="onAddCard('0')">+添加银行卡</cb-button>
|
||||
</bottom-view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@import '../../styles/index.scss';
|
||||
.bank-card {
|
||||
padding: 38rpx 24rpx;
|
||||
}
|
||||
</style>
|
||||
101
pages/my-index/wallet/edit-password.vue
Normal file
101
pages/my-index/wallet/edit-password.vue
Normal file
@@ -0,0 +1,101 @@
|
||||
<script setup>
|
||||
import { reactive } from 'vue'
|
||||
import CardInput from '../components/card-input.vue'
|
||||
import { useUI } from '@/utils/use-ui'
|
||||
import { validateTransactionPassword } from '@/utils/validate'
|
||||
|
||||
const { showToast } = useUI()
|
||||
|
||||
const formData = reactive({
|
||||
// 旧密码
|
||||
password: '',
|
||||
// 新密码
|
||||
newPassword: '',
|
||||
// 确认密码
|
||||
confirmPassword: ''
|
||||
})
|
||||
const onEdit = () => {
|
||||
const passwordValue = validateTransactionPassword(
|
||||
formData.password,
|
||||
'旧密码'
|
||||
)
|
||||
if (!passwordValue.valid) {
|
||||
showToast(passwordValue.message)
|
||||
return
|
||||
}
|
||||
|
||||
const newPasswordValue = validateTransactionPassword(
|
||||
formData.newPassword,
|
||||
'新的交易密码'
|
||||
)
|
||||
if (!newPasswordValue.valid) {
|
||||
showToast(newPasswordValue.message)
|
||||
return
|
||||
}
|
||||
|
||||
const confirmPasswordValue = validateTransactionPassword(
|
||||
formData.confirmPassword,
|
||||
'确认交易密码'
|
||||
)
|
||||
if (!confirmPasswordValue.valid) {
|
||||
showToast(confirmPasswordValue.message)
|
||||
return
|
||||
}
|
||||
|
||||
if (formData.newPassword !== formData.confirmPassword) {
|
||||
showToast('两次密码不一致')
|
||||
return
|
||||
}
|
||||
|
||||
console.log('修改密码:', formData)
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<view class="edit-password">
|
||||
<nav-bar isTopBg isPlaceholder title="交易密码">
|
||||
<template #right>
|
||||
<text class="top-right-name" @click="onEdit">确认</text>
|
||||
</template>
|
||||
</nav-bar>
|
||||
|
||||
<view class="input-box">
|
||||
<CardInput
|
||||
v-model="formData.password"
|
||||
title="旧密码"
|
||||
type="password"
|
||||
></CardInput>
|
||||
<CardInput
|
||||
v-model="formData.newPassword"
|
||||
title="设置新的交易密码"
|
||||
type="password"
|
||||
></CardInput>
|
||||
<CardInput
|
||||
v-model="formData.confirmPassword"
|
||||
title="重复新的交易密码"
|
||||
type="password"
|
||||
></CardInput>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@import '../styles/index.scss';
|
||||
|
||||
.top-right-name {
|
||||
font-family: PingFang SC, PingFang SC;
|
||||
font-weight: 500;
|
||||
font-size: 28rpx;
|
||||
color: #ffffff;
|
||||
text-align: center;
|
||||
font-style: normal;
|
||||
text-transform: none;
|
||||
background: #00d993;
|
||||
padding: 6rpx 20rpx;
|
||||
border-radius: 8rpx;
|
||||
}
|
||||
|
||||
.input-box {
|
||||
padding: 32rpx 24rpx;
|
||||
}
|
||||
</style>
|
||||
125
pages/my-index/wallet/index.vue
Normal file
125
pages/my-index/wallet/index.vue
Normal file
@@ -0,0 +1,125 @@
|
||||
<script setup>
|
||||
import { navigateTo } from '@/utils/router'
|
||||
|
||||
const itemList = [
|
||||
{
|
||||
title: '提现卡',
|
||||
key: '1',
|
||||
url: '/pages/my-index/wallet/bank-card/index'
|
||||
},
|
||||
{ title: '交易记录', key: '2', url: '' },
|
||||
{
|
||||
title: '修改支付密码',
|
||||
key: '3',
|
||||
url: '/pages/my-index/wallet/edit-password'
|
||||
},
|
||||
{ title: '实名认证', key: '4', url: '' }
|
||||
]
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<view class="wallet">
|
||||
<!-- 顶部样式 -->
|
||||
<view class="top-card">
|
||||
<view class="left-box">
|
||||
<text>我的资产</text>
|
||||
<text>2222</text>
|
||||
</view>
|
||||
<view class="right-box">
|
||||
<button>充值</button>
|
||||
<button>提现</button>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view
|
||||
v-for="(item, index) in itemList"
|
||||
:key="index"
|
||||
class="public-card"
|
||||
@click="item.url && navigateTo(item.url)"
|
||||
>
|
||||
<view class="left-box">
|
||||
<text>{{ item.title }}</text>
|
||||
</view>
|
||||
<view class="right-box">
|
||||
<uni-icons type="right" size="16" color="#999999"></uni-icons>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@import '../styles/index.scss';
|
||||
.wallet {
|
||||
padding: 32rpx 24rpx;
|
||||
}
|
||||
|
||||
.top-card {
|
||||
padding: 36rpx;
|
||||
margin-bottom: 48rpx;
|
||||
background: #ff4c54;
|
||||
border-radius: 32rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
position: relative;
|
||||
font-family: PingFang SC, PingFang SC;
|
||||
font-style: normal;
|
||||
text-transform: none;
|
||||
&::after {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
right: 54rpx;
|
||||
content: '';
|
||||
position: absolute;
|
||||
background: url('/static/images/my-index/wallet-bg.png');
|
||||
background-size: 30%;
|
||||
background-position: center;
|
||||
background-repeat: no-repeat;
|
||||
z-index: 1;
|
||||
pointer-events: none;
|
||||
}
|
||||
.left-box {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
text {
|
||||
font-weight: 500;
|
||||
font-size: 28rpx;
|
||||
color: #ffffff;
|
||||
margin-bottom: 8rpx;
|
||||
&:last-child {
|
||||
font-weight: bold;
|
||||
font-size: 64rpx;
|
||||
text-align: left;
|
||||
}
|
||||
}
|
||||
}
|
||||
.right-box {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
button {
|
||||
width: 128rpx;
|
||||
height: 64rpx;
|
||||
line-height: 64rpx;
|
||||
border-radius: 100rpx 100rpx 100rpx 100rpx;
|
||||
font-family: PingFang SC, PingFang SC;
|
||||
font-weight: 500;
|
||||
font-size: 28rpx;
|
||||
color: #ffffff;
|
||||
text-align: center;
|
||||
font-style: normal;
|
||||
text-transform: none;
|
||||
background: transparent;
|
||||
border: 2rpx solid #ffffff;
|
||||
&::after {
|
||||
border: none;
|
||||
}
|
||||
&:last-child {
|
||||
margin-left: 16rpx;
|
||||
background: #ffffff;
|
||||
color: #eb1c26;
|
||||
border: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user