feat: 查积分、支付、拆弹、取消订单

This commit is contained in:
2026-07-28 18:39:34 +08:00
parent 53305757f8
commit c443109869
40 changed files with 1814 additions and 163 deletions
@@ -55,7 +55,9 @@
<script>
import { mapActions, mapState } from 'pinia'
import { postFunction } from '@/api/supplied-service'
import { useCartStore } from '@/store/cart'
import { useUserStore } from '@/store/user'
import { readAddresses, readChosenAddressId } from '../../address/address-data'
import { createOrderNo, savePaymentInfo } from '../payment/payment-data'
@@ -67,10 +69,12 @@ export default {
remark: '',
goods: [],
showAllGoods: false,
chosenAddress: {}
chosenAddress: {},
submitting: false
}),
computed: {
...mapState(useCartStore, ['items']),
...mapState(useUserStore, ['supplierId', 'token', 'userId']),
visibleGoods() {
return this.showAllGoods ? this.goods : this.goods.slice(0, 3)
},
@@ -91,6 +95,7 @@ export default {
},
methods: {
...mapActions(useCartStore, ['loadCart']),
...mapActions(useUserStore, ['fetchBridgeToken']),
getCheckoutGoods() {
const storedItems = this.readCheckoutItems()
@@ -122,15 +127,44 @@ export default {
maskTel(tel = '') {
return tel.replace(/^(\d{3})\d{4}(\d{4})$/, '$1****$2')
},
onSubmit() {
savePaymentInfo({
orderNo: createOrderNo(),
amount: this.goodsAmount,
receiverName: this.chosenAddress.name || '',
receiverTel: this.maskTel(this.chosenAddress.tel || ''),
goods: this.goods
})
this.$router.push('/joyful-selection/payment')
async onSubmit() {
if (this.submitting) {
return
}
this.submitting = true
try {
await this.fetchBridgeToken()
if (!this.supplierId || !this.token || !this.userId) {
throw new Error('供应商授权信息不完整,请重新进入商城')
}
const orderNo = createOrderNo()
const data = await postFunction('order-create', {
supplierId: this.supplierId,
userId: this.userId,
token: this.token,
orderNo,
amount: this.goodsAmount,
goods: this.goods
})
savePaymentInfo({
orderNo: data?.orderId || orderNo,
orderNumberId: data?.orderNumberId || '',
amount: this.goodsAmount,
receiverName: this.chosenAddress.name || '',
receiverTel: this.maskTel(this.chosenAddress.tel || ''),
goods: this.goods
})
this.$router.push('/joyful-selection/payment')
} catch (error) {
console.warn('提交待支付订单失败', error)
this.$toast(error.message || '提交待支付订单失败')
} finally {
this.submitting = false
}
}
}
}