优化:请求接口全局处理loading和错误提示
This commit is contained in:
@@ -61,14 +61,8 @@ import GoodsPrice from '@/components/order/GoodsPrice.vue';
|
||||
*/
|
||||
const userInfo = ref({})
|
||||
const getUserInfo = async () => {
|
||||
try {
|
||||
const res = await orderApi.getUserInfo()
|
||||
if (res.code === 0) {
|
||||
userInfo.value = res.result || {}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取用户信息失败:', error)
|
||||
}
|
||||
const res = await orderApi.getUserInfo()
|
||||
userInfo.value = res.result || {}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -77,15 +71,11 @@ const getUserInfo = async () => {
|
||||
const goodsIds = ref<string>('')
|
||||
const goodsList = ref<IOrderGoods[]>([])
|
||||
const getGoodsList = async () => {
|
||||
try {
|
||||
// 获取商品详情
|
||||
const res = await orderApi.getShopProductListByIds(goodsIds.value)
|
||||
|
||||
if (res.code === 0 && res.shopProductList?.length > 0) {
|
||||
goodsList.value = res.shopProductList
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取商品列表失败:', error)
|
||||
// 获取商品详情
|
||||
const res = await orderApi.getShopProductListByIds(goodsIds.value)
|
||||
|
||||
if (res.shopProductList?.length > 0) {
|
||||
goodsList.value = res.shopProductList
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user