feat:
取消了订单轮询 更新押金提现及订单查询功能 归还成功之后不会有归还成功的弹窗出现 提现的判断目前判断押金状态和订单状态 修改了提现API的参数名称,从订单ID更改为订单号,并新增了根据设备号和状态查询订单列表的功能。同时,优化了用户在提现过程中的错误提示,确保用户能够获得更清晰的反馈。更新了多个页面的逻辑,提升了整体用户体验。
This commit is contained in:
+42
-40
@@ -40,7 +40,7 @@
|
||||
|
||||
<script>
|
||||
import { getUserInfo } from '../../util/index.js'
|
||||
import { withdrawDeposit, queryById, getOrderList } from '../../config/user.js'
|
||||
import { withdrawDeposit,queryById } from '../../config/user.js'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
@@ -48,8 +48,7 @@ export default {
|
||||
depositAmount: '0.00',
|
||||
orderNo: '',
|
||||
records: [],
|
||||
orderId: '',
|
||||
isLoading: false
|
||||
orderId:''
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
@@ -61,34 +60,15 @@ export default {
|
||||
methods: {
|
||||
async loadUserInfo() {
|
||||
try {
|
||||
this.isLoading = true
|
||||
const res = await getUserInfo()
|
||||
console.log('loadUserInfo', res);
|
||||
console.log('loadUserInfo',res);
|
||||
if (res.code === 200) {
|
||||
this.depositAmount = res.data.balanceAmount || '0.00'
|
||||
this.orderNo = res.data.latestOrderNo || ''
|
||||
this.orderId = res.data.latestOrderId || ''
|
||||
|
||||
// 如果有余额但没有orderId,尝试查询用户订单列表获取
|
||||
if (parseFloat(this.depositAmount) > 0 && !this.orderId) {
|
||||
console.log('没有latestOrderId但有余额,尝试查询订单列表')
|
||||
const orderRes = await getOrderList({ pageNum: 1, pageSize: 10 })
|
||||
if (orderRes.code === 200 && orderRes.data && orderRes.data.records && orderRes.data.records.length > 0) {
|
||||
// 查找最近的包含押金的订单
|
||||
const depositOrder = orderRes.data.records.find(order =>
|
||||
order.depositAmount && parseFloat(order.depositAmount) > 0
|
||||
)
|
||||
|
||||
if (depositOrder) {
|
||||
console.log('找到押金订单:', depositOrder)
|
||||
this.orderId = depositOrder.orderId
|
||||
this.orderNo = depositOrder.orderNo
|
||||
}
|
||||
}
|
||||
}
|
||||
this.orderId = res.data.latestOrderId||''
|
||||
|
||||
// 如果存在余额,获取押金记录
|
||||
if (parseFloat(this.depositAmount) > 0) {
|
||||
if (parseFloat(this.depositAmount) > 0 && this.orderNo) {
|
||||
this.records = [
|
||||
{
|
||||
type: '支付',
|
||||
@@ -106,8 +86,6 @@ export default {
|
||||
title: '获取用户信息失败',
|
||||
icon: 'none'
|
||||
})
|
||||
} finally {
|
||||
this.isLoading = false
|
||||
}
|
||||
},
|
||||
async handleWithdraw() {
|
||||
@@ -118,14 +96,15 @@ export default {
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
if (!this.orderId) {
|
||||
uni.showToast({
|
||||
title: '无法找到押金订单',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
const res = await queryById(Number(this.orderNo))
|
||||
console.log(res);
|
||||
// if(this.orderNo.length!=0){
|
||||
// uni.showToast({
|
||||
// title:'当前存在进行中的订单',
|
||||
// icon:'none'
|
||||
// })
|
||||
// return
|
||||
// }
|
||||
|
||||
uni.showModal({
|
||||
title: '确认提现',
|
||||
@@ -137,8 +116,8 @@ export default {
|
||||
})
|
||||
|
||||
try {
|
||||
console.log('发起提现请求,订单ID:', this.orderId)
|
||||
const result = await withdrawDeposit(this.orderId)
|
||||
console.log('发起提现请求,订单号:', this.orderNo)
|
||||
const result = await withdrawDeposit(this.orderNo)
|
||||
console.log('提现响应:', result)
|
||||
|
||||
if (result.code === 200) {
|
||||
@@ -166,9 +145,32 @@ export default {
|
||||
} catch (error) {
|
||||
console.error('提现失败:', error)
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: error.message || '提现失败,请稍后再试',
|
||||
icon: 'none'
|
||||
|
||||
// 更详细的错误处理
|
||||
let errorMessage = '提现失败,请稍后再试';
|
||||
|
||||
// 如果有具体错误信息,使用它
|
||||
if (error.message) {
|
||||
// 常见错误消息处理
|
||||
if (error.message.includes('尚未归还')) {
|
||||
errorMessage = '当前订单尚未归还,请归还后再提现';
|
||||
} else if (error.message.includes('已退还')) {
|
||||
errorMessage = '押金已退还,无需重复提现';
|
||||
} else if (error.message.includes('处理中')) {
|
||||
errorMessage = '押金退还处理中,请耐心等待';
|
||||
} else if (error.message.includes('余额为0')) {
|
||||
errorMessage = '账户余额为0,无法提现';
|
||||
} else {
|
||||
// 使用后端返回的具体错误消息
|
||||
errorMessage = error.message;
|
||||
}
|
||||
}
|
||||
|
||||
// 显示错误提示
|
||||
uni.showModal({
|
||||
title: '提现失败',
|
||||
content: errorMessage,
|
||||
showCancel: false
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user