优化:请求接口全局处理loading和错误提示

This commit is contained in:
2025-11-26 16:37:47 +08:00
24 changed files with 568 additions and 771 deletions

View File

@@ -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
}
}