feat: 积分商城-供应商-对账-发票

This commit is contained in:
2026-09-03 18:13:09 +08:00
parent 5c8fbddb2e
commit fc5df9c048
24 changed files with 1216 additions and 294 deletions
+18 -13
View File
@@ -20,7 +20,6 @@ const saveUser = data => {
export const useUserStore = defineStore('joyfulSelectionUser', {
state: () => ({
userId: '',
encryptedParam: '',
supplierIdentification: '',
supplierId: '',
supplierName: '',
@@ -54,16 +53,27 @@ export const useUserStore = defineStore('joyfulSelectionUser', {
})
this.loaded = true
},
hydrateFromRoute(query = {}) {
async hydrateFromRoute(query = {}) {
if (!this.loaded) {
this.loadUser()
}
const encryptedParam = query.AplParmObjct || query.aplParmObjct || ''
const keyword = query.keyword || new URLSearchParams(window.location.search).get('keyword') || ''
let nextUserId = query.userId || ''
if (encryptedParam) {
this.encryptedParam = encryptedParam
this.userId = ''
if (keyword) {
const sessionKeyword = String(keyword).replace(/ /g, '+')
console.log('[supplier-session] keyword', {
routeKeyword: query.keyword,
searchKeyword: new URLSearchParams(window.location.search).get('keyword') || '',
sessionKeyword
})
const data = await postFunction('supplier-session', { keyword: sessionKeyword })
nextUserId = data?.userId || ''
}
if (nextUserId && nextUserId !== this.userId) {
this.userId = nextUserId
this.pointsBalance = 0
}
if (!this.supplierIdentification) {
@@ -92,10 +102,7 @@ export const useUserStore = defineStore('joyfulSelectionUser', {
if (!this.loaded) {
this.loadUser()
}
if (!this.supplierIdentification || (!this.encryptedParam && this.hasToken)) {
return
}
if (!this.encryptedParam) {
if (!this.userId || !this.supplierIdentification || this.hasToken) {
return
}
if (this.loadingToken && bridgeTokenPromise) {
@@ -109,12 +116,10 @@ export const useUserStore = defineStore('joyfulSelectionUser', {
}
const data = await postFunction('supplier-token', {
AplParmObjct: this.encryptedParam,
userId: this.userId,
supplierIdentification: this.supplierIdentification
})
this.userId = data?.userId || ''
this.encryptedParam = ''
this.supplierId = data?.supplierId || this.supplierId
this.supplierName = data?.supplierName || this.supplierName
this.persistUser()
@@ -49,15 +49,17 @@ export default {
methods: {
...mapActions(useCartStore, ['loadCart']),
...mapActions(useUserStore, ['hydrateFromRoute', 'fetchBridgeToken']),
prepareUserSession() {
async prepareUserSession() {
this.sessionLoading = true
this.hydrateFromRoute(this.$route.query)
this.fetchBridgeToken().catch(error => {
try {
await this.hydrateFromRoute(this.$route.query)
await this.fetchBridgeToken()
} catch (error) {
console.warn('获取平台授权令牌失败', error)
this.$toast(error.message || '供应商验证失败,请稍后再试')
}).finally(() => {
} finally {
this.sessionLoading = false
})
}
}
}
}
@@ -6,6 +6,7 @@
<van-tabs v-model="activeTab" sticky offset-top="46" color="#ff5b20" @change="loadCurrentTab">
<van-tab title="待发货" name="ship" :badge="tabBadge('ship')">
<section class="list-panel">
<button v-if="orderItems.length" type="button" class="batch-ship-button" @click="quickShipAll">一键发货</button>
<section v-if="loading" class="skeleton-card">
<van-skeleton title :row="3" />
<van-skeleton title :row="3" />
@@ -359,11 +360,26 @@ export default {
openShipPopup(item) {
this.currentOrder = item
this.shipForm = {
crrgBsnNm: item.crrgBsnNm || '',
logisticsOrderId: item.logisticsOrderId || ''
crrgBsnNm: item.crrgBsnNm || '韵达快递',
logisticsOrderId: item.logisticsOrderId || 'YT20260903142053001'
}
this.showShipPopup = true
},
async quickShipAll() {
await Dialog.confirm({
title: '确认一键发货?',
message: `将为当前 ${this.orderItems.length} 个待发货订单提交发货。`
})
await Promise.all(this.orderItems.map(item => postFunction('merchant-order-ship', {
supplierId: this.supplierId,
userId: item.userId,
orderId: item.orderId,
crrgBsnNm: item.crrgBsnNm || '韵达快递',
logisticsOrderId: item.logisticsOrderId || 'YT20260903142053001'
})))
Toast('批量发货成功')
await this.loadOrders()
},
async submitShip() {
if (!this.shipForm.crrgBsnNm || !this.shipForm.logisticsOrderId) {
Toast('请填写完整发货信息')
@@ -467,6 +483,18 @@ export default {
padding: 12px 10px 18px;
}
.batch-ship-button {
width: 100%;
height: 38px;
margin-bottom: 12px;
border: 0;
border-radius: 8px;
color: #fff;
font-size: 14px;
font-weight: 700;
background: linear-gradient(90deg, #ff6a2a 0%, #ff4b18 100%);
}
.work-card {
position: relative;
margin-bottom: 12px;
@@ -15,6 +15,15 @@
</van-tabs>
<van-pull-refresh v-model="refreshing" class="order-list" @refresh="onRefresh">
<van-button
v-if="receivableOrders.length"
block
round
class="batch-receive-button"
@click="confirmReceiveAll"
>
一键收货({{ receivableOrders.length }})
</van-button>
<van-empty v-if="visibleOrders.length === 0" description="暂无订单" />
<template v-else>
@@ -164,6 +173,11 @@ export default {
activeTab() {
return this.tabs[this.active] || this.tabs[0]
},
receivableOrders() {
return this.visibleOrders.filter(order => {
return order.displayType === 'sub' && Number(order.orderState) === ORDER_STATE.IN_PROGRESS
})
},
visibleOrders() {
const tab = this.activeTab
@@ -321,6 +335,44 @@ export default {
this.refreshing = false
}
},
async confirmReceiveAll() {
try {
await Dialog.confirm({
title: '一键收货',
message: `确定将当前 ${this.receivableOrders.length} 个订单全部确认收货吗?`
})
} catch (error) {
return
}
this.operationKey = 'batch-confirm-receive'
try {
await this.fetchBridgeToken()
if (!this.supplierId || !this.userId) {
Toast('用户信息不完整,请重新进入商城')
return
}
await Promise.all(this.receivableOrders.map(order => postFunction('order-push-event', {
supplierId: this.supplierId,
userId: this.userId,
orderType: ORDER_EVENT_TYPE.CONFIRM_RECEIVE,
orderId: order.orderId,
mainOrderId: order.mainOrderId,
subOrderId: order.orderId,
amount: Number(order.amount || 0),
reason: '确认收货',
time: Date.now()
})))
Toast('批量收货成功')
await this.loadOrders()
} catch (error) {
Toast(error.message || '批量收货失败,请稍后再试')
} finally {
this.operationKey = ''
}
},
orderActions(order) {
if (order.displayType === 'main') {
return Number(order.orderState) === ORDER_STATE.PENDING_PAY
@@ -583,6 +635,12 @@ export default {
padding: 12px 10px 18px;
}
.batch-receive-button {
margin-bottom: 12px;
color: #ff5b20;
background: #fff1e8;
}
.order-card {
overflow: hidden;
margin-bottom: 14px;