Compare commits
15 Commits
b6801cdde2
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 69248d33c8 | |||
| 1973ec3faa | |||
| abc2dfeecf | |||
| bafb44ff06 | |||
| 0e27d801a4 | |||
| 0a0203e36d | |||
| 2656c59475 | |||
| 23eb9dc467 | |||
| 44f971b1c2 | |||
| 4a553c63fc | |||
|
|
baa60bbfcb | ||
|
|
64f0267457 | ||
|
|
8688b6b82d | ||
|
|
1678f787a3 | ||
|
|
3571740280 |
@@ -473,7 +473,7 @@ async function safeMarkAsRead(type, ids) {
|
|||||||
})
|
})
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// 标记已读失败不影响用户体验,静默处理
|
// 标记已读失败不影响用户体验,静默处理
|
||||||
console.error('标记已读失败:', err)
|
console.warn('标记已读失败:', err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ function formatSize(bytes) {
|
|||||||
|
|
||||||
function analyze() {
|
function analyze() {
|
||||||
if (!fs.existsSync(DIST_DIR)) {
|
if (!fs.existsSync(DIST_DIR)) {
|
||||||
console.error('dist 目录不存在,请先执行 taro build --type weapp');
|
console.warn('dist 目录不存在,请先执行 taro build --type weapp');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
"miniprogramRoot": "dist/",
|
"miniprogramRoot": "dist/",
|
||||||
"projectname": "playBallTogether",
|
"projectname": "playBallTogether",
|
||||||
"description": "playBallTogether",
|
"description": "playBallTogether",
|
||||||
"appid": "wx915ecf6c01bea4ec",
|
"appid": "wx815b533167eb7b53",
|
||||||
"setting": {
|
"setting": {
|
||||||
"urlCheck": true,
|
"urlCheck": true,
|
||||||
"es6": true,
|
"es6": true,
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ const { envConfigs } = require(envConfigPath);
|
|||||||
|
|
||||||
const config = envConfigs[appEnv];
|
const config = envConfigs[appEnv];
|
||||||
if (!config) {
|
if (!config) {
|
||||||
console.error(`[sync-project-config] Unknown APP_ENV: ${appEnv}`);
|
console.warn(`[sync-project-config] Unknown APP_ENV: ${appEnv}`);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import dayjs from "dayjs";
|
|||||||
import classnames from "classnames";
|
import classnames from "classnames";
|
||||||
import CommentServices from "@/services/commentServices";
|
import CommentServices from "@/services/commentServices";
|
||||||
import messageService from "@/services/messageService";
|
import messageService from "@/services/messageService";
|
||||||
import { delay } from "@/utils";
|
import { delay, getBackendErrorMsg } from "@/utils";
|
||||||
import type {
|
import type {
|
||||||
BaseComment,
|
BaseComment,
|
||||||
Comment,
|
Comment,
|
||||||
@@ -342,7 +342,7 @@ export default forwardRef(function Comments(
|
|||||||
try {
|
try {
|
||||||
await messageService.markAsRead("comment", [message_id]);
|
await messageService.markAsRead("comment", [message_id]);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error("标记评论已读失败:", e);
|
console.warn("标记评论已读失败:", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -459,36 +459,48 @@ export default forwardRef(function Comments(
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function createComment(val: string) {
|
async function createComment(val: string) {
|
||||||
const res = await CommentServices.createComment({ game_id, content: val });
|
try {
|
||||||
if (res.code === 0) {
|
const res = await CommentServices.createComment({ game_id, content: val });
|
||||||
setComments((prev) => {
|
if (res.code === 0) {
|
||||||
commentCountUpdateRef.current?.(prev.length + 1);
|
setComments((prev) => {
|
||||||
return [{ ...res.data, replies: [] }, ...prev];
|
commentCountUpdateRef.current?.(prev.length + 1);
|
||||||
});
|
return [{ ...res.data, replies: [] }, ...prev];
|
||||||
toast("发布成功");
|
});
|
||||||
|
toast("发布成功");
|
||||||
|
} else {
|
||||||
|
toast(getBackendErrorMsg(res, "评论失败"));
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
toast(getBackendErrorMsg(error, "评论失败"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function replyComment({ parent_id, reply_to_user_id, content }) {
|
async function replyComment({ parent_id, reply_to_user_id, content }) {
|
||||||
const res = await CommentServices.replyComment({
|
try {
|
||||||
parent_id,
|
const res = await CommentServices.replyComment({
|
||||||
reply_to_user_id,
|
parent_id,
|
||||||
content,
|
reply_to_user_id,
|
||||||
});
|
content,
|
||||||
if (res.code === 0) {
|
|
||||||
setComments((prev) => {
|
|
||||||
return prev.map((item) => {
|
|
||||||
if (item.id === parent_id) {
|
|
||||||
return {
|
|
||||||
...item,
|
|
||||||
replies: [res.data, ...item.replies],
|
|
||||||
reply_count: item.reply_count + 1,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
return item;
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
toast("回复成功");
|
if (res.code === 0) {
|
||||||
|
setComments((prev) => {
|
||||||
|
return prev.map((item) => {
|
||||||
|
if (item.id === parent_id) {
|
||||||
|
return {
|
||||||
|
...item,
|
||||||
|
replies: [res.data, ...item.replies],
|
||||||
|
reply_count: item.reply_count + 1,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return item;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
toast("回复成功");
|
||||||
|
} else {
|
||||||
|
toast(getBackendErrorMsg(res, "回复失败"));
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
toast(getBackendErrorMsg(error, "回复失败"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -134,7 +134,7 @@ const DistanceQuickFilterV2 = (props) => {
|
|||||||
throw new Error('获取位置信息失败');
|
throw new Error('获取位置信息失败');
|
||||||
}
|
}
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
console.error('重新定位失败:', error);
|
console.warn('重新定位失败:', error);
|
||||||
(Taro as any).showToast({
|
(Taro as any).showToast({
|
||||||
title: error?.message || '定位失败,请检查定位权限',
|
title: error?.message || '定位失败,请检查定位权限',
|
||||||
icon: 'none',
|
icon: 'none',
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ const FollowUserCard: React.FC<FollowUserCardProps> = ({ user, tabKey, onFollowC
|
|||||||
|
|
||||||
onFollowChange?.(user.id, new_status);
|
onFollowChange?.(user.id, new_status);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('关注操作失败:', error);
|
console.warn('关注操作失败:', error);
|
||||||
Taro.showToast({
|
Taro.showToast({
|
||||||
title: '操作失败',
|
title: '操作失败',
|
||||||
icon: 'none'
|
icon: 'none'
|
||||||
@@ -67,7 +67,7 @@ const FollowUserCard: React.FC<FollowUserCardProps> = ({ user, tabKey, onFollowC
|
|||||||
onBlockSuccess?.(user.id);
|
onBlockSuccess?.(user.id);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('删除推荐人员失败:', error);
|
console.warn('删除推荐人员失败:', error);
|
||||||
Taro.showToast({
|
Taro.showToast({
|
||||||
title: '操作失败',
|
title: '操作失败',
|
||||||
icon: 'none'
|
icon: 'none'
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ const HomeNavbar = (props: IProps) => {
|
|||||||
console.log(`[HomeNavbar] 距离上次选择"继续浏览"还不到2小时,剩余时间: ${Math.ceil((TWO_HOURS_MS - time_diff) / 1000 / 60)}分钟`);
|
console.log(`[HomeNavbar] 距离上次选择"继续浏览"还不到2小时,剩余时间: ${Math.ceil((TWO_HOURS_MS - time_diff) / 1000 / 60)}分钟`);
|
||||||
return false;
|
return false;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('[HomeNavbar] 检查定位弹窗显示条件失败:', error);
|
console.warn('[HomeNavbar] 检查定位弹窗显示条件失败:', error);
|
||||||
return true; // 出错时默认显示
|
return true; // 出错时默认显示
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -239,7 +239,7 @@ const HomeNavbar = (props: IProps) => {
|
|||||||
// console.log(`距离上次选择"继续浏览"还不到2小时,剩余时间: ${Math.ceil((TWO_HOURS_MS - time_diff) / 1000 / 60)}分钟`);
|
// console.log(`距离上次选择"继续浏览"还不到2小时,剩余时间: ${Math.ceil((TWO_HOURS_MS - time_diff) / 1000 / 60)}分钟`);
|
||||||
// return false;
|
// return false;
|
||||||
// } catch (error) {
|
// } catch (error) {
|
||||||
// console.error('检查定位弹窗显示条件失败:', error);
|
// console.warn('检查定位弹窗显示条件失败:', error);
|
||||||
// return true; // 出错时默认显示
|
// return true; // 出错时默认显示
|
||||||
// }
|
// }
|
||||||
// };
|
// };
|
||||||
@@ -276,7 +276,7 @@ const HomeNavbar = (props: IProps) => {
|
|||||||
(Taro as any).setStorageSync(CITY_CHANGE_TIME_KEY, current_time);
|
(Taro as any).setStorageSync(CITY_CHANGE_TIME_KEY, current_time);
|
||||||
console.log(`[LocationDialog] 已记录用户切换城市的时间,2小时内不再提示`);
|
console.log(`[LocationDialog] 已记录用户切换城市的时间,2小时内不再提示`);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('保存城市切换时间失败:', error);
|
console.warn('保存城市切换时间失败:', error);
|
||||||
}
|
}
|
||||||
console.log("切换到用户详情中的位置信息并更新缓存:", detectedProvince);
|
console.log("切换到用户详情中的位置信息并更新缓存:", detectedProvince);
|
||||||
|
|
||||||
@@ -304,7 +304,7 @@ const HomeNavbar = (props: IProps) => {
|
|||||||
(Taro as any).setStorageSync(LOCATION_DIALOG_DISMISS_TIME_KEY, current_time);
|
(Taro as any).setStorageSync(LOCATION_DIALOG_DISMISS_TIME_KEY, current_time);
|
||||||
console.log(`[LocationDialog] 已记录用户选择"继续浏览"的时间,2小时内不再提示`);
|
console.log(`[LocationDialog] 已记录用户选择"继续浏览"的时间,2小时内不再提示`);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('保存定位弹窗关闭时间失败:', error);
|
console.warn('保存定位弹窗关闭时间失败:', error);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 关闭弹窗
|
// 关闭弹窗
|
||||||
@@ -409,7 +409,7 @@ const HomeNavbar = (props: IProps) => {
|
|||||||
(Taro as any).setStorageSync(CITY_CHANGE_TIME_KEY, current_time);
|
(Taro as any).setStorageSync(CITY_CHANGE_TIME_KEY, current_time);
|
||||||
console.log("已保存城市到缓存并记录切换时间:", _newArea, current_time);
|
console.log("已保存城市到缓存并记录切换时间:", _newArea, current_time);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("保存城市缓存失败:", error);
|
console.warn("保存城市缓存失败:", error);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 先调用列表接口(会使用更新后的 state.area)
|
// 先调用列表接口(会使用更新后的 state.area)
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ const ImageUpload: React.FC<ImageUploadProps> = ({
|
|||||||
onChange([...images, ...newImages])
|
onChange([...images, ...newImages])
|
||||||
},
|
},
|
||||||
fail: (err) => {
|
fail: (err) => {
|
||||||
console.error('选择图片失败:', err)
|
console.warn('选择图片失败:', err)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}, [images.length, maxCount, onChange])
|
}, [images.length, maxCount, onChange])
|
||||||
|
|||||||
@@ -256,7 +256,7 @@ const RadarChartV2 = forwardRef<RadarChartV2Ref, RadarChartV2Props>(
|
|||||||
const bgImg = await loadImage(canvas, shareBgUrl);
|
const bgImg = await loadImage(canvas, shareBgUrl);
|
||||||
ctx.drawImage(bgImg, 0, 0, width, height);
|
ctx.drawImage(bgImg, 0, 0, width, height);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Failed to load background image:", error);
|
console.warn("Failed to load background image:", error);
|
||||||
// 如果加载失败,使用白色背景作为兜底
|
// 如果加载失败,使用白色背景作为兜底
|
||||||
ctx.fillStyle = "#FFFFFF";
|
ctx.fillStyle = "#FFFFFF";
|
||||||
ctx.fillRect(0, 0, width, height);
|
ctx.fillRect(0, 0, width, height);
|
||||||
@@ -392,12 +392,12 @@ const RadarChartV2 = forwardRef<RadarChartV2Ref, RadarChartV2Props>(
|
|||||||
);
|
);
|
||||||
ctx.restore();
|
ctx.restore();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Failed to load docCopy image:", error);
|
console.warn("Failed to load docCopy image:", error);
|
||||||
}
|
}
|
||||||
|
|
||||||
currentY += (48 + 20) * scale; // 头像区域高度 + gap
|
currentY += (48 + 20) * scale; // 头像区域高度 + gap
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Failed to load avatar image:", error);
|
console.warn("Failed to load avatar image:", error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -523,7 +523,7 @@ const RadarChartV2 = forwardRef<RadarChartV2Ref, RadarChartV2Props>(
|
|||||||
iconSize,
|
iconSize,
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Failed to load icon:", error);
|
console.warn("Failed to load icon:", error);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 绘制底部文字
|
// 绘制底部文字
|
||||||
@@ -601,7 +601,7 @@ const RadarChartV2 = forwardRef<RadarChartV2Ref, RadarChartV2Props>(
|
|||||||
// 恢复上下文状态
|
// 恢复上下文状态
|
||||||
ctx.restore();
|
ctx.restore();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Failed to load QR code:", error);
|
console.warn("Failed to load QR code:", error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -575,7 +575,7 @@ const ShareCardCanvas: React.FC<ShareCardCanvasProps> = ({
|
|||||||
setTempImagePath(res.tempFilePath)
|
setTempImagePath(res.tempFilePath)
|
||||||
},
|
},
|
||||||
fail: (error: any) => {
|
fail: (error: any) => {
|
||||||
console.error('图片生成失败:', error)
|
console.warn('图片生成失败:', error)
|
||||||
setIsDrawing(false)
|
setIsDrawing(false)
|
||||||
reject(error)
|
reject(error)
|
||||||
}
|
}
|
||||||
@@ -595,7 +595,7 @@ const ShareCardCanvas: React.FC<ShareCardCanvasProps> = ({
|
|||||||
console.log('Canvas绘制命令已发送')
|
console.log('Canvas绘制命令已发送')
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('绘制分享卡片失败:', error)
|
console.warn('绘制分享卡片失败:', error)
|
||||||
setIsDrawing(false) // 绘制失败,重置状态
|
setIsDrawing(false) // 绘制失败,重置状态
|
||||||
Taro.showToast({
|
Taro.showToast({
|
||||||
title: '生成分享卡片失败',
|
title: '生成分享卡片失败',
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ const SubscribeNotificationTip: React.FC<SubscribeNotificationTipProps> = ({
|
|||||||
navigateTo({
|
navigateTo({
|
||||||
url: '/other_pages/enable_notification/index',
|
url: '/other_pages/enable_notification/index',
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
console.error('跳转失败:', err);
|
console.warn('跳转失败:', err);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -86,9 +86,9 @@ async function onChooseImageSuccess(tempFiles) {
|
|||||||
...fileRes,
|
...fileRes,
|
||||||
...(height > IMAGE_MAX_SIZE.height
|
...(height > IMAGE_MAX_SIZE.height
|
||||||
? {
|
? {
|
||||||
width: Math.floor(IMAGE_MAX_SIZE.height * image_aspect_ratio),
|
width: Math.floor(IMAGE_MAX_SIZE.height * image_aspect_ratio),
|
||||||
height: IMAGE_MAX_SIZE.height,
|
height: IMAGE_MAX_SIZE.height,
|
||||||
}
|
}
|
||||||
: { width: Math.floor(height * image_aspect_ratio), height }),
|
: { width: Math.floor(height * image_aspect_ratio), height }),
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
@@ -96,9 +96,9 @@ async function onChooseImageSuccess(tempFiles) {
|
|||||||
...fileRes,
|
...fileRes,
|
||||||
...(width > IMAGE_MAX_SIZE.width
|
...(width > IMAGE_MAX_SIZE.width
|
||||||
? {
|
? {
|
||||||
width: IMAGE_MAX_SIZE.width,
|
width: IMAGE_MAX_SIZE.width,
|
||||||
height: Math.floor(IMAGE_MAX_SIZE.width / image_aspect_ratio),
|
height: Math.floor(IMAGE_MAX_SIZE.width / image_aspect_ratio),
|
||||||
}
|
}
|
||||||
: { width, height: Math.floor(width / image_aspect_ratio) }),
|
: { width, height: Math.floor(width / image_aspect_ratio) }),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -119,7 +119,6 @@ export default function UploadFromWx(props: UploadFromWxProps) {
|
|||||||
sourceType: ["album", "camera"],
|
sourceType: ["album", "camera"],
|
||||||
}).then(async (res) => {
|
}).then(async (res) => {
|
||||||
const analyzedFiles = await onChooseImageSuccess(res.tempFiles);
|
const analyzedFiles = await onChooseImageSuccess(res.tempFiles);
|
||||||
// cropping image to standard size
|
|
||||||
const compressedTempFiles = await compressImage(analyzedFiles);
|
const compressedTempFiles = await compressImage(analyzedFiles);
|
||||||
|
|
||||||
let start = Date.now();
|
let start = Date.now();
|
||||||
@@ -130,19 +129,22 @@ export default function UploadFromWx(props: UploadFromWxProps) {
|
|||||||
is_public: 1 as unknown as 0 | 1,
|
is_public: 1 as unknown as 0 | 1,
|
||||||
id: (start++).toString(),
|
id: (start++).toString(),
|
||||||
}));
|
}));
|
||||||
const onFileUpdate = uploadApi.batchUpload(files).then((res) => {
|
|
||||||
return res.map((item) => ({
|
Taro.showLoading({ title: "上传中..." });
|
||||||
id: item.id,
|
try {
|
||||||
url: item ? item.data.file_url : "",
|
const uploadRes = await uploadApi.batchUpload(files);
|
||||||
}));
|
const successful = uploadRes
|
||||||
});
|
.filter((item) => item.data != null)
|
||||||
onAdd(
|
.map((item) => ({
|
||||||
files.map((item) => ({
|
id: item.id,
|
||||||
id: item.id,
|
url: (item.data as { file_url: string }).file_url,
|
||||||
url: item.filePath,
|
}));
|
||||||
})),
|
onAdd(successful, Promise.resolve(successful));
|
||||||
onFileUpdate
|
} catch (e) {
|
||||||
);
|
console.warn("批量上传失败:", e);
|
||||||
|
} finally {
|
||||||
|
Taro.hideLoading();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import {
|
|||||||
useProfessions,
|
useProfessions,
|
||||||
useNtrpLevels,
|
useNtrpLevels,
|
||||||
} from "@/store/pickerOptionsStore";
|
} from "@/store/pickerOptionsStore";
|
||||||
import { formatNtrpDisplay } from "@/utils/helper";
|
import { formatNtrpDisplay, getBackendErrorMsg } from "@/utils/helper";
|
||||||
import { useGlobalState } from "@/store/global";
|
import { useGlobalState } from "@/store/global";
|
||||||
|
|
||||||
// 用户信息接口
|
// 用户信息接口
|
||||||
@@ -74,6 +74,7 @@ const on_edit = () => {
|
|||||||
// 用户信息卡片组件
|
// 用户信息卡片组件
|
||||||
const UserInfoCardComponent: React.FC<UserInfoCardProps> = ({
|
const UserInfoCardComponent: React.FC<UserInfoCardProps> = ({
|
||||||
editable = true,
|
editable = true,
|
||||||
|
user_info: user_info_prop,
|
||||||
is_current_user,
|
is_current_user,
|
||||||
is_following = false,
|
is_following = false,
|
||||||
collapseProfile,
|
collapseProfile,
|
||||||
@@ -84,8 +85,9 @@ const UserInfoCardComponent: React.FC<UserInfoCardProps> = ({
|
|||||||
set_user_info,
|
set_user_info,
|
||||||
onTab,
|
onTab,
|
||||||
}) => {
|
}) => {
|
||||||
|
const global_user_info = useUserInfo();
|
||||||
const user_info = useUserInfo();
|
// 查看别人页面时用传入的 user_info,个人页用全局 store
|
||||||
|
const user_info = is_current_user ? global_user_info : (user_info_prop ?? global_user_info);
|
||||||
const nickname_change_status = useNicknameChangeStatus();
|
const nickname_change_status = useNicknameChangeStatus();
|
||||||
const { setShowGuideBar } = useGlobalState();
|
const { setShowGuideBar } = useGlobalState();
|
||||||
const { updateUserInfo, updateNickname, fetchLastTestResult } =
|
const { updateUserInfo, updateNickname, fetchLastTestResult } =
|
||||||
@@ -98,18 +100,16 @@ const UserInfoCardComponent: React.FC<UserInfoCardProps> = ({
|
|||||||
const prevUserInfoRef = useRef<Partial<UserInfoType>>();
|
const prevUserInfoRef = useRef<Partial<UserInfoType>>();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// 只在 user_info 真正变化时打印(通过 JSON 序列化比较)
|
|
||||||
const prevStr = JSON.stringify(prevUserInfoRef.current);
|
const prevStr = JSON.stringify(prevUserInfoRef.current);
|
||||||
const currentStr = JSON.stringify(user_info);
|
const currentStr = JSON.stringify(user_info);
|
||||||
if (prevStr !== currentStr) {
|
if (prevStr !== currentStr) {
|
||||||
console.log("UserInfoCard 用户信息变化:", user_info);
|
|
||||||
prevUserInfoRef.current = user_info;
|
prevUserInfoRef.current = user_info;
|
||||||
}
|
}
|
||||||
// 如果全局状态中没有测试结果,则调用接口(使用请求锁,多个组件同时调用时只会请求一次)
|
// 仅当前用户才拉取 NTRP 测试结果
|
||||||
if (!lastTestResult && user_info?.id) {
|
if (is_current_user && !lastTestResult && user_info?.id) {
|
||||||
fetchLastTestResult();
|
fetchLastTestResult();
|
||||||
}
|
}
|
||||||
}, [user_info?.id, lastTestResult, fetchLastTestResult]);
|
}, [user_info?.id, lastTestResult, fetchLastTestResult, is_current_user]);
|
||||||
|
|
||||||
// 从全局状态中获取测试状态
|
// 从全局状态中获取测试状态
|
||||||
const ntrpTested = lastTestResult?.has_test_in_last_month || false;
|
const ntrpTested = lastTestResult?.has_test_in_last_month || false;
|
||||||
@@ -250,10 +250,10 @@ const UserInfoCardComponent: React.FC<UserInfoCardProps> = ({
|
|||||||
icon: "success",
|
icon: "success",
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("保存失败:", error);
|
console.warn("保存失败:", error);
|
||||||
Taro.showToast({
|
Taro.showToast({
|
||||||
title: "保存失败",
|
title: getBackendErrorMsg(error, "保存失败"),
|
||||||
icon: "error",
|
icon: "none",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -293,10 +293,10 @@ const UserInfoCardComponent: React.FC<UserInfoCardProps> = ({
|
|||||||
icon: "success",
|
icon: "success",
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("保存失败:", error);
|
console.warn("保存失败:", error);
|
||||||
Taro.showToast({
|
Taro.showToast({
|
||||||
title: "保存失败",
|
title: getBackendErrorMsg(error, "保存失败"),
|
||||||
icon: "error",
|
icon: "none",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import orderService from "@/services/orderService";
|
|||||||
import styles from "./index.module.scss";
|
import styles from "./index.module.scss";
|
||||||
import closeIcon from "@/static/order/orderListClose.svg";
|
import closeIcon from "@/static/order/orderListClose.svg";
|
||||||
|
|
||||||
function genRefundNotice(refund_policy) {
|
function genRefundNotice(refund_policy, order_amount) {
|
||||||
if (refund_policy.length === 0) {
|
if (refund_policy.length === 0) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
@@ -23,8 +23,7 @@ function genRefundNotice(refund_policy) {
|
|||||||
if (matchPolicyIndex === -1) {
|
if (matchPolicyIndex === -1) {
|
||||||
matchPolicyIndex = refund_policy.length - 1;
|
matchPolicyIndex = refund_policy.length - 1;
|
||||||
}
|
}
|
||||||
const { deadline_formatted, price, refund_rate } =
|
const { time_range, price, refund_rate } = refund_policy[matchPolicyIndex];
|
||||||
refund_policy[matchPolicyIndex];
|
|
||||||
if (refund_rate === 1) {
|
if (refund_rate === 1) {
|
||||||
return {
|
return {
|
||||||
refundPrice: price,
|
refundPrice: price,
|
||||||
@@ -33,20 +32,18 @@ function genRefundNotice(refund_policy) {
|
|||||||
} else if (refund_rate === 0) {
|
} else if (refund_rate === 0) {
|
||||||
return {
|
return {
|
||||||
refundPrice: 0,
|
refundPrice: 0,
|
||||||
notice: `当前退出不可退款,后续流程未明确,@麻真瑜`,
|
notice: `当前退出不可退款,¥${order_amount} 将不予退回`,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
const refundPrice = Number(Math.ceil(price * refund_rate * 100) / 100);
|
// const refundPrice = Number(Math.ceil(price * refund_rate * 100) / 100);
|
||||||
const leftHours = dayjs(deadline_formatted).diff(dayjs(), "hour");
|
// const leftHours = dayjs(deadline_formatted).diff(dayjs(), "hour");
|
||||||
return {
|
return {
|
||||||
refundPrice,
|
refundPrice: price,
|
||||||
notice: `距活动开始已不足${leftHours}h,当前退出您需扣除${
|
notice: `活动开始${time_range},当前退出需扣除您${Math.ceil((order_amount - price) * 100) / 100}元`,
|
||||||
Math.floor((price - refundPrice) * 100) / 100
|
|
||||||
}元`,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderCancelContent(refund_policy = []) {
|
function renderCancelContent(refund_policy = [], amount) {
|
||||||
const current = dayjs();
|
const current = dayjs();
|
||||||
const policyList = [
|
const policyList = [
|
||||||
{
|
{
|
||||||
@@ -65,7 +62,7 @@ function renderCancelContent(refund_policy = []) {
|
|||||||
}),
|
}),
|
||||||
];
|
];
|
||||||
const targetIndex = policyList.findIndex((item) => item.beforeCurrent);
|
const targetIndex = policyList.findIndex((item) => item.beforeCurrent);
|
||||||
const { notice } = genRefundNotice(refund_policy);
|
const { notice } = genRefundNotice(refund_policy, amount);
|
||||||
return (
|
return (
|
||||||
<View className={styles.refundPolicy}>
|
<View className={styles.refundPolicy}>
|
||||||
{/* <View className={styles.moduleTitle}>
|
{/* <View className={styles.moduleTitle}>
|
||||||
@@ -80,7 +77,7 @@ function renderCancelContent(refund_policy = []) {
|
|||||||
className={classnames(
|
className={classnames(
|
||||||
styles.policyItem,
|
styles.policyItem,
|
||||||
targetIndex > index && index !== 0 ? styles.pastItem : "",
|
targetIndex > index && index !== 0 ? styles.pastItem : "",
|
||||||
targetIndex === index ? styles.currentItem : ""
|
targetIndex === index ? styles.currentItem : "",
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<View className={styles.time}>
|
<View className={styles.time}>
|
||||||
@@ -169,7 +166,7 @@ export default forwardRef<RefundRef>(function RefundPopup(_props, ref) {
|
|||||||
onClick={onClose}
|
onClick={onClose}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
{renderCancelContent(refundPolicy)}
|
{renderCancelContent(refundPolicy, orderData.amount)}
|
||||||
<Button className={styles.action} onClick={handleConfirmQuit}>
|
<Button className={styles.action} onClick={handleConfirmQuit}>
|
||||||
确认并退出
|
确认并退出
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -48,8 +48,8 @@ function genRecommendGames(games, location, avatar) {
|
|||||||
formatNtrpDisplay(skill_level_max) || "-"
|
formatNtrpDisplay(skill_level_max) || "-"
|
||||||
}`
|
}`
|
||||||
: skill_level_min === "1"
|
: skill_level_min === "1"
|
||||||
? "无要求"
|
? "无要求"
|
||||||
: `${formatNtrpDisplay(skill_level_min)}以上`,
|
: `${formatNtrpDisplay(skill_level_min)}以上`,
|
||||||
playType: play_type,
|
playType: play_type,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
@@ -220,7 +220,9 @@ export default function OrganizerInfo(props) {
|
|||||||
>
|
>
|
||||||
<Text>{game.venue}</Text>
|
<Text>{game.venue}</Text>
|
||||||
<Text>·</Text>
|
<Text>·</Text>
|
||||||
<Text>{game.venueType}</Text>
|
<Text style={{ whiteSpace: "nowrap" }}>
|
||||||
|
{game.venueType}
|
||||||
|
</Text>
|
||||||
<Text>·</Text>
|
<Text>·</Text>
|
||||||
<Text>{game.distance}</Text>
|
<Text>{game.distance}</Text>
|
||||||
</View>
|
</View>
|
||||||
@@ -247,7 +249,7 @@ export default function OrganizerInfo(props) {
|
|||||||
styles[
|
styles[
|
||||||
"recommend-games-list-item-addon-message-applications"
|
"recommend-games-list-item-addon-message-applications"
|
||||||
],
|
],
|
||||||
styles.joinMsg
|
styles.joinMsg,
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<Text>已加入</Text>
|
<Text>已加入</Text>
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ function Index() {
|
|||||||
// handleShare(true);
|
// handleShare(true);
|
||||||
// }
|
// }
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("用户位置更新失败", error);
|
console.warn("用户位置更新失败", error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -17,14 +17,14 @@ const HomePage: React.FC = () => {
|
|||||||
if (loginResult.success) {
|
if (loginResult.success) {
|
||||||
// 静默登录成功,获取用户信息
|
// 静默登录成功,获取用户信息
|
||||||
fetchUserInfo().catch((error) => {
|
fetchUserInfo().catch((error) => {
|
||||||
console.error("获取用户信息失败:", error);
|
console.warn("获取用户信息失败:", error);
|
||||||
});
|
});
|
||||||
checkNicknameChangeStatus().catch((error) => {
|
checkNicknameChangeStatus().catch((error) => {
|
||||||
console.error("检查昵称变更状态失败:", error);
|
console.warn("检查昵称变更状态失败:", error);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("静默登录失败:", error);
|
console.warn("静默登录失败:", error);
|
||||||
// 静默登录失败不影响使用
|
// 静默登录失败不影响使用
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ const VerificationPage: React.FC = () => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("发送验证码异常:", error);
|
console.warn("发送验证码异常:", error);
|
||||||
Taro.showToast({
|
Taro.showToast({
|
||||||
title: "发送失败,请重试",
|
title: "发送失败,请重试",
|
||||||
icon: "none",
|
icon: "none",
|
||||||
|
|||||||
@@ -67,6 +67,8 @@ const ListPageContent: React.FC<ListPageContentProps> = ({
|
|||||||
} = store;
|
} = store;
|
||||||
|
|
||||||
const supportedCitiesList = useDictionaryStore((s) => s.getDictionaryValue('supported_cities', ['上海市'])) || [];
|
const supportedCitiesList = useDictionaryStore((s) => s.getDictionaryValue('supported_cities', ['上海市'])) || [];
|
||||||
|
// 首页是否展示二维码,由 getDictionaryManyKey 的 show_home_qrcode 控制,默认 true 保持原样
|
||||||
|
const showHomeQrcode = useDictionaryStore((s) => s.getDictionaryValue('show_home_qrcode', true));
|
||||||
|
|
||||||
const {
|
const {
|
||||||
isShowFilterPopup,
|
isShowFilterPopup,
|
||||||
@@ -227,18 +229,16 @@ const ListPageContent: React.FC<ListPageContentProps> = ({
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// 分批异步执行初始化操作,避免阻塞首屏渲染
|
// 分批异步执行初始化操作,避免阻塞首屏渲染
|
||||||
// 1. 立即执行:获取城市、二维码和行政区列表(轻量操作)
|
|
||||||
getCities();
|
getCities();
|
||||||
getCityQrCode();
|
if (showHomeQrcode) getCityQrCode();
|
||||||
getDistricts(); // 新增:获取行政区列表
|
getDistricts();
|
||||||
|
|
||||||
// 只有当页面激活时才加载位置和列表数据
|
|
||||||
if (isActive) {
|
if (isActive) {
|
||||||
getLocation().catch((error) => {
|
getLocation().catch((error) => {
|
||||||
console.error('获取位置信息失败:', error);
|
console.warn('获取位置信息失败:', error);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, [isActive]);
|
}, [isActive, showHomeQrcode]);
|
||||||
|
|
||||||
// 记录上一次的城市,用于检测城市变化
|
// 记录上一次的城市,用于检测城市变化
|
||||||
const prevAreaRef = useRef<[string, string] | null>(null);
|
const prevAreaRef = useRef<[string, string] | null>(null);
|
||||||
@@ -309,7 +309,7 @@ const ListPageContent: React.FC<ListPageContentProps> = ({
|
|||||||
lastLoadedAreaRef.current = [...currentArea] as [string, string];
|
lastLoadedAreaRef.current = [...currentArea] as [string, string];
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("重新加载数据失败:", error);
|
console.warn("重新加载数据失败:", error);
|
||||||
}
|
}
|
||||||
}, delayMs);
|
}, delayMs);
|
||||||
prevIsActiveRef.current = isActive;
|
prevIsActiveRef.current = isActive;
|
||||||
@@ -375,7 +375,7 @@ const ListPageContent: React.FC<ListPageContentProps> = ({
|
|||||||
await updateUserLocation(location.latitude, location.longitude, isFirstCall);
|
await updateUserLocation(location.latitude, location.longitude, isFirstCall);
|
||||||
hasUpdatedLocationRef.current = true;
|
hasUpdatedLocationRef.current = true;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("更新用户位置失败:", error);
|
console.warn("更新用户位置失败:", error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 先调用列表接口
|
// 先调用列表接口
|
||||||
@@ -462,7 +462,7 @@ const ListPageContent: React.FC<ListPageContentProps> = ({
|
|||||||
await getMatchesData();
|
await getMatchesData();
|
||||||
await fetchGetGamesCount();
|
await fetchGetGamesCount();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("刷新列表失败:", error);
|
console.warn("刷新列表失败:", error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -477,7 +477,7 @@ const ListPageContent: React.FC<ListPageContentProps> = ({
|
|||||||
const { fetchDictionary } = useDictionaryStore.getState();
|
const { fetchDictionary } = useDictionaryStore.getState();
|
||||||
await fetchDictionary();
|
await fetchDictionary();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("初始化字典数据失败:", error);
|
console.warn("初始化字典数据失败:", error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -537,7 +537,13 @@ const ListPageContent: React.FC<ListPageContentProps> = ({
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{shouldShowNoGames ? (
|
{shouldShowNoGames ? (
|
||||||
renderCityQrcode()
|
showHomeQrcode ? (
|
||||||
|
renderCityQrcode()
|
||||||
|
) : (
|
||||||
|
<View className={styles.cqContainer}>
|
||||||
|
<Text>当前城市暂无球局,敬请期待</Text>
|
||||||
|
</View>
|
||||||
|
)
|
||||||
) : (
|
) : (
|
||||||
<View ref={scrollContextRef}>
|
<View ref={scrollContextRef}>
|
||||||
<View className={styles.listPage} style={{ paddingTop: totalHeight }}>
|
<View className={styles.listPage} style={{ paddingTop: totalHeight }}>
|
||||||
@@ -610,7 +616,7 @@ const ListPageContent: React.FC<ListPageContentProps> = ({
|
|||||||
try {
|
try {
|
||||||
await loadMoreMatches();
|
await loadMoreMatches();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("加载更多失败:", error);
|
console.warn("加载更多失败:", error);
|
||||||
} finally {
|
} finally {
|
||||||
loadingMoreRef.current = false;
|
loadingMoreRef.current = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ const MyselfPageContent: React.FC<MyselfPageContentProps> = ({
|
|||||||
const end_time_str = end_time.replace(/\s/, "T");
|
const end_time_str = end_time.replace(/\s/, "T");
|
||||||
new Date(end_time_str).getTime() > now
|
new Date(end_time_str).getTime() > now
|
||||||
? notEndGames.push(game)
|
? notEndGames.push(game)
|
||||||
: finishedGames.push(game);
|
: finishedGames.unshift(game);
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("notEndGames", notEndGames);
|
console.log("notEndGames", notEndGames);
|
||||||
@@ -117,7 +117,7 @@ const MyselfPageContent: React.FC<MyselfPageContentProps> = ({
|
|||||||
set_game_records(notEndGames);
|
set_game_records(notEndGames);
|
||||||
setEndedGameRecords(finishedGames);
|
setEndedGameRecords(finishedGames);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("加载球局数据失败:", error);
|
console.warn("加载球局数据失败:", error);
|
||||||
}
|
}
|
||||||
}, [active_tab, user_info, classifyGameRecords]);
|
}, [active_tab, user_info, classifyGameRecords]);
|
||||||
|
|
||||||
@@ -150,7 +150,7 @@ const MyselfPageContent: React.FC<MyselfPageContentProps> = ({
|
|||||||
duration: 1500,
|
duration: 1500,
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("关注操作失败:", error);
|
console.warn("关注操作失败:", error);
|
||||||
(Taro as any).showToast({
|
(Taro as any).showToast({
|
||||||
title: "操作失败,请重试",
|
title: "操作失败,请重试",
|
||||||
icon: "error",
|
icon: "error",
|
||||||
@@ -198,7 +198,7 @@ const MyselfPageContent: React.FC<MyselfPageContentProps> = ({
|
|||||||
try {
|
try {
|
||||||
await Promise.all([fetchUserInfo(), load_game_data()]);
|
await Promise.all([fetchUserInfo(), load_game_data()]);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("刷新失败:", error);
|
console.warn("刷新失败:", error);
|
||||||
(Taro as any).showToast({
|
(Taro as any).showToast({
|
||||||
title: "刷新失败,请重试",
|
title: "刷新失败,请重试",
|
||||||
icon: "none",
|
icon: "none",
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ const MainPage: React.FC = () => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("微信授权异常:", error);
|
console.warn("微信授权异常:", error);
|
||||||
setAuthErrorMessage("微信授权失败,请重试");
|
setAuthErrorMessage("微信授权失败,请重试");
|
||||||
setShowAuthError(true);
|
setShowAuthError(true);
|
||||||
return;
|
return;
|
||||||
@@ -81,7 +81,7 @@ const MainPage: React.FC = () => {
|
|||||||
await fetchUserInfo();
|
await fetchUserInfo();
|
||||||
await checkNicknameChangeStatus();
|
await checkNicknameChangeStatus();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("获取用户信息失败:", error);
|
console.warn("获取用户信息失败:", error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import orderService, {
|
|||||||
GameOrderRes,
|
GameOrderRes,
|
||||||
OrderStatus,
|
OrderStatus,
|
||||||
refundTextMap,
|
refundTextMap,
|
||||||
|
RefundStatus,
|
||||||
} from "@/services/orderService";
|
} from "@/services/orderService";
|
||||||
import { debounce } from "@tarojs/runtime";
|
import { debounce } from "@tarojs/runtime";
|
||||||
import {
|
import {
|
||||||
@@ -76,7 +77,7 @@ function genGameNotice(order_status, start_time) {
|
|||||||
|
|
||||||
function GameInfo(props) {
|
function GameInfo(props) {
|
||||||
const { detail, currentLocation, orderDetail, init } = props;
|
const { detail, currentLocation, orderDetail, init } = props;
|
||||||
const { order_status, refund_status, amount } = orderDetail;
|
const { order_status, refund_status, amount, refund_amount } = orderDetail;
|
||||||
const {
|
const {
|
||||||
latitude,
|
latitude,
|
||||||
longitude,
|
longitude,
|
||||||
@@ -111,7 +112,7 @@ function GameInfo(props) {
|
|||||||
const startTime = dayjs(start_time);
|
const startTime = dayjs(start_time);
|
||||||
const endTime = dayjs(end_time);
|
const endTime = dayjs(end_time);
|
||||||
const game_length = Number(
|
const game_length = Number(
|
||||||
(endTime.diff(startTime, "minutes") / 60).toFixed()
|
(endTime.diff(startTime, "minutes") / 60).toFixed(),
|
||||||
);
|
);
|
||||||
|
|
||||||
const startMonth = startTime.format("M");
|
const startMonth = startTime.format("M");
|
||||||
@@ -244,7 +245,10 @@ function GameInfo(props) {
|
|||||||
<View className={styles.gameInfoContainer}>
|
<View className={styles.gameInfoContainer}>
|
||||||
{["refund", "progress", "expired"].includes(orderStatus) && (
|
{["refund", "progress", "expired"].includes(orderStatus) && (
|
||||||
<View className={styles.paidInfo}>
|
<View className={styles.paidInfo}>
|
||||||
{refundTextMap.get(refund_status)} ¥ {amount}
|
{refundTextMap.get(refund_status)} ¥{" "}
|
||||||
|
{[RefundStatus.PENDING, RefundStatus.SUCCESS].includes(refund_status)
|
||||||
|
? refund_amount
|
||||||
|
: amount}
|
||||||
</View>
|
</View>
|
||||||
)}
|
)}
|
||||||
{["progress", "expired"].includes(orderStatus) &&
|
{["progress", "expired"].includes(orderStatus) &&
|
||||||
@@ -344,7 +348,7 @@ function GameInfo(props) {
|
|||||||
handlePayNow: () => {},
|
handlePayNow: () => {},
|
||||||
handleViewGame,
|
handleViewGame,
|
||||||
},
|
},
|
||||||
"detail"
|
"detail",
|
||||||
)?.map((obj) => (
|
)?.map((obj) => (
|
||||||
<View className={classnames(styles.button, styles[obj.className])}>
|
<View className={classnames(styles.button, styles[obj.className])}>
|
||||||
<Text className={styles.buttonText}>{obj.text}</Text>
|
<Text className={styles.buttonText}>{obj.text}</Text>
|
||||||
@@ -504,7 +508,7 @@ function RefundPolicy(props) {
|
|||||||
const theTimeObj = dayjs(
|
const theTimeObj = dayjs(
|
||||||
isLast
|
isLast
|
||||||
? refund_policy.at(-2).deadline_formatted
|
? refund_policy.at(-2).deadline_formatted
|
||||||
: item.deadline_formatted
|
: item.deadline_formatted,
|
||||||
);
|
);
|
||||||
const year = theTimeObj.format("YYYY");
|
const year = theTimeObj.format("YYYY");
|
||||||
const month = theTimeObj.format("M");
|
const month = theTimeObj.format("M");
|
||||||
@@ -531,7 +535,7 @@ function RefundPolicy(props) {
|
|||||||
className={classnames(
|
className={classnames(
|
||||||
styles.policyItem,
|
styles.policyItem,
|
||||||
targetIndex > index && index !== 0 ? styles.pastItem : "",
|
targetIndex > index && index !== 0 ? styles.pastItem : "",
|
||||||
targetIndex === index ? styles.currentItem : ""
|
targetIndex === index ? styles.currentItem : "",
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<View className={styles.time}>
|
<View className={styles.time}>
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import orderService, {
|
|||||||
OrderStatus,
|
OrderStatus,
|
||||||
CancelType,
|
CancelType,
|
||||||
refundTextMap,
|
refundTextMap,
|
||||||
|
RefundStatus,
|
||||||
} from "@/services/orderService";
|
} from "@/services/orderService";
|
||||||
import { getStorage, removeStorage, setStorage } from "@/store/storage";
|
import { getStorage, removeStorage, setStorage } from "@/store/storage";
|
||||||
import { useGlobalStore } from "@/store/global";
|
import { useGlobalStore } from "@/store/global";
|
||||||
@@ -101,7 +102,7 @@ const OrderList = () => {
|
|||||||
newList.splice(
|
newList.splice(
|
||||||
index,
|
index,
|
||||||
clear ? newList.length - index : 1,
|
clear ? newList.length - index : 1,
|
||||||
addPageInfo(res.data.rows, page)
|
addPageInfo(res.data.rows, page),
|
||||||
);
|
);
|
||||||
return newList;
|
return newList;
|
||||||
});
|
});
|
||||||
@@ -264,13 +265,17 @@ const OrderList = () => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleQuit(item) {
|
async function handleQuit(item) {
|
||||||
if (refundRef.current) {
|
if (refundRef.current) {
|
||||||
refundRef.current.show(item, (result) => {
|
const res = await orderService.getRefundPolicy({ order_id: item.id });
|
||||||
if (result) {
|
refundRef.current.show(
|
||||||
getOrders(item.page);
|
{ ...item, refund_policy: res.data.refund_policy },
|
||||||
}
|
(result) => {
|
||||||
});
|
if (result) {
|
||||||
|
getOrders(item.page);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -316,7 +321,7 @@ const OrderList = () => {
|
|||||||
item.order_status === OrderStatus.PENDING &&
|
item.order_status === OrderStatus.PENDING &&
|
||||||
item.cancel_type === CancelType.NONE;
|
item.cancel_type === CancelType.NONE;
|
||||||
const canceled = [CancelType.USER, CancelType.TIMEOUT].includes(
|
const canceled = [CancelType.USER, CancelType.TIMEOUT].includes(
|
||||||
item.cancel_type
|
item.cancel_type,
|
||||||
);
|
);
|
||||||
const { game_info } = item;
|
const { game_info } = item;
|
||||||
|
|
||||||
@@ -349,7 +354,7 @@ const OrderList = () => {
|
|||||||
<View
|
<View
|
||||||
className={classnames(
|
className={classnames(
|
||||||
styles.payNum,
|
styles.payNum,
|
||||||
styles[unPay ? "pending" : "paid"]
|
styles[unPay ? "pending" : "paid"],
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<Text>
|
<Text>
|
||||||
@@ -358,7 +363,15 @@ const OrderList = () => {
|
|||||||
: refundTextMap.get(item.refund_status)}
|
: refundTextMap.get(item.refund_status)}
|
||||||
</Text>{" "}
|
</Text>{" "}
|
||||||
<View className={styles.amount}>
|
<View className={styles.amount}>
|
||||||
¥ <Text>{item.amount}</Text>
|
¥{" "}
|
||||||
|
<Text>
|
||||||
|
{[
|
||||||
|
RefundStatus.PENDING,
|
||||||
|
RefundStatus.SUCCESS,
|
||||||
|
].includes(item.refund_status)
|
||||||
|
? item.refund_amount
|
||||||
|
: item.amount}
|
||||||
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
)}
|
)}
|
||||||
@@ -370,7 +383,7 @@ const OrderList = () => {
|
|||||||
{insertDotInTags([location_name, court_type, "3.5km"]).map(
|
{insertDotInTags([location_name, court_type, "3.5km"]).map(
|
||||||
(text, index) => (
|
(text, index) => (
|
||||||
<Text key={index}>{text}</Text>
|
<Text key={index}>{text}</Text>
|
||||||
)
|
),
|
||||||
)}
|
)}
|
||||||
</View>
|
</View>
|
||||||
<View className={styles.gameOtherInfo}>
|
<View className={styles.gameOtherInfo}>
|
||||||
@@ -426,12 +439,12 @@ const OrderList = () => {
|
|||||||
handlePayNow,
|
handlePayNow,
|
||||||
handleViewGame,
|
handleViewGame,
|
||||||
},
|
},
|
||||||
"list"
|
"list",
|
||||||
)?.map((obj) => (
|
)?.map((obj) => (
|
||||||
<View
|
<View
|
||||||
className={classnames(
|
className={classnames(
|
||||||
styles.button,
|
styles.button,
|
||||||
styles[obj.className]
|
styles[obj.className],
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<Text className={styles.buttonText}>{obj.text}</Text>
|
<Text className={styles.buttonText}>{obj.text}</Text>
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ const CommentReply = () => {
|
|||||||
if (allCommentIds.length > 0) {
|
if (allCommentIds.length > 0) {
|
||||||
// 使用统一接口标记已读,传入所有评论ID
|
// 使用统一接口标记已读,传入所有评论ID
|
||||||
messageService.markAsRead('comment', allCommentIds).catch(e => {
|
messageService.markAsRead('comment', allCommentIds).catch(e => {
|
||||||
console.error("标记评论已读失败:", e);
|
console.warn("标记评论已读失败:", e);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -221,7 +221,7 @@ const CommentReply = () => {
|
|||||||
|
|
||||||
if (allCommentIds.length > 0) {
|
if (allCommentIds.length > 0) {
|
||||||
messageService.markAsRead('comment', allCommentIds).catch(e => {
|
messageService.markAsRead('comment', allCommentIds).catch(e => {
|
||||||
console.error("标记评论已读失败:", e);
|
console.warn("标记评论已读失败:", e);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ const EnableNotificationPage: React.FC = () => {
|
|||||||
setQrCodeUrl(res.data.ServiceAccountQRCode);
|
setQrCodeUrl(res.data.ServiceAccountQRCode);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('获取二维码失败:', error);
|
console.warn('获取二维码失败:', error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
fetchQRCode();
|
fetchQRCode();
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ const NewFollow = () => {
|
|||||||
if (allFanIds.length > 0) {
|
if (allFanIds.length > 0) {
|
||||||
// 使用统一接口标记已读,传入所有关注者ID
|
// 使用统一接口标记已读,传入所有关注者ID
|
||||||
messageService.markAsRead('follow', allFanIds).catch(e => {
|
messageService.markAsRead('follow', allFanIds).catch(e => {
|
||||||
console.error("标记关注已读失败:", e);
|
console.warn("标记关注已读失败:", e);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -168,7 +168,7 @@ const NewFollow = () => {
|
|||||||
|
|
||||||
if (allFanIds.length > 0) {
|
if (allFanIds.length > 0) {
|
||||||
messageService.markAsRead('follow', allFanIds).catch(e => {
|
messageService.markAsRead('follow', allFanIds).catch(e => {
|
||||||
console.error("标记关注已读失败:", e);
|
console.warn("标记关注已读失败:", e);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ function isOnCancelEmpty(onCancelFunc) {
|
|||||||
const normalized = funcString.replace(/\s/g, "");
|
const normalized = funcString.replace(/\s/g, "");
|
||||||
return emptyFunctionPatterns.includes(normalized);
|
return emptyFunctionPatterns.includes(normalized);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("检查 onCancel 函数时出错:", error);
|
console.warn("检查 onCancel 函数时出错:", error);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -531,7 +531,7 @@ function Result() {
|
|||||||
// setQrCodeUrl(tempFilePath);
|
// setQrCodeUrl(tempFilePath);
|
||||||
// }
|
// }
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("获取二维码失败:", error);
|
console.warn("获取二维码失败:", error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -645,7 +645,7 @@ function Result() {
|
|||||||
});
|
});
|
||||||
return imageUrl;
|
return imageUrl;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("生成图片失败:", error);
|
console.warn("生成图片失败:", error);
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ const AiImportPopup: React.FC<AiImportPopupProps> = ({
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('获取剪切板失败:', error)
|
console.warn('获取剪切板失败:', error)
|
||||||
Taro.showToast({
|
Taro.showToast({
|
||||||
title: '读取剪切板失败,请手动输入',
|
title: '读取剪切板失败,请手动输入',
|
||||||
icon: 'error',
|
icon: 'error',
|
||||||
@@ -163,7 +163,7 @@ const AiImportPopup: React.FC<AiImportPopupProps> = ({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('选择图片失败:', error)
|
console.warn('选择图片失败:', error)
|
||||||
if (!(typeof error === 'object' && error.errMsg && error.errMsg.includes('fail cancel'))) {
|
if (!(typeof error === 'object' && error.errMsg && error.errMsg.includes('fail cancel'))) {
|
||||||
setUploadFailCount(prev => prev + 1)
|
setUploadFailCount(prev => prev + 1)
|
||||||
Taro.showToast({
|
Taro.showToast({
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ const SelectStadium: React.FC<SelectStadiumProps> = ({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('获取场馆列表失败:', error)
|
console.warn('获取场馆列表失败:', error)
|
||||||
} finally {
|
} finally {
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
}
|
}
|
||||||
@@ -107,7 +107,7 @@ const SelectStadium: React.FC<SelectStadiumProps> = ({
|
|||||||
setShowDetail(true)
|
setShowDetail(true)
|
||||||
},
|
},
|
||||||
fail: (err: { errMsg: string }) => {
|
fail: (err: { errMsg: string }) => {
|
||||||
console.error('选择位置失败:', err)
|
console.warn('选择位置失败:', err)
|
||||||
const { errMsg } = err || {};
|
const { errMsg } = err || {};
|
||||||
if (!errMsg.includes('fail cancel')) {
|
if (!errMsg.includes('fail cancel')) {
|
||||||
Taro.showToast({
|
Taro.showToast({
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ const StadiumDetail = forwardRef<StadiumDetailRef, StadiumDetailProps>(({
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
fail: (err: { errMsg: string }) => {
|
fail: (err: { errMsg: string }) => {
|
||||||
console.error('选择位置失败:', err)
|
console.warn('选择位置失败:', err)
|
||||||
const { errMsg } = err || {};
|
const { errMsg } = err || {};
|
||||||
if (!errMsg.includes('fail cancel')) {
|
if (!errMsg.includes('fail cancel')) {
|
||||||
Taro.showToast({
|
Taro.showToast({
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import {
|
|||||||
} from "../../config/formSchema/publishBallFormSchema";
|
} from "../../config/formSchema/publishBallFormSchema";
|
||||||
import { PublishBallFormData } from "../../../types/publishBall";
|
import { PublishBallFormData } from "../../../types/publishBall";
|
||||||
import PublishService from "@/services/publishService";
|
import PublishService from "@/services/publishService";
|
||||||
import { getNextHourTime, getEndTime, delay } from "@/utils";
|
import { getNextHourTime, getEndTime, delay, getBackendErrorMsg } from "@/utils";
|
||||||
import { useGlobalState } from "@/store/global";
|
import { useGlobalState } from "@/store/global";
|
||||||
import GeneralNavbar from "@/components/GeneralNavbar";
|
import GeneralNavbar from "@/components/GeneralNavbar";
|
||||||
import images from "@/config/images";
|
import images from "@/config/images";
|
||||||
@@ -364,104 +364,27 @@ const PublishBall: React.FC = () => {
|
|||||||
};
|
};
|
||||||
// 提交表单
|
// 提交表单
|
||||||
const handleSubmit = async () => {
|
const handleSubmit = async () => {
|
||||||
// 基础验证
|
|
||||||
const params = getParams();
|
const params = getParams();
|
||||||
const { republish } = params || {};
|
const { republish } = params || {};
|
||||||
if (activityType === "individual") {
|
if (activityType === "individual") {
|
||||||
const isValid = validateFormData(formData[0]);
|
const isValid = validateFormData(formData[0]);
|
||||||
if (!isValid || publishLoading) {
|
if (!isValid || publishLoading) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
setPublishLoading(true);
|
setPublishLoading(true);
|
||||||
const {
|
try {
|
||||||
activityInfo,
|
|
||||||
descriptionInfo,
|
|
||||||
is_substitute_supported,
|
|
||||||
timeRange,
|
|
||||||
players,
|
|
||||||
skill_level,
|
|
||||||
image_list,
|
|
||||||
wechat,
|
|
||||||
id,
|
|
||||||
...rest
|
|
||||||
} = formData[0];
|
|
||||||
const { min, max, organizer_joined } = players;
|
|
||||||
const options = {
|
|
||||||
...rest,
|
|
||||||
...activityInfo,
|
|
||||||
...descriptionInfo,
|
|
||||||
...timeRange,
|
|
||||||
max_players: max,
|
|
||||||
min_players: min,
|
|
||||||
organizer_joined: organizer_joined === true ? 1 : 0,
|
|
||||||
skill_level_min: skill_level[0],
|
|
||||||
skill_level_max: skill_level[1],
|
|
||||||
image_list: image_list.map((item) => item.url),
|
|
||||||
is_wechat_contact: wechat.is_wechat_contact ? 1 : 0,
|
|
||||||
wechat_contact: wechat.wechat_contact || wechat.default_wechat_contact,
|
|
||||||
is_substitute_supported: is_substitute_supported ? "1" : "0",
|
|
||||||
...(republish === "0" ? { id } : {}),
|
|
||||||
};
|
|
||||||
const res =
|
|
||||||
republish === "0"
|
|
||||||
? await PublishService.gamesUpdate(options)
|
|
||||||
: await PublishService.createPersonal(options);
|
|
||||||
const successText = republish === "0" ? "更新成功" : "发布成功";
|
|
||||||
if (res.code === 0 && res.data) {
|
|
||||||
Taro.showToast({
|
|
||||||
title: successText,
|
|
||||||
icon: "success",
|
|
||||||
});
|
|
||||||
delay(1000);
|
|
||||||
// 如果是个人球局,则跳转到详情页,并自动分享
|
|
||||||
// 如果是畅打,则跳转第一个球局详情页,并自动分享 @刘杰
|
|
||||||
const id = (res as any).data?.id;
|
|
||||||
// 如果是编辑,就返回,否则就是新发布
|
|
||||||
if (republish === "0") {
|
|
||||||
Taro.navigateBack();
|
|
||||||
} else {
|
|
||||||
// 使用 redirectTo 替换当前页面,避免返回时回到发布页面
|
|
||||||
Taro.redirectTo({
|
|
||||||
// @ts-expect-error: id
|
|
||||||
url: `/game_pages/detail/index?id=${
|
|
||||||
id || 1
|
|
||||||
}&from=publish&autoShare=1`,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Taro.showToast({
|
|
||||||
title: res.message,
|
|
||||||
icon: "none",
|
|
||||||
});
|
|
||||||
setPublishLoading(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (activityType === "group") {
|
|
||||||
const isValid = formData.every((item) => validateFormData(item));
|
|
||||||
if (!isValid || publishLoading) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
setPublishLoading(true);
|
|
||||||
if (checkAdjacentDataSame(formData)) {
|
|
||||||
Taro.showToast({
|
|
||||||
title: "信息不可与前序场完全一致",
|
|
||||||
icon: "none",
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const options = formData.map((item) => {
|
|
||||||
const {
|
const {
|
||||||
activityInfo,
|
activityInfo,
|
||||||
descriptionInfo,
|
descriptionInfo,
|
||||||
|
is_substitute_supported,
|
||||||
timeRange,
|
timeRange,
|
||||||
players,
|
players,
|
||||||
skill_level,
|
skill_level,
|
||||||
is_substitute_supported,
|
image_list,
|
||||||
|
wechat,
|
||||||
id,
|
id,
|
||||||
...rest
|
...rest
|
||||||
} = item;
|
} = formData[0];
|
||||||
const { min, max, organizer_joined } = players;
|
const { min, max, organizer_joined } = players;
|
||||||
return {
|
const options = {
|
||||||
...rest,
|
...rest,
|
||||||
...activityInfo,
|
...activityInfo,
|
||||||
...descriptionInfo,
|
...descriptionInfo,
|
||||||
@@ -471,38 +394,108 @@ const PublishBall: React.FC = () => {
|
|||||||
organizer_joined: organizer_joined === true ? 1 : 0,
|
organizer_joined: organizer_joined === true ? 1 : 0,
|
||||||
skill_level_min: skill_level[0],
|
skill_level_min: skill_level[0],
|
||||||
skill_level_max: skill_level[1],
|
skill_level_max: skill_level[1],
|
||||||
|
image_list: image_list.map((item) => item.url),
|
||||||
|
is_wechat_contact: wechat.is_wechat_contact ? 1 : 0,
|
||||||
|
wechat_contact: wechat.wechat_contact || wechat.default_wechat_contact,
|
||||||
is_substitute_supported: is_substitute_supported ? "1" : "0",
|
is_substitute_supported: is_substitute_supported ? "1" : "0",
|
||||||
image_list: item.image_list.map((img) => img.url),
|
|
||||||
...(republish === "0" ? { id } : {}),
|
...(republish === "0" ? { id } : {}),
|
||||||
};
|
};
|
||||||
});
|
const res =
|
||||||
const successText = republish === "0" ? "更新成功" : "发布成功";
|
|
||||||
const res =
|
|
||||||
republish === "0"
|
|
||||||
? await PublishService.gamesUpdate(options[0])
|
|
||||||
: await PublishService.create_play_pmoothlys({ rows: options });
|
|
||||||
if (res.code === 0 && res.data) {
|
|
||||||
Taro.showToast({
|
|
||||||
title: successText,
|
|
||||||
icon: "success",
|
|
||||||
});
|
|
||||||
delay(1000);
|
|
||||||
// 如果是个人球局,则跳转到详情页,并自动分享
|
|
||||||
// 如果是畅打,则跳转第一个球局详情页,并自动分享 @刘杰
|
|
||||||
const id =
|
|
||||||
republish === "0"
|
republish === "0"
|
||||||
? (res as any).data?.id
|
? await PublishService.gamesUpdate(options)
|
||||||
: (res as any).data?.[0]?.id;
|
: await PublishService.createPersonal(options);
|
||||||
// 使用 redirectTo 替换当前页面,避免返回时回到发布页面
|
const successText = republish === "0" ? "更新成功" : "发布成功";
|
||||||
Taro.redirectTo({
|
if (res.code === 0 && res.data) {
|
||||||
// @ts-expect-error: id
|
Taro.showToast({ title: successText, icon: "success" });
|
||||||
url: `/game_pages/detail/index?id=${
|
delay(1000);
|
||||||
id || 1
|
const id = (res as any).data?.id;
|
||||||
}&from=publish&autoShare=1`,
|
if (republish === "0") {
|
||||||
});
|
Taro.navigateBack();
|
||||||
} else {
|
} else {
|
||||||
|
Taro.redirectTo({
|
||||||
|
url: `/game_pages/detail/index?id=${id || 1}&from=publish&autoShare=1`,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Taro.showToast({
|
||||||
|
title: getBackendErrorMsg(res, "发布失败"),
|
||||||
|
icon: "none",
|
||||||
|
});
|
||||||
|
setPublishLoading(false);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
Taro.showToast({
|
Taro.showToast({
|
||||||
title: res.message,
|
title: getBackendErrorMsg(error, "发布失败"),
|
||||||
|
icon: "none",
|
||||||
|
});
|
||||||
|
setPublishLoading(false);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (activityType === "group") {
|
||||||
|
const isValid = formData.every((item) => validateFormData(item));
|
||||||
|
if (!isValid || publishLoading) return;
|
||||||
|
if (checkAdjacentDataSame(formData)) {
|
||||||
|
Taro.showToast({
|
||||||
|
title: "信息不可与前序场完全一致",
|
||||||
|
icon: "none",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setPublishLoading(true);
|
||||||
|
try {
|
||||||
|
const options = formData.map((item) => {
|
||||||
|
const {
|
||||||
|
activityInfo,
|
||||||
|
descriptionInfo,
|
||||||
|
timeRange,
|
||||||
|
players,
|
||||||
|
skill_level,
|
||||||
|
is_substitute_supported,
|
||||||
|
id,
|
||||||
|
...rest
|
||||||
|
} = item;
|
||||||
|
const { min, max, organizer_joined } = players;
|
||||||
|
return {
|
||||||
|
...rest,
|
||||||
|
...activityInfo,
|
||||||
|
...descriptionInfo,
|
||||||
|
...timeRange,
|
||||||
|
max_players: max,
|
||||||
|
min_players: min,
|
||||||
|
organizer_joined: organizer_joined === true ? 1 : 0,
|
||||||
|
skill_level_min: skill_level[0],
|
||||||
|
skill_level_max: skill_level[1],
|
||||||
|
is_substitute_supported: is_substitute_supported ? "1" : "0",
|
||||||
|
image_list: item.image_list.map((img) => img.url),
|
||||||
|
...(republish === "0" ? { id } : {}),
|
||||||
|
};
|
||||||
|
});
|
||||||
|
const successText = republish === "0" ? "更新成功" : "发布成功";
|
||||||
|
const res =
|
||||||
|
republish === "0"
|
||||||
|
? await PublishService.gamesUpdate(options[0])
|
||||||
|
: await PublishService.create_play_pmoothlys({ rows: options });
|
||||||
|
if (res.code === 0 && res.data) {
|
||||||
|
Taro.showToast({ title: successText, icon: "success" });
|
||||||
|
delay(1000);
|
||||||
|
const id =
|
||||||
|
republish === "0"
|
||||||
|
? (res as any).data?.id
|
||||||
|
: (res as any).data?.[0]?.id;
|
||||||
|
Taro.redirectTo({
|
||||||
|
url: `/game_pages/detail/index?id=${id || 1}&from=publish&autoShare=1`,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
Taro.showToast({
|
||||||
|
title: getBackendErrorMsg(res, "发布失败"),
|
||||||
|
icon: "none",
|
||||||
|
});
|
||||||
|
setPublishLoading(false);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
Taro.showToast({
|
||||||
|
title: getBackendErrorMsg(error, "发布失败"),
|
||||||
icon: "none",
|
icon: "none",
|
||||||
});
|
});
|
||||||
setPublishLoading(false);
|
setPublishLoading(false);
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ export class FollowService {
|
|||||||
throw new Error(response.message || '获取互关列表失败');
|
throw new Error(response.message || '获取互关列表失败');
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('获取互关列表失败:', error);
|
console.warn('获取互关列表失败:', error);
|
||||||
return { list: [], total: 0 };
|
return { list: [], total: 0 };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -79,7 +79,7 @@ export class FollowService {
|
|||||||
throw new Error(response.message || '获取粉丝列表失败');
|
throw new Error(response.message || '获取粉丝列表失败');
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('获取粉丝列表失败:', error);
|
console.warn('获取粉丝列表失败:', error);
|
||||||
return { list: [], total: 0 };
|
return { list: [], total: 0 };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -107,7 +107,7 @@ export class FollowService {
|
|||||||
throw new Error(response.message || '获取新增粉丝列表失败');
|
throw new Error(response.message || '获取新增粉丝列表失败');
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('获取新增粉丝列表失败:', error);
|
console.warn('获取新增粉丝列表失败:', error);
|
||||||
return { list: [], total: 0 };
|
return { list: [], total: 0 };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -135,7 +135,7 @@ export class FollowService {
|
|||||||
throw new Error(response.message || '获取关注列表失败');
|
throw new Error(response.message || '获取关注列表失败');
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('获取关注列表失败:', error);
|
console.warn('获取关注列表失败:', error);
|
||||||
return { list: [], total: 0 };
|
return { list: [], total: 0 };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -178,7 +178,7 @@ export class FollowService {
|
|||||||
throw new Error(response.message || '关注失败');
|
throw new Error(response.message || '关注失败');
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('关注失败:', error);
|
console.warn('关注失败:', error);
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -201,7 +201,7 @@ export class FollowService {
|
|||||||
throw new Error(response.message || '取消关注失败');
|
throw new Error(response.message || '取消关注失败');
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('取消关注失败:', error);
|
console.warn('取消关注失败:', error);
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -231,7 +231,7 @@ export class FollowService {
|
|||||||
throw new Error(response.message || '获取推荐用户失败');
|
throw new Error(response.message || '获取推荐用户失败');
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('获取推荐用户失败:', error);
|
console.warn('获取推荐用户失败:', error);
|
||||||
return { list: [], total: 0 };
|
return { list: [], total: 0 };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -251,7 +251,7 @@ export class FollowService {
|
|||||||
return 'none';
|
return 'none';
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('检查关注状态失败:', error);
|
console.warn('检查关注状态失败:', error);
|
||||||
return 'none';
|
return 'none';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -269,7 +269,7 @@ export class FollowService {
|
|||||||
throw new Error(response.message || '屏蔽推荐用户失败');
|
throw new Error(response.message || '屏蔽推荐用户失败');
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('屏蔽推荐用户失败:', error);
|
console.warn('屏蔽推荐用户失败:', error);
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ export const getGamesList = async (params?: Record<string, any>) => {
|
|||||||
// const fetchApi = isIntegrate ? '/games/integrate_list' : '/games/list'
|
// const fetchApi = isIntegrate ? '/games/integrate_list' : '/games/list'
|
||||||
return httpService.post('/games/list', params, { showLoading: false })
|
return httpService.post('/games/list', params, { showLoading: false })
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("列表数据获取失败:", error);
|
console.warn("列表数据获取失败:", error);
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -41,7 +41,7 @@ export const getGamesIntegrateList = async (params?: Record<string, any>) => {
|
|||||||
try {
|
try {
|
||||||
return httpService.post('/games/integrate_list', params, { showLoading: false })
|
return httpService.post('/games/integrate_list', params, { showLoading: false })
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("列表数据获取失败:", error);
|
console.warn("列表数据获取失败:", error);
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -55,7 +55,7 @@ export const getGamesCount = async (params?: Record<string, any>) => {
|
|||||||
try {
|
try {
|
||||||
return httpService.post('/games/count', params, { showLoading: false })
|
return httpService.post('/games/count', params, { showLoading: false })
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("列表数量获取失败:", error);
|
console.warn("列表数量获取失败:", error);
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -71,7 +71,7 @@ export const getSearchHistory = async (params) => {
|
|||||||
return httpService.post('/games/search_history', params, { showLoading: false })
|
return httpService.post('/games/search_history', params, { showLoading: false })
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// 捕获并打印错误信息
|
// 捕获并打印错误信息
|
||||||
console.error("历史记录获取失败:", error);
|
console.warn("历史记录获取失败:", error);
|
||||||
// 抛出错误以便上层处理
|
// 抛出错误以便上层处理
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
@@ -87,7 +87,7 @@ export const clearHistory = async (params) => {
|
|||||||
return httpService.post('/games/search_history/delete_all', params, { showLoading: false })
|
return httpService.post('/games/search_history/delete_all', params, { showLoading: false })
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// 捕获并打印错误信息
|
// 捕获并打印错误信息
|
||||||
console.error("清除历史记录失败:", error);
|
console.warn("清除历史记录失败:", error);
|
||||||
// 抛出错误以便上层处理
|
// 抛出错误以便上层处理
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
@@ -104,7 +104,7 @@ export const searchSuggestion = async (params) => {
|
|||||||
return httpService.post('/games/search_recommendations', params)
|
return httpService.post('/games/search_recommendations', params)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// 捕获并打印错误信息
|
// 捕获并打印错误信息
|
||||||
console.error("搜索建议获取失败:", error);
|
console.warn("搜索建议获取失败:", error);
|
||||||
// 抛出错误以便上层处理
|
// 抛出错误以便上层处理
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
@@ -116,7 +116,7 @@ export const getCities = async () => {
|
|||||||
return httpService.post('/cities/tree', {})
|
return httpService.post('/cities/tree', {})
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// 捕获并打印错误信息
|
// 捕获并打印错误信息
|
||||||
console.error("城市列表获取失败:", error);
|
console.warn("城市列表获取失败:", error);
|
||||||
// 抛出错误以便上层处理
|
// 抛出错误以便上层处理
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
@@ -127,7 +127,7 @@ export const getCityQrCode = async () => {
|
|||||||
return httpService.post('/hot_city_qr/list', {})
|
return httpService.post('/hot_city_qr/list', {})
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// 捕获并打印错误信息
|
// 捕获并打印错误信息
|
||||||
console.error("城市二维码获取失败:", error);
|
console.warn("城市二维码获取失败:", error);
|
||||||
// 抛出错误以便上层处理
|
// 抛出错误以便上层处理
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
@@ -140,7 +140,7 @@ export const getDistricts = async (params: { province: string; city: string }) =
|
|||||||
return httpService.post('/cities/cities', params)
|
return httpService.post('/cities/cities', params)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// 捕获并打印错误信息
|
// 捕获并打印错误信息
|
||||||
console.error("行政区列表获取失败:", error);
|
console.warn("行政区列表获取失败:", error);
|
||||||
// 抛出错误以便上层处理
|
// 抛出错误以便上层处理
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ export const wechat_auth_login = async (
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("微信授权登录失败:", error);
|
console.warn("微信授权登录失败:", error);
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
message: "微信授权失败,请重试",
|
message: "微信授权失败,请重试",
|
||||||
@@ -160,7 +160,7 @@ export const phone_auth_login = async (
|
|||||||
await useUser.getState().fetchUserInfo();
|
await useUser.getState().fetchUserInfo();
|
||||||
await useUser.getState().checkNicknameChangeStatus();
|
await useUser.getState().checkNicknameChangeStatus();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("更新用户信息到 store 失败:", error);
|
console.warn("更新用户信息到 store 失败:", error);
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -178,7 +178,7 @@ export const phone_auth_login = async (
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("手机号登录失败:", error);
|
console.warn("手机号登录失败:", error);
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
message: error.message,
|
message: error.message,
|
||||||
@@ -206,7 +206,7 @@ export const send_sms_code = async (phone: string): Promise<SmsResponse> => {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("发送短信失败:", error);
|
console.warn("发送短信失败:", error);
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
message: error.message,
|
message: error.message,
|
||||||
@@ -232,7 +232,7 @@ export const verify_sms_code = async (
|
|||||||
user_info: response.data?.userInfo,
|
user_info: response.data?.userInfo,
|
||||||
};
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("验证验证码失败:", error);
|
console.warn("验证验证码失败:", error);
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
message: error.message,
|
message: error.message,
|
||||||
@@ -255,7 +255,7 @@ export const save_login_state = (token: string, user_info: WechatUserInfo) => {
|
|||||||
Taro.setStorageSync("is_logged_in", true);
|
Taro.setStorageSync("is_logged_in", true);
|
||||||
Taro.setStorageSync("login_time", Date.now());
|
Taro.setStorageSync("login_time", Date.now());
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("保存登录状态失败:", error);
|
console.warn("保存登录状态失败:", error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -270,7 +270,7 @@ export const clear_login_state = () => {
|
|||||||
Taro.removeStorageSync("is_logged_in");
|
Taro.removeStorageSync("is_logged_in");
|
||||||
Taro.removeStorageSync("login_time");
|
Taro.removeStorageSync("login_time");
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("清除登录状态失败:", error);
|
console.warn("清除登录状态失败:", error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -374,7 +374,7 @@ export const refresh_login_status = async (): Promise<boolean> => {
|
|||||||
// 检查本地存储的登录状态
|
// 检查本地存储的登录状态
|
||||||
return check_login_status();
|
return check_login_status();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("刷新登录状态失败:", error);
|
console.warn("刷新登录状态失败:", error);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -385,7 +385,7 @@ export const updateUserPhone = async (payload: ChangePhoneParams) => {
|
|||||||
const response = await httpService.post("/user/update_phone", payload);
|
const response = await httpService.post("/user/update_phone", payload);
|
||||||
return response;
|
return response;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("更新用户手机号失败:", error);
|
console.warn("更新用户手机号失败:", error);
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -402,7 +402,7 @@ export const getUserInfoById = async (id) => {
|
|||||||
);
|
);
|
||||||
return response;
|
return response;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("获取用户信息失败:", error);
|
console.warn("获取用户信息失败:", error);
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -415,7 +415,7 @@ export const followUser = async (following_id) => {
|
|||||||
});
|
});
|
||||||
return response;
|
return response;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("关注失败:", error);
|
console.warn("关注失败:", error);
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -428,7 +428,7 @@ export const unFollowUser = async (following_id) => {
|
|||||||
});
|
});
|
||||||
return response;
|
return response;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("取消关注失败:", error);
|
console.warn("取消关注失败:", error);
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -464,7 +464,7 @@ export const silentLogin = async (): Promise<LoginResponse> => {
|
|||||||
console.log("微信登录结果:", login_result);
|
console.log("微信登录结果:", login_result);
|
||||||
|
|
||||||
if (!login_result.code) {
|
if (!login_result.code) {
|
||||||
console.error("微信登录失败:未获取到code");
|
console.warn("微信登录失败:未获取到code");
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
message: "微信登录失败",
|
message: "微信登录失败",
|
||||||
@@ -506,14 +506,14 @@ export const silentLogin = async (): Promise<LoginResponse> => {
|
|||||||
user_info,
|
user_info,
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
console.error("静默登录失败:", auth_response.message);
|
console.warn("静默登录失败:", auth_response.message);
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
message: auth_response.message || "静默登录失败",
|
message: auth_response.message || "静默登录失败",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("静默登录异常:", error);
|
console.warn("静默登录异常:", error);
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
message: "静默登录失败,请重试",
|
message: "静默登录失败,请重试",
|
||||||
|
|||||||
@@ -188,6 +188,21 @@ class OrderService {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取退款政策
|
||||||
|
async getRefundPolicy({
|
||||||
|
order_id,
|
||||||
|
}: {
|
||||||
|
order_id: number;
|
||||||
|
}): Promise<ApiResponse<any>> {
|
||||||
|
return httpService.post(
|
||||||
|
"/payment/order_refund_policy",
|
||||||
|
{ order_id },
|
||||||
|
{
|
||||||
|
showLoading: true,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 导出认证服务实例
|
// 导出认证服务实例
|
||||||
|
|||||||
@@ -39,19 +39,28 @@ export interface uploadFileResponseData {
|
|||||||
updated_at: string,
|
updated_at: string,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 从上传错误中取出可展示的文案
|
||||||
|
function get_upload_error_msg(error: any): string {
|
||||||
|
if (!error) return "上传失败";
|
||||||
|
const msg =
|
||||||
|
error?.message ||
|
||||||
|
(typeof error?.error === "string" ? error.error : error?.error?.message) ||
|
||||||
|
(error?.data?.message ?? error?.data?.msg) ||
|
||||||
|
"";
|
||||||
|
return (msg && String(msg).trim()) || "上传失败";
|
||||||
|
}
|
||||||
|
|
||||||
// 发布球局类
|
// 发布球局类
|
||||||
class UploadApi {
|
class UploadApi {
|
||||||
async upload(req: UploadFilesData): Promise<{ id: string, data: uploadFileResponseData }> {
|
async upload(req: UploadFilesData): Promise<{ id: string, data: uploadFileResponseData }> {
|
||||||
|
const fullUrl = `${envConfig.apiBaseURL}/api/gallery/upload`;
|
||||||
let fullUrl = `${envConfig.apiBaseURL}/api/gallery/upload`
|
const authHeader = tokenManager.getAuthHeader();
|
||||||
|
const { id, ...rest } = req;
|
||||||
const authHeader = tokenManager.getAuthHeader()
|
|
||||||
const { id, ...rest } = req
|
|
||||||
try {
|
try {
|
||||||
const res = await Taro.uploadFile({
|
const res = await Taro.uploadFile({
|
||||||
url: fullUrl,
|
url: fullUrl,
|
||||||
filePath: rest.filePath,
|
filePath: rest.filePath,
|
||||||
name: 'file',
|
name: "file",
|
||||||
formData: {
|
formData: {
|
||||||
description: rest.description,
|
description: rest.description,
|
||||||
tags: rest.tags,
|
tags: rest.tags,
|
||||||
@@ -59,12 +68,17 @@ class UploadApi {
|
|||||||
},
|
},
|
||||||
header: authHeader,
|
header: authHeader,
|
||||||
});
|
});
|
||||||
return {
|
const parsed = JSON.parse(res.data);
|
||||||
id,
|
if (parsed.code !== 0) {
|
||||||
data: JSON.parse(res.data).data,
|
const msg = get_upload_error_msg(parsed);
|
||||||
|
Taro.showToast({ title: msg, icon: "none" });
|
||||||
|
throw new Error(msg);
|
||||||
}
|
}
|
||||||
|
return { id, data: parsed.data };
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw { id, error }
|
const msg = get_upload_error_msg(error);
|
||||||
|
Taro.showToast({ title: msg, icon: "none" });
|
||||||
|
throw { id, error };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,7 +117,7 @@ class UploadApi {
|
|||||||
throw new Error(result.message || '上传失败');
|
throw new Error(result.message || '上传失败');
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('上传图片失败:', error);
|
console.warn('上传图片失败:', error);
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -351,7 +351,7 @@ export class UserService {
|
|||||||
throw new Error(response.message || "获取用户信息失败");
|
throw new Error(response.message || "获取用户信息失败");
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("获取用户信息失败:", error);
|
console.warn("获取用户信息失败:", error);
|
||||||
// 返回默认用户信息
|
// 返回默认用户信息
|
||||||
return {} as UserInfo;
|
return {} as UserInfo;
|
||||||
}
|
}
|
||||||
@@ -392,7 +392,7 @@ export class UserService {
|
|||||||
throw new Error(response.message || "更新用户信息失败");
|
throw new Error(response.message || "更新用户信息失败");
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("更新用户信息失败:", error);
|
console.warn("更新用户信息失败:", error);
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -417,7 +417,7 @@ export class UserService {
|
|||||||
throw new Error(response.message || "获取主办球局失败");
|
throw new Error(response.message || "获取主办球局失败");
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("获取主办球局失败:", error);
|
console.warn("获取主办球局失败:", error);
|
||||||
// 返回符合ListContainer data格式的模拟数据
|
// 返回符合ListContainer data格式的模拟数据
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
@@ -443,7 +443,7 @@ export class UserService {
|
|||||||
throw new Error(response.message || "获取参与球局失败");
|
throw new Error(response.message || "获取参与球局失败");
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("获取参与球局失败:", error);
|
console.warn("获取参与球局失败:", error);
|
||||||
// 返回符合ListContainer data格式的模拟数据
|
// 返回符合ListContainer data格式的模拟数据
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
@@ -485,7 +485,7 @@ export class UserService {
|
|||||||
throw new Error(response.message || "操作失败");
|
throw new Error(response.message || "操作失败");
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("关注操作失败:", error);
|
console.warn("关注操作失败:", error);
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -543,7 +543,7 @@ export class UserService {
|
|||||||
throw new Error(response.message || "更新用户信息失败");
|
throw new Error(response.message || "更新用户信息失败");
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("保存用户信息失败:", error);
|
console.warn("保存用户信息失败:", error);
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -573,26 +573,16 @@ export class UserService {
|
|||||||
throw new Error(response.message || "获取用户动态失败");
|
throw new Error(response.message || "获取用户动态失败");
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("获取用户动态失败:", error);
|
console.warn("获取用户动态失败:", error);
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 上传头像
|
// 上传头像:仅在上传成功且 save 成功时返回 ossPath;失败则抛出,由调用方处理,避免误调 user/update
|
||||||
static async upload_avatar(file_path: string): Promise<string> {
|
static async upload_avatar(file_path: string): Promise<string> {
|
||||||
try {
|
const result = await uploadFiles.upload_oss_img(file_path);
|
||||||
// 先上传文件到服务器
|
await this.save_user_info({ avatar: result.ossPath });
|
||||||
const result = await uploadFiles.upload_oss_img(file_path);
|
return result.ossPath;
|
||||||
|
|
||||||
await this.save_user_info({ avatar: result.ossPath });
|
|
||||||
|
|
||||||
// 使用新的响应格式中的file_url字段
|
|
||||||
return result.ossPath;
|
|
||||||
} catch (error) {
|
|
||||||
console.error("头像上传失败:", error);
|
|
||||||
// 如果上传失败,返回默认头像
|
|
||||||
return require("../static/userInfo/default_avatar.svg");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 解析用户手机号
|
// 解析用户手机号
|
||||||
@@ -612,7 +602,7 @@ export class UserService {
|
|||||||
throw new Error(response.message || "获取手机号失败");
|
throw new Error(response.message || "获取手机号失败");
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("获取手机号失败:", error);
|
console.warn("获取手机号失败:", error);
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -628,7 +618,7 @@ export class UserService {
|
|||||||
throw new Error(message || "获取职业树失败");
|
throw new Error(message || "获取职业树失败");
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("获取职业树失败:", error);
|
console.warn("获取职业树失败:", error);
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -644,7 +634,7 @@ export class UserService {
|
|||||||
throw new Error(message || "获取城市树失败");
|
throw new Error(message || "获取城市树失败");
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("获取职业树失败:", error);
|
console.warn("获取职业树失败:", error);
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -665,7 +655,7 @@ export class UserService {
|
|||||||
throw new Error(message || "注销账户失败");
|
throw new Error(message || "注销账户失败");
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("注销账户失败:", error);
|
console.warn("注销账户失败:", error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -680,7 +670,7 @@ export const fetchUserProfile = async (): Promise<
|
|||||||
const response = await httpService.post("user/detail");
|
const response = await httpService.post("user/detail");
|
||||||
return response;
|
return response;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("获取用户信息失败:", error);
|
console.warn("获取用户信息失败:", error);
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -695,7 +685,7 @@ export const checkNicknameChangeStatus = async (): Promise<
|
|||||||
);
|
);
|
||||||
return response;
|
return response;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("获取昵称修改状态失败:", error);
|
console.warn("获取昵称修改状态失败:", error);
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -707,7 +697,7 @@ export const updateNickname = async (nickname: string) => {
|
|||||||
});
|
});
|
||||||
return response;
|
return response;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("昵称修改失败:", error);
|
console.warn("昵称修改失败:", error);
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -718,7 +708,7 @@ export const updateUserProfile = async (payload: Partial<UserInfoType>) => {
|
|||||||
const response = await httpService.post("/user/update", payload);
|
const response = await httpService.post("/user/update", payload);
|
||||||
return response;
|
return response;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("更新用户信息失败:", error);
|
console.warn("更新用户信息失败:", error);
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -737,7 +727,7 @@ export const updateUserLocation = async (
|
|||||||
});
|
});
|
||||||
return response;
|
return response;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("更新用户坐标位置失败:", error);
|
console.warn("更新用户坐标位置失败:", error);
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -774,13 +764,13 @@ export const handleCustomerService = async (): Promise<void> => {
|
|||||||
console.log("打开客服成功:", res);
|
console.log("打开客服成功:", res);
|
||||||
},
|
},
|
||||||
fail: (error) => {
|
fail: (error) => {
|
||||||
console.error("打开客服失败:", error);
|
console.warn("打开客服失败:", error);
|
||||||
// 如果官方客服不可用,显示备用联系方式
|
// 如果官方客服不可用,显示备用联系方式
|
||||||
showCustomerServiceFallback(customerService);
|
showCustomerServiceFallback(customerService);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("客服功能异常:", error);
|
console.warn("客服功能异常:", error);
|
||||||
// 备用方案:显示联系信息
|
// 备用方案:显示联系信息
|
||||||
showCustomerServiceFallback();
|
showCustomerServiceFallback();
|
||||||
}
|
}
|
||||||
@@ -810,7 +800,7 @@ const showCustomerServiceFallback = (customerInfo?: any) => {
|
|||||||
phoneNumber: customerInfo.phoneNumber,
|
phoneNumber: customerInfo.phoneNumber,
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("拨打电话失败:", error);
|
console.warn("拨打电话失败:", error);
|
||||||
Taro.showToast({
|
Taro.showToast({
|
||||||
title: "拨打电话失败",
|
title: "拨打电话失败",
|
||||||
icon: "none",
|
icon: "none",
|
||||||
@@ -827,7 +817,7 @@ const showCustomerServiceFallback = (customerInfo?: any) => {
|
|||||||
icon: "success",
|
icon: "success",
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("复制邮箱失败:", error);
|
console.warn("复制邮箱失败:", error);
|
||||||
Taro.showToast({
|
Taro.showToast({
|
||||||
title: "复制失败",
|
title: "复制失败",
|
||||||
icon: "none",
|
icon: "none",
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ export class WalletService {
|
|||||||
throw new Error(response.message || "获取钱包信息失败");
|
throw new Error(response.message || "获取钱包信息失败");
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("获取钱包信息失败:", error);
|
console.warn("获取钱包信息失败:", error);
|
||||||
// 返回模拟数据
|
// 返回模拟数据
|
||||||
return {
|
return {
|
||||||
balance: 1588.80,
|
balance: 1588.80,
|
||||||
@@ -62,7 +62,7 @@ export class WalletService {
|
|||||||
throw new Error(response.message || "获取交易记录失败");
|
throw new Error(response.message || "获取交易记录失败");
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("获取交易记录失败:", error);
|
console.warn("获取交易记录失败:", error);
|
||||||
// 返回模拟数据
|
// 返回模拟数据
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
@@ -107,7 +107,7 @@ export class WalletService {
|
|||||||
throw new Error(response.message || "提现申请提交失败");
|
throw new Error(response.message || "提现申请提交失败");
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("提现申请提交失败:", error);
|
console.warn("提现申请提交失败:", error);
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ function MyComponent() {
|
|||||||
|
|
||||||
console.log('请求成功!')
|
console.log('请求成功!')
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('请求失败:', error)
|
console.warn('请求失败:', error)
|
||||||
} finally {
|
} finally {
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,17 +35,22 @@ export const useDictionaryStore = create<DictionaryState>()((set, get) => ({
|
|||||||
set({ isLoading: true, error: null })
|
set({ isLoading: true, error: null })
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const keys = 'publishing_requirements,court_type,court_surface,supplementary_information,game_play,fabu_tip,supported_cities,bannerListImage,bannerDetailImage,bannerListIndex';
|
const keys = 'publishing_requirements,court_type,court_surface,supplementary_information,game_play,fabu_tip,supported_cities,show_home_qrcode,bannerListImage,bannerDetailImage,bannerListIndex';
|
||||||
const response = await commonApi.getDictionaryManyKey(keys)
|
const response = await commonApi.getDictionaryManyKey(keys)
|
||||||
|
|
||||||
if (response.code === 0 && response.data) {
|
if (response.code === 0 && response.data) {
|
||||||
const dictionaryData = {};
|
const dictionaryData: DictionaryData = {};
|
||||||
keys.split(',').forEach(key => {
|
keys.split(',').forEach(key => {
|
||||||
const list = response.data[key];
|
const raw = response.data[key];
|
||||||
|
// 单值配置:首页是否展示二维码(1/0 或 true/false)
|
||||||
|
if (key === 'show_home_qrcode') {
|
||||||
|
dictionaryData[key] = raw === '1' || raw === 1 || raw === true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
// supported_cities 格式如 "上海市||北京市",用 || 分割
|
// supported_cities 格式如 "上海市||北京市",用 || 分割
|
||||||
const listData = key === 'supported_cities'
|
const listData = key === 'supported_cities'
|
||||||
? (list ? String(list).split('||').map((s) => s.trim()).filter(Boolean) : [])
|
? (raw ? String(raw).split('||').map((s) => s.trim()).filter(Boolean) : [])
|
||||||
: (list ? list.split('|') : []);
|
: (raw ? String(raw).split('|') : []);
|
||||||
dictionaryData[key] = listData;
|
dictionaryData[key] = listData;
|
||||||
})
|
})
|
||||||
set({
|
set({
|
||||||
@@ -71,7 +76,7 @@ export const useDictionaryStore = create<DictionaryState>()((set, get) => ({
|
|||||||
error: errorMessage,
|
error: errorMessage,
|
||||||
isLoading: false
|
isLoading: false
|
||||||
})
|
})
|
||||||
console.error('获取字典数据失败:', error)
|
console.warn('获取字典数据失败:', error)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ export const useKeyboardStore = create<KeyboardStore>((set, get) => ({
|
|||||||
try {
|
try {
|
||||||
listener(height, true)
|
listener(height, true)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('键盘监听器执行错误:', error)
|
console.warn('键盘监听器执行错误:', error)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -92,7 +92,7 @@ export const useKeyboardStore = create<KeyboardStore>((set, get) => ({
|
|||||||
try {
|
try {
|
||||||
listener(0, false)
|
listener(0, false)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('键盘监听器执行错误:', error)
|
console.warn('键盘监听器执行错误:', error)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -410,7 +410,7 @@ export const useListStore = create<TennisStore>()((set, get) => ({
|
|||||||
|
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("更新列表数据失败:", error);
|
console.warn("更新列表数据失败:", error);
|
||||||
return Promise.reject(error);
|
return Promise.reject(error);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -724,7 +724,7 @@ export const useListStore = create<TennisStore>()((set, get) => ({
|
|||||||
}
|
}
|
||||||
return [];
|
return [];
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("获取行政区列表失败:", error);
|
console.warn("获取行政区列表失败:", error);
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ export const useMessageStore = create<MessageStore>()((set, get) => ({
|
|||||||
set({ loading: false });
|
set({ loading: false });
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error("获取红点信息失败:", e);
|
console.warn("获取红点信息失败:", e);
|
||||||
set({ loading: false });
|
set({ loading: false });
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ export const setStorage = (key: string, data: any) => {
|
|||||||
try {
|
try {
|
||||||
Taro.setStorageSync(key, JSON.stringify(data))
|
Taro.setStorageSync(key, JSON.stringify(data))
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('保存数据失败:', error)
|
console.warn('保存数据失败:', error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -17,7 +17,7 @@ export const getStorage = <T>(key: string): T | null => {
|
|||||||
}
|
}
|
||||||
return null
|
return null
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('读取数据失败:', error)
|
console.warn('读取数据失败:', error)
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -26,7 +26,7 @@ export const removeStorage = (key: string) => {
|
|||||||
try {
|
try {
|
||||||
Taro.removeStorageSync(key)
|
Taro.removeStorageSync(key)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('清除数据失败:', error)
|
console.warn('清除数据失败:', error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -34,6 +34,6 @@ export const clearAllStorage = () => {
|
|||||||
try {
|
try {
|
||||||
Taro.clearStorageSync()
|
Taro.clearStorageSync()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('清除所有数据失败:', error)
|
console.warn('清除所有数据失败:', error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -12,6 +12,7 @@ import evaluateService, {
|
|||||||
LastTimeTestResult,
|
LastTimeTestResult,
|
||||||
} from "@/services/evaluateService";
|
} from "@/services/evaluateService";
|
||||||
import { useListStore } from "./listStore";
|
import { useListStore } from "./listStore";
|
||||||
|
import { getBackendErrorMsg } from "@/utils/helper";
|
||||||
|
|
||||||
export interface UserState {
|
export interface UserState {
|
||||||
user: UserInfoType | {};
|
user: UserInfoType | {};
|
||||||
@@ -77,7 +78,7 @@ export const useUser = create<UserState>()((set) => ({
|
|||||||
|
|
||||||
return userData;
|
return userData;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("获取用户信息失败:", error);
|
console.warn("获取用户信息失败:", error);
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -87,7 +88,7 @@ export const useUser = create<UserState>()((set) => ({
|
|||||||
try {
|
try {
|
||||||
(Taro as any).setStorageSync?.(CITY_CACHE_KEY, newArea);
|
(Taro as any).setStorageSync?.(CITY_CACHE_KEY, newArea);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("保存城市缓存失败:", error);
|
console.warn("保存城市缓存失败:", error);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -122,7 +123,11 @@ export const useUser = create<UserState>()((set) => ({
|
|||||||
// 只有在更新头像等需要服务器返回新URL的字段时才需要重新获取
|
// 只有在更新头像等需要服务器返回新URL的字段时才需要重新获取
|
||||||
// 如果需要确保数据一致性,可以在特定场景下手动调用 fetchUserInfo
|
// 如果需要确保数据一致性,可以在特定场景下手动调用 fetchUserInfo
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("更新用户信息失败:", error);
|
console.warn("更新用户信息失败:", error);
|
||||||
|
Taro.showToast({
|
||||||
|
title: getBackendErrorMsg(error, "保存失败"),
|
||||||
|
icon: "none",
|
||||||
|
});
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -153,7 +158,7 @@ export const useUser = create<UserState>()((set) => ({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("检查昵称变更状态失败:", error);
|
console.warn("检查昵称变更状态失败:", error);
|
||||||
} finally {
|
} finally {
|
||||||
isCheckingNicknameStatus = false;
|
isCheckingNicknameStatus = false;
|
||||||
}
|
}
|
||||||
@@ -167,7 +172,7 @@ export const useUser = create<UserState>()((set) => ({
|
|||||||
user: { ...state.user, nickname },
|
user: { ...state.user, nickname },
|
||||||
}));
|
}));
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("更新用户昵称失败:", error);
|
console.warn("更新用户昵称失败:", error);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// NTRP 测试结果缓存
|
// NTRP 测试结果缓存
|
||||||
@@ -201,7 +206,7 @@ export const useUser = create<UserState>()((set) => ({
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("获取NTRP测试结果失败:", error);
|
console.warn("获取NTRP测试结果失败:", error);
|
||||||
return null;
|
return null;
|
||||||
} finally {
|
} finally {
|
||||||
isFetchingLastTestResult = false;
|
isFetchingLastTestResult = false;
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ const TestPage: React.FC = () => {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
fail(err) {
|
fail(err) {
|
||||||
console.error('订阅失败:', err);
|
console.warn('订阅失败:', err);
|
||||||
Taro.showToast({
|
Taro.showToast({
|
||||||
title: '订阅失败',
|
title: '订阅失败',
|
||||||
icon: 'error',
|
icon: 'error',
|
||||||
|
|||||||
@@ -206,11 +206,11 @@ const DownloadBill: React.FC = () => {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
fail: function (err) {
|
fail: function (err) {
|
||||||
console.error("文件下载失败:", err);
|
console.warn("文件下载失败:", err);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.warn(error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const handleDownloadBill = async () => {
|
const handleDownloadBill = async () => {
|
||||||
@@ -240,11 +240,11 @@ const DownloadBill: React.FC = () => {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
fail: function (err) {
|
fail: function (err) {
|
||||||
console.error("文件下载失败:", err);
|
console.warn("文件下载失败:", err);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.warn(error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -82,15 +82,15 @@ const DownloadBillRecords: React.FC = () => {
|
|||||||
console.log('打开文档成功');
|
console.log('打开文档成功');
|
||||||
},
|
},
|
||||||
fail: (err) => {
|
fail: (err) => {
|
||||||
console.error('打开文档失败', err);
|
console.warn('打开文档失败', err);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
console.error('下载失败,状态码:', res.statusCode);
|
console.warn('下载失败,状态码:', res.statusCode);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
fail: (err) => {
|
fail: (err) => {
|
||||||
console.error('下载失败', err);
|
console.warn('下载失败', err);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import {
|
|||||||
} from "@/store/pickerOptionsStore";
|
} from "@/store/pickerOptionsStore";
|
||||||
import { handleCustomerService } from "@/services/userService";
|
import { handleCustomerService } from "@/services/userService";
|
||||||
import evaluateService from "@/services/evaluateService";
|
import evaluateService from "@/services/evaluateService";
|
||||||
|
import { getBackendErrorMsg } from "@/utils/helper";
|
||||||
|
|
||||||
const EditProfilePage: React.FC = () => {
|
const EditProfilePage: React.FC = () => {
|
||||||
const { updateUserInfo, updateNickname } = useUserActions();
|
const { updateUserInfo, updateNickname } = useUserActions();
|
||||||
@@ -142,7 +143,7 @@ const EditProfilePage: React.FC = () => {
|
|||||||
// city: user_data.city || "",
|
// city: user_data.city || "",
|
||||||
// });
|
// });
|
||||||
// } catch (error) {
|
// } catch (error) {
|
||||||
// console.error("加载用户信息失败:", error);
|
// console.warn("加载用户信息失败:", error);
|
||||||
// Taro.showToast({
|
// Taro.showToast({
|
||||||
// title: "加载用户信息失败",
|
// title: "加载用户信息失败",
|
||||||
// icon: "error",
|
// icon: "error",
|
||||||
@@ -169,9 +170,9 @@ const EditProfilePage: React.FC = () => {
|
|||||||
icon: "success",
|
icon: "success",
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("头像上传失败:", error);
|
console.warn("头像上传失败:", error);
|
||||||
Taro.showToast({
|
Taro.showToast({
|
||||||
title: "头像上传失败",
|
title: error.message,
|
||||||
icon: "none",
|
icon: "none",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -246,10 +247,10 @@ const EditProfilePage: React.FC = () => {
|
|||||||
icon: "success",
|
icon: "success",
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("保存失败:", error);
|
console.warn("保存失败:", error);
|
||||||
Taro.showToast({
|
Taro.showToast({
|
||||||
title: "保存失败",
|
title: getBackendErrorMsg(error, "保存失败"),
|
||||||
icon: "error",
|
icon: "none",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -307,10 +308,10 @@ const EditProfilePage: React.FC = () => {
|
|||||||
icon: "success",
|
icon: "success",
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("保存失败:", error);
|
console.warn("保存失败:", error);
|
||||||
Taro.showToast({
|
Taro.showToast({
|
||||||
title: "保存失败",
|
title: getBackendErrorMsg(error, "保存失败"),
|
||||||
icon: "error",
|
icon: "none",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -438,7 +439,7 @@ const EditProfilePage: React.FC = () => {
|
|||||||
const phone = await UserService.parse_phone(e.detail.code);
|
const phone = await UserService.parse_phone(e.detail.code);
|
||||||
handle_field_edit("phone", phone);
|
handle_field_edit("phone", phone);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error("解析手机号失败:", e);
|
console.warn("解析手机号失败:", e);
|
||||||
Taro.showToast({
|
Taro.showToast({
|
||||||
title: "解析手机号失败,请重试",
|
title: "解析手机号失败,请重试",
|
||||||
icon: "none",
|
icon: "none",
|
||||||
@@ -564,9 +565,8 @@ const EditProfilePage: React.FC = () => {
|
|||||||
</View>
|
</View>
|
||||||
<View className="item_right">
|
<View className="item_right">
|
||||||
<Text
|
<Text
|
||||||
className={`item_value ${
|
className={`item_value ${form_data.gender ? "" : "placeholder"
|
||||||
form_data.gender ? "" : "placeholder"
|
}`}
|
||||||
}`}
|
|
||||||
>
|
>
|
||||||
{convert_db_gender_to_display(form_data.gender)}
|
{convert_db_gender_to_display(form_data.gender)}
|
||||||
</Text>
|
</Text>
|
||||||
@@ -597,9 +597,8 @@ const EditProfilePage: React.FC = () => {
|
|||||||
</View>
|
</View>
|
||||||
<View className="item_right">
|
<View className="item_right">
|
||||||
<Text
|
<Text
|
||||||
className={`item_value ${
|
className={`item_value ${form_data.birthday ? "" : "placeholder"
|
||||||
form_data.birthday ? "" : "placeholder"
|
}`}
|
||||||
}`}
|
|
||||||
>
|
>
|
||||||
{form_data.birthday || "选择生日"}
|
{form_data.birthday || "选择生日"}
|
||||||
</Text>
|
</Text>
|
||||||
@@ -628,9 +627,8 @@ const EditProfilePage: React.FC = () => {
|
|||||||
</View>
|
</View>
|
||||||
<View className="item_right">
|
<View className="item_right">
|
||||||
<Text
|
<Text
|
||||||
className={`item_value ${
|
className={`item_value ${form_data.personal_profile ? "" : "placeholder"
|
||||||
form_data.personal_profile ? "" : "placeholder"
|
}`}
|
||||||
}`}
|
|
||||||
>
|
>
|
||||||
{form_data.personal_profile.replace(/\n/g, " ") ||
|
{form_data.personal_profile.replace(/\n/g, " ") ||
|
||||||
"介绍一下自己"}
|
"介绍一下自己"}
|
||||||
@@ -661,17 +659,16 @@ const EditProfilePage: React.FC = () => {
|
|||||||
</View>
|
</View>
|
||||||
<View className="item_right">
|
<View className="item_right">
|
||||||
<Text
|
<Text
|
||||||
className={`item_value ${
|
className={`item_value ${form_data.province ||
|
||||||
form_data.province ||
|
|
||||||
form_data.city ||
|
form_data.city ||
|
||||||
form_data.district
|
form_data.district
|
||||||
? ""
|
? ""
|
||||||
: "placehoder"
|
: "placehoder"
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
{form_data.province ||
|
{form_data.province ||
|
||||||
form_data.city ||
|
form_data.city ||
|
||||||
form_data.district
|
form_data.district
|
||||||
? `${form_data.province} ${form_data.city} ${form_data.district}`
|
? `${form_data.province} ${form_data.city} ${form_data.district}`
|
||||||
: "选择所在地区"}
|
: "选择所在地区"}
|
||||||
</Text>
|
</Text>
|
||||||
@@ -697,9 +694,8 @@ const EditProfilePage: React.FC = () => {
|
|||||||
</View>
|
</View>
|
||||||
<View className="item_right">
|
<View className="item_right">
|
||||||
<Text
|
<Text
|
||||||
className={`item_value ${
|
className={`item_value ${form_data.ntrp_level ? "" : "placeholder"
|
||||||
form_data.ntrp_level ? "" : "placeholder"
|
}`}
|
||||||
}`}
|
|
||||||
>
|
>
|
||||||
{form_data.ntrp_level || "测测你的 NTRP 水平"}
|
{form_data.ntrp_level || "测测你的 NTRP 水平"}
|
||||||
</Text>
|
</Text>
|
||||||
@@ -724,14 +720,12 @@ const EditProfilePage: React.FC = () => {
|
|||||||
<Text className="item_label">职业</Text>
|
<Text className="item_label">职业</Text>
|
||||||
</View>
|
</View>
|
||||||
<View
|
<View
|
||||||
className={`item_right ${
|
className={`item_right ${form_data.occupation ? "" : "placeholder"
|
||||||
form_data.occupation ? "" : "placeholder"
|
}`}
|
||||||
}`}
|
|
||||||
>
|
>
|
||||||
<Text
|
<Text
|
||||||
className={`item_value ${
|
className={`item_value ${form_data.occupation ? "" : "placeholder"
|
||||||
form_data.occupation ? "" : "placeholder"
|
}`}
|
||||||
}`}
|
|
||||||
>
|
>
|
||||||
{form_data.occupation || "填写你的职业"}
|
{form_data.occupation || "填写你的职业"}
|
||||||
</Text>
|
</Text>
|
||||||
@@ -771,9 +765,9 @@ const EditProfilePage: React.FC = () => {
|
|||||||
>
|
>
|
||||||
{form_data.phone
|
{form_data.phone
|
||||||
? form_data.phone.replace(
|
? form_data.phone.replace(
|
||||||
/(\d{3})(\d{4})(\d{4})/,
|
/(\d{3})(\d{4})(\d{4})/,
|
||||||
"$1 $2 $3"
|
"$1 $2 $3"
|
||||||
)
|
)
|
||||||
: "未绑定"}
|
: "未绑定"}
|
||||||
</Button>
|
</Button>
|
||||||
<Image
|
<Image
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ const FollowPage: React.FC = () => {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`加载${TAB_CONFIG.find(t => t.key === tab)?.label}列表失败:`, error);
|
console.warn(`加载${TAB_CONFIG.find(t => t.key === tab)?.label}列表失败:`, error);
|
||||||
Taro.showToast({
|
Taro.showToast({
|
||||||
title: '加载失败',
|
title: '加载失败',
|
||||||
icon: 'none'
|
icon: 'none'
|
||||||
@@ -163,7 +163,7 @@ const FollowPage: React.FC = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('关注操作失败:', error);
|
console.warn('关注操作失败:', error);
|
||||||
Taro.showToast({
|
Taro.showToast({
|
||||||
title: '操作失败',
|
title: '操作失败',
|
||||||
icon: 'none'
|
icon: 'none'
|
||||||
@@ -202,7 +202,7 @@ const FollowPage: React.FC = () => {
|
|||||||
try {
|
try {
|
||||||
load_user_list(default_tab, true);
|
load_user_list(default_tab, true);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('初始化加载失败:', error);
|
console.warn('初始化加载失败:', error);
|
||||||
Taro.showToast({
|
Taro.showToast({
|
||||||
title: '初始化失败',
|
title: '初始化失败',
|
||||||
icon: 'none'
|
icon: 'none'
|
||||||
@@ -243,7 +243,7 @@ const FollowPage: React.FC = () => {
|
|||||||
// icon: 'success'
|
// icon: 'success'
|
||||||
// });
|
// });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('取消关注失败:', error);
|
console.warn('取消关注失败:', error);
|
||||||
Taro.showToast({
|
Taro.showToast({
|
||||||
title: '操作失败',
|
title: '操作失败',
|
||||||
icon: 'none'
|
icon: 'none'
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ const MyselfPage: React.FC = () => {
|
|||||||
// // }
|
// // }
|
||||||
// // set_game_records(games_data);
|
// // set_game_records(games_data);
|
||||||
// } catch (error) {
|
// } catch (error) {
|
||||||
// console.error("加载用户数据失败:", error);
|
// console.warn("加载用户数据失败:", error);
|
||||||
// Taro.showToast({
|
// Taro.showToast({
|
||||||
// title: "加载失败,请重试",
|
// title: "加载失败,请重试",
|
||||||
// icon: "error",
|
// icon: "error",
|
||||||
@@ -89,11 +89,10 @@ const MyselfPage: React.FC = () => {
|
|||||||
await fetchUserInfo();
|
await fetchUserInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 获取测试结果
|
// 获取测试结果
|
||||||
const res = await evaluateService.getLastResult();
|
const res = await evaluateService.getLastResult();
|
||||||
if (res.code === 0) {
|
if (res.code === 0) {
|
||||||
console.log( "getLastResult", res.data);
|
console.log("getLastResult", res.data);
|
||||||
setHasTestInLastMonth(res.data.has_test_in_last_month);
|
setHasTestInLastMonth(res.data.has_test_in_last_month);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -110,25 +109,28 @@ const MyselfPage: React.FC = () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// 分类球局数据(使用 useCallback 包装,避免每次渲染都创建新函数)
|
// 分类球局数据(使用 useCallback 包装,避免每次渲染都创建新函数)
|
||||||
const classifyGameRecords = useCallback((
|
const classifyGameRecords = useCallback(
|
||||||
game_records: TennisMatch[]
|
(
|
||||||
): { notEndGames: TennisMatch[]; finishedGames: TennisMatch[] } => {
|
game_records: TennisMatch[]
|
||||||
const now = new Date().getTime();
|
): { notEndGames: TennisMatch[]; finishedGames: TennisMatch[] } => {
|
||||||
return game_records.reduce(
|
const now = new Date().getTime();
|
||||||
(result, cur) => {
|
return game_records.reduce(
|
||||||
let { end_time } = cur;
|
(result, cur) => {
|
||||||
end_time = end_time.replace(/\s/, "T");
|
let { end_time } = cur;
|
||||||
new Date(end_time).getTime() > now
|
end_time = end_time.replace(/\s/, "T");
|
||||||
? result.notEndGames.push(cur)
|
new Date(end_time).getTime() > now
|
||||||
: result.finishedGames.push(cur);
|
? result.notEndGames.push(cur)
|
||||||
return result;
|
: result.finishedGames.unshift(cur);
|
||||||
},
|
return result;
|
||||||
{
|
},
|
||||||
notEndGames: [] as TennisMatch[],
|
{
|
||||||
finishedGames: [] as TennisMatch[],
|
notEndGames: [] as TennisMatch[],
|
||||||
}
|
finishedGames: [] as TennisMatch[],
|
||||||
);
|
}
|
||||||
}, []);
|
);
|
||||||
|
},
|
||||||
|
[]
|
||||||
|
);
|
||||||
|
|
||||||
// 加载球局数据(使用 useCallback 包装,避免每次渲染都创建新函数)
|
// 加载球局数据(使用 useCallback 包装,避免每次渲染都创建新函数)
|
||||||
const load_game_data = useCallback(async () => {
|
const load_game_data = useCallback(async () => {
|
||||||
@@ -150,7 +152,7 @@ const MyselfPage: React.FC = () => {
|
|||||||
setEndedGameRecords(finishedGames);
|
setEndedGameRecords(finishedGames);
|
||||||
// set_game_records(games_data);
|
// set_game_records(games_data);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("加载球局数据失败:", error);
|
console.warn("加载球局数据失败:", error);
|
||||||
}
|
}
|
||||||
}, [active_tab, user_info, classifyGameRecords]);
|
}, [active_tab, user_info, classifyGameRecords]);
|
||||||
|
|
||||||
@@ -176,7 +178,7 @@ const MyselfPage: React.FC = () => {
|
|||||||
duration: 1500,
|
duration: 1500,
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("关注操作失败:", error);
|
console.warn("关注操作失败:", error);
|
||||||
Taro.showToast({
|
Taro.showToast({
|
||||||
title: "操作失败,请重试",
|
title: "操作失败,请重试",
|
||||||
icon: "error",
|
icon: "error",
|
||||||
@@ -272,7 +274,7 @@ const MyselfPage: React.FC = () => {
|
|||||||
</View>
|
</View>
|
||||||
|
|
||||||
{/* 球局列表 */}
|
{/* 球局列表 */}
|
||||||
<View className="game_list_section" >
|
<View className="game_list_section">
|
||||||
<ScrollView scrollY refresherBackground="#FAFAFA">
|
<ScrollView scrollY refresherBackground="#FAFAFA">
|
||||||
<ListContainer
|
<ListContainer
|
||||||
data={game_records}
|
data={game_records}
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ const OtherUserPage: React.FC = () => {
|
|||||||
});
|
});
|
||||||
setIsFollowing(userData.is_following || false);
|
setIsFollowing(userData.is_following || false);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("加载用户数据失败:", error);
|
console.warn("加载用户数据失败:", error);
|
||||||
Taro.showToast({
|
Taro.showToast({
|
||||||
title: "加载失败",
|
title: "加载失败",
|
||||||
icon: "none",
|
icon: "none",
|
||||||
@@ -141,7 +141,7 @@ const OtherUserPage: React.FC = () => {
|
|||||||
end_time = end_time.replace(/\s/, "T");
|
end_time = end_time.replace(/\s/, "T");
|
||||||
new Date(end_time).getTime() > now
|
new Date(end_time).getTime() > now
|
||||||
? result.notEndGames.push(cur)
|
? result.notEndGames.push(cur)
|
||||||
: result.finishedGames.push(cur);
|
: result.finishedGames.unshift(cur);
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -169,7 +169,7 @@ const OtherUserPage: React.FC = () => {
|
|||||||
setGameRecords(notEndGames);
|
setGameRecords(notEndGames);
|
||||||
setEndedGameRecords(finishedGames);
|
setEndedGameRecords(finishedGames);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("加载球局数据失败:", error);
|
console.warn("加载球局数据失败:", error);
|
||||||
Taro.showToast({
|
Taro.showToast({
|
||||||
title: "加载失败,请重试",
|
title: "加载失败,请重试",
|
||||||
icon: "error",
|
icon: "error",
|
||||||
@@ -200,7 +200,7 @@ const OtherUserPage: React.FC = () => {
|
|||||||
duration: 1500,
|
duration: 1500,
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("关注操作失败:", error);
|
console.warn("关注操作失败:", error);
|
||||||
Taro.showToast({
|
Taro.showToast({
|
||||||
title: "操作失败",
|
title: "操作失败",
|
||||||
icon: "none",
|
icon: "none",
|
||||||
@@ -235,7 +235,7 @@ const OtherUserPage: React.FC = () => {
|
|||||||
try {
|
try {
|
||||||
await Promise.all([load_user_data(), load_game_data()]);
|
await Promise.all([load_user_data(), load_game_data()]);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("刷新失败:", error);
|
console.warn("刷新失败:", error);
|
||||||
} finally {
|
} finally {
|
||||||
setRefreshing(false);
|
setRefreshing(false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ const QueryTransactions = () => {
|
|||||||
setSearchHistory(response.data);
|
setSearchHistory(response.data);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e);
|
console.warn(e);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
background-color: #f5f5f5;
|
background-color: #f5f5f5;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
padding: 0 20px;
|
||||||
.custom-navbar {
|
.custom-navbar {
|
||||||
height: 56px;
|
height: 56px;
|
||||||
/* 通常与原生导航栏高度一致 */
|
/* 通常与原生导航栏高度一致 */
|
||||||
@@ -17,6 +18,7 @@
|
|||||||
top: 0;
|
top: 0;
|
||||||
z-index: 100;
|
z-index: 100;
|
||||||
background-color: #f5f5f5;
|
background-color: #f5f5f5;
|
||||||
|
padding: 0 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.detail-navigator {
|
.detail-navigator {
|
||||||
@@ -48,18 +50,22 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.form-item {
|
.form-item {
|
||||||
padding: 20px;
|
padding: 16px 0;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
height: 50px;
|
height: 50px;
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 10px;
|
gap: 20px;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
border-bottom: 1px solid #0000000d;
|
border-bottom: 1px solid #0000000d;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
|
|
||||||
.form-label {
|
.form-label {
|
||||||
width: 56px;
|
|
||||||
text-align: right;
|
text-align: right;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
Input {
|
||||||
|
flex: 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,7 +78,6 @@
|
|||||||
letter-spacing: 0px;
|
letter-spacing: 0px;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
color: #3c3c4366;
|
color: #3c3c4366;
|
||||||
padding: 0 20px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn {
|
.btn {
|
||||||
@@ -106,6 +111,5 @@
|
|||||||
border-radius: 16px;
|
border-radius: 16px;
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
transform: translateX(20px);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,10 +67,12 @@ const SetTransactionPassword: React.FC = () => {
|
|||||||
const { new_password, confirm_password, sms_code } = formData;
|
const { new_password, confirm_password, sms_code } = formData;
|
||||||
if (handleType === "set") {
|
if (handleType === "set") {
|
||||||
setValid(
|
setValid(
|
||||||
(sms_code !== "") && (new_password.length === 6) && (confirm_password.length === 6)
|
sms_code !== "" &&
|
||||||
|
new_password.length === 6 &&
|
||||||
|
confirm_password.length === 6
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
setValid((new_password.length === 6) && (confirm_password.length === 6));
|
setValid(new_password.length === 6 && confirm_password.length === 6);
|
||||||
}
|
}
|
||||||
}, [formData]);
|
}, [formData]);
|
||||||
|
|
||||||
@@ -97,7 +99,7 @@ const SetTransactionPassword: React.FC = () => {
|
|||||||
icon: "success",
|
icon: "success",
|
||||||
});
|
});
|
||||||
let delta = handleType === "set" ? 1 : 2;
|
let delta = handleType === "set" ? 1 : 2;
|
||||||
Taro.navigateBack({ delta })
|
Taro.navigateBack({ delta });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
Taro.showToast({
|
Taro.showToast({
|
||||||
title: "设置交易密码失败",
|
title: "设置交易密码失败",
|
||||||
@@ -166,13 +168,11 @@ const SetTransactionPassword: React.FC = () => {
|
|||||||
Taro.navigateBack();
|
Taro.navigateBack();
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<View
|
<View className="form-item" style={{ marginTop: `${totalHeight}px` }}>
|
||||||
className="form-item"
|
|
||||||
style={{ marginTop: `${totalHeight}px` }}
|
|
||||||
>
|
|
||||||
<Text className="form-label">交易密码</Text>
|
<Text className="form-label">交易密码</Text>
|
||||||
<Input
|
<Input
|
||||||
placeholder="请输入交易密码"
|
placeholder="请输入交易密码"
|
||||||
|
placeholderStyle="color: #d9d9d9;"
|
||||||
password
|
password
|
||||||
type="number"
|
type="number"
|
||||||
maxlength={6}
|
maxlength={6}
|
||||||
@@ -185,6 +185,7 @@ const SetTransactionPassword: React.FC = () => {
|
|||||||
<Text className="form-label">重复密码</Text>
|
<Text className="form-label">重复密码</Text>
|
||||||
<Input
|
<Input
|
||||||
placeholder="请再次输入交易密码"
|
placeholder="请再次输入交易密码"
|
||||||
|
placeholderStyle="color: #d9d9d9;"
|
||||||
password
|
password
|
||||||
type="number"
|
type="number"
|
||||||
maxlength={6}
|
maxlength={6}
|
||||||
@@ -198,6 +199,7 @@ const SetTransactionPassword: React.FC = () => {
|
|||||||
<Text className="form-label">手机验证</Text>
|
<Text className="form-label">手机验证</Text>
|
||||||
<Input
|
<Input
|
||||||
placeholder="请输入验证码"
|
placeholder="请输入验证码"
|
||||||
|
placeholderStyle="color: #d9d9d9;"
|
||||||
type="number"
|
type="number"
|
||||||
onInput={(e) => {
|
onInput={(e) => {
|
||||||
handleInput(e, "sms_code");
|
handleInput(e, "sms_code");
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
height: 100vh;
|
height: 100vh;
|
||||||
overflow-y: hidden;
|
overflow-y: hidden;
|
||||||
|
padding: 0 20px;
|
||||||
.custom-navbar {
|
.custom-navbar {
|
||||||
height: 56px;
|
height: 56px;
|
||||||
/* 通常与原生导航栏高度一致 */
|
/* 通常与原生导航栏高度一致 */
|
||||||
@@ -48,18 +49,22 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.form-item {
|
.form-item {
|
||||||
padding: 20px;
|
padding: 16px 0;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
height: 50px;
|
height: 50px;
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 10px;
|
gap: 20px;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
border-bottom: 1px solid #0000000d;
|
border-bottom: 1px solid #0000000d;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
|
|
||||||
.form-label {
|
.form-label {
|
||||||
width: 56px;
|
|
||||||
text-align: right;
|
text-align: right;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
Input {
|
||||||
|
flex: 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,6 +100,5 @@
|
|||||||
border-radius: 16px;
|
border-radius: 16px;
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
transform: translateX(20px);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -139,10 +139,7 @@ const ValidPhone: React.FC = () => {
|
|||||||
Taro.navigateBack();
|
Taro.navigateBack();
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<View
|
<View className="form-item" style={{ marginTop: `${totalHeight}px` }}>
|
||||||
className="form-item"
|
|
||||||
style={{ marginTop: `${totalHeight}px` }}
|
|
||||||
>
|
|
||||||
<Text className="form-label">手机号</Text>
|
<Text className="form-label">手机号</Text>
|
||||||
<Input defaultValue={formData.phone} type="number" disabled></Input>
|
<Input defaultValue={formData.phone} type="number" disabled></Input>
|
||||||
</View>
|
</View>
|
||||||
@@ -150,6 +147,7 @@ const ValidPhone: React.FC = () => {
|
|||||||
<Text className="form-label">验证码</Text>
|
<Text className="form-label">验证码</Text>
|
||||||
<Input
|
<Input
|
||||||
placeholder="请输入验证码"
|
placeholder="请输入验证码"
|
||||||
|
placeholderStyle="color: #d9d9d9;"
|
||||||
type="number"
|
type="number"
|
||||||
onInput={(e) => {
|
onInput={(e) => {
|
||||||
handleInput(e, "sms_code");
|
handleInput(e, "sms_code");
|
||||||
|
|||||||
@@ -195,7 +195,7 @@ const WalletPage: React.FC = () => {
|
|||||||
const res = await httpService.post("/wallet/check_password_status");
|
const res = await httpService.post("/wallet/check_password_status");
|
||||||
set_password_status(res.data.is_password_set);
|
set_password_status(res.data.is_password_set);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error("检查交易密码状态失败:", e);
|
console.warn("检查交易密码状态失败:", e);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -218,7 +218,7 @@ const WalletPage: React.FC = () => {
|
|||||||
total_withdraw,
|
total_withdraw,
|
||||||
});
|
});
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
console.error("加载钱包数据失败:", error);
|
console.warn("加载钱包数据失败:", error);
|
||||||
|
|
||||||
let errorMessage = "加载失败,请重试";
|
let errorMessage = "加载失败,请重试";
|
||||||
if (
|
if (
|
||||||
@@ -262,7 +262,7 @@ const WalletPage: React.FC = () => {
|
|||||||
set_transactions([]);
|
set_transactions([]);
|
||||||
}
|
}
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
console.error("加载交易记录失败:", error);
|
console.warn("加载交易记录失败:", error);
|
||||||
set_transactions([]);
|
set_transactions([]);
|
||||||
|
|
||||||
let errorMessage = "加载交易记录失败";
|
let errorMessage = "加载交易记录失败";
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ const Withdrawal: React.FC = () => {
|
|||||||
}, [initializeKeyboardListener, addListener]);
|
}, [initializeKeyboardListener, addListener]);
|
||||||
const [showTips, setShowTips] = useState(false);
|
const [showTips, setShowTips] = useState(false);
|
||||||
const [tipsText, setTipsText] = useState<string>("");
|
const [tipsText, setTipsText] = useState<string>("");
|
||||||
const [inputValue, setInputValue] = useState<string>("0.00");
|
const [inputValue, setInputValue] = useState<string>("");
|
||||||
const [walletInfo, setWalletInfo] = useState<WalletInfo>({
|
const [walletInfo, setWalletInfo] = useState<WalletInfo>({
|
||||||
balance: "0.00",
|
balance: "0.00",
|
||||||
});
|
});
|
||||||
@@ -65,8 +65,8 @@ const Withdrawal: React.FC = () => {
|
|||||||
|
|
||||||
const [inputValueObj, setInputValueObj] = useState({
|
const [inputValueObj, setInputValueObj] = useState({
|
||||||
integer: "0",
|
integer: "0",
|
||||||
decimal: "00"
|
decimal: "00",
|
||||||
})
|
});
|
||||||
|
|
||||||
useDidShow(() => {
|
useDidShow(() => {
|
||||||
load_wallet_data();
|
load_wallet_data();
|
||||||
@@ -87,11 +87,11 @@ const Withdrawal: React.FC = () => {
|
|||||||
}, [show_withdraw_popup]);
|
}, [show_withdraw_popup]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const value = Number(inputValue).toFixed(2).split(".")
|
const value = Number(inputValue).toFixed(2).split(".");
|
||||||
const integer = value[0]
|
const integer = value[0];
|
||||||
const decimal = value[1]
|
const decimal = value[1];
|
||||||
setInputValueObj({ integer, decimal })
|
setInputValueObj({ integer, decimal });
|
||||||
}, [inputValue])
|
}, [inputValue]);
|
||||||
|
|
||||||
const validateWithdrawAmount = (amount: string) => {
|
const validateWithdrawAmount = (amount: string) => {
|
||||||
if (Number(amount) > Number(walletInfo.balance)) {
|
if (Number(amount) > Number(walletInfo.balance)) {
|
||||||
@@ -135,7 +135,7 @@ const Withdrawal: React.FC = () => {
|
|||||||
total_withdraw,
|
total_withdraw,
|
||||||
});
|
});
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
console.error("加载钱包数据失败:", error);
|
console.warn("加载钱包数据失败:", error);
|
||||||
|
|
||||||
let errorMessage = "加载失败,请重试";
|
let errorMessage = "加载失败,请重试";
|
||||||
if (
|
if (
|
||||||
@@ -171,7 +171,7 @@ const Withdrawal: React.FC = () => {
|
|||||||
setMapErrorCodes(mapErrorCodes);
|
setMapErrorCodes(mapErrorCodes);
|
||||||
}
|
}
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
console.error("获取提现错误码失败:", error);
|
console.warn("获取提现错误码失败:", error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const handleWithdraw = async () => {
|
const handleWithdraw = async () => {
|
||||||
@@ -307,11 +307,11 @@ const Withdrawal: React.FC = () => {
|
|||||||
showBack={true}
|
showBack={true}
|
||||||
showAvatar={false}
|
showAvatar={false}
|
||||||
onBack={() => {
|
onBack={() => {
|
||||||
const pages = Taro.getCurrentPages()
|
const pages = Taro.getCurrentPages();
|
||||||
const prevPage = pages[pages.length - 2]
|
const prevPage = pages[pages.length - 2];
|
||||||
prevPage.setData({
|
prevPage.setData({
|
||||||
updateList: withdrawSuccess
|
updateList: withdrawSuccess,
|
||||||
})
|
});
|
||||||
Taro.navigateBack();
|
Taro.navigateBack();
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
@@ -325,6 +325,7 @@ const Withdrawal: React.FC = () => {
|
|||||||
<Input
|
<Input
|
||||||
type="digit"
|
type="digit"
|
||||||
placeholder="0.00"
|
placeholder="0.00"
|
||||||
|
placeholderStyle="color:rgba(120, 120, 128, 0.12);"
|
||||||
cursorColor="#000"
|
cursorColor="#000"
|
||||||
value={inputValue}
|
value={inputValue}
|
||||||
onInput={handleInput}
|
onInput={handleInput}
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ const initUserAuthCore = async (): Promise<void> => {
|
|||||||
await fetchUserInfo();
|
await fetchUserInfo();
|
||||||
await checkNicknameChangeStatus();
|
await checkNicknameChangeStatus();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("获取用户信息失败:", error);
|
console.warn("获取用户信息失败:", error);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 未登录,尝试静默登录
|
// 未登录,尝试静默登录
|
||||||
@@ -45,12 +45,12 @@ const initUserAuthCore = async (): Promise<void> => {
|
|||||||
await checkNicknameChangeStatus();
|
await checkNicknameChangeStatus();
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("静默登录失败:", error);
|
console.warn("静默登录失败:", error);
|
||||||
// 静默登录失败不影响使用
|
// 静默登录失败不影响使用
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("初始化用户授权失败:", error);
|
console.warn("初始化用户授权失败:", error);
|
||||||
} finally {
|
} finally {
|
||||||
isInitializingAuth = false;
|
isInitializingAuth = false;
|
||||||
authInitPromise = null;
|
authInitPromise = null;
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ export const sceneRedirectLogic = (options, defaultPage: string) => {
|
|||||||
url: query ? `/${defaultPage}?${query}` : `/${defaultPage}`,
|
url: query ? `/${defaultPage}?${query}` : `/${defaultPage}`,
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e);
|
console.warn(e);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -94,6 +94,19 @@ export function toast(message) {
|
|||||||
Taro.showToast({ title: message, icon: "none" });
|
Taro.showToast({ title: message, icon: "none" });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 从接口/请求错误中取出后端返回的文案,用于保存失败等场景的 toast */
|
||||||
|
export function getBackendErrorMsg(error: any, fallback = "操作失败"): string {
|
||||||
|
if (error == null) return fallback;
|
||||||
|
const msg =
|
||||||
|
error?.message ||
|
||||||
|
(typeof error?.error === "string" ? error.error : error?.error?.message) ||
|
||||||
|
error?.data?.message ||
|
||||||
|
error?.data?.msg ||
|
||||||
|
"";
|
||||||
|
const s = String(msg).trim();
|
||||||
|
return s || fallback;
|
||||||
|
}
|
||||||
|
|
||||||
// 将·作为连接符插入到标签文本之间
|
// 将·作为连接符插入到标签文本之间
|
||||||
export function insertDotInTags(tags: string[]) {
|
export function insertDotInTags(tags: string[]) {
|
||||||
if (!tags) return [];
|
if (!tags) return [];
|
||||||
|
|||||||
@@ -553,7 +553,7 @@ const drawShareCard = async (ctx: any, data: ShareCardData, offscreen: any): Pro
|
|||||||
console.log('Canvas绘制命令已发送')
|
console.log('Canvas绘制命令已发送')
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('绘制分享卡片失败:', error)
|
console.warn('绘制分享卡片失败:', error)
|
||||||
Taro.showToast({
|
Taro.showToast({
|
||||||
title: '生成分享卡片失败',
|
title: '生成分享卡片失败',
|
||||||
icon: 'none'
|
icon: 'none'
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ class TokenManager {
|
|||||||
try {
|
try {
|
||||||
return Taro.getStorageSync(TOKEN_KEY)
|
return Taro.getStorageSync(TOKEN_KEY)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('获取访问令牌失败:', error)
|
console.warn('获取访问令牌失败:', error)
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -26,7 +26,7 @@ class TokenManager {
|
|||||||
try {
|
try {
|
||||||
return Taro.getStorageSync(REFRESH_TOKEN_KEY)
|
return Taro.getStorageSync(REFRESH_TOKEN_KEY)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('获取刷新令牌失败:', error)
|
console.warn('获取刷新令牌失败:', error)
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -36,7 +36,7 @@ class TokenManager {
|
|||||||
try {
|
try {
|
||||||
return Taro.getStorageSync(TOKEN_EXPIRES_KEY)
|
return Taro.getStorageSync(TOKEN_EXPIRES_KEY)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('获取令牌过期时间失败:', error)
|
console.warn('获取令牌过期时间失败:', error)
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -54,7 +54,7 @@ class TokenManager {
|
|||||||
Taro.setStorageSync(TOKEN_EXPIRES_KEY, tokenInfo.expiresAt)
|
Taro.setStorageSync(TOKEN_EXPIRES_KEY, tokenInfo.expiresAt)
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('设置令牌失败:', error)
|
console.warn('设置令牌失败:', error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,7 +65,7 @@ class TokenManager {
|
|||||||
Taro.removeStorageSync(REFRESH_TOKEN_KEY)
|
Taro.removeStorageSync(REFRESH_TOKEN_KEY)
|
||||||
Taro.removeStorageSync(TOKEN_EXPIRES_KEY)
|
Taro.removeStorageSync(TOKEN_EXPIRES_KEY)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('清除令牌失败:', error)
|
console.warn('清除令牌失败:', error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ export function saveImage(url) {
|
|||||||
await Taro.saveImageToPhotosAlbum({ filePath })
|
await Taro.saveImageToPhotosAlbum({ filePath })
|
||||||
Taro.showToast({ title: "保存成功" })
|
Taro.showToast({ title: "保存成功" })
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e)
|
console.warn(e)
|
||||||
Taro.showToast({ title: "图片保存失败", icon: "none" })
|
Taro.showToast({ title: "图片保存失败", icon: "none" })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user