hookehuyr

fix: 移除重复的错误提示并优化API错误处理

移除提交、核销和删除操作中的重复错误提示
优化API错误处理逻辑,统一使用fn.js中的错误提示
/*
* @Date: 2022-05-18 22:56:08
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2026-01-06 20:56:55
* @FilePath: /git/xyxBooking-weapp/src/api/fn.js
* @LastEditTime: 2026-01-16 15:51:34
* @FilePath: /xyxBooking-weapp/src/api/fn.js
* @Description: 文件描述
*/
import axios from '@/utils/request';
......@@ -18,11 +18,11 @@ export const fn = (api) => {
return api
.then(res => {
// 适配 H5 逻辑,code === 1 为成功
if (res.data.code === 1) {
if (res.data.code == 1) {
return res.data || true;
} else {
// tslint:disable-next-line: no-console
console.warn(res);
console.warn('API Error:', res);
if (res.data.show === false) return false;
Taro.showToast({
title: res.data.msg || '请求失败',
......
<!--
* @Date: 2024-01-15 16:25:51
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2026-01-16 15:12:09
* @LastEditTime: 2026-01-16 16:13:44
* @FilePath: /xyxBooking-weapp/src/pages/submit/index.vue
* @Description: 预约人员信息
-->
......@@ -145,7 +145,6 @@ const submitBtn = async () => {
Taro.hideLoading();
if (!code || code !== 1) {
Taro.showToast({ title: msg || '提交失败', icon: 'none' });
return;
}
pay_id = data.pay_id;
......
<!--
* @Date: 2026-01-08 13:01:20
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2026-01-15 16:49:25
* @LastEditTime: 2026-01-16 16:14:06
* @FilePath: /xyxBooking-weapp/src/pages/verificationResult/index.vue
* @Description: 核销结果页面
-->
......@@ -110,7 +110,6 @@ const verify_ticket = async (code) => {
}
verify_status.value = 'fail'
msg.value = res?.msg || '核销失败'
Taro.showToast({ title: msg.value, icon: 'none' })
} catch (e) {
verify_status.value = 'fail'
msg.value = '核销失败'
......
......@@ -93,12 +93,10 @@ const removeItem = async (item) => {
const { confirm } = await Taro.showModal({ title: '提示', content: '确定删除该参观者吗?' });
if (confirm) {
try {
const { code, msg } = await delPersonAPI({ person_id: item.id });
if (code) {
const res = await delPersonAPI({ person_id: item.id });
if (res && res.code) {
Taro.showToast({ title: '删除成功' });
loadList();
} else {
Taro.showToast({ title: msg || '删除失败', icon: 'none' });
}
} catch (error) {
console.error(error);
......