feat: 已实现订单基本逻辑,到完成,却订单售后

This commit is contained in:
2026-07-30 15:55:36 +08:00
parent fb178d304f
commit dcc32b3d8f
34 changed files with 2534 additions and 149 deletions
@@ -49,12 +49,14 @@
<b>我的订单</b>
<span @click="$router.push('/joyful-selection/orders')">全部订单 <van-icon name="arrow" /></span>
</div>
<van-grid :column-num="5" :border="false">
<van-grid :column-num="4" :border="false">
<van-grid-item
v-for="item in orderItems"
:key="item.text"
:icon="item.icon"
:text="item.text"
:badge="orderBadge(item)"
@click="goOrders(item)"
/>
</van-grid>
</section>
@@ -78,6 +80,7 @@
<script>
import { mapActions, mapState } from 'pinia'
import { useUserStore } from '@/store/user'
import { postFunction } from '@/api/supplied-service'
import JoyfulSelectionProfileSkeleton from '@/skeleton-view/joyful-selection/profile/index.vue'
export default {
@@ -88,24 +91,31 @@ export default {
data: () => ({
loading: true,
orderItems: [
{ icon: 'balance-pay', text: '待付款' },
{ icon: 'logistics', text: '待发货' },
{ icon: 'send-gift-o', text: '待收货' },
{ icon: 'todo-list-o', text: '已完成' },
{ icon: 'after-sale', text: '售后' }
]
{ icon: 'balance-pay', text: '待付款', tab: 'pending-pay', badgeKey: 'pendingPay' },
{ icon: 'logistics', text: '待发货', tab: 'pending-ship' },
{ icon: 'send-gift-o', text: '待收货', tab: 'pending-receive', badgeKey: 'pendingReceive' },
{ icon: 'after-sale', text: '退款/售后', path: '/joyful-selection/after-sale', badgeKey: 'afterSale' }
],
orderCounts: {
pendingPay: 0,
pendingReceive: 0,
afterSale: 0
}
}),
computed: {
...mapState(useUserStore, ['pointsBalance']),
...mapState(useUserStore, ['pointsBalance', 'supplierId', 'userId']),
formattedPoints() {
return Number(this.pointsBalance || 0).toLocaleString('zh-CN', {
maximumFractionDigits: 2
})
},
orderBadgeCounts() {
return this.orderCounts
}
},
created() {
this.loading = true
this.fetchUserPoints().catch(error => {
this.fetchProfileData().catch(error => {
console.warn('查询用户积分失败', error)
this.$toast(error.message || '查询用户积分失败')
}).finally(() => {
@@ -113,7 +123,46 @@ export default {
})
},
methods: {
...mapActions(useUserStore, ['fetchUserPoints'])
...mapActions(useUserStore, ['fetchUserPoints']),
async fetchProfileData() {
await this.fetchUserPoints()
if (!this.supplierId || !this.userId) {
this.orderCounts = {
pendingPay: 0,
pendingReceive: 0,
afterSale: 0
}
return
}
const data = await postFunction('order-count', {
supplierId: this.supplierId,
userId: this.userId
})
this.orderCounts = {
pendingPay: Number(data?.pendingPay || 0),
pendingReceive: Number(data?.pendingReceive || 0),
afterSale: Number(data?.afterSale || 0)
}
},
orderBadge(item) {
const count = item.badgeKey ? this.orderBadgeCounts[item.badgeKey] : 0
return count > 0 ? count : undefined
},
goOrders(item) {
if (item.path) {
this.$router.push(item.path)
return
}
this.$router.push({
path: '/joyful-selection/orders',
query: item.tab ? { tab: item.tab } : {}
})
}
}
}
</script>