feat(cart): 购物车添加加购物品校验逻辑

This commit is contained in:
woody 2025-07-29 15:32:20 +08:00
parent a35ba61785
commit bc142f686b
7 changed files with 86 additions and 112 deletions

View File

@ -152,7 +152,7 @@
<script>
import * as api from '@/config/goods'
import { canOrder } from '@/config/order'
export default {
data() {
return {
@ -339,10 +339,33 @@ export default {
})
})
},
goBuy() {
canOrder(shoppingArr) {
return new Promise((resolve, reject) => {
canOrder({
shoppingIds: shoppingArr,
specialArea: this.specialArea,
}).then(res => {
if (res.code == 200 && res.data?.flag === 0) {
resolve(true)
} else {
reject(res.data?.msg)
}
})
})
},
async goBuy() {
let shoppArr = this.goodsCheck[0].orderItemsParams.map(item => {
return item.shoppingId
})
try {
await this.canOrder(shoppArr)
} catch (msg) {
uni.showToast({
title: msg,
icon: 'none',
})
return
}
uni.setStorageSync('allGoods', JSON.stringify(shoppArr))
if (
this.goodsCheck[0].specialArea == 1 ||

View File

@ -1,34 +1,46 @@
const http = uni.$u.http
//支付配置
export const payConfig = (params) => http.get('/pay/config', { params })
export const payConfig = params => http.get('/pay/config', { params })
//查询订单明细
export const orderInfo = (params) => http.post('/sale/api/order/query-order', params)
export const orderInfo = params =>
http.post('/sale/api/order/query-order', params)
//订单状态
export const orderStatus = (params) => http.get('/system/pub/enums/order-status-api', { params })
export const orderStatus = params =>
http.get('/system/pub/enums/order-status-api', { params })
//计算邮费
export const pickPostAge = (params) => http.get('/activity/api/pick/postage', { params })
export const pickPostAge = params =>
http.get('/activity/api/pick/postage', { params })
//订单列表
export const orderList = (params) => http.get('/sale/api/my-order/list', { params })
export const orderList = params =>
http.get('/sale/api/my-order/list', { params })
//订单详情
export const orderDetails = (orderCode) => http.get('/sale/api/my-order/detail/' + orderCode)
export const orderDetails = orderCode =>
http.get('/sale/api/my-order/detail/' + orderCode)
//订单取消
export const cancelOrder = (orderCode) => http.delete('/sale/api/my-order/cancel/' + orderCode)
export const cancelOrder = orderCode =>
http.delete('/sale/api/my-order/cancel/' + orderCode)
//物流状态
export const expressList = (id) => http.get('/sale/api/my-order/express/' + id,)
export const expressList = id => http.get('/sale/api/my-order/express/' + id)
//校验订单状态
export const payCheck = (id) => http.get('/sale/api/my-order/pay-check/' + id,)
export const payCheck = id => http.get('/sale/api/my-order/pay-check/' + id)
//订单类型
export const orderType = (params) => http.get('/sale/api/my-order/order-type', { params })
export const orderType = params =>
http.get('/sale/api/my-order/order-type', { params })
//提货卡详情
export const pickDetails = (params) => http.get('/activity/api/pick/detail', { params })
export const pickDetails = params =>
http.get('/activity/api/pick/detail', { params })
//自助撤单列表
export const selfRevokeList = (params) => http.get('/sale/api/my-order/selfRevokeList', { params })
export const selfRevokeList = params =>
http.get('/sale/api/my-order/selfRevokeList', { params })
//自助撤单参数校验
export const selfRevokeListCheck = (params) => http.post('/sale/api/my-order/check-self-revoke-order', params)
export const selfRevokeListCheck = params =>
http.post('/sale/api/my-order/check-self-revoke-order', params)
//自助撤单
export const selfRevokeOrder = (params) => http.post('/sale/api/my-order/self-revoke-order', params)
export const selfRevokeOrder = params =>
http.post('/sale/api/my-order/self-revoke-order', params)
export const canOrder = data =>
http.post('/sale/api/order/check-before-confirm', data)

View File

@ -99,6 +99,5 @@ export const specialExport = params =>
export const specialList = params =>
http.get('/member/api/member-special/special-list', { params })
// 创客空间接口
export const queryCard = params =>
http.post('/sale/api/wares/query-cabin-card', params)
// 判断选中商品是否可以下单
export const canOrder = data => http.post('/sale/api/order/can-order', data)

View File

@ -19,7 +19,7 @@ module.exports = vm => {
//#ifdef DEV_SERVER
console.log('DEV_SERVER')
config.baseURL = 'https://t-app.beida666.com/prod-api'
config.baseURL = 'http://localhost:8080'
//#endif
//#ifdef QA_SERVER

View File

@ -415,14 +415,6 @@
:columns="transList"
keyName="label"
></u-picker>
<!-- 创客空间 -->
<u-picker
:show="ishowSure"
@cancel="ishowSure = false"
@confirm="surehowSure"
:columns="queryCardList"
keyName="label"
></u-picker>
<!-- 强制阅读协议 -->
<mustAgreeMent :waresCodeList="waresCodeList"></mustAgreeMent>
@ -596,9 +588,6 @@ export default {
checkObj: {},
selTable: [],
pkCountry: '',
howSure: false,
ishowSure: false,
queryCardList: [],
}
},
onLoad(options) {
@ -718,16 +707,6 @@ export default {
})
this.allGoodsData.deleteList = deleteList
this.allGoodsData.upgradeMemberCode = this.form.upgradeMemberCode
if (this.specialArea == 2) {
let howSure = this.allGoodsData.orderItemsParams.some(
item => item.isMakerGift == 4 || item.isMakerGift == 0
)
this.howSure = howSure
//
if (this.howSure) {
this.getQueryCard()
}
}
api.memLevel(this.allGoodsData).then(res => {
if (res.data.isEnough) {
@ -1021,28 +1000,7 @@ export default {
}
})
},
getQueryCard() {
api
.queryCard({
specialArea: this.specialArea,
upgradeMemberCode: this.form.upgradeMemberCode,
})
.then(res => {
let data = res.data.map(item => {
return {
id: item.pkMember,
label: item.storeName,
}
})
this.queryCardList = [data]
})
},
surehowSure(e) {
const { value } = e
this.form.makerSpaceMember = value[0].id
this.form.makerSpaceMemberLabel = value[0].label
this.ishowSure = false
},
sureTrans(e) {
const { value } = e
this.form.transType = value[0].id

View File

@ -513,14 +513,6 @@
:columns="transList"
keyName="label"
></u-picker>
<!-- 创客空间 -->
<u-picker
:show="ishowSure"
@cancel="ishowSure = false"
@confirm="surehowSure"
:columns="queryCardList"
keyName="label"
></u-picker>
<!-- 银行名称 -->
<u-picker
@ -838,10 +830,6 @@ export default {
this.allGoodsData.specialArea = this.specialArea
this.allGoodsData.pkSettleCountry = this.pkCountry
let howSure = this.allGoodsData.orderItemsParams.some(
item => item.isMakerGift == 4 || item.isMakerGift == 0
)
this.howSure = howSure
this.selTable.forEach(item => {
this.allGoodsData.orderItemsParams.push(item)
})
@ -938,10 +926,7 @@ export default {
//
this.pt = false
}
//
if (this.howSure) {
this.getQueryCard()
}
this.$forceUpdate()
} else {
console.log(122)
@ -970,10 +955,7 @@ export default {
//
this.pt = false
}
//
if (this.howSure) {
this.getQueryCard()
}
this.$forceUpdate()
}
})
@ -1173,19 +1155,6 @@ export default {
// }
})
},
getQueryCard() {
api
.queryCard({ specialArea: this.specialArea, parent: this.form.parent })
.then(res => {
let data = res.data.map(item => {
return {
id: item.pkMember,
label: item.storeName,
}
})
this.queryCardList = [data]
})
},
getDeliveryList() {
api.deliveryList({ pkCountry: this.pkCountry }).then(res => {
let data = res.data.map(item => {
@ -1219,12 +1188,7 @@ export default {
this.form.transTypeLabel = value[0].label
this.isTrans = false
},
surehowSure(e) {
const { value } = e
this.form.makerSpaceMember = value[0].id
this.form.makerSpaceMemberLabel = value[0].label
this.ishowSure = false
},
sureCk(e) {
const { value } = e
this.form.pkStorehouse = value[0].id

View File

@ -182,7 +182,7 @@
import * as api from '@/config/goods'
import clTabbar from '@/components/cl-tabbar.vue'
import RaisedTabbar from '@/components/raised-tabbar.vue'
import { canOrder } from '@/config/order'
export default {
components: {
'cl-tabbar': RaisedTabbar,
@ -313,11 +313,34 @@ export default {
this.checkArea()
}
},
goBuy() {
console.log(this.goodsCheck[0])
canOrder(shoppingIds, specialArea) {
return new Promise((resolve, reject) => {
canOrder({
shoppingIds,
specialArea,
}).then(res => {
if (res.code == 200 && res.data?.flag === 0) {
resolve(true)
} else {
reject(res.data?.msg)
}
})
})
},
async goBuy() {
let shoppArr = this.goodsCheck[0].orderItemsParams.map(item => {
return item.shoppingId
})
try {
await this.canOrder(shoppArr, this.goodsCheck[0].specialArea)
} catch (msg) {
uni.showToast({
title: msg,
icon: 'none',
})
return
}
if (
this.goodsCheck[0].specialArea == 1 ||
this.goodsCheck[0].specialArea == 24
@ -548,11 +571,6 @@ export default {
})
})
this.shopCarList = res.data
console.log(
'%c [ this.shopCarList ]-337',
'font-size:13px; background:#5f9b00; color:#a3df44;',
this.shopCarList
)
})
},
},