feat: 新增多个页面及功能,优化用户体验

在项目中新增了多个页面,包括押金页面、设备详情页面、反馈页面和帮助页面。同时,更新了订单支付和归还成功页面的逻辑,确保用户在支付和归还设备时能够获得清晰的反馈。优化了扫码和订单状态处理逻辑,提升了整体用户体验。
This commit is contained in:
8vd8
2025-04-16 18:26:02 +08:00
parent f96ff2b030
commit 431ceb4bdb
117 changed files with 1854 additions and 616 deletions
+137 -12
View File
@@ -4,7 +4,7 @@
<view class="deposit-card">
<view class="title">押金余额</view>
<view class="amount">¥{{ depositAmount }}</view>
<button class="withdraw-btn" @click="handleWithdraw">提现</button>
<button class="withdraw-btn" @click="handleWithdraw" :disabled="depositAmount <= 0">提现</button>
</view>
<!-- 提现说明 -->
@@ -21,7 +21,7 @@
</view>
<!-- 押金记录 -->
<view class="record-card">
<view class="record-card" v-if="records.length > 0">
<view class="record-title">押金记录</view>
<view class="record-list">
<view class="record-item" v-for="(item, index) in records" :key="index">
@@ -39,30 +39,150 @@
</template>
<script>
import { getUserInfo } from '../../util/index.js'
import { withdrawDeposit, queryById, getOrderList } from '../../config/user.js'
export default {
data() {
return {
depositAmount: '99.00',
records: [
{ type: '支付', time: '2024-03-20 15:30', amount: '99.00' },
{ type: '退还', time: '2024-03-19 12:00', amount: '99.00' },
]
depositAmount: '0.00',
orderNo: '',
records: [],
orderId: '',
isLoading: false
}
},
onLoad() {
// this.loadUserInfo()
},
onShow() {
this.loadUserInfo()
},
methods: {
handleWithdraw() {
async loadUserInfo() {
try {
this.isLoading = true
const res = await getUserInfo()
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
}
}
}
// 如果存在余额,获取押金记录
if (parseFloat(this.depositAmount) > 0) {
this.records = [
{
type: '支付',
time: this.formatDate(new Date()),
amount: this.depositAmount
}
]
} else {
this.records = []
}
}
} catch (error) {
console.error('获取用户信息失败:', error)
uni.showToast({
title: '获取用户信息失败',
icon: 'none'
})
} finally {
this.isLoading = false
}
},
async handleWithdraw() {
if (parseFloat(this.depositAmount) <= 0) {
uni.showToast({
title: '无可提现余额',
icon: 'none'
})
return
}
if (!this.orderId) {
uni.showToast({
title: '无法找到押金订单',
icon: 'none'
})
return
}
uni.showModal({
title: '确认提现',
content: '押金将原路退回,预计0-7个工作日到账',
success: (res) => {
success: async (res) => {
if (res.confirm) {
uni.showToast({
title: '提现申请已提交',
icon: 'success'
uni.showLoading({
title: '提现中...'
})
try {
console.log('发起提现请求,订单ID', this.orderId)
const result = await withdrawDeposit(this.orderId)
console.log('提现响应:', result)
if (result.code === 200) {
uni.hideLoading()
uni.showToast({
title: '提现申请已提交',
icon: 'success'
})
// 更新余额为0
this.depositAmount = '0.00'
this.records.push({
type: '退还',
time: this.formatDate(new Date()),
amount: this.depositAmount
})
// 重新加载用户信息
setTimeout(() => {
this.loadUserInfo()
}, 1500)
} else {
throw new Error(result.msg || '提现失败')
}
} catch (error) {
console.error('提现失败:', error)
uni.hideLoading()
uni.showToast({
title: error.message || '提现失败,请稍后再试',
icon: 'none'
})
}
}
}
})
},
formatDate(date) {
const year = date.getFullYear()
const month = (date.getMonth() + 1).toString().padStart(2, '0')
const day = date.getDate().toString().padStart(2, '0')
const hours = date.getHours().toString().padStart(2, '0')
const minutes = date.getMinutes().toString().padStart(2, '0')
return `${year}-${month}-${day} ${hours}:${minutes}`
}
}
}
@@ -108,6 +228,11 @@ export default {
&:active {
transform: scale(0.98);
}
&[disabled] {
background: rgba(255,255,255,0.6);
color: rgba(25,118,210,0.5);
}
}
}