fix: api声明优化 接口请求错误兜底优化
This commit is contained in:
@@ -170,7 +170,7 @@ export default defineComponent({
|
||||
params.areaName = cityName;
|
||||
}
|
||||
const res = await getEventList(params as any);
|
||||
if (res.code == 200) {
|
||||
if (res.code === '200') {
|
||||
const list: TournamentAdminVO[] = res.data?.list || [];
|
||||
setEventOptions(
|
||||
list.map((item) => ({
|
||||
@@ -258,7 +258,7 @@ export default defineComponent({
|
||||
setEditLoading(true);
|
||||
getEventDetail(eventId)
|
||||
.then((detailRes) => {
|
||||
if (detailRes.code == 200) {
|
||||
if (detailRes.code === '200') {
|
||||
const eventName = detailRes.data?.name || eventId;
|
||||
setEventOptions([{ value: eventId, label: eventName }]);
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ export function useBannerModel() {
|
||||
loading,
|
||||
run: fetchList,
|
||||
} = useRequest<TournamentAdminBannerListVO[]>(() => getBannerList(buildQueryParams()), {
|
||||
formatResult: (res) => (res.code == 200 ? res.data : []),
|
||||
formatResult: (res) => (res.code === '200' ? res.data : []),
|
||||
});
|
||||
|
||||
const allData = computed(() => data.value || []);
|
||||
@@ -198,7 +198,7 @@ export function useBannerModel() {
|
||||
const res = isEdit
|
||||
? await updateBanner({ ...payload, id: editingRecord.value.id })
|
||||
: await saveBanner(payload);
|
||||
if (res.code == 200) {
|
||||
if (res.code === '200') {
|
||||
message.success(isEdit ? '编辑成功' : '新增成功');
|
||||
handleCloseModal();
|
||||
handleSearch();
|
||||
@@ -216,7 +216,7 @@ export function useBannerModel() {
|
||||
const handleDelete = useThrottleFn(async (record: any) => {
|
||||
try {
|
||||
const res = await delBanner(record.id);
|
||||
if (res.code == 200) {
|
||||
if (res.code === '200') {
|
||||
message.success('删除成功');
|
||||
fetchList();
|
||||
} else {
|
||||
@@ -233,7 +233,7 @@ export function useBannerModel() {
|
||||
const newStatus = record.status === '1' ? '0' : '1';
|
||||
const actionText = newStatus === '1' ? '启用' : '禁用';
|
||||
const res = await toggleBannerActive({ id: record.id, status: newStatus });
|
||||
if (res.code == 200) {
|
||||
if (res.code === '200') {
|
||||
message.success(`${actionText}成功`);
|
||||
fetchList();
|
||||
} else {
|
||||
|
||||
@@ -42,7 +42,7 @@ export default defineComponent({
|
||||
detail.value = null;
|
||||
try {
|
||||
const res = await getEventDetail(id);
|
||||
if (res.code == 200) {
|
||||
if (res.code === '200') {
|
||||
detail.value = res.data;
|
||||
} else {
|
||||
message.error(res.msg || '获取赛事详情失败');
|
||||
|
||||
@@ -116,7 +116,7 @@ export default defineComponent({
|
||||
page: String(page),
|
||||
limit: String(PAGE_SIZE),
|
||||
});
|
||||
if (res.code == 200) {
|
||||
if (res.code === '200') {
|
||||
categoryPlayers.value[categoryId] = res.data.list;
|
||||
categoryPlayers.value = { ...categoryPlayers.value };
|
||||
categoryPlayerTotal.value[categoryId] = res.data.total;
|
||||
@@ -143,7 +143,7 @@ export default defineComponent({
|
||||
setDetail(null);
|
||||
try {
|
||||
const res = await getEventDetail(id);
|
||||
if (res.code == 200 && res.data) {
|
||||
if (res.code === '200' && res.data) {
|
||||
setDetail(res.data);
|
||||
// 为每个组别加载第一页选手
|
||||
for (const cat of res.data.categoryList) {
|
||||
|
||||
@@ -29,7 +29,7 @@ export default defineComponent({
|
||||
ruleData.value = null;
|
||||
try {
|
||||
const res = await getRuleInfo(id);
|
||||
if (res.code == 200 && res.data) {
|
||||
if (res.code === '200' && res.data) {
|
||||
ruleData.value = res.data;
|
||||
} else {
|
||||
ruleData.value = null;
|
||||
|
||||
@@ -157,14 +157,14 @@ export function useEventListModel() {
|
||||
setTogglingId(record.id);
|
||||
try {
|
||||
const res = await toggleEventOnline({ id: record.id, online: isRemoved ? '1' : '0' });
|
||||
if (res.code === 200) {
|
||||
if (res.code === '200') {
|
||||
message.success(`${actionText}成功`);
|
||||
fetchList();
|
||||
} else {
|
||||
message.error(res.msg || `${actionText}失败`);
|
||||
}
|
||||
} catch (e: any) {
|
||||
message.error(e?.message || `${actionText}失败`);
|
||||
console.error(`${actionText}失败:`, e);
|
||||
} finally {
|
||||
setTogglingId('');
|
||||
}
|
||||
|
||||
@@ -148,7 +148,7 @@ export default defineComponent({
|
||||
page: String(page),
|
||||
limit: String(playerPageSize),
|
||||
});
|
||||
if (res.code == 200) {
|
||||
if (res.code === '200') {
|
||||
setPlayers(res.data.list);
|
||||
setPlayerTotal(res.data.total);
|
||||
setPlayerPage(page);
|
||||
@@ -184,7 +184,7 @@ export default defineComponent({
|
||||
else params['uniqueId'] = props.uniqueId;
|
||||
|
||||
const [detailRes] = await Promise.all([getOrderDetail(params), fetchPlayers(1)]);
|
||||
if (detailRes.code == 200) {
|
||||
if (detailRes.code === '200') {
|
||||
setDetail(detailRes.data);
|
||||
}
|
||||
setDetailLoading(false);
|
||||
|
||||
@@ -38,7 +38,7 @@ function promptReRefund(record: any) {
|
||||
onOk: async () => {
|
||||
try {
|
||||
const res = await retryRefundOrder({ payOrderNo: record.orderNo });
|
||||
if (res.code == 200) {
|
||||
if (res.code === '200') {
|
||||
message.success('重新退款提交成功');
|
||||
} else {
|
||||
message.error(res.msg || '操作失败');
|
||||
|
||||
@@ -124,7 +124,7 @@ export function useUserModel() {
|
||||
setTogglingId(record.id);
|
||||
try {
|
||||
const res = await toggleUserActive({ userId: record.id, status: isActive ? '0' : '1' });
|
||||
if (res.code == 200) {
|
||||
if (res.code === '200') {
|
||||
message.success(`${actionText}成功`);
|
||||
fetchList();
|
||||
} else {
|
||||
@@ -132,7 +132,6 @@ export function useUserModel() {
|
||||
}
|
||||
} catch (e: any) {
|
||||
console.error(`用户${actionText}失败:`, e);
|
||||
message.error(`用户${actionText}失败`);
|
||||
} finally {
|
||||
setTogglingId('');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user