Commit 1bb27e6a by 岑成威

fix:清空商品

1 parent ad08607b
......@@ -7,6 +7,24 @@ const HOST = {
merchant: merchantDomain,
ip: 'http://192.168.1.125:8080'
}
/** 接口 message 转可展示的 Toast 文案(非字符串、过长在部分端上会导致不弹提示) */
function normalizeApiToastMessage(message) {
if (message == null || message === '') return '系统异常'
let text
if (typeof message === 'string') {
text = message
} else {
try {
text = JSON.stringify(message)
} catch (e) {
return '系统异常'
}
}
const max = 42
return text.length > max ? text.slice(0, max) + '…' : text
}
class Request {
get(params, returnAll = false, hostType) {
return this.request('GET', params, returnAll, hostType)
......@@ -105,7 +123,8 @@ class Request {
uni.$logger.error(`${params.method}接口异常:${errMsg}`)
return reject(errMsg)
}
let { code, message } = data
let { code, message, msg, errId } = data
if (message == null || message === '') message = msg
if (returnAll) {
resolve(data)
return
......@@ -121,15 +140,35 @@ class Request {
})
} else {
if (code == '0') {
const errIdStr = errId != null && errId !== '' ? String(errId) : ''
if (errIdStr && errIdStr !== '0') {
uni.hideLoading()
const toastTitle = normalizeApiToastMessage(message)
setTimeout(() => {
uni.showToast({
title: toastTitle,
icon: 'none',
duration: 3000
})
}, 0)
uni.$logger.error(`${params.method}接口异常(errId):${toastTitle}`)
reject(toastTitle)
return
}
resolve(data.data)
} else {
uni.hideLoading()
uni.$logger.error(`${params.method}接口异常:${message || '系统异常'}`)
uni.showToast({
title: message || '系统异常',
icon: 'none'
})
reject(message || '系统异常')
const toastTitle = normalizeApiToastMessage(message)
// 先提示再记日志:避免 RemoteLog/Sentry 同步异常时用户看不到 Toast
setTimeout(() => {
uni.showToast({
title: toastTitle,
icon: 'none',
duration: 3000
})
}, 0)
uni.$logger.error(`${params.method}接口异常:${toastTitle}`)
reject(toastTitle)
}
}
} catch (error) {
......@@ -139,12 +178,23 @@ class Request {
},
fail(error) {
uni.hideLoading()
// console.error(`${params.method}接口异常:`, error)
uni.$logger.error(`${params.method}接口异常:${error.errMsg || error.message || JSON.stringify(error)}`)
uni.showToast({
title: typeof error == 'string' ? error : error.errMsg ? error.errMsg : JSON.stringify(error) || '系统异常',
icon: 'error'
})
const raw =
typeof error == 'string'
? error
: error.errMsg
? error.errMsg
: error.message
? error.message
: JSON.stringify(error) || '系统异常'
const toastTitle = normalizeApiToastMessage(raw)
setTimeout(() => {
uni.showToast({
title: toastTitle,
icon: 'none',
duration: 3000
})
}, 0)
uni.$logger.error(`${params.method}接口异常:${toastTitle}`)
reject(error)
},
complete() {
......
......@@ -623,7 +623,7 @@ export default {
this.$emit('jump', 'OrderDetail', data)
}
} else {
uni.showToast({ title: message, icon: null })
uni.showToast({ title: '未获取到支付结果,请重试', icon: 'none' })
}
})
}
......
......@@ -747,6 +747,13 @@ export default {
baseSceneCode: chooseContent.baseSceneCode || chooseContent.uuid
})
}
// 场景名称切换时,清除已选商品(与订单类型切换一致)
productFields.forEach(field => {
this.$set(this.orderObj, field, null)
})
this.goodsList = []
this.otherProduct = []
this.changeTotalPrice()
// 选中场景后,放开下方表单并触发依赖接口
this.$refs.orderPopup && this.$refs.orderPopup.clearCacheByTypes([0, 1, 3, 6, 7, 8, 9, 10, 11, 12])
this.updateSceneGate()
......
......@@ -506,6 +506,13 @@ export default {
baseSceneCode: chooseContent.baseSceneCode || chooseContent.uuid
})
}
// 场景名称切换时,清除已选商品(与新建工单一致)
productFields.forEach(field => {
this.$set(this.orderObj, field, null)
})
this.goodsList = []
this.otherProduct = []
this.changeTotalPrice()
// 选中场景后,放开下方表单并触发依赖接口
this.$refs.orderPopup && this.$refs.orderPopup.clearCacheByTypes([0, 1, 3, 6, 7, 8, 9, 10, 11, 12])
this.updateSceneGate()
......
......@@ -667,6 +667,8 @@ export default {
// 选中场景后,放开下方表单并触发依赖接口
// 立即清空 goodsList,确保弹窗打开时 externalData 为空,迫使 SkuGoodsList 重新调接口
this.goodsList = []
this.$set(this.orderObj, 'skuGoods', [])
this.changeTotalPrice()
this.$refs.orderPopup && this.$refs.orderPopup.clearCacheByTypes([0, 1, 3, 6, 7, 8, 9, 10, 11, 12])
this.updateSceneGate()
this.getSelectOrderGoodsList()
......@@ -936,8 +938,14 @@ export default {
console.log(error)
this.saveStatus = false
uni.hideLoading()
let title = '提交失败'
if (typeof error === 'string' && error) title = error
else if (error instanceof Error && error.message) title = error.message
else if (error && typeof error === 'object' && typeof error.message === 'string' && error.message) {
title = error.message
}
uni.showToast({
title: '提交失败',
title,
icon: 'none'
})
}
......
......@@ -384,6 +384,14 @@ export default {
baseSceneCode: chooseContent.baseSceneCode || chooseContent.uuid
})
}
// 场景名称切换时,清除已选/带入的商品(与新建工单一致)
const productFields = ['frontGear', 'frontWindow', 'rearGear', 'rearWindow', 'sunRoof', 'package', 'skuGoods']
productFields.forEach(field => {
this.$set(this.orderObj, field, null)
})
this.goodsList = []
// 按新场景重拉报价商品列表,更新 defaultMsg.vdQuotationGoodsList(取列表首条)
this.getGoodsProduct()
// 选中场景后,放开下方表单并触发依赖接口
this.$refs.orderPopup && this.$refs.orderPopup.clearCacheByTypes([0, 1, 3, 6, 7, 8, 9, 10, 11, 12])
this.updateSceneGate()
......@@ -524,14 +532,22 @@ export default {
}
}, 300),
// 获取商品列表数据
// 获取商品列表数据(与权益新建工单 getSelectOrderGoodsList 一致带上场景,便于切换场景名称后刷新 vdQuotationGoodsList 数据源)
getGoodsProduct() {
let { default4SStoreInfo } = this.userInfo
const userInfo = this.userInfo || {}
const { default4SStoreInfo } = userInfo
if (!default4SStoreInfo?.merchantId) return
const params = {
merchantId: default4SStoreInfo.merchantId,
suitCarPrice: ''
}
const baseSceneCode = this.orderObj.baseSceneCodeValue || this.orderObj.baseSceneCode
if (baseSceneCode) params.baseSceneCode = baseSceneCode
if (userInfo.sceneType !== undefined && userInfo.sceneType !== null) {
params.sceneType = userInfo.sceneType
}
uni.$api.equityApi
.quotationGoodsList({
merchantId: default4SStoreInfo.merchantId,
suitCarPrice: ''
})
.quotationGoodsList(params)
.then(data => {
data = data.map(ele => {
if (ele.goods) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!