1
This commit is contained in:
@@ -639,8 +639,13 @@ export default {
|
||||
return
|
||||
}
|
||||
|
||||
// 判断成功条件:code === 200 或者直接返回了giftCouponKey
|
||||
const isSuccess = res.code === 200 || (res.data && (res.data.giftCouponKey || res.data.giftKey))
|
||||
// 判断成功条件:code === 200 且 giftCouponKey 不为null
|
||||
// 注意:即使code是200,如果giftCouponKey为null,也应该视为失败
|
||||
const hasGiftKey = res.data &&
|
||||
(res.data.giftCouponKey !== null && res.data.giftCouponKey !== undefined && res.data.giftCouponKey !== '') ||
|
||||
(res.data.giftKey !== null && res.data.giftKey !== undefined && res.data.giftKey !== '')
|
||||
|
||||
const isSuccess = res.code === 200 && hasGiftKey
|
||||
|
||||
if (isSuccess) {
|
||||
// 解析返回的giftCouponKey(参考xbmessage中的处理方式)
|
||||
@@ -768,15 +773,24 @@ export default {
|
||||
// 错误处理 - 更详细的错误信息
|
||||
console.error('创建礼金失败,返回:', res)
|
||||
let errorMsg = '创建失败'
|
||||
|
||||
// 优先显示后端返回的错误信息
|
||||
if (res.msg) {
|
||||
errorMsg = res.msg
|
||||
} else if (res.data && res.data.msg) {
|
||||
errorMsg = res.data.msg
|
||||
} else if (res.message) {
|
||||
}
|
||||
// 如果是code:200但giftCouponKey为null的情况
|
||||
else if (res.code === 200 && res.data && res.data.giftCouponKey === null) {
|
||||
errorMsg = '礼金创建失败:返回的礼金Key为null。可能的原因:\n1. 商品不支持创建礼金\n2. 商品类型(自营/POP)判断错误\n3. 京东API调用失败\n4. 商品已下架或不存在\n\n请检查:\n- 商品链接是否正确\n- 商品类型是否匹配(查询到的owner是否正确)\n- 查看JD项目日志获取详细错误信息'
|
||||
}
|
||||
// 其他错误情况
|
||||
else if (res.message) {
|
||||
errorMsg = res.message
|
||||
} else if (typeof res === 'string') {
|
||||
errorMsg = res
|
||||
}
|
||||
|
||||
this.$modal.msgError('创建失败:' + errorMsg)
|
||||
}
|
||||
} catch (e) {
|
||||
|
||||
Reference in New Issue
Block a user