diff --git a/config/env.ts b/config/env.ts new file mode 100644 index 0000000..2eb1e0b --- /dev/null +++ b/config/env.ts @@ -0,0 +1,128 @@ +import Taro from '@tarojs/taro' + +// 环境类型 +export type EnvType = 'development' | 'production' + +// 环境配置接口 +export interface EnvConfig { + name: string + apiBaseURL: string + timeout: number + enableLog: boolean + enableMock: boolean + // 客服配置 + customerService: { + corpId: string + serviceUrl: string + phoneNumber?: string + email?: string + } +} + +// 各环境配置 +const envConfigs: Record = { + + + // 开发环境 + development: { + name: '开发环境', + // apiBaseURL: 'https://tennis.bimwe.com', + apiBaseURL: 'http://localhost:9098', + timeout: 15000, + enableLog: true, + enableMock: false, + // 客服配置 + customerService: { + corpId: 'ww51fc969e8b76af82', // 企业ID + serviceUrl: 'https://work.weixin.qq.com/kfid/kfc64085b93243c5c91', + + } + }, + + + + // 生产环境1 + // production: { + // name: '生产环境1', + // apiBaseURL: 'https://tennis.bimwe.com', + // timeout: 10000, + // enableLog: false, + // enableMock: false, + // // 客服配置 + // customerService: { + // corpId: 'ww51fc969e8b76af82', // 企业ID + // serviceUrl: 'https://work.weixin.qq.com/kfid/kfc64085b93243c5c91', + + // } + // }, + + // 生产环境2 + production: { + name: '生产环境2', + apiBaseURL: 'https://youchang.qiongjingtiyu.com', + timeout: 10000, + enableLog: false, + enableMock: false, + // 客服配置 + customerService: { + corpId: 'ww9a2d9a5d9410c664', // 企业ID + serviceUrl: 'https://work.weixin.qq.com/kfid/kfcd355e162e0390684', + + } + } +} + +// 获取当前环境 +export const getCurrentEnv = (): EnvType => { + // 在小程序环境中,使用默认逻辑判断环境 + // 可以根据实际需要配置不同的判断逻辑 + + // 可以根据实际部署情况添加更多判断逻辑 + // 比如通过 Taro.getEnv() 获取当前平台环境 + + const isProd = process.env.NODE_ENV === 'production' + if (isProd) { + return 'production' + } else { + return 'development' + } +} + +// 获取当前环境配置 +export const getCurrentConfig = (): EnvConfig => { + const env = getCurrentEnv() + return envConfigs[env] +} + +// 获取指定环境配置 +export const getEnvConfig = (env: EnvType): EnvConfig => { + return envConfigs[env] +} + +// 是否为开发环境 +export const isDevelopment = (): boolean => { + return getCurrentEnv() === 'development' +} + +// 是否为生产环境 +export const isProduction = (): boolean => { + return getCurrentEnv() === 'production' +} + + + +// 环境配置调试信息 +export const getEnvInfo = () => { + const config = getCurrentConfig() + return { + env: getCurrentEnv(), + config, + taroEnv: Taro.getEnv(), + platform: Taro.getEnv() === Taro.ENV_TYPE.WEAPP ? '微信小程序' : + Taro.getEnv() === Taro.ENV_TYPE.WEB ? 'Web' : + Taro.getEnv() === Taro.ENV_TYPE.RN ? 'React Native' : '未知' + } +} + +// 导出当前环境配置(方便直接使用) +export default getCurrentConfig() \ No newline at end of file diff --git a/src/components/ListCard/index.tsx b/src/components/ListCard/index.tsx index 55d5246..5f5eb27 100644 --- a/src/components/ListCard/index.tsx +++ b/src/components/ListCard/index.tsx @@ -5,8 +5,9 @@ import img from "../../config/images"; import { ListCardProps } from "../../../types/list/types"; import { formatGameTime, calculateDuration } from "@/utils/timeUtils"; import { navigateTo } from "@/utils/navigation"; -import images from '@/config/images' +import images from "@/config/images"; import "./index.scss"; +import { OSS_BASE } from "@/config/api"; const ListCard: React.FC = ({ id, @@ -45,7 +46,7 @@ const ListCard: React.FC = ({ className="image" mode="aspectFill" lazyLoad - defaultSource={require("@/static/emptyStatus/publish-empty-card.png")} + defaultSource={`${OSS_BASE}/front/ball/images/publish-empty-card.svg`} /> ); }; @@ -67,7 +68,9 @@ const ListCard: React.FC = ({ const containerWidthPx = screenWidth - 130; // 计算固定信息宽度 - const extraInfo = `${court_type ? `・${court_type}` : ''}${distance_km ? `・${distance_km}km` : ''}`; + const extraInfo = `${court_type ? `・${court_type}` : ""}${ + distance_km ? `・${distance_km}km` : "" + }`; // 估算字符宽度(基于 12px 字体) const getTextWidth = (text: string) => { @@ -98,7 +101,9 @@ const ListCard: React.FC = ({ let currentWidth = 0; for (let i = 0; i < location.length; i++) { const char = location[i]; - const charWidth = /[\u4e00-\u9fa5\u3000-\u303f\uff00-\uffef]/.test(char) ? 12 : 6; + const charWidth = /[\u4e00-\u9fa5\u3000-\u303f\uff00-\uffef]/.test(char) + ? 12 + : 6; if (currentWidth + charWidth > availableWidth) { break; } @@ -106,7 +111,7 @@ const ListCard: React.FC = ({ maxChars++; } - return location.slice(0, maxChars) + '...'; + return location.slice(0, maxChars) + "..."; }, [location, court_type, distance_km]); // 根据图片数量决定展示样式 @@ -220,9 +225,10 @@ const ListCard: React.FC = ({ - + - {Number(skill_level_min)?.toFixed(1)} - {Number(skill_level_max)?.toFixed(1)} + {Number(skill_level_min)?.toFixed(1)} -{" "} + {Number(skill_level_max)?.toFixed(1)} {/* 分割线 */} @@ -251,22 +257,16 @@ const ListCard: React.FC = ({ /> {/* {game_type} */} - { - venue_description && () - } - { - venue_description && - ( - - - 场馆方: - - - {venue_description} - + {venue_description && } + {venue_description && ( + + 场馆方: + + + {venue_description} - ) - } + + )} )} diff --git a/src/components/ListLoadError/index.tsx b/src/components/ListLoadError/index.tsx index daddcfa..3d6be09 100644 --- a/src/components/ListLoadError/index.tsx +++ b/src/components/ListLoadError/index.tsx @@ -24,7 +24,6 @@ const ListLoadError = (props: IProps) => { wrapperHeight = "", width = "", height = "", - scale = "", } = props; const handleReload = () => { reload && typeof reload === "function" && reload(); @@ -34,7 +33,7 @@ const ListLoadError = (props: IProps) => { {text && {text}} diff --git a/src/components/UserInfo/index.tsx b/src/components/UserInfo/index.tsx index fb6f2c1..788b945 100644 --- a/src/components/UserInfo/index.tsx +++ b/src/components/UserInfo/index.tsx @@ -6,7 +6,11 @@ import "./index.scss"; import { EditModal } from "@/components"; import { UserService, PickerOption } from "@/services/userService"; import { PopupPicker } from "@/components/Picker/index"; -import { useUserActions, useNicknameChangeStatus, useLastTestResult } from "@/store/userStore"; +import { + useUserActions, + useNicknameChangeStatus, + useLastTestResult, +} from "@/store/userStore"; import { UserInfoType } from "@/services/userService"; import { useCities, @@ -82,7 +86,8 @@ const UserInfoCardComponent: React.FC = ({ }) => { const nickname_change_status = useNicknameChangeStatus(); const { setShowGuideBar } = useGlobalState(); - const { updateUserInfo, updateNickname, fetchLastTestResult } = useUserActions(); + const { updateUserInfo, updateNickname, fetchLastTestResult } = + useUserActions(); const ntrpLevels = useNtrpLevels(); // 使用全局状态中的测试结果,避免重复调用接口 const lastTestResult = useLastTestResult(); @@ -129,6 +134,7 @@ const UserInfoCardComponent: React.FC = ({ location_picker_visible, ntrp_picker_visible, occupation_picker_visible, + edit_modal_visible, ]; const allPickersClosed = visibles.every((item) => !item); // 所有选择器都关闭时,显示 GuideBar;否则隐藏 @@ -138,6 +144,7 @@ const UserInfoCardComponent: React.FC = ({ location_picker_visible, ntrp_picker_visible, occupation_picker_visible, + edit_modal_visible, ]); // 职业数据 @@ -295,8 +302,8 @@ const UserInfoCardComponent: React.FC = ({ // 处理地区选择 const handle_location_change = (e: any) => { - const [country, province, city] = e; - handle_field_edit({ country, province, city }); + const [province, city, district] = e; + handle_field_edit({ province, city, district }); }; // 处理NTRP水平选择 @@ -307,8 +314,8 @@ const UserInfoCardComponent: React.FC = ({ // 处理职业选择 const handle_occupation_change = (e: any) => { - const [country, province, city] = e; - handle_field_edit("occupation", `${country} ${province} ${city}`); + const [firstVal, secondVal, thirdVal] = e; + handle_field_edit("occupation", `${firstVal} ${secondVal} ${thirdVal}`); }; const handle_edit_modal_cancel = () => { // 关闭编辑弹窗时显示 GuideBar @@ -565,12 +572,12 @@ const UserInfoCardComponent: React.FC = ({ 选择职业 ) : null} - {user_info.country || user_info.province || user_info.city ? ( + {user_info.province || user_info.city || user_info.district ? ( editable && handle_open_edit_modal("location")} > - {`${user_info.province}${user_info.city}`} + {`${user_info.city}${user_info.district}`} ) : is_current_user ? ( = ({ visible={location_picker_visible} setvisible={setLocationPickerVisible} value={ - form_data.country - ? [form_data.country, form_data.province, form_data.city] + form_data.province + ? [form_data.province, form_data.city, form_data.district] : getDefaultOption(cities) } onChange={handle_location_change} @@ -678,15 +685,12 @@ const UserInfoCardComponent: React.FC = ({ showHeader={true} title="选择 NTRP 自评水平" ntrpTested={ntrpTested} - options={ntrpLevels.map((level) => ({ - text: level, - value: level, - }))} + options={ntrpLevels} type="ntrp" img={user_info.avatar_url || ""} visible={ntrp_picker_visible} setvisible={setNtrpPickerVisible} - value={[form_data.ntrp_level || "2.5"]} + value={!form_data.ntrp_level ? ["2.5"] : [form_data.ntrp_level]} onChange={handle_ntrp_level_change} /> )} diff --git a/src/config/images.js b/src/config/images.js index 62eaddb..9f84625 100644 --- a/src/config/images.js +++ b/src/config/images.js @@ -1,74 +1,75 @@ +import { OSS_BASE } from "@/config/api"; export default { - ICON_REMOVE: require('@/static/publishBall/icon-remove.svg'), - ICON_UPLOAD: require('@/static/publishBall/icon-upload.svg'), - ICON_LOCATION: require('@/static/publishBall/icon-location.svg'), - ICON_GAMEPLAY: require('@/static/publishBall/icon-gameplay.svg'), - ICON_PERSONAL: require('@/static/publishBall/icon-personal.svg'), - ICON_CHANGDA: require('@/static/publishBall/icon-changda.svg'), - ICON_COST: require('@/static/publishBall/icon-cost.svg'), - ICON_TIPS: require('@/static/publishBall/icon-tips.svg'), - ICON_ARROW_RIGHT: require('@/static/publishBall/icon-arrow-right.svg'), - ICON_FILTER: require('@/static/list/icon-filter.svg'), - ICON_FILTER_SELECTED: require('@/static/list/icon-filter-selected.svg'), - ICON_SEARCH: require('@/static/list/icon-search.svg'), - ICON_PLAY: require('@/static/list/icon-play.svg'), - ICON_SITE: require('@/static/list/icon-site.svg'), - ICON_ARROW_DOWN: require('@/static/list/icon-arrow-down.svg'), - ICON_MENU_ITEM_SELECTED: require('@/static/list/icon-menu-item-selected.svg'), - ICON_ARROW_DOWN_WHITE: require('@/static/list/icon-arrow-down-white.svg'), - ICON_LIST_RIGHT_ARROW: require('@/static/list/icon-list-right-arrow.svg'), - ICON_ARROW_LEFT: require('@/static/detail/icon-arrow-left.svg'), - ICON_LOGO_GO: require('@/static/detail/icon-logo-go.svg'), - ICON_MAP: require('@/static/publishBall/icon-map.svg'), - ICON_STADIUM: require('@/static/publishBall/icon-stadium.svg'), - ICON_ARRORW_SMALL: require('@/static/publishBall/icon-arrow-small.svg'), - ICON_MAP_SEARCH: require('@/static/publishBall/icon-map-search.svg'), - ICON_HEART_CIRCLE: require('@/static/publishBall/icon-heartcircle.png'), - ICON_ADD: require('@/static/publishBall/icon-add.svg'), - ICON_COPY: require('@/static/publishBall/icon-arrow-right.svg'), - ICON_DELETE: require('@/static/publishBall/icon-delete.svg'), - ICON_RIGHT_MAX: require('@/static/publishBall/icon-right-max.svg'), - ICON_PLUS: require('@/static/publishBall/icon-plus.svg'), - ICON_GROUP: require('@/static/publishBall/icon-group.svg'), - ICON_PERSON: require('@/static/publishBall/icon-person.svg'), - ICON_PUBLISH: require('@/static/publishBall/icon-publish.png'), - ICON_CIRCLE_UNSELECT: require('@/static/publishBall/icon-circle-unselect.svg'), - ICON_CIRCLE_SELECT: require('@/static/publishBall/icon-circle-select-ring.svg'), - ICON_CIRCLE_SELECT_ARROW: require('@/static/publishBall/icon-circle-select-arrow.svg'), - ICON_LOGO: require('@/static/logo.svg'), - ICON_CHANGE: require('@/static/list/icon-change.svg'), - ICON_DETAIL_MAP: require('@/static/detail/icon-map.svg'), - ICON_DETAIL_ARROW_RIGHT: require('@/static/detail/icon-arrow-right.svg'), - ICON_DETAIL_NOTICE: require('@/static/detail/icon-notice.svg'), - ICON_DETAIL_APPLICATION_ADD: require('@/static/detail/icon-application-add.svg'), - ICON_DETAIL_COMMENT: require('@/static/detail/icon-comment.svg'), - ICON_DETAIL_COMMENT_LIGHT: require('@/static/detail/icon-comment-light.svg'), - ICON_DETAIL_SHARE: require('@/static/detail/icon-share-light.svg'), - ICON_GUIDE_BAR_PUBLISH: require('@/static/common/guide-bar-publish.svg'), - ICON_NAVIGATOR_BACK: require('@/static/common/navigator-back.svg'), - ICON_LIST_PLAYING_GAME: require('@/static/list/icon-paying-game.svg'), - ICON_LIST_LOAD_ERROR: require('@/static/list/icon-load-error.svg'), - ICON_LIST_RELOAD: require('@/static/list/icon-reload.svg'), - ICON_LIST_EMPTY: require('@/static/emptyStatus/publish-empty.png'), - ICON_LIST_EMPTY_CARD: require('@/static/emptyStatus/publish-empty-card.png'), - ICON_LIST_SEARCH_SEARCH: require('@/static/search/icon-search.svg'), - ICON_LIST_SEARCH_BACK: require('@/static/search/icon-back.svg'), - ICON_LIST_SEARCH_CLEAR: require('@/static/search/icon-search-clear.svg'), - ICON_LIST_SEARCH_CLEAR_HISTORY: require('@/static/search/icon-clear-history.svg'), - ICON_LIST_SEARCH_SUGGESTION: require('@/static/search/icon-search-suggestion.svg'), - ICON_LIST_INPUT_LOGO: require('@/static/list/icon-input-logo.svg'), - ICON_IMPORTANT_BTN: require('@/static/publishBall/icon-important-btn.svg'), - ICON_IMPORTANT_BLACK: require('@/static/publishBall/icon-important-black.svg'), - ICON_ARROW_RIGHT_WHITE: require('@/static/publishBall/icon-arrow-right-white.svg'), - ICON_ARROW_RIGHT_BLACK: require('@/static/publishBall/icon-arrow-right-black.svg'), - ICON_EXAMINATION: require('@/static/userInfo/examination.svg'), - ICON_ARROW_GREEN: require('@/static/userInfo/arrow-green.svg'), - ICON_COPY: require('@/static/publishBall/icon-copy.svg'), - ICON_UPLOAD_IMG: require('@/static/publishBall/icon-upload-img.svg'), - ICON_UPLOAD_SUCCESS: require('@/static/publishBall/icon-upload-success.svg'), - ICON_CLOSE: require('@/static/publishBall/icon-close.svg'), - ICON_LIST_NTPR: require('@/static/list/ntpr.svg'), - ICON_LIST_CHANGDA: require('@/static/list/icon-changda.svg'), - ICON_LIST_CHANGDA_QIuju: require('@/static/list/changdaqiuju.png'), - ICON_RELOCATE: require('@/static/list/icon-relocate.svg'), - } + ICON_REMOVE: require("@/static/publishBall/icon-remove.svg"), + ICON_UPLOAD: require("@/static/publishBall/icon-upload.svg"), + ICON_LOCATION: require("@/static/publishBall/icon-location.svg"), + ICON_GAMEPLAY: require("@/static/publishBall/icon-gameplay.svg"), + ICON_PERSONAL: require("@/static/publishBall/icon-personal.svg"), + ICON_CHANGDA: require("@/static/publishBall/icon-changda.svg"), + ICON_COST: require("@/static/publishBall/icon-cost.svg"), + ICON_TIPS: require("@/static/publishBall/icon-tips.svg"), + ICON_ARROW_RIGHT: require("@/static/publishBall/icon-arrow-right.svg"), + ICON_FILTER: require("@/static/list/icon-filter.svg"), + ICON_FILTER_SELECTED: require("@/static/list/icon-filter-selected.svg"), + ICON_SEARCH: require("@/static/list/icon-search.svg"), + ICON_PLAY: require("@/static/list/icon-play.svg"), + ICON_SITE: require("@/static/list/icon-site.svg"), + ICON_ARROW_DOWN: require("@/static/list/icon-arrow-down.svg"), + ICON_MENU_ITEM_SELECTED: require("@/static/list/icon-menu-item-selected.svg"), + ICON_ARROW_DOWN_WHITE: require("@/static/list/icon-arrow-down-white.svg"), + ICON_LIST_RIGHT_ARROW: require("@/static/list/icon-list-right-arrow.svg"), + ICON_ARROW_LEFT: require("@/static/detail/icon-arrow-left.svg"), + ICON_LOGO_GO: require("@/static/detail/icon-logo-go.svg"), + ICON_MAP: require("@/static/publishBall/icon-map.svg"), + ICON_STADIUM: require("@/static/publishBall/icon-stadium.svg"), + ICON_ARRORW_SMALL: require("@/static/publishBall/icon-arrow-small.svg"), + ICON_MAP_SEARCH: require("@/static/publishBall/icon-map-search.svg"), + ICON_HEART_CIRCLE: require("@/static/publishBall/icon-heartcircle.png"), + ICON_ADD: require("@/static/publishBall/icon-add.svg"), + ICON_COPY: require("@/static/publishBall/icon-arrow-right.svg"), + ICON_DELETE: require("@/static/publishBall/icon-delete.svg"), + ICON_RIGHT_MAX: require("@/static/publishBall/icon-right-max.svg"), + ICON_PLUS: require("@/static/publishBall/icon-plus.svg"), + ICON_GROUP: require("@/static/publishBall/icon-group.svg"), + ICON_PERSON: require("@/static/publishBall/icon-person.svg"), + ICON_PUBLISH: require("@/static/publishBall/icon-publish.png"), + ICON_CIRCLE_UNSELECT: require("@/static/publishBall/icon-circle-unselect.svg"), + ICON_CIRCLE_SELECT: require("@/static/publishBall/icon-circle-select-ring.svg"), + ICON_CIRCLE_SELECT_ARROW: require("@/static/publishBall/icon-circle-select-arrow.svg"), + ICON_LOGO: require("@/static/logo.svg"), + ICON_CHANGE: require("@/static/list/icon-change.svg"), + ICON_DETAIL_MAP: require("@/static/detail/icon-map.svg"), + ICON_DETAIL_ARROW_RIGHT: require("@/static/detail/icon-arrow-right.svg"), + ICON_DETAIL_NOTICE: require("@/static/detail/icon-notice.svg"), + ICON_DETAIL_APPLICATION_ADD: require("@/static/detail/icon-application-add.svg"), + ICON_DETAIL_COMMENT: require("@/static/detail/icon-comment.svg"), + ICON_DETAIL_COMMENT_LIGHT: require("@/static/detail/icon-comment-light.svg"), + ICON_DETAIL_SHARE: require("@/static/detail/icon-share-light.svg"), + ICON_GUIDE_BAR_PUBLISH: require("@/static/common/guide-bar-publish.svg"), + ICON_NAVIGATOR_BACK: require("@/static/common/navigator-back.svg"), + ICON_LIST_PLAYING_GAME: require("@/static/list/icon-paying-game.svg"), + ICON_LIST_LOAD_ERROR: require("@/static/list/icon-load-error.svg"), + ICON_LIST_RELOAD: require("@/static/list/icon-reload.svg"), + ICON_LIST_EMPTY: require("@/static/emptyStatus/publish-empty.png"), + ICON_LIST_EMPTY_CARD: `${OSS_BASE}/front/ball/images/publish-empty-card.svg`, + ICON_LIST_SEARCH_SEARCH: require("@/static/search/icon-search.svg"), + ICON_LIST_SEARCH_BACK: require("@/static/search/icon-back.svg"), + ICON_LIST_SEARCH_CLEAR: require("@/static/search/icon-search-clear.svg"), + ICON_LIST_SEARCH_CLEAR_HISTORY: require("@/static/search/icon-clear-history.svg"), + ICON_LIST_SEARCH_SUGGESTION: require("@/static/search/icon-search-suggestion.svg"), + ICON_LIST_INPUT_LOGO: require("@/static/list/icon-input-logo.svg"), + ICON_IMPORTANT_BTN: require("@/static/publishBall/icon-important-btn.svg"), + ICON_IMPORTANT_BLACK: require("@/static/publishBall/icon-important-black.svg"), + ICON_ARROW_RIGHT_WHITE: require("@/static/publishBall/icon-arrow-right-white.svg"), + ICON_ARROW_RIGHT_BLACK: require("@/static/publishBall/icon-arrow-right-black.svg"), + ICON_EXAMINATION: require("@/static/userInfo/examination.svg"), + ICON_ARROW_GREEN: require("@/static/userInfo/arrow-green.svg"), + ICON_COPY: require("@/static/publishBall/icon-copy.svg"), + ICON_UPLOAD_IMG: require("@/static/publishBall/icon-upload-img.svg"), + ICON_UPLOAD_SUCCESS: require("@/static/publishBall/icon-upload-success.svg"), + ICON_CLOSE: require("@/static/publishBall/icon-close.svg"), + ICON_LIST_NTPR: require("@/static/list/ntpr.svg"), + ICON_LIST_CHANGDA: require("@/static/list/icon-changda.svg"), + ICON_LIST_CHANGDA_QIuju: require("@/static/list/changdaqiuju.png"), + ICON_RELOCATE: require("@/static/list/icon-relocate.svg"), +}; diff --git a/src/login_pages/index/index.tsx b/src/login_pages/index/index.tsx index d5c85e3..fa3ee27 100644 --- a/src/login_pages/index/index.tsx +++ b/src/login_pages/index/index.tsx @@ -1,6 +1,7 @@ import React, { useState } from "react"; import { View, Text, Button, Image } from "@tarojs/components"; import Taro, { useRouter } from "@tarojs/taro"; +import { GeneralNavbar } from "@/components"; import { wechat_auth_login, save_login_state, @@ -171,6 +172,8 @@ const LoginPage: React.FC = () => { + + {/* 主要内容 */} {/* 品牌区域 */} @@ -216,9 +219,9 @@ const LoginPage: React.FC = () => { 手机号快捷登录 - + {/* 返回首页 - + */} {/* 用户协议复选框 */} diff --git a/src/main_pages/components/MyselfPageContent.tsx b/src/main_pages/components/MyselfPageContent.tsx index 81a3296..7c9145f 100644 --- a/src/main_pages/components/MyselfPageContent.tsx +++ b/src/main_pages/components/MyselfPageContent.tsx @@ -16,7 +16,9 @@ interface MyselfPageContentProps { isActive?: boolean; } -const MyselfPageContent: React.FC = ({ isActive = true }) => { +const MyselfPageContent: React.FC = ({ + isActive = true, +}) => { const pickerOption = usePickerOption(); const { statusNavbarHeightInfo } = useGlobalState() || {}; const { totalHeight = 98 } = statusNavbarHeightInfo || {}; @@ -65,20 +67,22 @@ const MyselfPageContent: React.FC = ({ isActive = true } game_records: TennisMatch[] ): { notEndGames: TennisMatch[]; finishedGames: TennisMatch[] } => { const now = new Date().getTime(); - return game_records.reduce( - (result, cur) => { - let { end_time } = cur; - end_time = end_time.replace(/\s/, "T"); - new Date(end_time).getTime() > now - ? result.notEndGames.push(cur) - : result.finishedGames.push(cur); - return result; - }, - { - notEndGames: [] as TennisMatch[], - finishedGames: [] as TennisMatch[], - } - ); + + // 使用for + const notEndGames: TennisMatch[] = []; + const finishedGames: TennisMatch[] = []; + for (const game of game_records) { + const { end_time } = game; + const end_time_str = end_time.replace(/\s/, "T"); + new Date(end_time_str).getTime() > now + ? notEndGames.push(game) + : finishedGames.push(game); + } + + console.log("notEndGames", notEndGames); + + return { notEndGames, finishedGames }; + }, [] ); @@ -95,6 +99,8 @@ const MyselfPageContent: React.FC = ({ isActive = true } } else { games_data = await UserService.get_participated_games(user_info.id); } + + const sorted_games = games_data.sort((a, b) => { return ( new Date(a.original_start_time.replace(/\s/, "T")).getTime() - @@ -102,6 +108,8 @@ const MyselfPageContent: React.FC = ({ isActive = true } ); }); const { notEndGames, finishedGames } = classifyGameRecords(sorted_games); + console.log("notEndGames", notEndGames); + set_game_records(notEndGames); setEndedGameRecords(finishedGames); } catch (error) { @@ -250,17 +258,15 @@ const MyselfPageContent: React.FC = ({ isActive = true } setActiveTab("hosted")} > 我主办的 setActiveTab("participated")} > 我参与的 @@ -281,16 +287,15 @@ const MyselfPageContent: React.FC = ({ isActive = true } btnImg="ICON_ADD" reload={goPublish} isShowNoData={game_records.length === 0} - loadMoreMatches={() => {}} + loadMoreMatches={() => { }} collapse={true} style={{ paddingBottom: ended_game_records.length ? 0 : "90px", overflow: "hidden", }} listLoadErrorWrapperHeight="fit-content" - listLoadErrorWidth="320px" - listLoadErrorHeight="152px" - listLoadErrorScale="1.2" + listLoadErrorWidth="410px" + listLoadErrorHeight="185px" defaultShowNum={3} /> @@ -308,13 +313,12 @@ const MyselfPageContent: React.FC = ({ isActive = true } error={null} errorImg="ICON_LIST_EMPTY_CARD" isShowNoData={ended_game_records.length === 0} - loadMoreMatches={() => {}} + loadMoreMatches={() => { }} collapse={true} style={{ paddingBottom: "90px", overflow: "hidden" }} listLoadErrorWrapperHeight="fit-content" - listLoadErrorWidth="320px" - listLoadErrorHeight="152px" - listLoadErrorScale="1.2" + listLoadErrorWidth="410px" + listLoadErrorHeight="185px" defaultShowNum={3} /> diff --git a/src/other_pages/comment_reply/index.tsx b/src/other_pages/comment_reply/index.tsx index 6a94d53..ef889cd 100644 --- a/src/other_pages/comment_reply/index.tsx +++ b/src/other_pages/comment_reply/index.tsx @@ -249,7 +249,7 @@ const CommentReply = () => { handleUserClick(e, item.user_id)} /> diff --git a/src/services/userService.ts b/src/services/userService.ts index e1bc150..fe75426 100644 --- a/src/services/userService.ts +++ b/src/services/userService.ts @@ -2,7 +2,7 @@ import { UserInfo } from "@/components/UserInfo"; import { API_CONFIG } from "@/config/api"; import httpService, { ApiResponse } from "./httpService"; import uploadFiles from "./uploadFiles"; -import * as Taro from "@tarojs/taro"; +import * as Taro from "@tarojs/taro"; import getCurrentConfig from "@/config/env"; import { clear_login_state } from "@/services/loginService"; @@ -151,6 +151,7 @@ interface BackendGameData { longitude: string; venue_type: string; surface_type: string; + distance_km: string; }; participants: { user: { @@ -206,7 +207,7 @@ export class UserService { latitude = parseFloat(game.venue_dtl.latitude) || latitude; longitude = parseFloat(game.venue_dtl.longitude) || longitude; } - const distance = this.calculate_distance(latitude, longitude); + // 处理地点信息 - 优先使用venue_dtl中的信息 let location = game.location_name || game.location || "未知地点"; @@ -227,7 +228,7 @@ export class UserService { original_start_time: game.start_time, end_time: game.end_time || "", location: location, - distance_km: parseFloat(distance.replace("km", "")) || 0, + distance_km: game.venue_dtl?.distance_km , current_players: registered_count, max_players: max_count, skill_level_min: parseInt(game.skill_level_min) || 0, @@ -303,20 +304,7 @@ export class UserService { return `${date_str} ${time_str}`; } - // 计算距离(模拟实现,实际需要根据用户位置计算) - private static calculate_distance( - latitude: number, - longitude: number - ): string { - if (latitude === 0 && longitude === 0) { - return "未知距离"; - } - // 这里应该根据用户当前位置计算实际距离 - // 暂时返回模拟距离 - const distances = ["1.2km", "2.5km", "3.8km", "5.1km", "7.3km"]; - return distances[Math.floor(Math.random() * distances.length)]; - } // 获取用户信息 static async get_user_info(user_id?: string): Promise { try { @@ -330,7 +318,7 @@ export class UserService { if (response.code === 0) { const userData = response.data; - + return { id: userData.id || "", nickname: userData.nickname || "", @@ -359,8 +347,6 @@ export class UserService { last_location_province: userData.last_location_province || "", last_location_city: userData.last_location_city || "", }; - - } else { throw new Error(response.message || "获取用户信息失败"); } @@ -747,7 +733,7 @@ export const updateUserLocation = async ( const response = await httpService.post("/user/update_location", { latitude, longitude, - force + force, }); return response; } catch (error) { diff --git a/src/static/emptyStatus/publish-empty-card.png b/src/static/emptyStatus/publish-empty-card.png deleted file mode 100644 index 95da019..0000000 Binary files a/src/static/emptyStatus/publish-empty-card.png and /dev/null differ diff --git a/src/store/pickerOptionsStore.ts b/src/store/pickerOptionsStore.ts index 0c7ccc4..af789a8 100644 --- a/src/store/pickerOptionsStore.ts +++ b/src/store/pickerOptionsStore.ts @@ -5,7 +5,7 @@ import { UserService } from "@/services/userService"; export interface PickerOptionState { cities: any[]; professions: any[]; - ntrpLevels: string[]; + ntrpLevels: any[]; getCities: () => Promise; getProfessions: () => Promise; } @@ -13,7 +13,40 @@ export interface PickerOptionState { export const usePickerOption = create((set) => ({ cities: [], professions: [], - ntrpLevels: ["1.5", "2.0", "2.5", "3.0", "3.5", "4.0", "4.5", "4.5+"], + ntrpLevels: [ + { + text: "1.5", + value: "1.5", + }, + { + text: "2.0", + value: "2.0", + }, + { + text: "2.5", + value: "2.5", + }, + { + text: "3.0", + value: "3.0", + }, + { + text: "3.5", + value: "3.5", + }, + { + text: "4.0", + value: "4.0", + }, + { + text: "4.5", + value: "4.5", + }, + { + text: "4.5+", + value: "4.5+", + }, + ], getCities: async () => { try { const res = await UserService.getCities(); diff --git a/src/store/userStore.ts b/src/store/userStore.ts index b7f839f..4912277 100644 --- a/src/store/userStore.ts +++ b/src/store/userStore.ts @@ -8,7 +8,9 @@ import { NicknameChangeStatus, updateNickname as updateNicknameApi, } from "@/services/userService"; -import evaluateService, { LastTimeTestResult } from "@/services/evaluateService"; +import evaluateService, { + LastTimeTestResult, +} from "@/services/evaluateService"; import { useListStore } from "./listStore"; export interface UserState { @@ -23,7 +25,6 @@ export interface UserState { fetchLastTestResult: () => Promise; } - const getTimeNextDate = (time: string) => { const date = new Date(time); date.setDate(date.getDate() + 1); @@ -51,8 +52,6 @@ export const useUser = create()((set) => ({ const cachedCity = (Taro as any).getStorageSync?.(CITY_CACHE_KEY); - - if (cachedCity && Array.isArray(cachedCity) && cachedCity.length === 2) { // 如果有缓存的城市,使用缓存,不更新 area console.log("[userStore] 检测到缓存的城市,使用缓存,不更新 area"); @@ -66,7 +65,10 @@ export const useUser = create()((set) => ({ // 只有当 area 不存在时才使用用户信息中的位置 if (!currentArea) { - const newArea: [string, string] = [userData.last_location_province||"", userData.last_location_city||""]; + const newArea: [string, string] = [ + userData.last_location_province || "", + userData.last_location_city || "", + ]; listStore.updateArea(newArea); // 保存到缓存 useUser.getState().updateCache(newArea); @@ -102,8 +104,14 @@ export const useUser = create()((set) => ({ const listStore = useListStore.getState(); const currentArea = listStore.area; // 只有当 area 不存在或与 userLastLocationProvince 不一致时才更新 - if (!currentArea || currentArea[1] !== userInfo.last_location_province) { - const newArea: [string, string] = [userInfo.last_location_province || "", userInfo.last_location_city || ""]; + if ( + !currentArea || + currentArea[1] !== userInfo.last_location_province + ) { + const newArea: [string, string] = [ + userInfo.last_location_province || "", + userInfo.last_location_city || "", + ]; listStore.updateArea(newArea); } } @@ -127,7 +135,10 @@ export const useUser = create()((set) => ({ // 如果已经有状态数据且不是强制更新,跳过,避免重复调用 if (!force) { const currentState = useUser.getState(); - if (currentState.nicknameChangeStatus && Object.keys(currentState.nicknameChangeStatus).length > 0) { + if ( + currentState.nicknameChangeStatus && + Object.keys(currentState.nicknameChangeStatus).length > 0 + ) { return; } } diff --git a/src/user_pages/edit/index.tsx b/src/user_pages/edit/index.tsx index 91fde3f..9010dff 100644 --- a/src/user_pages/edit/index.tsx +++ b/src/user_pages/edit/index.tsx @@ -44,6 +44,7 @@ const EditProfilePage: React.FC = () => { country: info?.country ?? "", province: info?.province ?? "", city: info?.city ?? "", + district: info?.district ?? "", }; }; const [form_data, setFormData] = useState(getInitialFormData()); @@ -85,6 +86,7 @@ const EditProfilePage: React.FC = () => { country: info?.country ?? "", province: info?.province ?? "", city: info?.city ?? "", + district: info?.district ?? "", }); } @@ -358,11 +360,11 @@ const EditProfilePage: React.FC = () => { }); return; } - const [country, province, city] = e; + const [province, city, district] = e; handle_field_edit({ - country: String(country ?? ""), province: String(province ?? ""), city: String(city ?? ""), + district: String(district ?? ""), }); }; @@ -660,15 +662,17 @@ const EditProfilePage: React.FC = () => { - {form_data.country || form_data.province || form_data.city - ? `${form_data.country} ${form_data.province} ${form_data.city}` + {form_data.province || + form_data.city || + form_data.district + ? `${form_data.province} ${form_data.city} ${form_data.district}` : "选择所在地区"} { visible={location_picker_visible} setvisible={setLocationPickerVisible} value={ - form_data.country - ? [form_data.country, form_data.province, form_data.city] + form_data.province + ? [form_data.province, form_data.city, form_data.district] : getDefaultOption(cities) } onChange={handle_location_change} @@ -899,15 +903,12 @@ const EditProfilePage: React.FC = () => { title="选择 NTRP 自评水平" confirmText="保存" ntrpTested={ntrpTested} - options={ntrpLevels.map((level) => ({ - text: level, - value: level, - }))} + options={ntrpLevels} type="ntrp" // img={(user_info as UserInfoType)?.avatar_url} visible={ntrp_picker_visible} setvisible={setNtrpPickerVisible} - value={[form_data.ntrp_level || "2.5"]} + value={!form_data.ntrp_level ? ["2.5"] : [form_data.ntrp_level]} onChange={handle_ntrp_level_change} /> )} diff --git a/src/user_pages/other/index.tsx b/src/user_pages/other/index.tsx index 0dd9222..037a915 100644 --- a/src/user_pages/other/index.tsx +++ b/src/user_pages/other/index.tsx @@ -329,9 +329,8 @@ const OtherUserPage: React.FC = () => { overflow: "hidden", }} listLoadErrorWrapperHeight="fit-content" - listLoadErrorWidth="320px" - listLoadErrorHeight="152px" - listLoadErrorScale="1.2" + listLoadErrorWidth="410px" + listLoadErrorHeight="185px" defaultShowNum={3} /> @@ -375,9 +374,8 @@ const OtherUserPage: React.FC = () => { collapse={true} style={{ paddingBottom: "90px", overflow: "hidden" }} listLoadErrorWrapperHeight="fit-content" - listLoadErrorWidth="320px" - listLoadErrorHeight="152px" - listLoadErrorScale="1.2" + listLoadErrorWidth="410px" + listLoadErrorHeight="185px" defaultShowNum={3} />