fix: 兼容后端 code 类型不统一问题
This commit is contained in:
@@ -47,7 +47,7 @@ export interface BannerActiveParams {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface ApiResult<T> {
|
export interface ApiResult<T> {
|
||||||
code: string;
|
code: number | string;
|
||||||
msg: string;
|
msg: string;
|
||||||
data: T;
|
data: T;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ export interface PageData<T> {
|
|||||||
/** 统一响应包裹 */
|
/** 统一响应包裹 */
|
||||||
export interface ApiResult<T> {
|
export interface ApiResult<T> {
|
||||||
/** 编码:200表示成功,其他值表示失败 */
|
/** 编码:200表示成功,其他值表示失败 */
|
||||||
code: string;
|
code: number | string;
|
||||||
/** 消息内容 */
|
/** 消息内容 */
|
||||||
msg: string;
|
msg: string;
|
||||||
/** 响应数据 */
|
/** 响应数据 */
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ export type { LoginResult } from './types';
|
|||||||
|
|
||||||
export const login = (params: { phone: string; password: string }) => {
|
export const login = (params: { phone: string; password: string }) => {
|
||||||
return post(`/op/login`, params) as Promise<{
|
return post(`/op/login`, params) as Promise<{
|
||||||
code: string;
|
code: number | string;
|
||||||
msg: string;
|
msg: string;
|
||||||
data: LoginResult;
|
data: LoginResult;
|
||||||
}>;
|
}>;
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ export interface PageData<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface ApiResult<T> {
|
export interface ApiResult<T> {
|
||||||
code: string;
|
code: number | string;
|
||||||
msg: string;
|
msg: string;
|
||||||
data: T;
|
data: T;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ export interface PageData<T> {
|
|||||||
|
|
||||||
/** 统一响应包裹 */
|
/** 统一响应包裹 */
|
||||||
export interface ApiResult<T> {
|
export interface ApiResult<T> {
|
||||||
code: string;
|
code: number | string;
|
||||||
msg: string;
|
msg: string;
|
||||||
data: T;
|
data: T;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ export interface PaymentFlowPageData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface ApiResult<T> {
|
export interface ApiResult<T> {
|
||||||
code: string;
|
code: number | string;
|
||||||
msg: string;
|
msg: string;
|
||||||
data: T;
|
data: T;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ export interface ReportQueryParams {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface ApiResult<T> {
|
export interface ApiResult<T> {
|
||||||
code: string;
|
code: number | string;
|
||||||
msg: string;
|
msg: string;
|
||||||
data: T;
|
data: T;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ export interface PageData<T> {
|
|||||||
list: T[];
|
list: T[];
|
||||||
}
|
}
|
||||||
export interface ApiResult<T> {
|
export interface ApiResult<T> {
|
||||||
code: string;
|
code: number | string;
|
||||||
msg: string;
|
msg: string;
|
||||||
data: T;
|
data: T;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ export interface PageData<T> {
|
|||||||
list: T[];
|
list: T[];
|
||||||
}
|
}
|
||||||
export interface ApiResult<T> {
|
export interface ApiResult<T> {
|
||||||
code: string;
|
code: number | string;
|
||||||
msg: string;
|
msg: string;
|
||||||
data: T;
|
data: T;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ export interface PageData<T> {
|
|||||||
list: T[];
|
list: T[];
|
||||||
}
|
}
|
||||||
export interface ApiResult<T> {
|
export interface ApiResult<T> {
|
||||||
code: string;
|
code: number | string;
|
||||||
msg: string;
|
msg: string;
|
||||||
data: T;
|
data: T;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ export interface PageData<T> {
|
|||||||
list: T[];
|
list: T[];
|
||||||
}
|
}
|
||||||
export interface ApiResult<T> {
|
export interface ApiResult<T> {
|
||||||
code: string;
|
code: number | string;
|
||||||
msg: string;
|
msg: string;
|
||||||
data: T;
|
data: T;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ export default defineComponent({
|
|||||||
password: payload.newPassword,
|
password: payload.newPassword,
|
||||||
confirmPassword: payload.newPassword,
|
confirmPassword: payload.newPassword,
|
||||||
});
|
});
|
||||||
if (res.code === '200') {
|
if (res.code == 200) {
|
||||||
message.success('密码修改成功');
|
message.success('密码修改成功');
|
||||||
setChangePwdVisible(false);
|
setChangePwdVisible(false);
|
||||||
window.setTimeout(() => {
|
window.setTimeout(() => {
|
||||||
|
|||||||
@@ -170,7 +170,7 @@ export default defineComponent({
|
|||||||
params.areaName = cityName;
|
params.areaName = cityName;
|
||||||
}
|
}
|
||||||
const res = await getEventList(params as any);
|
const res = await getEventList(params as any);
|
||||||
if (res.code === '200') {
|
if (res.code == 200) {
|
||||||
const list: TournamentAdminVO[] = res.data?.list || [];
|
const list: TournamentAdminVO[] = res.data?.list || [];
|
||||||
setEventOptions(
|
setEventOptions(
|
||||||
list.map((item) => ({
|
list.map((item) => ({
|
||||||
@@ -258,7 +258,7 @@ export default defineComponent({
|
|||||||
setEditLoading(true);
|
setEditLoading(true);
|
||||||
getEventDetail(eventId)
|
getEventDetail(eventId)
|
||||||
.then((detailRes) => {
|
.then((detailRes) => {
|
||||||
if (detailRes.code === '200') {
|
if (detailRes.code == 200) {
|
||||||
const eventName = detailRes.data?.name || eventId;
|
const eventName = detailRes.data?.name || eventId;
|
||||||
setEventOptions([{ value: eventId, label: eventName }]);
|
setEventOptions([{ value: eventId, label: eventName }]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ export function useBannerModel() {
|
|||||||
loading,
|
loading,
|
||||||
run: fetchList,
|
run: fetchList,
|
||||||
} = useRequest<TournamentAdminBannerListVO[]>(() => getBannerList(buildQueryParams()), {
|
} = useRequest<TournamentAdminBannerListVO[]>(() => getBannerList(buildQueryParams()), {
|
||||||
formatResult: (res) => (res.code === '200' ? res.data : []),
|
formatResult: (res) => (res.code == 200 ? res.data : []),
|
||||||
});
|
});
|
||||||
|
|
||||||
const allData = computed(() => data.value || []);
|
const allData = computed(() => data.value || []);
|
||||||
@@ -198,7 +198,7 @@ export function useBannerModel() {
|
|||||||
const res = isEdit
|
const res = isEdit
|
||||||
? await updateBanner({ ...payload, id: editingRecord.value.id })
|
? await updateBanner({ ...payload, id: editingRecord.value.id })
|
||||||
: await saveBanner(payload);
|
: await saveBanner(payload);
|
||||||
if (res.code === '200') {
|
if (res.code == 200) {
|
||||||
message.success(isEdit ? '编辑成功' : '新增成功');
|
message.success(isEdit ? '编辑成功' : '新增成功');
|
||||||
handleCloseModal();
|
handleCloseModal();
|
||||||
handleSearch();
|
handleSearch();
|
||||||
@@ -216,7 +216,7 @@ export function useBannerModel() {
|
|||||||
const handleDelete = useThrottleFn(async (record: any) => {
|
const handleDelete = useThrottleFn(async (record: any) => {
|
||||||
try {
|
try {
|
||||||
const res = await delBanner(record.id);
|
const res = await delBanner(record.id);
|
||||||
if (res.code === '200') {
|
if (res.code == 200) {
|
||||||
message.success('删除成功');
|
message.success('删除成功');
|
||||||
fetchList();
|
fetchList();
|
||||||
} else {
|
} else {
|
||||||
@@ -233,7 +233,7 @@ export function useBannerModel() {
|
|||||||
const newStatus = record.status === '1' ? '0' : '1';
|
const newStatus = record.status === '1' ? '0' : '1';
|
||||||
const actionText = newStatus === '1' ? '启用' : '禁用';
|
const actionText = newStatus === '1' ? '启用' : '禁用';
|
||||||
const res = await toggleBannerActive({ id: record.id, status: newStatus });
|
const res = await toggleBannerActive({ id: record.id, status: newStatus });
|
||||||
if (res.code === '200') {
|
if (res.code == 200) {
|
||||||
message.success(`${actionText}成功`);
|
message.success(`${actionText}成功`);
|
||||||
fetchList();
|
fetchList();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ export default defineComponent({
|
|||||||
detail.value = null;
|
detail.value = null;
|
||||||
try {
|
try {
|
||||||
const res = await getEventDetail(id);
|
const res = await getEventDetail(id);
|
||||||
if (res.code === '200') {
|
if (res.code == 200) {
|
||||||
detail.value = res.data;
|
detail.value = res.data;
|
||||||
} else {
|
} else {
|
||||||
message.error(res.msg || '获取赛事详情失败');
|
message.error(res.msg || '获取赛事详情失败');
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ export default defineComponent({
|
|||||||
page: String(page),
|
page: String(page),
|
||||||
limit: String(PAGE_SIZE),
|
limit: String(PAGE_SIZE),
|
||||||
});
|
});
|
||||||
if (res.code === '200') {
|
if (res.code == 200) {
|
||||||
categoryPlayers.value[categoryId] = res.data.list;
|
categoryPlayers.value[categoryId] = res.data.list;
|
||||||
categoryPlayers.value = { ...categoryPlayers.value };
|
categoryPlayers.value = { ...categoryPlayers.value };
|
||||||
categoryPlayerTotal.value[categoryId] = res.data.total;
|
categoryPlayerTotal.value[categoryId] = res.data.total;
|
||||||
@@ -145,7 +145,7 @@ export default defineComponent({
|
|||||||
setDetail(null);
|
setDetail(null);
|
||||||
try {
|
try {
|
||||||
const res = await getEventDetail(id);
|
const res = await getEventDetail(id);
|
||||||
if (res.code === '200' && res.data) {
|
if (res.code == 200 && res.data) {
|
||||||
setDetail(res.data);
|
setDetail(res.data);
|
||||||
// 为每个组别加载第一页选手
|
// 为每个组别加载第一页选手
|
||||||
for (const cat of res.data.categoryList) {
|
for (const cat of res.data.categoryList) {
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ export default defineComponent({
|
|||||||
ruleData.value = null;
|
ruleData.value = null;
|
||||||
try {
|
try {
|
||||||
const res = await getRuleInfo(id);
|
const res = await getRuleInfo(id);
|
||||||
if (res.code === '200' && res.data) {
|
if (res.code == 200 && res.data) {
|
||||||
ruleData.value = res.data;
|
ruleData.value = res.data;
|
||||||
} else {
|
} else {
|
||||||
ruleData.value = null;
|
ruleData.value = null;
|
||||||
|
|||||||
@@ -157,7 +157,7 @@ export function useEventListModel() {
|
|||||||
setTogglingId(record.id);
|
setTogglingId(record.id);
|
||||||
try {
|
try {
|
||||||
const res = await toggleEventOnline({ id: record.id, online: isRemoved ? '1' : '0' });
|
const res = await toggleEventOnline({ id: record.id, online: isRemoved ? '1' : '0' });
|
||||||
if (res.code === '200') {
|
if (res.code == 200) {
|
||||||
message.success(`${actionText}成功`);
|
message.success(`${actionText}成功`);
|
||||||
fetchList();
|
fetchList();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -156,7 +156,7 @@ export default defineComponent({
|
|||||||
page: String(page),
|
page: String(page),
|
||||||
limit: String(playerPageSize),
|
limit: String(playerPageSize),
|
||||||
});
|
});
|
||||||
if (res.code === '200') {
|
if (res.code == 200) {
|
||||||
setPlayers(res.data.list);
|
setPlayers(res.data.list);
|
||||||
setPlayerTotal(res.data.total);
|
setPlayerTotal(res.data.total);
|
||||||
setPlayerPage(page);
|
setPlayerPage(page);
|
||||||
@@ -192,7 +192,7 @@ export default defineComponent({
|
|||||||
else params['uniqueId'] = props.uniqueId;
|
else params['uniqueId'] = props.uniqueId;
|
||||||
|
|
||||||
const [detailRes] = await Promise.all([getOrderDetail(params), fetchPlayers(1)]);
|
const [detailRes] = await Promise.all([getOrderDetail(params), fetchPlayers(1)]);
|
||||||
if (detailRes.code === '200') {
|
if (detailRes.code == 200) {
|
||||||
setDetail(detailRes.data);
|
setDetail(detailRes.data);
|
||||||
}
|
}
|
||||||
setDetailLoading(false);
|
setDetailLoading(false);
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ function promptReRefund(record: any) {
|
|||||||
onOk: async () => {
|
onOk: async () => {
|
||||||
try {
|
try {
|
||||||
const res = await retryRefundOrder({ payOrderNo: record.orderNo });
|
const res = await retryRefundOrder({ payOrderNo: record.orderNo });
|
||||||
if (res.code === '200') {
|
if (res.code == 200) {
|
||||||
message.success('重新退款提交成功');
|
message.success('重新退款提交成功');
|
||||||
} else {
|
} else {
|
||||||
message.error(res.msg || '操作失败');
|
message.error(res.msg || '操作失败');
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ export function useUserModel() {
|
|||||||
setTogglingId(record.id);
|
setTogglingId(record.id);
|
||||||
try {
|
try {
|
||||||
const res = await toggleUserActive({ userId: record.id, status: isActive ? '0' : '1' });
|
const res = await toggleUserActive({ userId: record.id, status: isActive ? '0' : '1' });
|
||||||
if (res.code === '200') {
|
if (res.code == 200) {
|
||||||
message.success(`${actionText}成功`);
|
message.success(`${actionText}成功`);
|
||||||
fetchList();
|
fetchList();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ export function useReportsModel() {
|
|||||||
() => getFinanceReport(buildQueryParams()),
|
() => getFinanceReport(buildQueryParams()),
|
||||||
{
|
{
|
||||||
refreshDeps: [dateRange],
|
refreshDeps: [dateRange],
|
||||||
formatResult: (res) => (res.code === '200' ? res.data : null),
|
formatResult: (res) => (res.code == 200 ? res.data : null),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ export default defineComponent({
|
|||||||
try {
|
try {
|
||||||
const params = buildQueryParams();
|
const params = buildQueryParams();
|
||||||
const res = await getWalletTransactionList(params);
|
const res = await getWalletTransactionList(params);
|
||||||
if (res.code === '200') {
|
if (res.code == 200) {
|
||||||
dataSource.value = res.data.list;
|
dataSource.value = res.data.list;
|
||||||
pagination.total = res.data.total;
|
pagination.total = res.data.total;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ export default defineComponent({
|
|||||||
detail.value = null;
|
detail.value = null;
|
||||||
try {
|
try {
|
||||||
const res = await getWithdrawInfo(id);
|
const res = await getWithdrawInfo(id);
|
||||||
if (res.code === '200') detail.value = res.data;
|
if (res.code == 200) detail.value = res.data;
|
||||||
} catch {
|
} catch {
|
||||||
// 网络层已统一提示
|
// 网络层已统一提示
|
||||||
} finally {
|
} finally {
|
||||||
@@ -136,7 +136,7 @@ export default defineComponent({
|
|||||||
checkMsg: auditForm.remark.trim(),
|
checkMsg: auditForm.remark.trim(),
|
||||||
checkImg,
|
checkImg,
|
||||||
});
|
});
|
||||||
if (res.code === '200') {
|
if (res.code == 200) {
|
||||||
message.success(auditForm.pass ? '已审核通过' : '已审核驳回');
|
message.success(auditForm.pass ? '已审核通过' : '已审核驳回');
|
||||||
props.onAudited?.();
|
props.onAudited?.();
|
||||||
props.onClose();
|
props.onClose();
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ export function useLoginModel() {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const res = await login({ phone: form.phone, password: form.password });
|
const res = await login({ phone: form.phone, password: form.password });
|
||||||
if (res.code !== '200') {
|
if (res.code != 200) {
|
||||||
message.error(res.msg || '登录失败');
|
message.error(res.msg || '登录失败');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ export default defineComponent({
|
|||||||
treeLoading.value = true;
|
treeLoading.value = true;
|
||||||
try {
|
try {
|
||||||
const res = await getPermissionTree(roleId);
|
const res = await getPermissionTree(roleId);
|
||||||
if (res.code === '200' && res.data) {
|
if (res.code == 200 && res.data) {
|
||||||
rawApiTree.value = res.data;
|
rawApiTree.value = res.data;
|
||||||
const result = buildTreeData(res.data);
|
const result = buildTreeData(res.data);
|
||||||
treeData.value = result.treeData;
|
treeData.value = result.treeData;
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ export default defineComponent({
|
|||||||
roleId: String(props.roleId),
|
roleId: String(props.roleId),
|
||||||
...(filterForm.text.trim() ? { text: filterForm.text.trim() } : {}),
|
...(filterForm.text.trim() ? { text: filterForm.text.trim() } : {}),
|
||||||
});
|
});
|
||||||
if (res.code === '200') {
|
if (res.code == 200) {
|
||||||
setDataSource(res.data.list);
|
setDataSource(res.data.list);
|
||||||
setPagination({ ...pagination.value, total: res.data.total });
|
setPagination({ ...pagination.value, total: res.data.total });
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ export function useRoleModel() {
|
|||||||
menuIds,
|
menuIds,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (res.code === '200') {
|
if (res.code == 200) {
|
||||||
message.success(isEdit.value ? '编辑成功' : '新增成功');
|
message.success(isEdit.value ? '编辑成功' : '新增成功');
|
||||||
handleCloseForm();
|
handleCloseForm();
|
||||||
fetchList();
|
fetchList();
|
||||||
@@ -170,7 +170,7 @@ export function useRoleModel() {
|
|||||||
const handleDelete = useThrottleFn(async (record: any) => {
|
const handleDelete = useThrottleFn(async (record: any) => {
|
||||||
try {
|
try {
|
||||||
const res = await deleteRole(record.roleId);
|
const res = await deleteRole(record.roleId);
|
||||||
if (res.code === '200') {
|
if (res.code == 200) {
|
||||||
message.success('删除成功');
|
message.success('删除成功');
|
||||||
fetchList();
|
fetchList();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ export default defineComponent({
|
|||||||
try {
|
try {
|
||||||
const params: Record<string, string> = { page: '1', limit: '999', name: keyword.trim() };
|
const params: Record<string, string> = { page: '1', limit: '999', name: keyword.trim() };
|
||||||
const res = await getRoleList(params);
|
const res = await getRoleList(params);
|
||||||
if (res.code === '200') {
|
if (res.code == 200) {
|
||||||
const list: TournamentAdminRolePageVO[] = res.data?.list || [];
|
const list: TournamentAdminRolePageVO[] = res.data?.list || [];
|
||||||
setRoleOptions(
|
setRoleOptions(
|
||||||
list.map((item) => ({
|
list.map((item) => ({
|
||||||
@@ -91,7 +91,7 @@ export default defineComponent({
|
|||||||
const fetchInitialRoles = async () => {
|
const fetchInitialRoles = async () => {
|
||||||
try {
|
try {
|
||||||
const res = await getRoleList({ page: '1', limit: '999' });
|
const res = await getRoleList({ page: '1', limit: '999' });
|
||||||
if (res.code === '200') {
|
if (res.code == 200) {
|
||||||
const list: TournamentAdminRolePageVO[] = res.data?.list || [];
|
const list: TournamentAdminRolePageVO[] = res.data?.list || [];
|
||||||
const opts = list.map((item) => ({
|
const opts = list.map((item) => ({
|
||||||
value: String(item.roleId),
|
value: String(item.roleId),
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ export default defineComponent({
|
|||||||
userId: record.id,
|
userId: record.id,
|
||||||
status: isActive ? '0' : '1',
|
status: isActive ? '0' : '1',
|
||||||
});
|
});
|
||||||
if (res.code === '200') {
|
if (res.code == 200) {
|
||||||
message.success(`${actionText}成功`);
|
message.success(`${actionText}成功`);
|
||||||
handleSearch();
|
handleSearch();
|
||||||
} else {
|
} else {
|
||||||
@@ -169,7 +169,7 @@ export default defineComponent({
|
|||||||
confirmPassword: formPayload.password,
|
confirmPassword: formPayload.password,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (res.code === '200') {
|
if (res.code == 200) {
|
||||||
message.success(editingRecord.value ? '编辑成功' : '新增成功');
|
message.success(editingRecord.value ? '编辑成功' : '新增成功');
|
||||||
handleCloseModal();
|
handleCloseModal();
|
||||||
handleSearch();
|
handleSearch();
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ export function useUserModel() {
|
|||||||
const fetchRoleOptions = async () => {
|
const fetchRoleOptions = async () => {
|
||||||
try {
|
try {
|
||||||
const res = await getRoleList({ page: '1', limit: '999' });
|
const res = await getRoleList({ page: '1', limit: '999' });
|
||||||
if (res.code === '200') {
|
if (res.code == 200) {
|
||||||
const list: TournamentAdminRolePageVO[] = res.data?.list || [];
|
const list: TournamentAdminRolePageVO[] = res.data?.list || [];
|
||||||
const opts = list.map((item) => ({
|
const opts = list.map((item) => ({
|
||||||
value: String(item.roleId),
|
value: String(item.roleId),
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ const request = (
|
|||||||
|
|
||||||
const data = await res.json();
|
const data = await res.json();
|
||||||
|
|
||||||
if (data.code === '401') {
|
if (data.code == 401) {
|
||||||
handleUnauthorized(data.msg);
|
handleUnauthorized(data.msg);
|
||||||
return Promise.reject(new Error(data.msg || 'Unauthorized'));
|
return Promise.reject(new Error(data.msg || 'Unauthorized'));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user