|
|
@@ -338,7 +338,9 @@ async function change() {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
+let loading = ref(false)
|
|
|
const recharge = async (userId) => {
|
|
|
+ let loading
|
|
|
ElMessageBox.prompt('请输入充值金额', '余额充值', {
|
|
|
confirmButtonText: '确认',
|
|
|
cancelButtonText: '取消',
|
|
|
@@ -356,19 +358,28 @@ const recharge = async (userId) => {
|
|
|
}
|
|
|
})
|
|
|
.then(async ({ value }) => {
|
|
|
+ loading = ElLoading.service({
|
|
|
+ lock: true,
|
|
|
+ text: '正在充值中,请勿重复操作.',
|
|
|
+ background: 'rgba(0, 0, 0, 0.7)'
|
|
|
+ })
|
|
|
const url = '/balance/recharge/' + userId + '/' + value
|
|
|
await http.get(url)
|
|
|
+ loading.close()
|
|
|
table.value.refresh()
|
|
|
ElMessage({
|
|
|
type: 'success',
|
|
|
message: `充值成功`
|
|
|
})
|
|
|
})
|
|
|
- .catch(() => {
|
|
|
- ElMessage({
|
|
|
- type: 'info',
|
|
|
- message: '取消充值'
|
|
|
- })
|
|
|
+ .catch((error) => {
|
|
|
+ console.log('error:', error)
|
|
|
+ if (error === 'cancel') {
|
|
|
+ ElMessage({ type: 'info', message: '取消充值' })
|
|
|
+ } else {
|
|
|
+ loading.close()
|
|
|
+ ElMessage({ type: 'error', message: '充值失败,请稍后重试或联系管理员' })
|
|
|
+ }
|
|
|
})
|
|
|
}
|
|
|
|
|
|
@@ -407,41 +418,46 @@ const screenRecharge = async (userId) => {
|
|
|
}
|
|
|
|
|
|
const transfer = async (userId) => {
|
|
|
- try {
|
|
|
- const { value } = await ElMessageBox.prompt('请输入划转金额', '余额划转', {
|
|
|
- confirmButtonText: '确认',
|
|
|
- cancelButtonText: '取消',
|
|
|
- inputType: 'number',
|
|
|
- inputValidator: (value) => {
|
|
|
- if (!value) {
|
|
|
- return '请输入充值金额'
|
|
|
- }
|
|
|
- const regex = /^-?\d+(\.\d{1,2})?$/
|
|
|
- if (regex.test(value)) {
|
|
|
- return true
|
|
|
- } else {
|
|
|
- return '金额不能超出俩位小数'
|
|
|
- }
|
|
|
+ let loading
|
|
|
+ ElMessageBox.prompt('请输入划转金额', '余额划转', {
|
|
|
+ confirmButtonText: '确认',
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ inputType: 'number',
|
|
|
+ inputValidator: (value) => {
|
|
|
+ if (!value) {
|
|
|
+ return '请输入划转金额'
|
|
|
}
|
|
|
- })
|
|
|
- try {
|
|
|
- const res = await http.get(`/balance/transfer/${userId}/${value}`)
|
|
|
+ const regex = /^-?\d+(\.\d{1,2})?$/
|
|
|
+ if (regex.test(value)) {
|
|
|
+ return true
|
|
|
+ } else {
|
|
|
+ return '金额不能超出俩位小数'
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .then(async ({ value }) => {
|
|
|
+ loading = ElLoading.service({
|
|
|
+ lock: true,
|
|
|
+ text: '正在划转中,请勿重复操作.',
|
|
|
+ background: 'rgba(0, 0, 0, 0.7)'
|
|
|
+ })
|
|
|
+ await http.get(`/balance/transfer/${userId}/${value}`)
|
|
|
+ loading.close()
|
|
|
+ table.value.refresh()
|
|
|
ElMessage({
|
|
|
type: 'success',
|
|
|
message: `划转成功`
|
|
|
})
|
|
|
- } catch (e) {
|
|
|
- console.log(e)
|
|
|
- ElMessage.error(e.message || '划转失败,请联系管理员')
|
|
|
- }
|
|
|
- } catch (e) {
|
|
|
- console.log(e)
|
|
|
- if ('cancel' !== e) {
|
|
|
- ElMessage.error(e.message || '划转失败,请联系管理员')
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- table.value.refresh()
|
|
|
+ })
|
|
|
+ .catch((error) => {
|
|
|
+ console.log('error:', error)
|
|
|
+ if (error === 'cancel') {
|
|
|
+ ElMessage({ type: 'info', message: '取消划转' })
|
|
|
+ } else {
|
|
|
+ loading.close()
|
|
|
+ ElMessage({ type: 'error', message: '划转失败,请稍后重试或联系管理员' })
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
const rate = async (userId) => {
|