提现功能需要添加
This commit is contained in:
@@ -1,12 +1,17 @@
|
||||
<script setup>
|
||||
import { onLoad } from '@dcloudio/uni-app'
|
||||
import { reactive } from 'vue'
|
||||
import CardInput from '../components/card-input.vue'
|
||||
import { useUI } from '@/utils/use-ui'
|
||||
import { navigateBack } from '@/utils/router'
|
||||
import { validateTransactionPassword } from '@/utils/validate'
|
||||
import { updateUserPayPwd, getUserPayPwd } from '@/api/my-index'
|
||||
|
||||
const { showToast } = useUI()
|
||||
|
||||
const formData = reactive({
|
||||
id: '',
|
||||
state: '0',
|
||||
// 旧密码
|
||||
password: '',
|
||||
// 新密码
|
||||
@@ -14,41 +19,72 @@
|
||||
// 确认密码
|
||||
confirmPassword: ''
|
||||
})
|
||||
const onEdit = () => {
|
||||
const passwordValue = validateTransactionPassword(
|
||||
formData.password,
|
||||
'旧密码'
|
||||
)
|
||||
if (!passwordValue.valid) {
|
||||
showToast(passwordValue.message)
|
||||
return
|
||||
const onEdit = async () => {
|
||||
let data = {}
|
||||
if (formData.state === '1') {
|
||||
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
|
||||
}
|
||||
|
||||
data = {
|
||||
id: formData.id,
|
||||
oldPassword: formData.password,
|
||||
password: formData.confirmPassword
|
||||
}
|
||||
} else {
|
||||
if (!formData.password) {
|
||||
showToast('请输入设置交易密码')
|
||||
return
|
||||
}
|
||||
data = {
|
||||
password: formData.password
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
await updateUserPayPwd(data, formData.id ? 'put' : 'post')
|
||||
await showToast(`${formData.id ? '修改' : '添加'}成功`, 'success')
|
||||
navigateBack()
|
||||
}
|
||||
|
||||
const getData = async () => {
|
||||
const res = await getUserPayPwd()
|
||||
formData.id = res.data.id
|
||||
}
|
||||
|
||||
onLoad(e => {
|
||||
formData.state = e.type
|
||||
if (e.type === '1') {
|
||||
getData()
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -59,7 +95,7 @@
|
||||
</template>
|
||||
</nav-bar>
|
||||
|
||||
<view class="input-box">
|
||||
<view v-if="formData.state === '1'" class="input-box">
|
||||
<CardInput
|
||||
v-model="formData.password"
|
||||
title="旧密码"
|
||||
@@ -76,6 +112,13 @@
|
||||
type="password"
|
||||
></CardInput>
|
||||
</view>
|
||||
<view v-else class="input-box">
|
||||
<CardInput
|
||||
v-model="formData.password"
|
||||
title="设置交易密码"
|
||||
type="password"
|
||||
></CardInput>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user