From f131c9896dff610a62bdc3db74140958a1184e93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=88=90?= Date: Sat, 7 Feb 2026 18:07:33 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9oss=20=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app.scss | 5 +- src/components/NTRPTestEntryCard/index.tsx | 6 +- src/components/Radar/indexV2.tsx | 4 +- src/components/ShareCardCanvas/index.tsx | 8 +- src/config/api.ts | 7 +- .../detail/components/SharePopup/index.tsx | 6 +- src/game_pages/sharePoster/index.tsx | 4 +- .../components/MyselfPageContent.tsx | 21 ++++ src/order_pages/orderDetail/index.tsx | 4 +- src/order_pages/orderList/index.tsx | 21 ++++ .../enable_notification/index.config.ts | 2 +- .../enable_notification/index.scss | 3 +- src/other_pages/ntrp-evaluate/index.tsx | 14 +-- src/user_pages/other/index.tsx | 108 ++++++++++-------- src/user_pages/wallet/index.scss | 11 +- src/user_pages/wallet/index.tsx | 55 ++++++--- src/utils/genPoster.ts | 19 +-- src/utils/share.ts | 8 +- 18 files changed, 195 insertions(+), 111 deletions(-) diff --git a/src/app.scss b/src/app.scss index 58ee657..44e4d57 100644 --- a/src/app.scss +++ b/src/app.scss @@ -19,8 +19,7 @@ page { @font-face { font-family: "Quicksand"; - // 注意:此路径来自 @/config/api.ts 中的 OSS_BASE_URL 配置 - // 如需修改,请更新配置文件中的 OSS_BASE_URL - src: url("https://youchang2026.oss-cn-shanghai.aliyuncs.com/front/ball/other/57dc951f-f10e-45b7-9157-0b1e468187fd.ttf") format("truetype"); + // 注意:此路径对应 @/config/api.ts 中的 OSS_BASE + src: url("https://bimwe-oss.oss-cn-shanghai.aliyuncs.com/front/ball/other/57dc951f-f10e-45b7-9157-0b1e468187fd.ttf") format("truetype"); font-display: swap; } \ No newline at end of file diff --git a/src/components/NTRPTestEntryCard/index.tsx b/src/components/NTRPTestEntryCard/index.tsx index 23b58e6..3004bf7 100644 --- a/src/components/NTRPTestEntryCard/index.tsx +++ b/src/components/NTRPTestEntryCard/index.tsx @@ -8,7 +8,7 @@ import { useLastTestResult, } from "@/store/userStore"; // import { getCurrentFullPath } from "@/utils"; -import { OSS_BASE_URL } from "@/config/api"; +import { OSS_BASE } from "@/config/api"; import { StageType } from "@/services/evaluateService"; import { waitForAuthInit } from "@/utils/authInit"; import DocCopy from "@/static/ntrp/ntrp_doc_copy.svg"; @@ -148,7 +148,7 @@ function NTRPTestEntryCard(props: { @@ -188,7 +188,7 @@ function NTRPTestEntryCard(props: { diff --git a/src/components/Radar/indexV2.tsx b/src/components/Radar/indexV2.tsx index ab1e276..7d223b4 100644 --- a/src/components/Radar/indexV2.tsx +++ b/src/components/Radar/indexV2.tsx @@ -3,7 +3,7 @@ import { View, Canvas } from "@tarojs/components"; import { forwardRef, useImperativeHandle } from "react"; import shareLogoSvg from "@/static/ntrp/ntrp_share_logo.png"; import docCopyPng from "@/static/ntrp/ntrp_doc_copy.png"; -import { OSS_BASE_URL } from "@/config/api"; +import { OSS_BASE } from "@/config/api"; interface RadarChartV2Props { data: [string, number][]; @@ -233,7 +233,7 @@ const RadarChartV2 = forwardRef((props, ref) // 绘制背景 - 使用 share_bg.png 背景图,撑满整个画布(从 OSS 动态加载) try { - const shareBgUrl = `${OSS_BASE_URL}/images/share_bg.png`; + const shareBgUrl = `${OSS_BASE}/front/ball/images/share_bg.png`; const bgImg = await loadImage(canvas, shareBgUrl); ctx.drawImage(bgImg, 0, 0, width, height); } catch (error) { diff --git a/src/components/ShareCardCanvas/index.tsx b/src/components/ShareCardCanvas/index.tsx index da83484..e1c48fc 100644 --- a/src/components/ShareCardCanvas/index.tsx +++ b/src/components/ShareCardCanvas/index.tsx @@ -1,7 +1,7 @@ import React, { useEffect, useState } from 'react' import { View, Canvas } from '@tarojs/components' import Taro from '@tarojs/taro' -import { OSS_BASE_URL } from "@/config/api"; +import { OSS_BASE } from "@/config/api"; // 分享卡片数据接口 export interface ShareCardData { @@ -506,7 +506,7 @@ const ShareCardCanvas: React.FC = ({ const textX = iconX + iconSize + 20 // 绘制网球图标 - const tennisBallPath = await loadImage(`${OSS_BASE_URL}/images/b3eaf45e-ef28-4e45-9195-823b832e0451.jpg`, canvasNode) + const tennisBallPath = await loadImage(`${OSS_BASE}/front/ball/images/b3eaf45e-ef28-4e45-9195-823b832e0451.jpg`, canvasNode) ctx.drawImage(tennisBallPath, iconX, gameInfoY, iconSize, iconSize) // 绘制"单打"标签 @@ -542,7 +542,7 @@ const ShareCardCanvas: React.FC = ({ const dateX = danDaX const timeInfoY = infoStartY + infoSpacing const timeInfoFontSize = scale * 24 * dpr - const calendarPath = await loadImage(`${OSS_BASE_URL}/images/ea792a5d-b105-4c95-bfc4-8af558f2b33b.jpg`, canvasNode) + const calendarPath = await loadImage(`${OSS_BASE}/front/ball/images/ea792a5d-b105-4c95-bfc4-8af558f2b33b.jpg`, canvasNode) ctx.drawImage(calendarPath, iconX, timeInfoY, iconSize, iconSize) // 绘制日期(绿色) @@ -556,7 +556,7 @@ const ShareCardCanvas: React.FC = ({ // 绘制地点 const locationInfoY = infoStartY + infoSpacing * 2 const locationFontSize = scale * 22 * dpr - const locationPath = await loadImage(`${OSS_BASE_URL}/images/adc9a167-2ea9-4e3b-b963-6a894a1fd91b.jpg`, canvasNode) + const locationPath = await loadImage(`${OSS_BASE}/front/ball/images/adc9a167-2ea9-4e3b-b963-6a894a1fd91b.jpg`, canvasNode) ctx.drawImage(locationPath, iconX, locationInfoY, iconSize, iconSize) drawBoldText(ctx, data.venueName, danDaX, locationInfoY + 10, locationFontSize, '#000000') diff --git a/src/config/api.ts b/src/config/api.ts index 262666c..113ef40 100644 --- a/src/config/api.ts +++ b/src/config/api.ts @@ -1,7 +1,10 @@ import envConfig from './env'// API配置 -// OSS 基础路径配置 -export const OSS_BASE_URL = 'https://youchang2026.oss-cn-shanghai.aliyuncs.com/front/ball' +// OSS 配置:仅域名,调用处拼接 /front/ball 及后续路径 +export const OSS_BASE = "https://bimwe-oss.oss-cn-shanghai.aliyuncs.com"; + +// 因乐驰OSS 配置:仅域名,调用处拼接 /front/ball 及后续路径 +// export const OSS_BASE = "https://youchang2026.oss-cn-shanghai.aliyuncs.com"; export const API_CONFIG = { // 基础URL diff --git a/src/game_pages/detail/components/SharePopup/index.tsx b/src/game_pages/detail/components/SharePopup/index.tsx index 9abe2d8..d8cee88 100644 --- a/src/game_pages/detail/components/SharePopup/index.tsx +++ b/src/game_pages/detail/components/SharePopup/index.tsx @@ -15,7 +15,7 @@ import CrossIcon from "@/static/detail/cross.svg"; import { genNTRPRequirementText, navto } from "@/utils/helper"; import { waitForAuthInit } from "@/utils/authInit"; import { useUserActions } from "@/store/userStore"; -import { OSS_BASE_URL } from "@/config/api"; +import { OSS_BASE } from "@/config/api"; import { generatePosterImage, base64ToTempFilePath, delay } from "@/utils"; import { DayOfWeekMap } from "../../config"; import styles from "./index.module.scss"; @@ -145,7 +145,7 @@ export default forwardRef(({ id, from, detail, userInfo }, ref) => { mainCoursal: image_list[0] && image_list[0].startsWith("http") ? image_list[0] - : `${OSS_BASE_URL}/images/0621b8cf-f7d6-43ad-b852-7dc39f29a782.png`, + : `${OSS_BASE}/front/ball/images/0621b8cf-f7d6-43ad-b852-7dc39f29a782.png`, nickname, avatarUrl: avatar_url, title, @@ -207,7 +207,7 @@ export default forwardRef(({ id, from, detail, userInfo }, ref) => { = ({ isActive = true } const [hasLoaded, setHasLoaded] = useState(false); // 记录是否已经加载过数据 const [collapseProfile, setCollapseProfile] = useState(false); + const [refreshing, setRefreshing] = useState(false); useEffect(() => { pickerOption.getCities(); @@ -169,6 +170,23 @@ const MyselfPageContent: React.FC = ({ isActive = true } setActiveTab(tab); }; + // 下拉刷新:刷新用户信息和球局数据 + const handle_refresh = async () => { + setRefreshing(true); + try { + await Promise.all([fetchUserInfo(), load_game_data()]); + } catch (error) { + console.error("刷新失败:", error); + (Taro as any).showToast({ + title: "刷新失败,请重试", + icon: "none", + duration: 2000, + }); + } finally { + setRefreshing(false); + } + }; + // const handleScroll = (event: any) => { // const scrollData = event.detail; // setCollapseProfile(scrollData.scrollTop > 1); @@ -178,6 +196,9 @@ const MyselfPageContent: React.FC = ({ isActive = true } {/* location message */} diff --git a/src/order_pages/orderList/index.tsx b/src/order_pages/orderList/index.tsx index 046356e..760cae5 100644 --- a/src/order_pages/orderList/index.tsx +++ b/src/order_pages/orderList/index.tsx @@ -69,6 +69,7 @@ function generateTimeMsg(game_info) { const OrderList = () => { const [list, setList] = useState([]); const [total, setTotal] = useState(0); + const [refreshing, setRefreshing] = useState(false); const refundRef = useRef(null); const end = list.length * PAGESIZE >= total; @@ -114,6 +115,22 @@ const OrderList = () => { } } + // 下拉刷新:重新加载第一页订单 + async function handle_refresh() { + setRefreshing(true); + try { + await getOrders(1); + } catch (error) { + Taro.showToast({ + title: "刷新失败,请重试", + icon: "none", + duration: 2000, + }); + } finally { + setRefreshing(false); + } + } + async function handlePayNow(item) { // 检查登录状态和手机号 if (!requireLoginWithPhone()) { @@ -285,6 +302,10 @@ const OrderList = () => { scrollWithAnimation lowerThreshold={20} onScrollToLower={handleFetchNext} + refresherBackground="#FAFAFA" + refresherEnabled + refresherTriggered={refreshing} + onRefresherRefresh={handle_refresh} enhanced showScrollbar={false} className={styles.list} diff --git a/src/other_pages/enable_notification/index.config.ts b/src/other_pages/enable_notification/index.config.ts index d50d007..9adf962 100644 --- a/src/other_pages/enable_notification/index.config.ts +++ b/src/other_pages/enable_notification/index.config.ts @@ -1,6 +1,6 @@ export default definePageConfig({ navigationBarTitleText: '开启消息通知', navigationStyle: 'custom', - enablePullDownRefresh: false, + backgroundColor:"#FAFAFA" }); diff --git a/src/other_pages/enable_notification/index.scss b/src/other_pages/enable_notification/index.scss index b2e1ca5..f5fbae8 100644 --- a/src/other_pages/enable_notification/index.scss +++ b/src/other_pages/enable_notification/index.scss @@ -1,7 +1,7 @@ .enable_notification_page { width: 100%; // min-height: 100vh; - background: radial-gradient(circle at 50% 0%, rgba(191, 255, 239, 1) 0%, rgba(255, 255, 255, 1) 37%); + // background: radial-gradient(circle at 50% 0%, rgba(191, 255, 239, 1) 0%, rgba(255, 255, 255, 1) 37%); display: flex; flex-direction: column; @@ -29,7 +29,6 @@ align-items: center; gap: 8px; padding: 10px 16px; - background: #ffffff; border: 0.5px solid rgba(0, 0, 0, 0.08); border-radius: 20px; box-shadow: 0px 4px 20px 0px rgba(0, 0, 0, 0.08); diff --git a/src/other_pages/ntrp-evaluate/index.tsx b/src/other_pages/ntrp-evaluate/index.tsx index be26a95..3a9d20f 100644 --- a/src/other_pages/ntrp-evaluate/index.tsx +++ b/src/other_pages/ntrp-evaluate/index.tsx @@ -18,7 +18,7 @@ import { formatNtrpDisplay } from "@/utils/helper"; import { waitForAuthInit } from "@/utils/authInit"; import httpService from "@/services/httpService"; import DetailService from "@/services/detailService"; -import { OSS_BASE_URL } from "@/config/api"; +import { OSS_BASE } from "@/config/api"; import CloseIcon from "@/static/ntrp/ntrp_close_icon.svg"; import DocCopy from "@/static/ntrp/ntrp_doc_copy.svg"; import ArrowRight from "@/static/ntrp/ntrp_arrow_right.svg"; @@ -225,7 +225,7 @@ function Intro() { @@ -252,7 +252,7 @@ function Intro() { @@ -310,7 +310,7 @@ function Intro() { @@ -318,7 +318,7 @@ function Intro() { @@ -427,7 +427,7 @@ function Test() { @@ -720,7 +720,7 @@ function Result() { diff --git a/src/user_pages/other/index.tsx b/src/user_pages/other/index.tsx index f24e10f..0dd9222 100644 --- a/src/user_pages/other/index.tsx +++ b/src/user_pages/other/index.tsx @@ -68,6 +68,7 @@ const OtherUserPage: React.FC = () => { ); const [collapseProfile, setCollapseProfile] = useState(false); + const [refreshing, setRefreshing] = useState(false); // 进入页面时检查 user_id,只在组件挂载时执行一次 useEffect(() => { @@ -82,56 +83,52 @@ const OtherUserPage: React.FC = () => { } }, []); // 空依赖数组,确保只在进入时执行一次 - // 页面加载时获取用户信息 - useEffect(() => { - const load_user_data = async () => { - if (user_id) { - try { - // const user_data = await UserService.get_user_info(user_id); - const res = await LoginService.getUserInfoById(user_id); - const { data: userData } = res; - // setUserInfo({...res.data as UserInfo, avatar: data.avatar_url || require("@/static/userInfo/default_avatar.svg")}); - setUserInfo({ - id: parseInt(user_id || "") || 0, - nickname: userData.nickname || "", - avatar_url: userData.avatar_url || "", - join_date: userData.subscribe_time - ? `${new Date(userData.subscribe_time).getFullYear()}年${ - new Date(userData.subscribe_time).getMonth() + 1 - }月加入` - : "", - stats: { - following_count: userData.stats?.following_count || 0, - followers_count: userData.stats?.followers_count || 0, - hosted_games_count: userData.stats?.hosted_games_count || 0, - participated_games_count: - userData.stats?.participated_games_count || 0, - }, - - personal_profile: userData.personal_profile || "", - province: userData.province || "", - city: userData.city || "", - district: userData.district || "", - occupation: userData.occupation || "", - ntrp_level: "", - phone: userData.phone || "", - gender: userData.gender || "", - birthday: userData.birthday || "", - }); - setIsFollowing(userData.is_following || false); - } catch (error) { - console.error("加载用户数据失败:", error); - Taro.showToast({ - title: "加载失败", - icon: "none", - }); - } - } - }; - - load_user_data(); + // 加载用户信息(使用 useCallback 便于下拉刷新复用) + const load_user_data = useCallback(async () => { + if (!user_id) return; + try { + const res = await LoginService.getUserInfoById(user_id); + const { data: userData } = res; + setUserInfo({ + id: parseInt(user_id || "") || 0, + nickname: userData.nickname || "", + avatar_url: userData.avatar_url || "", + join_date: userData.subscribe_time + ? `${new Date(userData.subscribe_time).getFullYear()}年${ + new Date(userData.subscribe_time).getMonth() + 1 + }月加入` + : "", + stats: { + following_count: userData.stats?.following_count || 0, + followers_count: userData.stats?.followers_count || 0, + hosted_games_count: userData.stats?.hosted_games_count || 0, + participated_games_count: + userData.stats?.participated_games_count || 0, + }, + personal_profile: userData.personal_profile || "", + province: userData.province || "", + city: userData.city || "", + district: userData.district || "", + occupation: userData.occupation || "", + ntrp_level: "", + phone: userData.phone || "", + gender: userData.gender || "", + birthday: userData.birthday || "", + }); + setIsFollowing(userData.is_following || false); + } catch (error) { + console.error("加载用户数据失败:", error); + Taro.showToast({ + title: "加载失败", + icon: "none", + }); + } }, [user_id]); + useEffect(() => { + load_user_data(); + }, [load_user_data]); + // 分类球局数据(使用 useCallback 包装,避免每次渲染都创建新函数) const classifyGameRecords = useCallback( ( @@ -232,6 +229,18 @@ const OtherUserPage: React.FC = () => { setCollapseProfile(scrollData.scrollTop > 1); }, []); + // 下拉刷新:刷新用户信息和球局数据 + const handle_refresh = useCallback(async () => { + setRefreshing(true); + try { + await Promise.all([load_user_data(), load_game_data()]); + } catch (error) { + console.error("刷新失败:", error); + } finally { + setRefreshing(false); + } + }, [load_user_data, load_game_data]); + // 处理球局详情 // const handle_game_detail = (game_id: string) => { // Taro.navigateTo({ @@ -244,6 +253,9 @@ const OtherUserPage: React.FC = () => { scrollY className="other_user_page" refresherBackground="#FAFAFA" + refresherEnabled + refresherTriggered={refreshing} + onRefresherRefresh={handle_refresh} > {/* diff --git a/src/user_pages/wallet/index.scss b/src/user_pages/wallet/index.scss index d63145a..407a050 100644 --- a/src/user_pages/wallet/index.scss +++ b/src/user_pages/wallet/index.scss @@ -1,12 +1,19 @@ // @use '../../scss/common.scss' as *; .wallet_page { + display: flex; + flex-direction: column; height: 100vh; - overflow-y: auto; + overflow: hidden; background-color: #fafafa; - padding-bottom: 5px; box-sizing: border-box; + .wallet_scroll { + flex: 1; + height: 0; + padding-bottom: 5px; + } + &::-webkit-scrollbar { display: none; width: 0; diff --git a/src/user_pages/wallet/index.tsx b/src/user_pages/wallet/index.tsx index 86f0590..46f4c0a 100644 --- a/src/user_pages/wallet/index.tsx +++ b/src/user_pages/wallet/index.tsx @@ -1,6 +1,6 @@ -import React, { useEffect, useState } from "react"; -import { View, Text, Input, Button, Image } from "@tarojs/components"; -import Taro, { useDidShow, useReachBottom } from "@tarojs/taro"; +import React, { useEffect, useState, useCallback } from "react"; +import { View, Text, Input, Button, Image, ScrollView } from "@tarojs/components"; +import Taro, { useDidShow } from "@tarojs/taro"; import "./index.scss"; import { CommonPopup, EmptyState } from "@/components"; import httpService from "@/services/httpService"; @@ -109,16 +109,6 @@ const WalletPage: React.FC = () => { const pageConfig = currentPage.page?.config; const pageTitle = pageConfig?.navigationBarTitleText; - useReachBottom(() => { - if (load_transactions_params.page >= totalPages) return; - // 加载更多方法 - set_load_transactions_params((prev) => { - return { - ...prev, - page: prev.page + 1, - }; - }); - }); // 钱包信息状态 const [wallet_info, set_wallet_info] = useState({ balance: 0, @@ -158,6 +148,7 @@ const WalletPage: React.FC = () => { }); const [totalPages, setTotalPages] = useState(1); + const [refreshing, setRefreshing] = useState(false); useEffect(() => { load_transactions(); @@ -452,6 +443,33 @@ const WalletPage: React.FC = () => { setShowFilterPopup(true); }; + // 下拉刷新:刷新钱包余额和交易记录 + const handle_refresh = useCallback(async () => { + setRefreshing(true); + try { + await load_wallet_data(); + set_transactions([]); + set_load_transactions_params((prev) => ({ ...prev, page: 1 })); + } catch (error) { + Taro.showToast({ + title: "刷新失败,请重试", + icon: "none", + duration: 2000, + }); + } finally { + setRefreshing(false); + } + }, []); + + // 滚动到底部加载更多交易记录 + const handle_scroll_to_lower = useCallback(() => { + if (load_transactions_params.page >= totalPages) return; + set_load_transactions_params((prev) => ({ + ...prev, + page: prev.page + 1, + })); + }, [load_transactions_params.page, totalPages]); + const handleFilterCancel = () => { setShowFilterPopup(false); setFilterParams({ @@ -488,6 +506,16 @@ const WalletPage: React.FC = () => { Taro.navigateBack(); }} /> + {/* 钱包主卡片 */} { )} + {/* 提现弹窗 */} { return new Promise((resolve, reject) => { diff --git a/src/utils/share.ts b/src/utils/share.ts index 8e60115..5adc4ea 100644 --- a/src/utils/share.ts +++ b/src/utils/share.ts @@ -1,5 +1,5 @@ import Taro from '@tarojs/taro' -import { OSS_BASE_URL } from "@/config/api"; +import { OSS_BASE } from "@/config/api"; export interface ShareCardData { userAvatar: string @@ -481,7 +481,7 @@ const drawShareCard = async (ctx: any, data: ShareCardData, offscreen: any): Pro const textX = iconX + iconSize + 20 // 绘制网球图标 - const tennisBallPath = await loadImage(`${OSS_BASE_URL}/images/b3eaf45e-ef28-4e45-9195-823b832e0451.jpg`) + const tennisBallPath = await loadImage(`${OSS_BASE}/front/ball/images/b3eaf45e-ef28-4e45-9195-823b832e0451.jpg`) ctx.drawImage(tennisBallPath, iconX, gameInfoY, iconSize, iconSize) // 绘制"单打"标签 @@ -517,7 +517,7 @@ const drawShareCard = async (ctx: any, data: ShareCardData, offscreen: any): Pro const dateX = danDaX const timeInfoY = infoStartY + infoSpacing const timeInfoFontSize = scale * 24 * dpr - const calendarPath = await loadImage(`${OSS_BASE_URL}/images/ea792a5d-b105-4c95-bfc4-8af558f2b33b.jpg`) + const calendarPath = await loadImage(`${OSS_BASE}/front/ball/images/ea792a5d-b105-4c95-bfc4-8af558f2b33b.jpg`) ctx.drawImage(calendarPath, iconX, timeInfoY, iconSize, iconSize) // 绘制日期(绿色,非描边粗体) @@ -530,7 +530,7 @@ const drawShareCard = async (ctx: any, data: ShareCardData, offscreen: any): Pro // 绘制地点 const locationInfoY = infoStartY + infoSpacing * 2 const locationFontSize = scale * 22 * dpr - const locationPath = await loadImage(`${OSS_BASE_URL}/images/adc9a167-2ea9-4e3b-b963-6a894a1fd91b.jpg`) + const locationPath = await loadImage(`${OSS_BASE}/front/ball/images/adc9a167-2ea9-4e3b-b963-6a894a1fd91b.jpg`) ctx.drawImage(locationPath, iconX, locationInfoY, iconSize, iconSize) drawBoldText(ctx, data.venueName, danDaX, locationInfoY + 10, locationFontSize, '#000000')