61 Commits

Author SHA1 Message Date
李瑞
99c8026f61 数据为空时允许展示banner 2026-02-11 23:13:49 +08:00
05966b2acb 优化ntrp和性别picker偶尔选不上值 2026-02-10 18:00:26 +08:00
张成
4cf2b959b5 1 2026-02-10 12:42:42 +08:00
张成
43610dcf99 修复首页数据少的问题 2026-02-10 11:46:39 +08:00
张成
05aa820466 Merge branch 'master' of https://git.bimwe.com/bimwe/mini-programs 2026-02-09 22:03:59 +08:00
筱野
b154e31f8f Merge branch 'master' of https://git.bimwe.com/bimwe/mini-programs 2026-02-09 22:03:09 +08:00
筱野
669ee2fe4e 解决按钮问题与键盘弹出问题 2026-02-09 22:03:01 +08:00
张成
281ee2b746 Merge branch 'master' of https://git.bimwe.com/bimwe/mini-programs 2026-02-09 22:02:46 +08:00
张成
132c74d27c 1 2026-02-09 22:02:43 +08:00
李瑞
6b6a4c9480 替换玩法icon 2026-02-09 22:01:36 +08:00
筱野
0f8dd44f5a 解决按钮问题与键盘弹出问题 2026-02-09 21:16:48 +08:00
82ba753b8b Merge remote-tracking branch 'refs/remotes/origin/master' 2026-02-09 20:07:47 +08:00
159d81ed12 fix: 详情管理功能按钮逻辑修改 2026-02-09 20:07:05 +08:00
22965eedf3 个人简介和昵称修改后显示底部导航 2026-02-09 16:36:15 +08:00
49935dd049 优化省市区和占位图片 2026-02-09 13:53:19 +08:00
张成
cab90aa1cb 1 2026-02-09 13:25:13 +08:00
632da5112d feat: 删除小猫 2026-02-09 09:49:43 +08:00
28955e9da1 fix: 修改分享初始化逻辑、去除小猫图 2026-02-08 23:58:37 +08:00
70a66fabdc Merge branch 'feat/liujie' 2026-02-08 22:57:48 +08:00
c47ebce43c fix: 修复取消活动后还可以编辑和取消、详情页参与者卡片展示NTRP 等级、生成海报的图片质量降低到1M以下, 详情页海报与测试结果页海报 2026-02-08 22:57:35 +08:00
b0f4b5713d Merge branch 'master' into feat/liujie 2026-02-08 21:25:19 +08:00
f7f10f5d15 查询下载账单 2026-02-08 16:03:08 +08:00
李瑞
2bcdd93479 Merge branch 'feat/juguohong/20260206' 2026-02-08 12:46:27 +08:00
李瑞
af2c472030 处理图片顺序 2026-02-08 12:46:01 +08:00
张成
8d0ed5b1b3 1 2026-02-08 12:36:21 +08:00
张成
e99986c52a 修改审核不通过的问题 2026-02-08 12:29:48 +08:00
张成
4b2f6707cc 1 2026-02-08 12:18:04 +08:00
张成
a019fe473b Merge branch 'master' of https://git.bimwe.com/bimwe/mini-programs 2026-02-08 12:14:11 +08:00
张成
1d0d2edaa2 修改项目 build 结构 2026-02-08 12:14:10 +08:00
5926e096b5 图片样式优化 2026-02-08 12:09:46 +08:00
筱野
e07f2ad2d1 解决按钮问题与键盘弹出问题 2026-02-07 23:37:28 +08:00
筱野
bfc6a149f0 修改日期问题弹出问题 2026-02-07 22:15:14 +08:00
李瑞
6f73bb6d99 Merge branch 'feat/juguohong/20260206' 2026-02-07 22:09:39 +08:00
李瑞
744169fe34 处理地点展示样式 2026-02-07 22:08:30 +08:00
54b7a27af5 Merge branch 'feat/liujie' 2026-02-07 20:25:51 +08:00
396ff4a347 fix: 修改取值 2026-02-07 20:25:37 +08:00
张成
b732bd361e Merge branch 'master' of https://git.bimwe.com/bimwe/mini-programs 2026-02-07 20:24:50 +08:00
张成
5146894d92 1 2026-02-07 20:24:49 +08:00
张成
07cf8e884e 1 2026-02-07 20:24:45 +08:00
5416ea127c Merge branch 'master' into feat/liujie 2026-02-07 20:19:23 +08:00
a7bc517fae Merge branch 'feat/liujie' 2026-02-07 20:19:15 +08:00
16b38539f6 fix: 修改取值 2026-02-07 20:19:04 +08:00
张成
0d46311bbc 1 2026-02-07 19:27:58 +08:00
e884b1f258 Merge branch 'master' into feat/liujie 2026-02-07 18:13:23 +08:00
84159a4835 Merge branch 'feat/liujie' 2026-02-07 18:13:15 +08:00
2acee85dd5 fix: 修复分享弹窗打开逻辑 2026-02-07 18:13:00 +08:00
ba72e0ec97 Merge branch 'master' into feat/liujie 2026-02-07 18:11:15 +08:00
张成
32f5339cc2 Merge branch 'master' of https://git.bimwe.com/bimwe/mini-programs 2026-02-07 18:11:14 +08:00
张成
2cbbc7f432 1 2026-02-07 18:11:12 +08:00
694b00e011 Merge branch 'feat/liujie' 2026-02-07 18:11:01 +08:00
87eaa31cef fix: 修复发布后分享弹窗打开问题 2026-02-07 18:10:44 +08:00
张成
f131c9896d 修改oss 路径 2026-02-07 18:07:33 +08:00
b08f3325e6 Merge branch 'feat/liujie' 2026-02-07 17:38:28 +08:00
ff864fe64d feat: 修改两处海报logo-text图片、修改创建球局后跳转详情页打开分享弹窗位置、修改分享二维码接口取值、修改ntrp修改弹窗的初始值、增加复制链接功能 2026-02-07 17:37:07 +08:00
张成
da0ae6046c 1 2026-02-07 16:45:10 +08:00
42025d49f8 Merge branch 'master' into feat/liujie 2026-02-07 16:03:34 +08:00
张成
536619ebfc 1 2026-02-07 13:08:28 +08:00
张成
5a10c73adf 修复一堆问题 2026-02-07 11:56:43 +08:00
李瑞
b29e000747 Merge branch 'master' of https://git.bimwe.com/bimwe/mini-programs 2026-02-07 01:00:17 +08:00
李瑞
02841222a2 Merge branch feat/juguohong/20260206 2026-02-07 00:59:44 +08:00
李瑞
9dca489aba 处理banner插入 2026-02-07 00:53:40 +08:00
86 changed files with 2580 additions and 1426 deletions

2
.env.dev Normal file
View File

@@ -0,0 +1,2 @@
APP_ENV=dev
TARO_APP_ID=wx815b533167eb7b53

2
.env.dev_local Normal file
View File

@@ -0,0 +1,2 @@
APP_ENV=dev_local
TARO_APP_ID=wx815b533167eb7b53

2
.env.pr Normal file
View File

@@ -0,0 +1,2 @@
APP_ENV=pr
TARO_APP_ID=wx915ecf6c01bea4ec

2
.env.sit Normal file
View File

@@ -0,0 +1,2 @@
APP_ENV=sit
TARO_APP_ID=wx815b533167eb7b53

4
.gitignore vendored
View File

@@ -8,4 +8,6 @@ node_modules/
src/config/env.ts
.vscode
*.http
env.ts
.cursor
.codewiz

View File

@@ -4,7 +4,11 @@ export default {
quiet: false,
stats: true
},
mini: {},
mini: {
webpackChain(chain) {
chain.devtool('source-map')
}
},
h5: {},
// 添加这个配置来显示完整错误信息
compiler: {

79
config/env.config.ts Normal file
View File

@@ -0,0 +1,79 @@
/**
* 统一环境配置dev/sit/pr
* 构建时通过 APP_ENV 选择defineConstants 注入业务代码
* project.config.json 的 appid 由 scripts/sync-project-config.js 同步
*/
export type EnvType = "dev" | "dev_local" | "sit" | "pr";
export interface EnvConfig {
name: string;
apiBaseURL: string;
ossBaseURL: string;
appid: string;
timeout: number;
enableLog: boolean;
enableMock: boolean;
customerService: {
corpId: string;
serviceUrl: string;
};
}
const baseConfig = {
apiBaseURL: "https://tennis.bimwe.com",
ossBaseURL: "https://bimwe.oss-cn-shanghai.aliyuncs.com",
appid: "wx815b533167eb7b53", // 测试号
timeout: 15000,
enableLog: true,
enableMock: false,
customerService: {
corpId: "ww51fc969e8b76af82",
serviceUrl: "https://work.weixin.qq.com/kfid/kfc64085b93243c5c91",
},
}
export const envConfigs: Record<EnvType, EnvConfig> = {
// 本地开发API 指向本地或测试服
dev: {
name: "DEV",
// apiBaseURL: "http://localhost:9098",
...baseConfig
},
// 本地联调API 指向本机
dev_local: {
name: "DEV_LOCAL",
...Object.assign(baseConfig, {
apiBaseURL: "http://localhost:9098",
})
},
// SIT 测试环境
sit: {
name: "SIT",
...Object.assign(baseConfig, {
apiBaseURL: "https://tennis.bimwe.com",
})
},
// PR 生产环境
pr: {
name: "PR",
apiBaseURL: "https://youchang.qiongjingtiyu.com",
ossBaseURL: "https://youchang2026.oss-cn-shanghai.aliyuncs.com",
appid: "wx915ecf6c01bea4ec", // 生产小程序 appid按实际填写
timeout: 10000,
enableLog: false,
enableMock: false,
customerService: {
corpId: "ww9a2d9a5d9410c664",
serviceUrl: "https://work.weixin.qq.com/kfid/kfcd355e162e0390684",
},
},
};
export function getEnvConfig(env: EnvType): EnvConfig {
return envConfigs[env];
}

128
config/env.ts Normal file
View File

@@ -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<EnvType, EnvConfig> = {
// 开发环境
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()

View File

@@ -2,11 +2,21 @@ import { defineConfig, type UserConfigExport } from '@tarojs/cli'
import TsconfigPathsPlugin from 'tsconfig-paths-webpack-plugin'
import devConfig from './dev'
import prodConfig from './prod'
// import vitePluginImp from 'vite-plugin-imp'
import { getEnvConfig, type EnvType } from './env.config'
import path from 'path'
// 环境dev(本地) | dev_local(联调) | sit(测试) | pr(生产)
const ENV_LIST: EnvType[] = ['dev', 'dev_local', 'sit', 'pr']
// https://taro-docs.jd.com/docs/next/config#defineconfig-辅助函数
export default defineConfig<'webpack5'>(async (merge, { command, mode }) => {
const appEnv = (
(ENV_LIST.includes(mode as EnvType) ? mode : process.env.APP_ENV) ||
(process.env.NODE_ENV === 'production' ? 'pr' : 'dev')
) as EnvType
const envConfig = getEnvConfig(appEnv)
const baseConfig: UserConfigExport<'webpack5'> = {
projectName: 'playBallTogether',
date: '2025-8-9',
@@ -22,6 +32,13 @@ export default defineConfig<'webpack5'>(async (merge, { command, mode }) => {
outputRoot: 'dist',
plugins: ['@tarojs/plugin-html'],
defineConstants: {
'process.env.APP_ENV': JSON.stringify(appEnv),
'process.env.API_BASE_URL': JSON.stringify(envConfig.apiBaseURL),
'process.env.OSS_BASE_URL': JSON.stringify(envConfig.ossBaseURL),
'process.env.ENABLE_LOG': JSON.stringify(envConfig.enableLog),
'process.env.TIMEOUT': JSON.stringify(envConfig.timeout),
'process.env.CUSTOMER_CORP_ID': JSON.stringify(envConfig.customerService.corpId),
'process.env.CUSTOMER_SERVICE_URL': JSON.stringify(envConfig.customerService.serviceUrl),
},
alias: {
'@': path.resolve(__dirname, '..', 'src'),
@@ -76,6 +93,9 @@ export default defineConfig<'webpack5'>(async (merge, { command, mode }) => {
},
// @ts-expect-error: Taro 类型定义缺少 mini.hot
hot: true,
projectConfig: {
appid: envConfig.appid,
},
},
h5: {
publicPath: '/',

View File

@@ -10,32 +10,17 @@
"framework": "React"
},
"scripts": {
"build": "npm run build:weapp ",
"dev": "npm run dev:weapp ",
"build:weapp": "taro build --type weapp --mode production",
"build:swan": "taro build --type swan",
"build:alipay": "taro build --type alipay",
"build:tt": "taro build --type tt",
"build:h5": "taro build --type h5",
"build:rn": "taro build --type rn",
"build:qq": "taro build --type qq",
"build:jd": "taro build --type jd",
"build:quickapp": "taro build --type quickapp",
"dev:weapp": "npm run build:weapp -- --watch",
"dev:swan": "npm run build:swan -- --watch",
"dev:alipay": "npm run build:alipay -- --watch",
"dev:tt": "npm run build:tt -- --watch",
"dev:h5": "npm run build:h5 -- --watch",
"dev:rn": "npm run build:rn -- --watch",
"dev:qq": "npm run build:qq -- --watch",
"dev:jd": "npm run build:jd -- --watch",
"dev:quickapp": "npm run build:quickapp -- --watch"
"dev": "npm run dev:weapp",
"dev:local": "npm run dev:weapp:dev_local",
"dev:weapp": "node scripts/sync-project-config.js dev && taro build --type weapp --mode dev --watch",
"dev:weapp:dev_local": "node scripts/sync-project-config.js dev_local && taro build --type weapp --mode dev_local --watch",
"build": "npm run build:weapp",
"build:weapp": "node scripts/sync-project-config.js pr && taro build --type weapp --mode pr",
"build:sit": "node scripts/sync-project-config.js sit && taro build --type weapp --mode sit",
"build:pr": "node scripts/sync-project-config.js pr && taro build --type weapp --mode pr",
"dev:h5": "npm run build:h5 -- --watch"
},
"browserslist": [
"last 3 versions",
"Android >= 4.1",
"ios >= 8"
],
"browserslist": ["last 3 versions", "Android >= 4.1", "ios >= 8"],
"author": "",
"dependencies": {
"@babel/plugin-transform-runtime": "^7.28.3",

View File

@@ -2,8 +2,7 @@
"miniprogramRoot": "dist/",
"projectname": "playBallTogether",
"description": "playBallTogether",
"appid": "wx915ecf6c01bea4ec",
"appid": "wx815b533167eb7b53",
"setting": {
"urlCheck": true,
"es6": true,

View File

@@ -0,0 +1,25 @@
const fs = require('fs');
const path = require('path');
require('ts-node/register/transpile-only');
const envArg = process.argv[2];
const appEnv = envArg || process.env.APP_ENV || (process.env.NODE_ENV === 'production' ? 'pr' : 'dev');
const envConfigPath = path.resolve(__dirname, '../config/env.config.ts');
const { envConfigs } = require(envConfigPath);
const config = envConfigs[appEnv];
if (!config) {
console.error(`[sync-project-config] Unknown APP_ENV: ${appEnv}`);
process.exit(1);
}
const projectConfigPath = path.resolve(__dirname, '../project.config.json');
const projectConfigRaw = fs.readFileSync(projectConfigPath, 'utf-8');
const projectConfig = JSON.parse(projectConfigRaw);
projectConfig.appid = config.appid;
fs.writeFileSync(projectConfigPath, JSON.stringify(projectConfig, null, 2) + '\n', 'utf-8');
console.log(`[sync-project-config] project.config.json appid -> ${config.appid} (${appEnv})`);

View File

@@ -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-cn-shanghai.aliyuncs.com/front/ball/other/57dc951f-f10e-45b7-9157-0b1e468187fd.ttf") format("truetype");
font-display: swap;
}

View File

@@ -34,7 +34,7 @@ function toast(msg) {
interface CommentInputProps {
onConfirm?: (
value: { content: string } & Partial<CommentInputReplyParamsType>
value: { content: string } & Partial<CommentInputReplyParamsType>,
) => void;
}
@@ -49,119 +49,118 @@ interface CommentInputReplyParamsType {
nickname: string;
}
const CommentInput = forwardRef<CommentInputRef, CommentInputProps>(function (
props,
ref
) {
const { onConfirm } = props;
const [visible, setVisible] = useState(false);
const [value, setValue] = useState("");
const [params, setParams] = useState<
CommentInputReplyParamsType | undefined
>();
const CommentInput = forwardRef<CommentInputRef, CommentInputProps>(
function (props, ref) {
const { onConfirm } = props;
const [visible, setVisible] = useState(false);
const [value, setValue] = useState("");
const [params, setParams] = useState<
CommentInputReplyParamsType | undefined
>();
const {
keyboardHeight,
isKeyboardVisible,
addListener,
initializeKeyboardListener,
} = useKeyboardHeight();
const {
keyboardHeight,
isKeyboardVisible,
addListener,
initializeKeyboardListener,
} = useKeyboardHeight();
// 使用全局键盘状态监听
useEffect(() => {
// 初始化全局键盘监听器
initializeKeyboardListener();
// 使用全局键盘状态监听
useEffect(() => {
// 初始化全局键盘监听器
initializeKeyboardListener();
// 添加本地监听器
const removeListener = addListener((height, visible) => {
console.log("PublishBall 收到键盘变化:", height, visible);
// 这里只记录或用于其他逻辑,布局是否响应交由 shouldReactToKeyboard 决定
});
// 添加本地监听器
const removeListener = addListener(() => {
// 布局是否响应交由 shouldReactToKeyboard 决定
});
return () => {
removeListener();
};
}, [initializeKeyboardListener, addListener]);
return () => {
removeListener();
};
}, [initializeKeyboardListener, addListener]);
const inputDomRef = useRef(null);
const inputDomRef = useRef(null);
useImperativeHandle(ref, () => ({
show: (_params: CommentInputReplyParamsType | undefined) => {
setVisible(true);
setTimeout(() => {
inputDomRef.current && inputDomRef.current?.focus();
}, 100);
setParams(_params);
},
}));
useImperativeHandle(ref, () => ({
show: (_params: CommentInputReplyParamsType | undefined) => {
setVisible(true);
setTimeout(() => {
inputDomRef.current && inputDomRef.current?.focus();
}, 100);
setParams(_params);
},
}));
function handleSend() {
if (!value) {
toast("评论内容不得为空");
return;
function handleSend() {
if (!value) {
toast("评论内容不得为空");
return;
}
if (value.length > 200) {
return;
}
onConfirm?.({ content: value, ...params });
onClose();
}
if (value.length > 200) {
return;
}
onConfirm?.({ content: value, ...params });
onClose();
}
function onClose() {
setVisible(false);
setValue("");
inputDomRef.current && inputDomRef.current?.blur();
}
console.log(keyboardHeight, "keyboardHeight");
return (
<CommonPopup
visible={visible}
showHeader={false}
hideFooter
zIndex={1002}
onClose={onClose}
style={{
// height: "60px!important",
minHeight: "unset",
bottom:
isKeyboardVisible && keyboardHeight > 0 ? `${keyboardHeight}px` : "0",
}}
enableDragToClose={false}
>
<View className={styles.inputContainer}>
<View className={styles.inputWrapper}>
<Textarea
adjustPosition={false}
ref={inputDomRef}
className={styles.input}
value={value}
onInput={(e) => setValue(e.detail.value)}
placeholder={
params?.reply_to_user_id ? `回复 @${params.nickname}` : "写评论"
}
confirmType="send"
onConfirm={handleSend}
focus
maxlength={-1}
autoHeight
// showCount
/>
<View
className={classnames(
styles.limit,
value.length > 200 ? styles.red : ""
)}
>
<Text>{value.length}</Text>/<Text>200</Text>
function onClose() {
setVisible(false);
setValue("");
inputDomRef.current && inputDomRef.current?.blur();
}
return (
<CommonPopup
visible={visible}
showHeader={false}
hideFooter
zIndex={1002}
onClose={onClose}
style={{
// height: "60px!important",
minHeight: "unset",
bottom:
isKeyboardVisible && keyboardHeight > 0
? `${keyboardHeight}px`
: "0",
}}
enableDragToClose={false}
>
<View className={styles.inputContainer}>
<View className={styles.inputWrapper}>
<Textarea
adjustPosition={false}
ref={inputDomRef}
className={styles.input}
value={value}
onInput={(e) => setValue(e.detail.value)}
placeholder={
params?.reply_to_user_id ? `回复 @${params.nickname}` : "写评论"
}
confirmType="send"
onConfirm={handleSend}
focus
maxlength={-1}
autoHeight
// showCount
/>
<View
className={classnames(
styles.limit,
value.length > 200 ? styles.red : "",
)}
>
<Text>{value.length}</Text>/<Text>200</Text>
</View>
</View>
<View className={styles.sendIcon} onClick={handleSend}>
<Image className={styles.sendImage} src={sendImg} />
</View>
</View>
<View className={styles.sendIcon} onClick={handleSend}>
<Image className={styles.sendImage} src={sendImg} />
</View>
</View>
</CommonPopup>
);
});
</CommonPopup>
);
},
);
function isReplyComment(item: BaseComment<any>): item is ReplyComment {
return "reply_to_user" in item;
@@ -208,7 +207,7 @@ function CommentItem(props: {
className={classnames(
styles.commentItem,
blink_id === comment.id && styles.blink,
styles.weight_super
styles.weight_super,
)}
key={comment.id}
id={`comment_id_${comment.id}`}
@@ -293,7 +292,8 @@ function CommentItem(props: {
/>
))}
{!isReplyComment(comment) &&
comment.replies.length !== comment.reply_count && (
comment.replies.length !== comment.reply_count &&
comment.replies.length > 3 && (
<View
className={styles.viewMore}
onClick={() => handleLoadMore(comment)}
@@ -313,7 +313,7 @@ export default forwardRef(function Comments(
message_id?: number;
onScrollTo: (id: string) => void;
},
ref
ref,
) {
const { game_id, publisher_id, message_id, onScrollTo } = props;
const [comments, setComments] = useState<Comment[]>([]);
@@ -371,7 +371,7 @@ export default forwardRef(function Comments(
replies: [res.data, ...item.replies].sort((a, b) =>
dayjs(a.create_time).isAfter(dayjs(b.create_time))
? 1
: -1
: -1,
),
};
});
@@ -435,7 +435,7 @@ export default forwardRef(function Comments(
item.replies.splice(
page === 1 ? 0 : page * PAGESIZE - 1,
newReplies.length,
...newReplies
...newReplies,
);
item.reply_count = res.data.count;
}
@@ -502,7 +502,7 @@ export default forwardRef(function Comments(
return {
...item,
replies: item.replies.filter(
(replyItem) => replyItem.id !== id
(replyItem) => replyItem.id !== id,
),
reply_count: item.reply_count - 1,
};

View File

@@ -3,6 +3,12 @@
.common-popup {
position: fixed;
z-index: 9999 !important;
padding: 0;
box-sizing: border-box;
max-height: calc(100vh - 10px);
display: flex;
flex-direction: column;
background-color: theme.$page-background-color;
&:global(.nut-popup-bottom.nut-popup-round) {
border-radius: 20px 20px 0 0 !important;
}
@@ -32,12 +38,7 @@
}
}
padding: 0;
box-sizing: border-box;
max-height: calc(100vh - 10px);
display: flex;
flex-direction: column;
background-color: theme.$page-background-color;
// .common-popup__header {
// padding: 12px 16px;

View File

@@ -0,0 +1,215 @@
import React, { useRef, useState, useEffect } from 'react'
import type { CSSProperties, ReactNode } from 'react'
import { View, Text } from '@tarojs/components'
import { Button } from '@nutui/nutui-react-taro'
import { useKeyboardHeight } from '@/store/keyboardStore'
import styles from './index.module.scss'
export interface CustomPopupProps {
visible: boolean
onClose: () => void
title?: ReactNode
showHeader?: boolean
hideFooter?: boolean
cancelText?: string
confirmText?: string
onCancel?: () => void
onConfirm?: () => void
children?: ReactNode
className?: string
style?: CSSProperties
// 与 CommonPopup 保持入参一致
position?: 'center' | 'bottom' | 'top' | 'left' | 'right'
round?: boolean
zIndex?: number
enableDragToClose?: boolean
}
const CustomPopup: React.FC<CustomPopupProps> = ({
visible,
onClose,
title,
showHeader = false,
hideFooter = false,
cancelText = '返回',
confirmText = '完成',
onCancel,
onConfirm,
children,
className,
style,
position = 'bottom',
round = true,
zIndex,
enableDragToClose = true,
}) => {
const [dragOffset, setDragOffset] = useState(0)
const [isDragging, setIsDragging] = useState(false)
const touchStartY = useRef(0)
// 使用全局键盘状态
const { keyboardHeight, isKeyboardVisible, addListener, initializeKeyboardListener, setKeyboardVisible } = useKeyboardHeight()
// 当弹窗显示时,设置键盘为不可见
useEffect(() => {
if (visible) {
setKeyboardVisible(false)
}
}, [visible, setKeyboardVisible])
// 使用全局键盘状态监听
useEffect(() => {
// 初始化全局键盘监听器
initializeKeyboardListener()
// 添加本地监听器
const removeListener = addListener((height, visible) => {
console.log('CustomPopup 收到键盘变化:', height, visible)
})
return () => {
removeListener()
}
}, [initializeKeyboardListener, addListener])
if (!visible) {
return null
}
const handleCancel = () => {
if (onCancel) {
onCancel()
} else {
onClose()
}
}
const handleTouchStart = (e: any) => {
if (!enableDragToClose) return
touchStartY.current = e.touches[0].clientY
setIsDragging(true)
}
const handleTouchMove = (e: any) => {
if (!enableDragToClose || !isDragging) return
const currentY = e.touches[0].clientY
const deltaY = currentY - touchStartY.current
if (deltaY > 0) {
setDragOffset(Math.min(deltaY, 100))
}
}
const handleTouchEnd = () => {
if (!enableDragToClose || !isDragging) return
setIsDragging(false)
if (dragOffset > 50) {
onClose()
}
setDragOffset(0)
}
const overlayAlignItems =
position === 'center'
? 'center'
: position === 'top'
? 'flex-start'
: 'flex-end'
const handleOverlayClick = () => {
onClose()
}
// 阻止弹窗内的触摸事件冒泡
const handleTouchMoveInPopup = (e: any) => {
if (!isKeyboardVisible) {
e.stopPropagation()
}
}
return (
<View
className={styles['custom-popup-overlay']}
style={{ zIndex: zIndex ?? undefined, alignItems: overlayAlignItems }}
onClick={handleOverlayClick}
>
<View className={styles['custom-popup-move']} onTouchMove={handleTouchMoveInPopup} catchMove></View>
<View
className={`${styles['custom-popup']} ${className ? className : ''}`}
style={{
...style,
paddingBottom: isKeyboardVisible ? `${keyboardHeight}px` : undefined,
}}
onClick={(e) => {
e.stopPropagation()
}}
>
{enableDragToClose && (
<View
className={styles['custom-popup__drag-handle-container']}
onTouchStart={handleTouchStart}
onTouchMove={handleTouchMove}
onTouchEnd={handleTouchEnd}
>
<View
className={styles['custom-popup__drag-handle']}
style={{
transform: `translateX(-50%) translateY(${dragOffset * 0.3}px)`,
opacity: isDragging ? 0.8 : 1,
transition: isDragging ? 'none' : 'all 0.3s ease-out',
}}
/>
</View>
)}
{showHeader && (
<View className={styles['custom-popup__header']}>
{typeof title === 'string' ? (
<Text className={styles['custom-popup__title']}>{title}</Text>
) : (
title
)}
<View className={styles['close_button']} onClick={onClose}>
<View className={styles['close_icon']}>
<View className={styles['close_line']} />
<View className={styles['close_line']} />
</View>
</View>
</View>
)}
<View className={styles['custom-popup__body']}>{children}</View>
{!hideFooter && !isKeyboardVisible && (
<View className={styles['custom-popup__footer']}>
<Button
className={`${styles['custom-popup__btn']} ${styles['custom-popup__btn-cancel']}`}
type="default"
size="small"
onClick={handleCancel}
>
{cancelText}
</Button>
<Button
className={`${styles['custom-popup__btn']} ${styles['custom-popup__btn-confirm']}`}
type="primary"
size="small"
onClick={onConfirm}
>
{confirmText}
</Button>
</View>
)}
</View>
</View>
)
}
export default CustomPopup

View File

@@ -0,0 +1,155 @@
@use "~@/scss/themeColor.scss" as theme;
.custom-popup-overlay {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0, 0, 0, 0.5);
z-index: 999;
display: flex;
align-items: flex-end;
justify-content: center;
}
.custom-popup-move{
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
z-index: 998;
}
.custom-popup {
position: relative;
z-index: 999;
width: 100%;
padding: 0;
box-sizing: border-box;
display: flex;
flex-direction: column;
background-color: theme.$page-background-color;
border-radius: 20px 20px 0 0;
overflow: hidden;
transition: padding-bottom 0.3s ease;
.custom-popup__drag-handle-container {
position: relative;
height: 0;
}
.custom-popup__drag-handle {
position: absolute;
top: 6px;
left: 50%;
width: 90px;
height: 30px;
z-index: 10;
display: flex;
justify-content: center;
align-items: flex-start;
&::before {
content: "";
width: 32px;
height: 4px;
background-color: rgba(22, 24, 35, 0.2);
border-radius: 2px;
}
}
.custom-popup__header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 16px 20px;
.custom-popup__title {
font-family: "PingFang SC";
font-weight: 600;
font-size: 22px;
line-height: 1.27em;
color: #000000;
text-align: center;
}
.close_button {
width: 40px;
height: 40px;
display: flex;
align-items: center;
justify-content: center;
background: #ffffff;
border: 1px solid rgba(0, 0, 0, 0.06);
border-radius: 50%;
cursor: pointer;
box-shadow: 0px 4px 36px 0px rgba(0, 0, 0, 0.06);
.close_icon {
position: relative;
width: 24px;
height: 24px;
.close_line {
position: absolute;
top: 50%;
left: 50%;
width: 17px;
height: 3px;
border-radius: 3px;
background: #000000;
transform: translate(-50%, -50%) rotate(45deg);
&:nth-child(2) {
transform: translate(-50%, -50%) rotate(-45deg);
}
}
}
}
}
.custom-popup__body {
flex: 1 1 auto;
max-height: 80vh;
overflow-y: auto;
}
.custom-popup__footer {
padding: 8px 10px 0 10px;
display: flex;
gap: 8px;
background: #fafafa;
padding-bottom: max(10px, env(safe-area-inset-bottom));
}
.custom-popup__btn {
flex: 1;
font-feature-settings: "liga" off, "clig" off;
font-family: "PingFang SC";
font-size: 16px;
font-style: normal;
font-weight: 600;
line-height: normal;
}
.custom-popup__btn-cancel {
background: #f5f6f7;
color: #1f2329;
border: none;
width: 154px;
height: 44px;
border-radius: 12px !important;
border: 0.5px solid rgba(0, 0, 0, 0.06);
background: #fff;
padding: 4px 10px;
}
.custom-popup__btn-confirm {
width: 154px;
height: 44px;
border: 0.5px solid rgba(0, 0, 0, 0.06);
background: #000;
border-radius: 12px !important;
padding: 4px 10px;
}
}

View File

@@ -0,0 +1,4 @@
import CustomPopup from './CustomPopup'
export default CustomPopup
export * from './CustomPopup'

View File

@@ -13,7 +13,9 @@
align-items: center;
color: #000;
text-align: center;
font-feature-settings: 'liga' off, 'clig' off;
font-feature-settings:
"liga" off,
"clig" off;
font-family: "PingFang SC";
font-size: 16px;
font-style: normal;
@@ -32,7 +34,9 @@
padding-top: 24px;
color: #000;
text-align: center;
font-feature-settings: 'liga' off, 'clig' off;
font-feature-settings:
"liga" off,
"clig" off;
font-family: "PingFang SC";
font-size: 16px;
font-style: normal;
@@ -48,8 +52,10 @@
align-items: center;
.tips {
color: rgba(60, 60, 67, 0.60);
font-feature-settings: 'liga' off, 'clig' off;
color: rgba(60, 60, 67, 0.6);
font-feature-settings:
"liga" off,
"clig" off;
font-family: "PingFang SC";
font-size: 16px;
font-style: normal;
@@ -62,13 +68,15 @@
margin-top: 8px;
padding: 8px;
border-radius: 4px;
background: #F0F0F0;
background: #f0f0f0;
.input {
width: 100%;
&:placeholder-shown {
color: rgba(60, 60, 67, 0.30);
font-feature-settings: 'liga' off, 'clig' off;
color: rgba(60, 60, 67, 0.3);
font-feature-settings:
"liga" off,
"clig" off;
font-family: "PingFang SC";
font-size: 14px;
font-style: normal;
@@ -84,11 +92,12 @@
justify-content: space-between;
align-items: center;
height: 44px;
border-top: 0.5px solid #CECECE;
background: #FFF;
border-top: 0.5px solid #cecece;
background: #fff;
margin-top: 2px;
.confirm, .cancel {
.confirm,
.cancel {
width: 50%;
height: 44px;
display: flex;
@@ -96,7 +105,9 @@
align-items: center;
color: #000;
text-align: center;
font-feature-settings: 'liga' off, 'clig' off;
font-feature-settings:
"liga" off,
"clig" off;
font-family: "PingFang SC";
font-size: 16px;
font-style: normal;

View File

@@ -186,10 +186,11 @@ export default forwardRef(function GameManagePopup(props, ref) {
.some((item) => item.user.id === userInfo.id);
const finished = [MATCH_STATUS.FINISHED, MATCH_STATUS.CANCELED].includes(
detail.match_status
detail.match_status,
);
const inTwoHours = dayjs(detail.start_time).diff(dayjs(), "hour") < 2;
// const inTwoHours = dayjs(detail.start_time).diff(dayjs(), "hour") < 2;
const beforeStart = dayjs(detail.start_time).isAfter(dayjs());
const hasOtherParticiappants = (detail.participants || [])
.filter((item) => item.status === "joined")
@@ -207,7 +208,7 @@ export default forwardRef(function GameManagePopup(props, ref) {
style={{ minHeight: "unset" }}
>
<View className={styles.container}>
{!inTwoHours && !hasOtherParticiappants && (
{!finished && !hasOtherParticiappants && beforeStart && (
<View className={styles.button} onClick={handleEditGame}>
</View>
@@ -217,12 +218,12 @@ export default forwardRef(function GameManagePopup(props, ref) {
</View>
)}
{!inTwoHours && !hasOtherParticiappants && (
{!finished && beforeStart && (
<View className={styles.button} onClick={handleCancelGame}>
</View>
)}
{hasJoin && (
{!finished && beforeStart && hasJoin && (
<View className={styles.button} onClick={handleQuitGame}>
退
</View>

View File

@@ -15,7 +15,7 @@ const GamePlayType = (props: IProps) => {
const { name, onChange, value, options } = props;
return (
<View className={styles.gamePlayWrapper}>
<TitleComponent title="玩法" icon={<Image src={img.ICON_SITE} />} />
<TitleComponent title="玩法" icon={<Image src={img.ICON_GAME_PLAY} />} />
<Bubble
options={options}
value={value}

View File

@@ -53,7 +53,7 @@
}
.location-position {
flex: 1;
// flex: 1;
min-width: 0; // 允许缩小
white-space: nowrap;
overflow: hidden;

View File

@@ -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<ListCardProps> = ({
id,
@@ -45,7 +46,7 @@ const ListCard: React.FC<ListCardProps> = ({
className="image"
mode="aspectFill"
lazyLoad
defaultSource="https://images.unsplash.com/photo-1554068865-24cecd4e34b8?w=200&h=200&fit=crop&crop=center"
defaultSource={`${OSS_BASE}/front/ball/images/publish-empty-card.svg`}
/>
);
};
@@ -67,7 +68,9 @@ const ListCard: React.FC<ListCardProps> = ({
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<ListCardProps> = ({
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<ListCardProps> = ({
maxChars++;
}
return location.slice(0, maxChars) + '...';
return location.slice(0, maxChars) + "...";
}, [location, court_type, distance_km]);
// 根据图片数量决定展示样式
@@ -127,10 +132,10 @@ const ListCard: React.FC<ListCardProps> = ({
return (
<View className="double-image">
<View className="image-container">
{renderItemImage(image_list?.[0])}
{renderItemImage(image_list?.[1])}
</View>
<View className="image-container">
{renderItemImage(image_list?.[1])}
{renderItemImage(image_list?.[0])}
</View>
</View>
);
@@ -220,9 +225,10 @@ const ListCard: React.FC<ListCardProps> = ({
</Text>
</View>
<View className="tag ntprTag">
<Image src={images.ICON_LIST_NTPR} className='ntprIcon' />
<Image src={images.ICON_LIST_NTPR} className="ntprIcon" />
<Text className="tag-text">
{Number(skill_level_min)?.toFixed(1)} - {Number(skill_level_max)?.toFixed(1)}
{Number(skill_level_min)?.toFixed(1)} -{" "}
{Number(skill_level_max)?.toFixed(1)}
</Text>
{/* 分割线 */}
<View className="typeLine" />
@@ -251,22 +257,16 @@ const ListCard: React.FC<ListCardProps> = ({
/>
{/* <Text className="smoothTitle">{game_type}</Text> */}
</View>
{
venue_description && (<View className="line" />)
}
{
venue_description &&
(
<View className="localAreaContainer">
<View className="localAreaTitle">:</View>
<View className="localAreaWrapper">
<Image className="localArea" src={venueImage} />
<Text className="localAreaText">{venue_description}</Text>
</View>
{venue_description && <View className="line" />}
{venue_description && (
<View className="localAreaContainer">
<View className="localAreaTitle">:</View>
<View className="localAreaWrapper">
<Image className="localArea" src={venueImage} />
<Text className="localAreaText">{venue_description}</Text>
</View>
)
}
</View>
)}
</View>
)}
</View>

View File

@@ -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) => {
<View className={styles.listLoadError} style={{ height: wrapperHeight }}>
<Image
className={styles.listLoadErrorImg}
style={{ width, height, transform: `scale(${scale})` }}
style={{ width, height }}
src={errorImg ? img[errorImg] : img.ICON_LIST_LOAD_ERROR}
/>
{text && <Text className={styles.listLoadErrorText}>{text}</Text>}

View File

@@ -62,7 +62,7 @@ const NTRPEvaluatePopup = (props: NTRPEvaluatePopupProps, ref) => {
showGuide = false,
} = props;
const [visible, setVisible] = useState(false);
const [ntrp, setNtrp] = useState<string>("");
const [ntrp, setNtrp] = useState<string>("1.5");
const [guideShow, setGuideShow] = useState(() => showGuide);
const { updateUserInfo } = useUserActions();
const userInfo = useUserInfo();
@@ -105,10 +105,10 @@ const NTRPEvaluatePopup = (props: NTRPEvaluatePopupProps, ref) => {
if (match) {
setNtrp(match[0]);
} else {
setNtrp("");
setNtrp("1.5");
}
} else {
setNtrp("");
setNtrp("1.5");
}
}
}, [visible, userInfo?.ntrp_level]);

View File

@@ -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: {
<View
className={styles.lines}
style={{
backgroundImage: `url(${OSS_BASE_URL}/images/215f1ce1-be52-4a92-8250-5a4a69e7f2b3.png)`,
backgroundImage: `url(${OSS_BASE}/front/ball/images/215f1ce1-be52-4a92-8250-5a4a69e7f2b3.png)`,
}}
/>
<View className={styles.desc}>
@@ -188,7 +188,7 @@ function NTRPTestEntryCard(props: {
<View
className={styles.lines}
style={{
backgroundImage: `url(${OSS_BASE_URL}/images/215f1ce1-be52-4a92-8250-5a4a69e7f2b3.png)`,
backgroundImage: `url(${OSS_BASE}/front/ball/images/215f1ce1-be52-4a92-8250-5a4a69e7f2b3.png)`,
}}
/>
<View className={styles.desc}>

View File

@@ -1,6 +1,7 @@
import React, { useState, useEffect, useRef } from "react";
import CommonPopup from "@/components/CommonPopup";
import { View } from "@tarojs/components";
import Taro from "@tarojs/taro";
import CalendarUI, {
CalendarUIRef,
} from "@/components/Picker/CalendarUI/CalendarUI";
@@ -47,6 +48,13 @@ const DialogCalendarCard: React.FC<DialogCalendarCardProps> = ({
onClose();
return;
}
if (!selected) {
Taro.showToast({
title: '请选择日期',
icon: "none",
});
return;
}
// 年份选择完成后,进入月份选择
setType("time");
} else if (type === "month") {

View File

@@ -1,5 +1,6 @@
import React, { useState, useEffect, useRef } from "react";
import CommonPopup from "@/components/CommonPopup";
import Taro from "@tarojs/taro";
import { View } from "@tarojs/components";
import CalendarUI, {
CalendarUIRef,
@@ -32,6 +33,13 @@ const DayDialog: React.FC<DayDialogProps> = ({
} | null>(null);
const handleConfirm = () => {
console.log(selected, 'selectedselected');
if (!selected) {
Taro.showToast({
title: '请选择日期',
icon: "none",
});
return;
}
const finalDate = dayjs(selected as Date).format("YYYY-MM-DD");
if (onChange){
onChange(finalDate)

View File

@@ -52,7 +52,7 @@ const PopupPicker = ({
ntrpTested,
}: PickerProps) => {
const [defaultValue, setDefaultValue] = useState<(string | number)[]>([]);
const [defaultOptions, setDefaultOptions] = useState<PickerOption[][]>([]);
const [defaultOptions, setDefaultOptions] = useState<PickerOption[][]>([...options]);
const [pickerCurrentValue, setPickerCurrentValue] =
useState<(string | number)[]>(value);

View File

@@ -89,25 +89,15 @@ const RadarChart: React.FC = forwardRef((props, ref) => {
ctx.lineWidth = 1;
ctx.stroke();
// 标签
const offset = 10;
const textX = center.x + (radius + offset) * Math.cos(angle);
const textY = center.y + (radius + offset) * Math.sin(angle);
// 标签:沿轴线外侧延伸,文字中心对齐轴线端点
const labelOffset = 28;
const textX = center.x + (radius + labelOffset) * Math.cos(angle);
const textY = center.y + (radius + labelOffset) * Math.sin(angle);
ctx.font = "12px sans-serif";
ctx.fillStyle = "#333";
ctx.textBaseline = "middle";
if (
Math.abs(angle) < 0.01 ||
Math.abs(Math.abs(angle) - Math.PI) < 0.01
) {
ctx.textAlign = "center";
} else if (angle > -Math.PI / 2 && angle < Math.PI / 2) {
ctx.textAlign = "left";
} else {
ctx.textAlign = "right";
}
ctx.textAlign = "center";
ctx.fillText(label, textX, textY);
});

File diff suppressed because it is too large Load Diff

View File

@@ -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<ShareCardCanvasProps> = ({
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<ShareCardCanvasProps> = ({
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<ShareCardCanvasProps> = ({
// 绘制地点
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')

View File

@@ -79,6 +79,7 @@ const TextareaTag: React.FC<TextareaTagProps> = ({
autoHeight={true}
onFocus={onFocus}
onBlur={onBlur}
adjustPosition={false}
/>
<View className={`char-count${isOverflow ? ' char-count--error' : ''}`}>
{value.description.length}/{maxLength}

View File

@@ -6,7 +6,12 @@ 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,
useUserInfo,
} from "@/store/userStore";
import { UserInfoType } from "@/services/userService";
import {
useCities,
@@ -69,7 +74,6 @@ const on_edit = () => {
// 用户信息卡片组件
const UserInfoCardComponent: React.FC<UserInfoCardProps> = ({
editable = true,
user_info,
is_current_user,
is_following = false,
collapseProfile,
@@ -80,9 +84,12 @@ const UserInfoCardComponent: React.FC<UserInfoCardProps> = ({
set_user_info,
onTab,
}) => {
const user_info = useUserInfo();
const nickname_change_status = useNicknameChangeStatus();
const { setShowGuideBar } = useGlobalState();
const { updateUserInfo, updateNickname, fetchLastTestResult } = useUserActions();
const { updateUserInfo, updateNickname, fetchLastTestResult } =
useUserActions();
const ntrpLevels = useNtrpLevels();
// 使用全局状态中的测试结果,避免重复调用接口
const lastTestResult = useLastTestResult();
@@ -117,11 +124,15 @@ const UserInfoCardComponent: React.FC<UserInfoCardProps> = ({
useState(false);
// 表单状态
const [form_data, set_form_data] = useState<Partial<UserInfoType>>({});
const [form_data, set_form_data] = useState<Partial<UserInfoType>>({ ...user_info });
useDidShow(() => {
// useDidShow(() => {
// set_form_data({ ...user_info });
// });
useEffect(() => {
set_form_data({ ...user_info });
});
}, [user_info])
useEffect(() => {
const visibles = [
@@ -129,6 +140,7 @@ const UserInfoCardComponent: React.FC<UserInfoCardProps> = ({
location_picker_visible,
ntrp_picker_visible,
occupation_picker_visible,
edit_modal_visible,
];
const allPickersClosed = visibles.every((item) => !item);
// 所有选择器都关闭时,显示 GuideBar否则隐藏
@@ -138,6 +150,7 @@ const UserInfoCardComponent: React.FC<UserInfoCardProps> = ({
location_picker_visible,
ntrp_picker_visible,
occupation_picker_visible,
edit_modal_visible,
]);
// 职业数据
@@ -295,8 +308,8 @@ const UserInfoCardComponent: React.FC<UserInfoCardProps> = ({
// 处理地区选择
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 +320,8 @@ const UserInfoCardComponent: React.FC<UserInfoCardProps> = ({
// 处理职业选择
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
@@ -365,7 +378,6 @@ const UserInfoCardComponent: React.FC<UserInfoCardProps> = ({
urls: [url],
});
};
return (
<View className="user_info_card">
{/* 头像和基本信息 */}
@@ -406,11 +418,11 @@ const UserInfoCardComponent: React.FC<UserInfoCardProps> = ({
<View className="stats_section">
<View
className="stats_container"
// style={{
// marginBottom: `${
// collapseProfile && setMarginBottom ? "16px" : "unset"
// }`,
// }}
// style={{
// marginBottom: `${
// collapseProfile && setMarginBottom ? "16px" : "unset"
// }`,
// }}
>
<View
className="stat_item clickable"
@@ -565,12 +577,12 @@ const UserInfoCardComponent: React.FC<UserInfoCardProps> = ({
<Text></Text>
</View>
) : null}
{user_info.country || user_info.province || user_info.city ? (
{user_info.province || user_info.city || user_info.district ? (
<View
className="tag_item"
onClick={() => editable && handle_open_edit_modal("location")}
>
<Text className="tag_text">{`${user_info.province}${user_info.city}`}</Text>
<Text className="tag_text">{`${user_info.city}${user_info.district}`}</Text>
</View>
) : is_current_user ? (
<View
@@ -643,16 +655,16 @@ const UserInfoCardComponent: React.FC<UserInfoCardProps> = ({
<PopupPicker
showHeader={true}
title="选择性别"
options={[
options={
[
{ text: "男", value: "0" },
{ text: "女", value: "1" },
{ text: "保密", value: "2" },
],
]}
]
}
visible={gender_picker_visible}
setvisible={setGenderPickerVisible}
value={form_data.gender === "" ? ["0"] : [form_data.gender]}
value={!form_data.gender ? ["0"] : [form_data.gender]}
onChange={handle_gender_change}
/>
)}
@@ -665,8 +677,8 @@ const UserInfoCardComponent: React.FC<UserInfoCardProps> = ({
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 +690,12 @@ const UserInfoCardComponent: React.FC<UserInfoCardProps> = ({
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}
/>
)}
@@ -864,9 +873,8 @@ export const GameTabs: React.FC<GameTabsProps> = ({
<Text className="tab_text">{hosted_text}</Text>
</View>
<View
className={`tab_item ${
active_tab === "participated" ? "active" : ""
}`}
className={`tab_item ${active_tab === "participated" ? "active" : ""
}`}
onClick={() => on_tab_change("participated")}
>
<Text className="tab_text">{participated_text}</Text>

View File

@@ -8,6 +8,7 @@ import NumberInterval from "./NumberInterval";
import TimeSelector from "./TimeSelector";
import TitleTextarea from "./TitleTextarea";
import CommonPopup from "./CommonPopup";
import CustomPopup from "./CustomPopup";
import { CalendarUI, DialogCalendarCard } from "./Picker";
import CommonDialog from "./CommonDialog";
import PublishMenu from "./PublishMenu/PublishMenu";
@@ -37,6 +38,7 @@ export {
TimeSelector,
TitleTextarea,
CommonPopup,
CustomPopup,
DialogCalendarCard,
CalendarUI,
CommonDialog,

View File

@@ -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 = envConfig.ossBaseURL;
export const API_CONFIG = {
// 基础URL

61
src/config/env.ts Normal file
View File

@@ -0,0 +1,61 @@
import Taro from "@tarojs/taro";
/**
* 环境配置:从 config/env.config.ts 经 defineConstants 注入
* 构建时由 config/index.ts 根据 APP_ENV 选择并注入
*/
export type EnvType = "dev" | "dev_local" | "sit" | "pr";
export interface EnvConfig {
name: string;
apiBaseURL: string;
ossBaseURL: string;
timeout: number;
enableLog: boolean;
enableMock: boolean;
customerService: {
corpId: string;
serviceUrl: string;
};
}
// 从 defineConstants 注入的编译时常量读取
const getInjectedConfig = (): EnvConfig => ({
name: process.env.APP_ENV || "dev",
apiBaseURL: process.env.API_BASE_URL || "",
ossBaseURL: process.env.OSS_BASE_URL || "",
timeout: Number(process.env.TIMEOUT) || 10000,
enableLog: process.env.ENABLE_LOG === "true",
enableMock: false,
customerService: {
corpId: process.env.CUSTOMER_CORP_ID || "",
serviceUrl: process.env.CUSTOMER_SERVICE_URL || "",
},
});
export const getCurrentEnv = (): EnvType =>
(process.env.APP_ENV as EnvType) || "dev";
export const getCurrentConfig = (): EnvConfig => getInjectedConfig();
export const isDevelopment = (): boolean =>
getCurrentEnv() === "dev" || getCurrentEnv() === "dev_local" || getCurrentEnv() === "sit";
export const isProduction = (): boolean => getCurrentEnv() === "pr";
export const getEnvInfo = () => {
const config = getCurrentConfig();
return {
env: getCurrentEnv(),
config,
taroEnv: (Taro as any).getEnv?.(),
platform:
(Taro as any).getEnv?.() === (Taro as any).ENV_TYPE?.WEAPP
? "微信小程序"
: (Taro as any).getEnv?.() === (Taro as any).ENV_TYPE?.WEB
? "Web"
: "未知",
};
};
export default getCurrentConfig();

View File

@@ -1,74 +1,76 @@
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"),
ICON_GAME_PLAY: require("@/static/list/icon_game_type.svg"),
};

View File

@@ -10,6 +10,7 @@ import { EvaluateScene } from "@/store/evaluateStore";
import { waitForAuthInit } from "@/utils/authInit";
import "./index.scss";
import { useRef, useEffect, useState, useMemo } from "react";
import { useDictionaryStore } from "@/store/dictionaryStore";
const ListContainer = (props) => {
const {
@@ -28,6 +29,7 @@ const ListContainer = (props) => {
collapse = false,
defaultShowNum,
evaluateFlag,
enableHomeCards = false, // 仅首页需要 banner 和 NTRP 测评卡片
listLoadErrorWrapperHeight,
listLoadErrorWidth,
listLoadErrorHeight,
@@ -44,7 +46,7 @@ const ListContainer = (props) => {
const { fetchUserInfo, fetchLastTestResult } = useUserActions();
// 使用全局状态中的测试结果,避免重复调用接口
const lastTestResult = useLastTestResult();
const { bannerListImage, bannerDetailImage, bannerListIndex = 0 } = useDictionaryStore((s) => s.bannerDict) || {};
useReachBottom(() => {
// 加载更多方法
if (loading) {
@@ -93,10 +95,10 @@ const ListContainer = (props) => {
};
}, []);
// 获取测试结果,判断最近一个月是否有测试记录
// 获取测试结果,判断最近一个月是否有测试记录(仅首页需要)
useEffect(() => {
const init = async () => {
if (!evaluateFlag) return;
if (!evaluateFlag || !enableHomeCards) return;
// 先等待静默登录完成
await waitForAuthInit();
// 然后再获取用户信息
@@ -111,7 +113,7 @@ const ListContainer = (props) => {
}
};
init();
}, [evaluateFlag, userInfo, lastTestResult, fetchLastTestResult]);
}, [evaluateFlag, enableHomeCards, userInfo, lastTestResult, fetchLastTestResult]);
// 从全局状态中获取测试状态
const hasTestInLastMonth = lastTestResult?.has_test_in_last_month || false;
@@ -130,33 +132,45 @@ const ListContainer = (props) => {
);
};
// 对于没有ntrp等级的用户每个月展示一次, 插在第二个位置后面
function insertEvaluateCard(list) {
if (!evaluateFlag)
return showNumber !== undefined ? list.slice(0, showNumber) : list;
if (!list || list.length === 0) {
return list;
}
// 如果最近一个月有测试记录,则不插入 card
if (hasTestInLastMonth) {
return showNumber !== undefined ? list.slice(0, showNumber) : list;
}
// showNumber 为 0 表示尚未同步,不参与截断;截断时只限制「数据条数」,插卡不占数据条数
const shouldLimitByShowNumber = showNumber > 0;
if (list.length <= 2) {
return [...list, { type: "evaluateCard" }];
// 插入 banner 卡片(在 bannerListIndex 位置插入,不替换数据)
function insertBannerCard(list) {
if (!bannerListImage) return list;
if (!list || !Array.isArray(list)) {
list = [];
}
const [item1, item2, ...rest] = list;
const idx = Number(bannerListIndex);
return [
item1,
item2,
{ type: "evaluateCard" },
...(showNumber !== undefined ? rest.slice(0, showNumber - 3) : rest),
...list.slice(0, idx),
{ type: "banner", banner_image_url: bannerListImage, banner_detail_url: bannerDetailImage },
...list.slice(idx),
];
}
// 对于没有 ntrp 等级的用户每个月展示一次,插在第 2 条数据后面;插卡是插入不替换,保留全部 showNumber 条数据
function insertEvaluateCard(list) {
if (!list || !Array.isArray(list)) return insertBannerCard(list ?? []);
const limitedList = shouldLimitByShowNumber ? list.slice(0, showNumber) : list;
if (!evaluateFlag || hasTestInLastMonth) {
return insertBannerCard(limitedList);
}
if (limitedList.length <= 2) {
return insertBannerCard([...limitedList, { type: "evaluateCard" }]);
}
const [item1, item2, ...rest] = limitedList;
const result = [item1, item2, { type: "evaluateCard" }, ...rest];
return insertBannerCard(result);
}
const memoizedList = useMemo(
() => insertEvaluateCard(data),
[evaluateFlag, data, hasTestInLastMonth, showNumber]
() => (enableHomeCards ? insertEvaluateCard(data) : data),
[enableHomeCards, evaluateFlag, data, hasTestInLastMonth, showNumber, bannerListImage, bannerDetailImage, bannerListIndex]
);
// 渲染 banner 卡片
@@ -176,7 +190,7 @@ const ListContainer = (props) => {
}
}}
style={{
height: "122px",
height: "100px",
overflow: "hidden",
borderRadius: "12px",
backgroundImage: `url(${item.banner_image_url})`,
@@ -189,10 +203,12 @@ const ListContainer = (props) => {
);
};
const showNoData = isShowNoData && !loading && memoizedList?.length === 0;
// 渲染列表
const renderList = () => {
// 请求数据为空
if (isShowNoData) {
if (showNoData) {
return (
<ListLoadError
reload={reload}
@@ -212,10 +228,10 @@ const ListContainer = (props) => {
return (
<>
{memoizedList.map((match, index) => {
if (match.type === "banner") {
if (enableHomeCards && match?.type === "banner") {
return renderBanner(match, index);
}
if (match.type === "evaluateCard") {
if (enableHomeCards && match?.type === "evaluateCard") {
return (
<NTRPTestEntryCard key={`evaluate-${index}`} type={EvaluateScene.list} />
);

View File

@@ -40,7 +40,7 @@ function isFull(counts) {
function matchNtrpRequestment(
target?: string,
min?: string,
max?: string
max?: string,
): boolean {
// 目标值为空或 undefined
if (!target?.trim()) return true;
@@ -110,7 +110,7 @@ export default function Participants(props) {
user_action_status;
const showApplicationEntry =
[can_pay, can_substitute, is_substituting, waiting_start].every(
(item) => !item
(item) => !item,
) &&
can_join &&
dayjs(start_time).isAfter(dayjs());
@@ -138,7 +138,7 @@ export default function Participants(props) {
Taro.navigateTo({
url: `/login_pages/index/index?redirect=${encodeURIComponent(
fullPath
fullPath,
)}`,
});
}
@@ -153,7 +153,7 @@ export default function Participants(props) {
const matchNtrpReq = matchNtrpRequestment(
userInfo?.ntrp_level,
skill_level_min,
skill_level_max
skill_level_max,
);
function handleSelfEvaluate() {
@@ -180,7 +180,7 @@ export default function Participants(props) {
}
function generateTextAndAction(
user_action_status: null | { [key: string]: boolean }
user_action_status: null | { [key: string]: boolean },
):
| undefined
| { text: string | React.FC; action?: () => void; available?: boolean } {
@@ -259,7 +259,7 @@ export default function Participants(props) {
const res = await OrderService.getUnpaidOrder(id);
if (res.code === 0) {
navto(
`/order_pages/orderDetail/index?id=${res.data.order_info.order_id}`
`/order_pages/orderDetail/index?id=${res.data.order_info.order_id}`,
);
}
}),
@@ -296,10 +296,11 @@ export default function Participants(props) {
const { action = () => {} } = generateTextAndAction(user_action_status)!;
const leftCount = max_participants - participant_count;
const leftSubstituteCount = (max_substitute_players || 0) - (substitute_count || 0);
const leftSubstituteCount =
(max_substitute_players || 0) - (substitute_count || 0);
const showSubstituteApplicationEntry =
[can_pay, can_join, is_substituting, waiting_start].every(
(item) => !item
(item) => !item,
) &&
can_substitute &&
dayjs(start_time).isAfter(dayjs());
@@ -336,7 +337,7 @@ export default function Participants(props) {
refresherBackground="#FAFAFA"
className={classnames(
styles["participants-list-scroll"],
showApplicationEntry ? styles.withApplication : ""
showApplicationEntry ? styles.withApplication : "",
)}
scrollX
>
@@ -377,14 +378,14 @@ export default function Participants(props) {
src={avatar_url}
onClick={handleViewUserInfo.bind(
null,
participant_user_id
participant_user_id,
)}
/>
<Text className={styles["participants-list-item-name"]}>
{nickname || "未知"}
</Text>
<Text className={styles["participants-list-item-level"]}>
{displayNtrp}
NTRP {displayNtrp}
</Text>
<Text className={styles["participants-list-item-role"]}>
{role}
@@ -400,97 +401,107 @@ export default function Participants(props) {
)}
</View>
{/* 候补区域 */}
{max_substitute_players > 0 && (substitute_count > 0 || showSubstituteApplicationEntry) && (
<View className={styles["detail-page-content-participants"]}>
<View className={styles["participants-title"]}>
<Text></Text>
<Text>·</Text>
<Text>{leftSubstituteCount > 0 ? `剩余空位 ${leftSubstituteCount}` : "已满员"}</Text>
</View>
<View className={styles["participants-list"]}>
{/* 候补申请入口 */}
{showSubstituteApplicationEntry && (
<View
className={styles["participants-list-application"]}
onClick={() => {
action?.();
}}
>
<Image
className={styles["participants-list-application-icon"]}
src={img.ICON_DETAIL_APPLICATION_ADD}
/>
<Text className={styles["participants-list-application-text"]}>
</Text>
</View>
)}
{/* 候补成员列表 */}
<ScrollView
refresherBackground="#FAFAFA"
className={classnames(
styles["participants-list-scroll"],
showSubstituteApplicationEntry ? styles.withApplication : ""
{max_substitute_players > 0 &&
(substitute_count > 0 || showSubstituteApplicationEntry) && (
<View className={styles["detail-page-content-participants"]}>
<View className={styles["participants-title"]}>
<Text></Text>
<Text>·</Text>
<Text>
{leftSubstituteCount > 0
? `剩余空位 ${leftSubstituteCount}`
: "已满员"}
</Text>
</View>
<View className={styles["participants-list"]}>
{/* 候补申请入口 */}
{showSubstituteApplicationEntry && (
<View
className={styles["participants-list-application"]}
onClick={() => {
action?.();
}}
>
<Image
className={styles["participants-list-application-icon"]}
src={img.ICON_DETAIL_APPLICATION_ADD}
/>
<Text
className={styles["participants-list-application-text"]}
>
</Text>
</View>
)}
scrollX
>
<View
className={styles["participants-list-scroll-content"]}
style={{
width: `${
Math.max(substitute_members.length, 1) * 103 + (Math.max(substitute_members.length, 1) - 1) * 8
}px`,
}}
{/* 候补成员列表 */}
<ScrollView
refresherBackground="#FAFAFA"
className={classnames(
styles["participants-list-scroll"],
showSubstituteApplicationEntry ? styles.withApplication : "",
)}
scrollX
>
{substitute_members.map((substitute) => {
const {
is_organizer,
user: {
avatar_url,
nickname,
level,
ntrp_level,
id: substitute_user_id,
},
} = substitute;
const role = is_organizer ? "组织者" : "参与者";
// 优先使用 ntrp_level如果没有则使用 level
const ntrpValue = ntrp_level || level;
// 格式化显示 NTRP如果没有值则显示"初学者"
const displayNtrp = ntrpValue
? formatNtrpDisplay(ntrpValue)
: "初学者";
return (
<View
key={substitute.id}
className={styles["participants-list-item"]}
>
<Image
className={styles["participants-list-item-avatar"]}
mode="aspectFill"
src={avatar_url}
onClick={handleViewUserInfo.bind(
null,
substitute_user_id
)}
/>
<Text className={styles["participants-list-item-name"]}>
{nickname || "未知"}
</Text>
<Text className={styles["participants-list-item-level"]}>
{displayNtrp}
</Text>
<Text className={styles["participants-list-item-role"]}>
{role}
</Text>
</View>
);
})}
</View>
</ScrollView>
<View
className={styles["participants-list-scroll-content"]}
style={{
width: `${
Math.max(substitute_members.length, 1) * 103 +
(Math.max(substitute_members.length, 1) - 1) * 8
}px`,
}}
>
{substitute_members.map((substitute) => {
const {
is_organizer,
user: {
avatar_url,
nickname,
level,
ntrp_level,
id: substitute_user_id,
},
} = substitute;
const role = is_organizer ? "组织者" : "参与者";
// 优先使用 ntrp_level如果没有则使用 level
const ntrpValue = ntrp_level || level;
// 格式化显示 NTRP如果没有值则显示"初学者"
const displayNtrp = ntrpValue
? formatNtrpDisplay(ntrpValue)
: "初学者";
return (
<View
key={substitute.id}
className={styles["participants-list-item"]}
>
<Image
className={styles["participants-list-item-avatar"]}
mode="aspectFill"
src={avatar_url}
onClick={handleViewUserInfo.bind(
null,
substitute_user_id,
)}
/>
<Text className={styles["participants-list-item-name"]}>
{nickname || "未知"}
</Text>
<Text
className={styles["participants-list-item-level"]}
>
{displayNtrp}
</Text>
<Text className={styles["participants-list-item-role"]}>
{role}
</Text>
</View>
);
})}
</View>
</ScrollView>
</View>
</View>
</View>
)}
)}
<NTRPEvaluatePopup type={EvaluateScene.detail} ref={ntrpRef} showGuide />
</>
);

View File

@@ -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";
@@ -25,9 +25,10 @@ dayjs.locale("zh-cn");
// 分享弹窗
export default forwardRef(({ id, from, detail, userInfo }, ref) => {
const [visible, setVisible] = useState(false);
const [publishFlag, setPublishFlag] = useState(false);
const [shareImageUrl, setShareImageUrl] = useState("");
const { fetchUserInfo } = useUserActions();
const publishFlag = from === "publish";
// const posterRef = useRef();
const { max_participants, participant_count } = detail || {};
@@ -57,16 +58,20 @@ export default forwardRef(({ id, from, detail, userInfo }, ref) => {
}
useImperativeHandle(ref, () => ({
show: async (publish_flag = false) => {
setPublishFlag(publish_flag);
if (publish_flag) {
const url = await generateShareImageUrl();
setShareImageUrl(url);
}
show: async () => {
setVisible(true);
},
}));
useEffect(() => {
if (from === "publish") {
generateShareImageUrl().then((url) => {
setShareImageUrl(url);
setVisible(true);
});
}
}, [from]);
async function generateShareImageUrl() {
const {
play_type,
@@ -81,13 +86,14 @@ export default forwardRef(({ id, from, detail, userInfo }, ref) => {
const endTime = dayjs(end_time);
const dayofWeek = DayOfWeekMap.get(startTime.day());
const gameLength = `${endTime.diff(startTime, "hour")}小时`;
console.log(userInfo, "userInfo");
const url = await generateShareImage({
userAvatar: userInfo.avatar_url,
userNickname: userInfo.nickname,
gameType: play_type,
skillLevel: `NTRP ${genNTRPRequirementText(
skill_level_min,
skill_level_max
skill_level_max,
)}`,
gameDate: `${startTime.format("M月D日")} (${dayofWeek})`,
gameTime: `${startTime.format("ah")}${gameLength}`,
@@ -103,7 +109,7 @@ export default forwardRef(({ id, from, detail, userInfo }, ref) => {
// console.log(res, "res");
return {
title: detail.title,
imageUrl: url || "https://img.yzcdn.cn/vant/cat.jpeg",
imageUrl: url,
path: `/game_pages/detail/index?id=${id}&from=share`,
};
});
@@ -128,22 +134,25 @@ export default forwardRef(({ id, from, detail, userInfo }, ref) => {
const endTime = dayjs(end_time);
const dayofWeek = DayOfWeekMap.get(startTime.day());
const gameLength = `${endTime.diff(startTime, "hour")}小时`;
Taro.showLoading({ title: "生成中..." });
// Taro.showLoading({ title: "生成中..." });
const qrCodeUrlRes = await DetailService.getQrCodeUrl({
page: "game_pages/detail/index",
scene: `id=${id}`,
});
const qrCodeUrl = await base64ToTempFilePath(
qrCodeUrlRes.data.qr_code_base64
);
// const qrCodeUrl = await base64ToTempFilePath(
// qrCodeUrlRes.data.qr_code_base64
// );
const qrCodeUrl = qrCodeUrlRes.data.ossPath;
await delay(100);
// Taro.showLoading({ title: "生成中..." });
console.log('url', qrCodeUrl)
const url = await generatePosterImage({
playType: play_type,
ntrp: `NTRP ${genNTRPRequirementText(skill_level_min, skill_level_max)}`,
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,
@@ -152,7 +161,9 @@ export default forwardRef(({ id, from, detail, userInfo }, ref) => {
time: `${startTime.format("ah")}${gameLength}`,
qrCodeUrl,
});
Taro.hideLoading();
console.log('urlend', url)
// Taro.hideLoading();
Taro.showShareImageMenu({
path: url,
});
@@ -164,9 +175,20 @@ export default forwardRef(({ id, from, detail, userInfo }, ref) => {
setVisible(false);
}
async function handleCopyLink() {
const linkUrlRes = await DetailService.getLinkUrl({
path: "game_pages/detail/index",
query: `id=${id}`,
});
await Taro.setClipboardData({
data: linkUrlRes.data.url_link,
});
Taro.showToast({ title: "链接已复制到剪贴板", icon: "success" });
setVisible(false);
}
function onClose() {
setVisible(false);
setPublishFlag(false);
}
return (
@@ -193,14 +215,14 @@ export default forwardRef(({ id, from, detail, userInfo }, ref) => {
<View
className={styles.contentContainer}
style={{
backgroundImage: `url(${OSS_BASE_URL}/images/215f1ce1-be52-4a92-8250-5a4a69e7f2b3.png)`,
backgroundImage: `url(${OSS_BASE}/front/ball/images/215f1ce1-be52-4a92-8250-5a4a69e7f2b3.png)`,
}}
>
<View
catchMove
className={classnames(
styles.title,
publishFlag ? styles.publishTitle : ""
publishFlag ? styles.publishTitle : "",
)}
>
{publishFlag ? (
@@ -254,7 +276,7 @@ export default forwardRef(({ id, from, detail, userInfo }, ref) => {
</View>
</View>
<View className={styles.customBtnWrapper}>
<Button className={styles.button}>
<Button className={styles.button} onClick={handleCopyLink}>
<View className={styles.icon}>
<Image className={styles.linkIcon} src={LinkIcon} />
</View>

View File

@@ -23,6 +23,7 @@ import SupplementalNotes from "./components/SupplementalNotes";
import OrganizerInfo from "./components/OrganizerInfo";
import SharePopup from "./components/SharePopup";
import { navto, toast } from "@/utils/helper";
import { delay } from "@/utils";
import ArrowLeft from "@/static/detail/icon-arrow-left.svg";
// import Logo from "@/static/detail/icon-logo-go.svg";
import styles from "./index.module.scss";
@@ -81,9 +82,9 @@ function Index() {
// 位置更新后,重新获取详情页数据(因为距离等信息可能发生变化)
// 注意:这里不调用 fetchDetail避免与 useDidShow 中的调用重复
// 如果需要更新距离信息,可以在 fetchDetail 成功后根据当前位置重新计算
if (from === "publish") {
handleShare(true);
}
// if (from === "publish") {
// handleShare(true);
// }
} catch (error) {
console.error("用户位置更新失败", error);
}
@@ -119,8 +120,12 @@ function Index() {
}
}
function handleShare(flag = false) {
sharePopupRef.current.show(flag);
function handleShare() {
if (!detail.id) {
toast("球局未加载完成,请稍后再试");
return false;
}
sharePopupRef.current.show();
}
const handleJoinGame = async () => {
@@ -161,7 +166,7 @@ function Index() {
navto(
userId === myInfo.id
? "/user_pages/myself/index"
: `/user_pages/other/index?userid=${userId}`
: `/user_pages/other/index?userid=${userId}`,
);
}
@@ -195,7 +200,7 @@ function Index() {
<View
className={classnames(
styles["custom-navbar"],
glass ? styles.glass : ""
glass ? styles.glass : "",
)}
style={{
height: `${totalHeight}px`,
@@ -286,13 +291,15 @@ function Index() {
currentUserInfo={myInfo}
/>
{/* share popup */}
<SharePopup
ref={sharePopupRef}
id={id as string}
from={from as string}
detail={detail}
userInfo={userInfo}
/>
{detail.id && myInfo.id && (
<SharePopup
ref={sharePopupRef}
id={id as string}
from={from as string}
detail={detail}
userInfo={myInfo}
/>
)}
</View>
</ScrollView>
);

View File

@@ -5,7 +5,7 @@ import Taro, { useRouter } from "@tarojs/taro";
import classnames from "classnames";
import dayjs from "dayjs";
import "dayjs/locale/zh-cn";
import { generatePosterImage, base64ToTempFilePath, delay } from "@/utils";
import { generatePosterImage, delay } from "@/utils";
import { withAuth } from "@/components";
import GeneralNavbar from "@/components/GeneralNavbar";
import DetailService from "@/services/detailService";
@@ -16,7 +16,7 @@ import { useUserActions } from "@/store/userStore";
import { DayOfWeekMap } from "../detail/config";
import { genNTRPRequirementText } from "@/utils/helper";
import { waitForAuthInit } from "@/utils/authInit";
import { OSS_BASE_URL } from "@/config/api";
import { OSS_BASE } from "@/config/api";
import styles from "./index.module.scss";
dayjs.locale("zh-cn");
@@ -59,10 +59,11 @@ function SharePoster(props) {
page: "game_pages/detail/index",
scene: `id=${id}`,
});
const qrCodeUrl = await base64ToTempFilePath(
qrCodeUrlRes.data.qr_code_base64
);
debugger
const qrCodeUrl = qrCodeUrlRes.data.ossPath;
// const qrCodeUrl = await base64ToTempFilePath(
// qrCodeUrlRes.data.qr_code_base64
// );
// debugger
await delay(100);
const url = await generatePosterImage({
playType: play_type,
@@ -70,7 +71,7 @@ function SharePoster(props) {
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,

View File

@@ -9,6 +9,23 @@
}
.link_button
{
display: flex;
align-items: center;
justify-content: center;
gap: 12px;
height: 52px;
border-radius: 16px;
border: none;
position: relative;
font-size: 16px;
.button_text {
color: #fff;
}
}
// 背景图片和渐变覆盖层
.background_image {
position: absolute;

View File

@@ -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,
@@ -155,6 +156,11 @@ const LoginPage: React.FC = () => {
e.stopPropagation();
};
// 返回首页
const handle_return_home = () => {
Taro.navigateTo({ url: "/main_pages/index" });
};
return (
<View className="login_page">
<View className="background_image">
@@ -166,6 +172,8 @@ const LoginPage: React.FC = () => {
<View className="bg_overlay"></View>
</View>
<GeneralNavbar title="" showBack={true} showAvatar={false} onBack={handle_return_home} />
{/* 主要内容 */}
<View className="login_main_content">
{/* 品牌区域 */}
@@ -211,6 +219,10 @@ const LoginPage: React.FC = () => {
<Text className="button_text"></Text>
</Button>
{/* <View className="return_home_button link_button" onClick={handle_return_home}>
<Text className="button_text">返回首页</Text>
</View> */}
{/* 用户协议复选框 */}
<View className="terms_checkbox_section">
<View className="checkbox_container" onClick={handle_toggle_terms}>

View File

@@ -627,6 +627,7 @@ const ListPageContent: React.FC<ListPageContentProps> = ({
reload={refreshMatches}
loadMoreMatches={loadMoreMatches}
evaluateFlag
enableHomeCards
/>
</ScrollView>
</View>

View File

@@ -16,7 +16,9 @@ interface MyselfPageContentProps {
isActive?: boolean;
}
const MyselfPageContent: React.FC<MyselfPageContentProps> = ({ isActive = true }) => {
const MyselfPageContent: React.FC<MyselfPageContentProps> = ({
isActive = true,
}) => {
const pickerOption = usePickerOption();
const { statusNavbarHeightInfo } = useGlobalState() || {};
const { totalHeight = 98 } = statusNavbarHeightInfo || {};
@@ -37,6 +39,7 @@ const MyselfPageContent: React.FC<MyselfPageContentProps> = ({ isActive = true }
const [hasLoaded, setHasLoaded] = useState(false); // 记录是否已经加载过数据
const [collapseProfile, setCollapseProfile] = useState(false);
const [refreshing, setRefreshing] = useState(false);
useEffect(() => {
pickerOption.getCities();
@@ -64,20 +67,22 @@ const MyselfPageContent: React.FC<MyselfPageContentProps> = ({ 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 };
},
[]
);
@@ -94,6 +99,8 @@ const MyselfPageContent: React.FC<MyselfPageContentProps> = ({ 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() -
@@ -101,6 +108,8 @@ const MyselfPageContent: React.FC<MyselfPageContentProps> = ({ isActive = true }
);
});
const { notEndGames, finishedGames } = classifyGameRecords(sorted_games);
console.log("notEndGames", notEndGames);
set_game_records(notEndGames);
setEndedGameRecords(finishedGames);
} catch (error) {
@@ -169,6 +178,23 @@ const MyselfPageContent: React.FC<MyselfPageContentProps> = ({ 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 +204,9 @@ const MyselfPageContent: React.FC<MyselfPageContentProps> = ({ isActive = true }
<ScrollView
scrollY
refresherBackground="#FAFAFA"
refresherEnabled
refresherTriggered={refreshing}
onRefresherRefresh={handle_refresh}
className={styles.myselfPage}
>
<View
@@ -229,17 +258,15 @@ const MyselfPageContent: React.FC<MyselfPageContentProps> = ({ isActive = true }
<View className={styles.gameTabsSection}>
<View className={styles.tabContainer}>
<View
className={`${styles.tabItem} ${
active_tab === "hosted" ? styles.active : ""
}`}
className={`${styles.tabItem} ${active_tab === "hosted" ? styles.active : ""
}`}
onClick={() => setActiveTab("hosted")}
>
<Text className={styles.tabText}></Text>
</View>
<View
className={`${styles.tabItem} ${
active_tab === "participated" ? styles.active : ""
}`}
className={`${styles.tabItem} ${active_tab === "participated" ? styles.active : ""
}`}
onClick={() => setActiveTab("participated")}
>
<Text className={styles.tabText}></Text>
@@ -260,16 +287,15 @@ const MyselfPageContent: React.FC<MyselfPageContentProps> = ({ 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}
/>
</ScrollView>
@@ -287,13 +313,12 @@ const MyselfPageContent: React.FC<MyselfPageContentProps> = ({ 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}
/>
</ScrollView>

View File

@@ -1,6 +1,7 @@
export default definePageConfig({
navigationBarTitleText: '首页',
navigationStyle: 'custom',
navigationBarBackgroundColor: '#FAFAFA'
})
navigationBarTitleText: '首页',
navigationStyle: 'custom',
navigationBarBackgroundColor: '#FAFAFA',
enableShareAppMessage: true,
})

View File

@@ -1,6 +1,7 @@
import React, { useState, useEffect, useCallback } from "react";
import { View } from "@tarojs/components";
import Taro from "@tarojs/taro";
import Taro, { useRouter, useShareAppMessage } from "@tarojs/taro";
import { OSS_BASE } from "@/config/api";
import { wechat_auth_login, save_login_state } from "@/services/loginService";
import { useUserActions } from "@/store/userStore";
import { useGlobalState } from "@/store/global";
@@ -18,7 +19,11 @@ import { useDictionaryStore } from "@/store/dictionaryStore";
type TabType = "list" | "message" | "personal";
const MainPage: React.FC = () => {
const [currentTab, setCurrentTab] = useState<TabType>("list");
const { params } = useRouter();
const [currentTab, setCurrentTab] = useState<TabType>(() => {
const tab = params?.tab as TabType | undefined;
return tab === "list" || tab === "message" || tab === "personal" ? tab : "list";
});
const [isPublishMenuVisible, setIsPublishMenuVisible] = useState(false);
const [isDistanceFilterVisible, setIsDistanceFilterVisible] = useState(false);
const [isCityPickerVisible, setIsCityPickerVisible] = useState(false);
@@ -35,6 +40,14 @@ const MainPage: React.FC = () => {
const { showGuideBar, guideBarZIndex, setShowGuideBar, setGuideBarZIndex } =
useGlobalState();
// 从分享链接进入时根据 ?tab= 定位到对应 tab
useEffect(() => {
const tab = params?.tab as TabType | undefined;
if (tab === "list" || tab === "message" || tab === "personal") {
setCurrentTab(tab);
}
}, [params?.tab]);
// 初始化:自动微信授权并获取用户信息
useEffect(() => {
const init = async () => {
@@ -67,12 +80,6 @@ const MainPage: React.FC = () => {
try {
await fetchUserInfo();
await checkNicknameChangeStatus();
// 启动时预取 Banner 字典(与业务无强依赖,失败不影响主流程)
try {
await useDictionaryStore.getState().fetchBannerDictionary();
} catch (e) {
console.error("预取 Banner 字典失败:", e);
}
} catch (error) {
console.error("获取用户信息失败:", error);
}
@@ -159,6 +166,21 @@ const MainPage: React.FC = () => {
[]
);
// 分享:首页、个人页均支持转发
// 分享图:配置 OSS 地址 + 路径(不含 ? 后参数),首页用 share_home.png个人页用 share_self.png
useShareAppMessage(() => {
const isList = currentTab === "list";
const isPersonal = currentTab === "personal";
const title = isList ? "约球 - 发现身边的球局" : isPersonal ? "约球 - 我的约球" : "约球";
const image_path = isPersonal ? "system/share_self.png" : "system/share_home.png";
const imageUrl = OSS_BASE ? `${OSS_BASE.replace(/\/$/, "")}/${image_path}` : "";
return {
title,
path: "/main_pages/index" + (isList ? "?tab=list" : isPersonal ? "?tab=personal" : ""),
imageUrl: imageUrl,
};
});
// 滚动到顶部
const scrollToTop = useCallback(() => {
// 如果当前是列表页,触发列表页内部滚动

View File

@@ -26,7 +26,7 @@ import { useGlobalStore } from "@/store/global";
import { useOrder } from "@/store/orderStore";
import detailService, { GameData } from "@/services/detailService";
import { withAuth, RefundPopup, GeneralNavbar } from "@/components";
import { OSS_BASE_URL } from "@/config/api";
import { OSS_BASE } from "@/config/api";
import img from "@/config/images";
import CustomerIcon from "@/static/order/customer.svg";
import { handleCustomerService } from "@/services/userService";
@@ -301,7 +301,7 @@ function GameInfo(props) {
<View className={styles.locationMessageIcon}>
<Image
className={styles.locationMessageIconImage}
src={`${OSS_BASE_URL}/images/3ee5c89c-fe58-4a56-9471-1295da09c743.png`}
src={`${OSS_BASE}/front/ball/images/3ee5c89c-fe58-4a56-9471-1295da09c743.png`}
/>
</View>
{/* location message */}

View File

@@ -69,6 +69,7 @@ function generateTimeMsg(game_info) {
const OrderList = () => {
const [list, setList] = useState<any[][]>([]);
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}

View File

@@ -249,7 +249,7 @@ const CommentReply = () => {
<View className="comment-left">
<Image
className="user-avatar"
src={item.user_avatar || "https://img.yzcdn.cn/vant/cat.jpeg"}
src={item.user_avatar }
mode="aspectFill"
onClick={(e) => handleUserClick(e, item.user_id)}
/>

View File

@@ -1,6 +1,6 @@
export default definePageConfig({
navigationBarTitleText: '开启消息通知',
navigationStyle: 'custom',
enablePullDownRefresh: false,
backgroundColor:"#FAFAFA"
});

View File

@@ -1,7 +1,9 @@
.enable_notification_page {
width: 100%;
// min-height: 100vh;
height: 100%;
background: radial-gradient(circle at 50% 0%, rgba(191, 255, 239, 1) 0%, rgba(255, 255, 255, 1) 37%);
box-sizing: border-box;
display: flex;
flex-direction: column;
@@ -12,7 +14,6 @@
align-items: center;
flex: 1;
position: relative;
overflow: hidden;
}
// 示例消息卡片区域
@@ -30,12 +31,12 @@
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);
box-sizing: border-box;
position: absolute;
background: #ffffff;
// 第三个卡片(最上面)
&--3 {

View File

@@ -21,10 +21,10 @@ const OrderCheck = () => {
//TODO: get order msg from id
const handlePay = async () => {
Taro.showLoading({
title: '支付中...',
mask: true
})
// Taro.showLoading({
// title: '支付中...',
// mask: true
// })
const res = await orderService.createOrder(Number(gameId))
if (res.code === 0) {
const { payment_required, payment_params } = res.data
@@ -37,7 +37,7 @@ const OrderCheck = () => {
signType,
paySign,
success: async () => {
Taro.hideLoading()
// Taro.hideLoading()
Taro.showToast({
title: '支付成功',
icon: 'success'
@@ -48,7 +48,7 @@ const OrderCheck = () => {
})
},
fail: () => {
Taro.hideLoading()
// Taro.hideLoading()
Taro.showToast({
title: '支付失败',
icon: 'none'

View File

@@ -193,7 +193,7 @@ const NewFollow = () => {
<View className="follow-left" onClick={() => handleUserClick(item.user_id)}>
<Image
className="user-avatar" mode="aspectFill"
src={item.user_avatar || "https://img.yzcdn.cn/vant/cat.jpeg"}
src={item.user_avatar || require("@/static/userInfo/default_avatar.svg")}
/>

View File

@@ -16,10 +16,9 @@ import { useGlobalState } from "@/store/global";
import { delay, getCurrentFullPath } from "@/utils";
import { formatNtrpDisplay } from "@/utils/helper";
import { waitForAuthInit } from "@/utils/authInit";
import httpService from "@/services/httpService";
// import httpService from "@/services/httpService";
import DetailService from "@/services/detailService";
import { base64ToTempFilePath } from "@/utils/genPoster";
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";
@@ -38,7 +37,7 @@ const sourceTypeToTextMap = new Map([
function adjustRadarLabels(
source: [string, number][],
topK: number = 4 // 默认挑前4个最长的标签保护
topK: number = 4, // 默认挑前4个最长的标签保护
): [string, number][] {
if (source.length === 0) return source;
@@ -226,7 +225,7 @@ function Intro() {
<View
className={styles.introContainer}
style={{
backgroundImage: `url(${OSS_BASE_URL}/images/215f1ce1-be52-4a92-8250-5a4a69e7f2b3.png)`,
backgroundImage: `url(${OSS_BASE}/front/ball/images/215f1ce1-be52-4a92-8250-5a4a69e7f2b3.png)`,
}}
>
<CommonGuideBar />
@@ -253,7 +252,7 @@ function Intro() {
<View className={styles.tip}>
<Image
className={styles.tipImage}
src={`${OSS_BASE_URL}/images/b7cb47aa-b609-4112-899f-3fde02ed2431.png`}
src={`${OSS_BASE}/front/ball/images/b7cb47aa-b609-4112-899f-3fde02ed2431.png`}
mode="aspectFit"
/>
</View>
@@ -311,7 +310,7 @@ function Intro() {
<View className={styles.tip}>
<Image
className={styles.tipImage}
src={`${OSS_BASE_URL}/images/b7cb47aa-b609-4112-899f-3fde02ed2431.png`}
src={`${OSS_BASE}/front/ball/images/b7cb47aa-b609-4112-899f-3fde02ed2431.png`}
mode="aspectFit"
/>
</View>
@@ -319,7 +318,7 @@ function Intro() {
<View className={styles.radar}>
<Image
className={styles.radarImage}
src={`${OSS_BASE_URL}/images/a2e1b639-82a9-4ab8-b767-8605556eafcb.png`}
src={`${OSS_BASE}/front/ball/images/a2e1b639-82a9-4ab8-b767-8605556eafcb.png`}
mode="aspectFit"
/>
</View>
@@ -381,7 +380,7 @@ function Test() {
prev.map((item, pIndex) => ({
...item,
...(pIndex === index ? { choosen: i } : {}),
}))
})),
);
}
@@ -428,7 +427,7 @@ function Test() {
<View
className={styles.testContainer}
style={{
backgroundImage: `url(${OSS_BASE_URL}/images/215f1ce1-be52-4a92-8250-5a4a69e7f2b3.png)`,
backgroundImage: `url(${OSS_BASE}/front/ball/images/215f1ce1-be52-4a92-8250-5a4a69e7f2b3.png)`,
}}
>
<CommonGuideBar confirm title={`${index + 1} / ${questions.length}`} />
@@ -523,13 +522,14 @@ function Result() {
page: "other_pages/ntrp-evaluate/index",
scene: `stage=${StageType.INTRO}`,
});
if (qrCodeUrlRes.code === 0 && qrCodeUrlRes.data?.qr_code_base64) {
// 将 base64 转换为临时文件路径
const tempFilePath = await base64ToTempFilePath(
qrCodeUrlRes.data.qr_code_base64
);
setQrCodeUrl(tempFilePath);
}
setQrCodeUrl(qrCodeUrlRes.data.ossPath);
// if (qrCodeUrlRes.code === 0 && qrCodeUrlRes.data?.qr_code_base64) {
// // 将 base64 转换为临时文件路径
// const tempFilePath = await base64ToTempFilePath(
// qrCodeUrlRes.data.qr_code_base64
// );
// setQrCodeUrl(tempFilePath);
// }
} catch (error) {
console.error("获取二维码失败:", error);
}
@@ -539,18 +539,25 @@ function Result() {
const res = await evaluateService.getTestResult({ record_id: Number(id) });
if (res.code === 0) {
setResult(res.data);
// delay(1000);
setRadarData(
adjustRadarLabels(
Object.entries(res.data.radar_data.abilities).map(([key, value]) => [
key,
Math.min(
100,
Math.floor((value.current_score / value.max_score) * 100)
),
])
)
const sortOrder = res.data.sort || [];
const abilities = res.data.radar_data.abilities;
const sortedKeys = sortOrder.filter((k) => k in abilities);
const remainingKeys = Object.keys(abilities).filter(
(k) => !sortOrder.includes(k),
);
const allKeys = [...sortedKeys, ...remainingKeys];
let radarData: [string, number][] = allKeys.map((key) => [
key,
Math.min(
100,
Math.floor(
(abilities[key].current_score / abilities[key].max_score) * 100,
),
),
]);
// 直接使用接口 sort 顺序,不经过 adjustRadarLabels 重新排序
setRadarData(radarData);
updateUserLevel(res.data.record_id, res.data.ntrp_level);
}
}
@@ -588,7 +595,7 @@ function Result() {
if (!userInfo?.phone) {
Taro.redirectTo({
url: `/login_pages/index/index?redirect=${encodeURIComponent(
`/main_pages/index`
`/main_pages/index`,
)}`,
});
clear();
@@ -613,11 +620,12 @@ function Result() {
page: "other_pages/ntrp-evaluate/index",
scene: `stage=${StageType.INTRO}`,
});
if (qrCodeUrlRes.code === 0 && qrCodeUrlRes.data?.qr_code_base64) {
finalQrCodeUrl = await base64ToTempFilePath(
qrCodeUrlRes.data.qr_code_base64
);
}
finalQrCodeUrl = qrCodeUrlRes.data.ossPath;
// if (qrCodeUrlRes.code === 0 && qrCodeUrlRes.data?.qr_code_base64) {
// finalQrCodeUrl = await base64ToTempFilePath(
// qrCodeUrlRes.data.qr_code_base64
// );
// }
}
// 使用 RadarV2 的 generateFullImage 方法生成完整图片
@@ -712,7 +720,7 @@ function Result() {
<View
className={styles.card}
style={{
backgroundImage: `url(${OSS_BASE_URL}/images/f5b45cea-5015-41d6-aaf4-83b2e76678e1.png)`,
backgroundImage: `url(${OSS_BASE}/front/ball/images/f5b45cea-5015-41d6-aaf4-83b2e76678e1.png)`,
}}
>
<View className={styles.avatarWrap}>
@@ -762,7 +770,8 @@ function Result() {
{userInfo?.phone ? (
<View className={styles.updateTip}>
<Text>
NTRP {formatNtrpDisplay(result?.ntrp_level || "")}{" "}
NTRP {" "}
{formatNtrpDisplay(result?.ntrp_level || "")}{" "}
</Text>
<Text className={styles.grayTip}>()</Text>
</View>

View File

@@ -1,7 +1,7 @@
import React, { useState, useEffect } from 'react'
import { View, Text, Textarea, Image } from '@tarojs/components'
import Taro from '@tarojs/taro'
import { ConfigProvider, Loading, Popup, Toast } from '@nutui/nutui-react-taro'
import { ConfigProvider, Loading, Toast } from '@nutui/nutui-react-taro'
import styles from './index.module.scss'
import uploadFiles from '@/services/uploadFiles'
import publishService from '@/services/publishService'
@@ -109,7 +109,10 @@ const AiImportPopup: React.FC<AiImportPopupProps> = ({
}
const handleTextChange = (e: any) => {
setText(e.detail.value)
const text = e.detail.value;
const maxAllowedLength = 120;
const truncatedVal = text.length > maxAllowedLength ? text.slice(0, maxAllowedLength) : text
setText(truncatedVal)
}
// 使用全局键盘状态监听
@@ -191,73 +194,90 @@ const AiImportPopup: React.FC<AiImportPopupProps> = ({
}
const showManualButton = uploadFailCount >= maxFailCount
if (!visible) {
return null
}
// 阻止弹窗内的触摸事件冒泡
const handleTouchMoveInPopup = (e) => {
if (!isKeyboardVisible) {
e.stopPropagation()
}
}
return (
<Popup
visible={visible}
position="bottom"
round={true}
closeable={false}
onClose={closePopupBefore}
className={styles.aiImportPopup}
style={{ paddingBottom: isKeyboardVisible ? `${keyboardHeight}px` : undefined }}
>
<View className={styles.popupContent}>
{/* 头部 */}
<View className={styles.header}>
<View className={styles.titleContainer}>
<Image src={images.ICON_IMPORTANT_BLACK} className={styles.lightningIcon} />
<Text className={styles.title}></Text>
</View>
<View className={styles.closeButton} onClick={closePopupBefore}>
<Image src={images.ICON_CLOSE} className={styles.lightningIcon} />
</View>
</View>
{/* 文本域 */}
<View className={styles.textAreaContainer}>
<Textarea
className={styles.textArea}
value={text}
onInput={handleTextChange}
onFocus={() => {}}
onBlur={() => {}}
placeholder="在此「粘贴识别」或输入文本,智能拆分球局时间、费用、地点和其他信息,并帮你智能生成球局标题"
maxlength={-1}
showConfirmBar={false}
placeholderClass={styles.textArea_placeholder}
autoHeight
// 关闭系统自动上推,改为手动根据键盘高度加内边距
adjustPosition={false}
/>
<View className={styles.charCount}>
<Text className={`${styles.charCountText} ${isCharCountExceeded ? styles.charCountTextExceeded : ''}`}>
{text.length}/100
</Text>
</View>
</View>
{/* 图片识别按钮 */}
<View className={styles.imageRecognitionContainer}>
<View className={`${styles.imageRecognitionButton} ${uploadLoading ? styles.uploadLoadingContainer : ''}`} onClick={handleImageRecognition}>
{
uploadLoading ? (<Image src={images.ICON_UPLOAD_SUCCESS} className={styles.cameraIcon} />) : (<Image src={images.ICON_UPLOAD_IMG} className={styles.cameraIcon} />)
}
<Text className={styles.imageRecognitionText}></Text>
<Text className={styles.imageRecognitionDesc}>{uploadLoading ? '已上传 1 张图片' : '支持订场截图/小红书笔记截图等图片'}</Text>
</View>
</View>
{/* 底部按钮 */}
<View className={styles.bottomButtons}>
{showManualButton && (
<View className={styles.manualButton} onClick={handleManualPublish}>
<Text className={styles.manualButtonText}></Text>
<View
className={styles.aiImportPopupOverlay}
>
<View className={styles.aiImportPopupWrapper} onTouchMove={handleTouchMoveInPopup} catchMove></View>
<View
className={styles.aiImportPopup}
style={{ paddingBottom: isKeyboardVisible ? `${keyboardHeight}px` : undefined }}
>
<View className={styles.popupContent}>
{/* 头部 */}
<View className={styles.header}>
<View className={styles.titleContainer}>
<Image src={images.ICON_IMPORTANT_BLACK} className={styles.lightningIcon} />
<Text className={styles.title}></Text>
</View>
)}
<View className={styles.pasteButton} onClick={handlePasteAndRecognize}>
{
loading ? (
<View className={styles.closeButton} onClick={closePopupBefore}>
<Image src={images.ICON_CLOSE} className={styles.lightningIcon} />
</View>
</View>
{/* 文本域 */}
<View className={styles.textAreaContainer}>
<Textarea
className={styles.textArea}
value={text}
onInput={handleTextChange}
onFocus={() => {}}
onBlur={() => {}}
placeholder="在此「粘贴识别」或输入文本,智能拆分球局时间、费用、地点和其他信息,并帮你智能生成球局标题"
maxlength={-1}
showConfirmBar={false}
placeholderClass={styles.textArea_placeholder}
autoHeight
// 关闭系统自动上推,改为手动根据键盘高度加内边距
adjustPosition={false}
/>
<View className={styles.charCount}>
<Text className={`${styles.charCountText} ${isCharCountExceeded ? styles.charCountTextExceeded : ''}`}>
{text.length}/100
</Text>
</View>
</View>
{/* 图片识别按钮 */}
<View className={styles.imageRecognitionContainer}>
<View
className={`${styles.imageRecognitionButton} ${
uploadLoading ? styles.uploadLoadingContainer : ''
}`}
onClick={handleImageRecognition}
>
{uploadLoading ? (
<Image src={images.ICON_UPLOAD_SUCCESS} className={styles.cameraIcon} />
) : (
<Image src={images.ICON_UPLOAD_IMG} className={styles.cameraIcon} />
)}
<Text className={styles.imageRecognitionText}></Text>
<Text className={styles.imageRecognitionDesc}>
{uploadLoading ? '已上传 1 张图片' : '支持订场截图/小红书笔记截图等图片'}
</Text>
</View>
</View>
{/* 底部按钮 */}
<View className={styles.bottomButtons}>
{showManualButton && (
<View className={styles.manualButton} onClick={handleManualPublish}>
<Text className={styles.manualButtonText}></Text>
</View>
)}
<View className={styles.pasteButton} onClick={handlePasteAndRecognize}>
{loading ? (
<View className={styles.loadingContainer}>
<ConfigProvider theme={{ nutuiLoadingIconColor: '#fff', nutuiLoadingIconSize: '20px' }}>
<Loading type="circular" />
@@ -269,13 +289,13 @@ const AiImportPopup: React.FC<AiImportPopupProps> = ({
<Image src={images.ICON_COPY} className={styles.clipboardIcon} />
<Text className={styles.pasteButtonText}></Text>
</>
)
}
)}
</View>
</View>
</View>
<Toast id="toast" />
</View>
<Toast id="toast" />
</Popup>
</View>
)
}

View File

@@ -1,14 +1,34 @@
@use '~@/scss/themeColor.scss' as theme;
.aiImportPopupOverlay {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0, 0, 0, 0.5);
z-index: 9998;
display: flex;
align-items: flex-end;
justify-content: center;
}
.aiImportPopupWrapper {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
z-index: 9998;
}
.aiImportPopup {
background-color: #fff;
&:global(.nut-popup-bottom.nut-popup-round) {
border-radius: 20px 20px 0 0!important;
}
width: 100%;
background-color:#fafafa;
border-radius: 16px 16px 0 0;
position: relative;
z-index: 9999;
.popupContent {
width: 100%;
background: #fff;
border-radius: 16px 16px 0 0;
padding: 0;
box-sizing: border-box;
max-height: 80vh;

View File

@@ -3,7 +3,7 @@ import { View, Text, Input, ScrollView, Image } from '@tarojs/components'
import Taro from '@tarojs/taro'
import { Loading } from '@nutui/nutui-react-taro'
import StadiumDetail, { StadiumDetailRef } from './StadiumDetail'
import { CommonPopup } from '../../../../components'
import { CommonPopup, CustomPopup } from '../../../../components'
import { getLocation } from '@/utils/locationUtils'
import PublishService from '@/services/publishService'
import images from '@/config/images'
@@ -188,24 +188,20 @@ const SelectStadium: React.FC<SelectStadiumProps> = ({
// 如果显示详情页面
if (showDetail && selectedStadium) {
return (
<CommonPopup
<CustomPopup
visible={visible}
onClose={handleCancel}
cancelText="返回"
confirmText="确认"
className="select-stadium-popup"
onCancel={handleDetailCancel}
onConfirm={handleConfirm}
position="bottom"
//style={{ paddingBottom: keyboardVisible ? `20px` : undefined }}
round
>
<StadiumDetail
ref={stadiumDetailRef}
stadium={selectedStadium}
//onAnyInput={handleAnyInput}
/>
</CommonPopup>
{/* 内容区域 */}
<StadiumDetail
ref={stadiumDetailRef}
stadium={selectedStadium}
/>
</CustomPopup>
)
}

View File

@@ -4,7 +4,7 @@
display: flex;
flex-direction: column;
.stadium-detail-scroll{
height:60vh;
max-height:60vh;
}
// 已选球场
// 场馆列表

View File

@@ -1,10 +1,11 @@
import React, { useState, useCallback, forwardRef, useImperativeHandle } from 'react'
import React, { useState, useCallback, forwardRef, useImperativeHandle, useEffect } from 'react'
import Taro from '@tarojs/taro'
import { View, Text, Image, ScrollView } from '@tarojs/components'
import images from '@/config/images'
import TextareaTag from '@/components/TextareaTag'
// import CoverImageUpload, { type CoverImage } from '@/components/ImageUpload'
import UploadCover, { type CoverImageValue } from '@/components/UploadCover'
import { useKeyboardHeight } from '@/store/keyboardStore'
import { useDictionaryActions } from '@/store/dictionaryStore'
import './StadiumDetail.scss'
@@ -69,12 +70,16 @@ const StadiumDetail = forwardRef<StadiumDetailRef, StadiumDetailProps>(({
stadium,
onAnyInput
}, ref) => {
const [openPicker, setOpenPicker] = useState(false);
const [openPicker, setOpenPicker] = useState(false); //为了解决上传图片时按钮样式问题
const [scrollTop, setScrollTop] = useState(0);
const { getDictionaryValue } = useDictionaryActions()
const court_type = getDictionaryValue('court_type') || []
const court_surface = getDictionaryValue('court_surface') || []
const supplementary_information = getDictionaryValue('supplementary_information') || []
// 使用全局键盘状态
const { keyboardHeight, isKeyboardVisible, addListener, initializeKeyboardListener } = useKeyboardHeight()
const stadiumInfo = [
{
label: '场地类型',
@@ -171,19 +176,40 @@ const StadiumDetail = forwardRef<StadiumDetailRef, StadiumDetailProps>(({
const changeTextarea = (value) => {
// 使用全局键盘状态监听
useEffect(() => {
// 初始化全局键盘监听器
initializeKeyboardListener()
// 添加本地监听器
const removeListener = addListener((height, visible) => {
console.log('AiImportPopup 收到键盘变化:', height, visible)
})
return () => {
removeListener()
}
}, [initializeKeyboardListener, addListener])
const changeTextarea = (value: boolean) => {
if (value) {
// 先滚动到底部
setScrollTop(scrollTop ? scrollTop + 1 : 9999);
setScrollTop(140);
// 使用 setTimeout 确保滚动后再更新 openPicker
}
}
const changePicker = (value) => {
const changePicker = (value:boolean) => {
setOpenPicker(value);
}
console.log(stadium,'stadiumstadium');
// 计算滚动区域的最大高度
const scrollMaxHeight = isKeyboardVisible
? `calc(100vh - ${keyboardHeight+40}px)`
: '60vh'
return (
<View className='stadium-detail'>
<ScrollView
@@ -191,6 +217,7 @@ const StadiumDetail = forwardRef<StadiumDetailRef, StadiumDetailProps>(({
refresherBackground="#FAFAFA"
scrollY={!openPicker}
scrollTop={scrollTop}
style={{ maxHeight: scrollMaxHeight }}
>
{/* 已选球场 */}
<View
@@ -235,11 +262,13 @@ const StadiumDetail = forwardRef<StadiumDetailRef, StadiumDetailProps>(({
<TextareaTag
value={formData[item.prop]}
onChange={(value) => {
changeTextarea(true)
updateFormData(item.prop, value)
}}
// onBlur={() => changeTextarea(false)}
onFocus={() => changeTextarea(true)}
// onBlur={() => {
// }}
onFocus={() => {
changeTextarea(true)
}}
placeholder='有其他场地信息可备注'
options={(item.options || []).map((o) => ({ label: o, value: o }))}
/>

View File

@@ -78,9 +78,8 @@ const PublishBall: React.FC = () => {
} = useKeyboardHeight();
// 获取页面参数并设置导航标题
const [optionsConfig, setOptionsConfig] = useState<FormFieldConfig[]>(
publishBallFormSchema
publishBallFormSchema,
);
console.log(userInfo, "userInfo");
const [formData, setFormData] = useState<PublishBallFormData[]>([
defaultFormData,
]);
@@ -103,13 +102,11 @@ const PublishBall: React.FC = () => {
const updateFormData = (
key: keyof PublishBallFormData,
value: any,
index: number
index: number,
) => {
console.log(key, value, index, "key, value, index");
setFormData((prev) => {
const newData = [...prev];
newData[index] = { ...newData[index], [key]: value };
console.log(newData, "newData");
return newData;
});
};
@@ -186,7 +183,7 @@ const PublishBall: React.FC = () => {
const confirmDelete = () => {
if (deleteConfirm.index >= 0) {
setFormData((prev) =>
prev.filter((_, index) => index !== deleteConfirm.index)
prev.filter((_, index) => index !== deleteConfirm.index),
);
closeDeleteConfirm();
Taro.showToast({
@@ -198,7 +195,7 @@ const PublishBall: React.FC = () => {
const validateFormData = (
formData: PublishBallFormData,
isOnSubmit: boolean = false
isOnSubmit: boolean = false,
) => {
const {
activityInfo,
@@ -207,7 +204,7 @@ const PublishBall: React.FC = () => {
image_list,
players,
current_players,
descriptionInfo
descriptionInfo,
} = formData;
const { play_type, price, location_name } = activityInfo;
const { description } = descriptionInfo;
@@ -225,7 +222,7 @@ const PublishBall: React.FC = () => {
// 判断图片是否上传完成
if (image_list?.length > 0) {
const uploadInProgress = image_list.some((item) =>
item.url.startsWith("http://tmp/")
item?.url?.startsWith?.("http://tmp/"),
);
if (uploadInProgress) {
Taro.showToast({
@@ -368,7 +365,6 @@ const PublishBall: React.FC = () => {
// 提交表单
const handleSubmit = async () => {
// 基础验证
console.log(formData, "formData");
const params = getParams();
const { republish } = params || {};
if (activityType === "individual") {
@@ -516,7 +512,7 @@ const PublishBall: React.FC = () => {
const mergeWithDefault = (
data: any,
isDetail: boolean = false
isDetail: boolean = false,
): PublishBallFormData => {
// ai导入与详情数据处理
const {
@@ -741,7 +737,6 @@ const PublishBall: React.FC = () => {
} else {
setIsSubmitDisabled(false);
}
console.log(formData, "formData");
}, [formData]);
useEffect(() => {
@@ -754,9 +749,8 @@ const PublishBall: React.FC = () => {
initializeKeyboardListener();
// 添加本地监听器
const removeListener = addListener((height, visible) => {
console.log("PublishBall 收到键盘变化:", height, visible);
// 这里只记录或用于其他逻辑,布局是否响应交由 shouldReactToKeyboard 决定
const removeListener = addListener(() => {
// 布局是否响应交由 shouldReactToKeyboard 决定
});
return () => {
@@ -789,6 +783,7 @@ const PublishBall: React.FC = () => {
>
<GeneralNavbar
title={titleBar}
backgroundColor={'#FAFAFA'}
className={styles["publish-ball-navbar"]}
/>
<View

View File

@@ -51,7 +51,6 @@ class CommonApiService {
data: results.map(result => result.data)
}
} catch (error) {
throw error
} finally {
Taro.hideLoading()
}

View File

@@ -158,14 +158,19 @@ class GameDetailService {
async getQrCodeUrl(req: { page: string, scene: string }): Promise<ApiResponse<{
qr_code_base64: string,
image_size: number,
ossPath: string,
page: string,
scene: string,
width: number
}>> {
return httpService.post('/user/generate_qrcode', req, {
showLoading: false
showLoading: true
})
}
async getLinkUrl(req: { path: string, query: string }): Promise<ApiResponse<{ url_link: string, path: string, query: string }>> {
return httpService.post('/user/generate_url_link', req, { showLoading: false })
}
}
// 导出认证服务实例

View File

@@ -58,6 +58,7 @@ export interface TestResultData {
level_img?: string; // 等级图片URL
radar_data: RadarData;
answers: Answer[];
sort?: string[]; // 雷达图能力项排序,如 ["正手球质", "正手控制", ...]
}
// 单条测试记录

View File

@@ -129,23 +129,30 @@ class HttpService {
// 隐藏loading支持多个并发请求
private hideLoading(): void {
this.loadingCount = Math.max(0, this.loadingCount - 1)
try {
this.loadingCount = Math.max(0, this.loadingCount - 1)
// 只有所有请求都完成时才隐藏loading
if (this.loadingCount === 0) {
// 清除之前的延时器
if (this.hideLoadingTimer) {
clearTimeout(this.hideLoadingTimer)
this.hideLoadingTimer = null
// 只有所有请求都完成时才隐藏loading
if (this.loadingCount === 0) {
// 清除之前的延时器
if (this.hideLoadingTimer) {
clearTimeout(this.hideLoadingTimer)
this.hideLoadingTimer = null
}
// 延时300ms后隐藏loading避免频繁切换
this.hideLoadingTimer = setTimeout(() => {
Taro.hideLoading()
this.currentLoadingText = ''
this.hideLoadingTimer = null
}, 800)
}
// 延时300ms后隐藏loading避免频繁切换
this.hideLoadingTimer = setTimeout(() => {
Taro.hideLoading()
this.currentLoadingText = ''
this.hideLoadingTimer = null
}, 800)
}
catch (e) {
console.warn(e)
}
}
// 处理响应
@@ -175,7 +182,7 @@ class HttpService {
url: '/login_pages/index/index'
})
reject(new Error('用户不存在'))
return response.data
return response.data
}
@@ -187,7 +194,7 @@ class HttpService {
} else {
reject(response.data)
}
return response.data
return response.data
}
}

View File

@@ -263,7 +263,7 @@ export const save_login_state = (token: string, user_info: WechatUserInfo) => {
export const clear_login_state = () => {
try {
// 使用 tokenManager 清除令牌
tokenManager.clearTokens();
// tokenManager.clearTokens();
// 清除其他登录状态
Taro.removeStorageSync("user_info");

View File

@@ -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<UserInfo> {
try {
@@ -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) {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 44 KiB

View File

@@ -0,0 +1,13 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<g clip-path="url(#clip0_3006_15051)">
<path d="M12.8375 3.17871C11.6157 2.03414 9.9731 1.33331 8.16683 1.33331C4.3929 1.33331 1.3335 4.39271 1.3335 8.16665C1.3335 11.9406 4.3929 15 8.16683 15C10.0384 15 11.7343 14.2475 12.9684 13.0287L8.00016 7.99998L12.8375 3.17871Z" stroke="black" stroke-width="1.33333" stroke-linejoin="round"/>
<path d="M13.3333 9.33335C14.0697 9.33335 14.6667 8.73639 14.6667 8.00002C14.6667 7.26365 14.0697 6.66669 13.3333 6.66669C12.597 6.66669 12 7.26365 12 8.00002C12 8.73639 12.597 9.33335 13.3333 9.33335Z" stroke="black" stroke-width="1.33333" stroke-linejoin="round"/>
<path d="M5.6665 4.33331V6.99998" stroke="black" stroke-width="1.33333" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M4.3335 5.66669H7.00016" stroke="black" stroke-width="1.33333" stroke-linecap="round" stroke-linejoin="round"/>
</g>
<defs>
<clipPath id="clip0_3006_15051">
<rect width="16" height="16" fill="white"/>
</clipPath>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 18 KiB

View File

@@ -20,7 +20,6 @@ interface DictionaryState {
bannerDetailImage: string
bannerListIndex: string
} | null
fetchBannerDictionary: () => Promise<void>
}
// 创建字典Store
@@ -36,7 +35,7 @@ export const useDictionaryStore = create<DictionaryState>()((set, get) => ({
set({ isLoading: true, error: null })
try {
const keys = 'publishing_requirements,court_type,court_surface,supplementary_information,game_play,fabu_tip,supported_cities';
const keys = 'publishing_requirements,court_type,court_surface,supplementary_information,game_play,fabu_tip,supported_cities,bannerListImage,bannerDetailImage,bannerListIndex';
const response = await commonApi.getDictionaryManyKey(keys)
if (response.code === 0 && response.data) {
@@ -53,6 +52,15 @@ export const useDictionaryStore = create<DictionaryState>()((set, get) => ({
dictionaryData: dictionaryData || {},
isLoading: false
})
set({
bannerDict: {
bannerListImage: response.data.bannerListImage || '',
bannerDetailImage: response.data.bannerDetailImage || '',
bannerListIndex: (response.data.bannerListIndex ?? '').toString(),
}
})
console.log('字典数据获取成功:', response.data)
} else {
throw new Error(response.message || '获取字典数据失败')
@@ -67,26 +75,7 @@ export const useDictionaryStore = create<DictionaryState>()((set, get) => ({
}
},
// 获取 Banner 字典(启动时或手动调用)
fetchBannerDictionary: async () => {
try {
const keys = 'bannerListImage,bannerDetailImage,bannerListIndex';
const response = await commonApi.getDictionaryManyKey(keys)
if (response.code === 0 && response.data) {
const data = response.data || {};
set({
bannerDict: {
bannerListImage: data.bannerListImage || '',
bannerDetailImage: data.bannerDetailImage || '',
bannerListIndex: (data.bannerListIndex ?? '').toString(),
}
})
}
} catch (error) {
// 保持静默,避免影响启动流程
console.error('获取 Banner 字典失败:', error)
}
},
// 获取字典值
getDictionaryValue: (key: string, defaultValue?: any) => {

View File

@@ -150,12 +150,13 @@ export const useKeyboardStore = create<KeyboardStore>((set, get) => ({
// 导出便捷的 hooks
export const useKeyboardHeight = () => {
const { keyboardHeight, isKeyboardVisible, addListener, initializeKeyboardListener } = useKeyboardStore()
const { keyboardHeight, isKeyboardVisible, addListener, initializeKeyboardListener, setKeyboardVisible } = useKeyboardStore()
return {
keyboardHeight,
isKeyboardVisible,
addListener,
initializeKeyboardListener
initializeKeyboardListener,
setKeyboardVisible
}
}

View File

@@ -11,8 +11,6 @@ import {
getCityQrCode,
getDistricts,
} from "../services/listApi";
// 不再在这里请求 banner 字典,统一由 dictionaryStore 启动时获取
import { useDictionaryStore } from "./dictionaryStore";
import {
ListActions,
IFilterOptions,
@@ -20,26 +18,6 @@ import {
IPayload,
} from "../../types/list/types";
// 将 banner 按索引插入到列表的工具方法0基长度不足则插末尾先移除已存在的 banner
function insertBannersToRows(rows: any[], dictData: any) {
if (!Array.isArray(rows) || !dictData) return rows;
const img = (dictData?.bannerListImage || "").trim();
const indexRaw = (dictData?.bannerListIndex || "").toString().trim();
if (!img) return rows;
const parsed = parseInt(indexRaw, 10);
const normalized = Number.isFinite(parsed) ? parsed : 0;
// 先移除已有的 banner确保列表中仅一条 banner
const resultRows = rows?.filter((item) => item?.type !== "banner") || [];
const target = Math.max(0, Math.min(normalized, resultRows.length));
resultRows.splice(target, 0, {
type: "banner",
id: `banner-${target}`,
banner_image_url: img,
banner_detail_url: (dictData?.bannerDetailImage || "").trim(),
} as any);
return resultRows;
}
function translateCityData(dataTree) {
return dataTree.map((item) => {
const { children, ...rest } = item;
@@ -272,14 +250,11 @@ export const useListStore = create<TennisStore>()((set, get) => ({
const currentPageState = state.isSearchResult ? state.searchPageState : state.listPageState;
const currentData = currentPageState?.data || [];
const newData = isAppend ? [...currentData, ...(data || [])] : (data || []);
// 从字典缓存获取 banner并将其插入到最终列表指定位置全局索引
const dictData = useDictionaryStore.getState().bannerDict;
const processedData = dictData ? insertBannersToRows(newData, dictData) : newData;
state.updateCurrentPageState({
data: processedData,
data: newData,
isHasMoreData,
// 使用插入后的最终数据判断是否显示空状态,避免有 banner 时仍显示空
isShowNoData: processedData?.length === 0,
isShowNoData: newData?.length === 0,
});
set({

View File

@@ -5,7 +5,7 @@ import { UserService } from "@/services/userService";
export interface PickerOptionState {
cities: any[];
professions: any[];
ntrpLevels: string[];
ntrpLevels: any[];
getCities: () => Promise<any>;
getProfessions: () => Promise<any>;
}
@@ -13,7 +13,40 @@ export interface PickerOptionState {
export const usePickerOption = create<PickerOptionState>((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();

View File

@@ -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<LastTimeTestResult | null>;
}
const getTimeNextDate = (time: string) => {
const date = new Date(time);
date.setDate(date.getDate() + 1);
@@ -51,8 +52,6 @@ export const useUser = create<UserState>()((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<UserState>()((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<UserState>()((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<UserState>()((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;
}
}

View File

@@ -66,6 +66,34 @@ const DownloadBillRecords: React.FC = () => {
});
}
};
const handlePreviewFile = (fileUrl: string) => {
wx.downloadFile({
url: fileUrl,
success: (res) => {
if (res.statusCode === 200) {
// 确保文件路径正确并添加扩展名
const filePath = res.tempFilePath;
wx.openDocument({
filePath: filePath,
fileType: 'xlsx', // 指定文件类型为xlsx
showMenu: true, // 显示右上角菜单按钮
success: (openRes) => {
console.log('打开文档成功');
},
fail: (err) => {
console.error('打开文档失败', err);
}
});
} else {
console.error('下载失败,状态码:', res.statusCode);
}
},
fail: (err) => {
console.error('下载失败', err);
}
});
}
return (
<View className="download-bill-records-page">
{/* 导航栏 */}
@@ -111,7 +139,7 @@ const DownloadBillRecords: React.FC = () => {
</View>
<View className="info-item">
<Text></Text>
<Text className="btn"></Text>
<Text className="btn" onClick={() => handlePreviewFile(record.file_url)}></Text>
</View>
</View>
)) : <EmptyState text="暂无数据" />}

View File

@@ -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 = () => {
<View className="item_right">
<Text
className={`item_value ${
form_data.country ||
form_data.province ||
form_data.city
form_data.city ||
form_data.district
? ""
: "placehoder"
}`}
>
{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}`
: "选择所在地区"}
</Text>
<Image
@@ -885,8 +889,8 @@ const EditProfilePage: React.FC = () => {
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}
/>
)}

View File

@@ -37,6 +37,7 @@
.qrcode {
width: 240px;
height: 240px;
margin: 32px 0 -20px;
}

View File

@@ -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}
>
{/* <CustomNavbar>
<View className="navbar_content">
@@ -317,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}
/>
</ScrollView>
@@ -363,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}
/>
</ScrollView>

View File

@@ -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;

View File

@@ -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<WalletInfo>({
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();
}}
/>
<ScrollView
scrollY
refresherBackground="#FAFAFA"
refresherEnabled
refresherTriggered={refreshing}
onRefresherRefresh={handle_refresh}
lowerThreshold={50}
onScrollToLower={handle_scroll_to_lower}
className="wallet_scroll"
>
{/* 钱包主卡片 */}
<View
className="wallet_main_card"
@@ -649,6 +677,7 @@ const WalletPage: React.FC = () => {
)}
</View>
</View>
</ScrollView>
{/* 提现弹窗 */}
<CommonPopup

View File

@@ -1,17 +1,11 @@
import Taro from "@tarojs/taro";
import { OSS_BASE_URL } from "@/config/api";
import { OSS_BASE } from "@/config/api";
const bgUrl = `${OSS_BASE_URL}/images/5e2c85ab-fb0c-4026-974d-1e0725181542.png`;
const ringUrl = `${OSS_BASE_URL}/images/b635164f-ecec-434a-a00b-69614a918f2f.png`;
const dateIcon = `${OSS_BASE_URL}/images/1b49476e-0eda-42ff-b08c-002ce510df82.jpg`;
const mapIcon = `${OSS_BASE_URL}/images/06b994fa-9227-4708-8555-8a07af8d0c3b.jpg`;
// const logo = `${OSS_BASE_URL}/images/fb732da6-11b9-4022-a524-a377b17635eb.jpg`
const logoText = `${OSS_BASE_URL}/images/9d8cbc9d-9601-4e2d-ab23-76420a4537d6.png`;
const bgUrl = `${OSS_BASE}/front/ball/images/5e2c85ab-fb0c-4026-974d-1e0725181542.png`;
const ringUrl = `${OSS_BASE}/front/ball/images/b635164f-ecec-434a-a00b-69614a918f2f.png`;
const dateIcon = `${OSS_BASE}/front/ball/images/1b49476e-0eda-42ff-b08c-002ce510df82.jpg`;
const mapIcon = `${OSS_BASE}/front/ball/images/06b994fa-9227-4708-8555-8a07af8d0c3b.jpg`;
const logoText = `${OSS_BASE}/system/youchang_tip_text.png`;
export function base64ToTempFilePath(base64Data: string): Promise<string> {
return new Promise((resolve, reject) => {
@@ -41,21 +35,48 @@ export function base64ToTempFilePath(base64Data: string): Promise<string> {
}
interface TaroGetImageInfo {
getImageInfo(option: {
src: string;
success?: (res: { width: number; height: number }) => void;
fail?: (err: unknown) => void;
}): void;
}
/** 获取图片宽高 */
function getImageWh(src: string): Promise<{ width: number; height: number }> {
return new Promise((resolve) => {
Taro.getImageInfo({
return new Promise((resolve, reject) => {
(Taro as TaroGetImageInfo).getImageInfo({
src,
success: ({ width, height }) => resolve({ width, height }),
fail: (e) => reject(e),
});
});
}
/** 加载图片 */
function loadImage(canvas: any, src: string): Promise<any> {
return new Promise((resolve) => {
return new Promise((resolve, reject) => {
let timer: any;
const img = canvas.createImage();
img.onload = () => resolve(img);
img.crossOrigin = "anonymous"
img.onload = () => {
clearTimeout(timer);
resolve(img);
};
img.onerror = () => {
clearTimeout(timer);
console.log('img error', src)
}
timer = setTimeout(() => {
reject(new Error(`Image load timeout: ${src}`));
}, 8000);
img.src = src;
});
}
@@ -143,6 +164,7 @@ async function drawRotateCoverImage(
rotate = 0 // 旋转角度(弧度)
) {
const { width, height } = await getImageWh(src);
console.log('width', width, 'height', height)
const scale = Math.max(w / width, h / height);
const newW = width * scale;
const newH = height * scale;
@@ -176,6 +198,7 @@ async function drawRotateCoverImage(
// 绘制 cover
ctx.drawImage(img, offsetX, offsetY, newW, newH);
console.log('drawImage', offsetX, offsetY, newW, newH)
ctx.restore();
}
@@ -287,24 +310,39 @@ function drawTextWrap(
/** 核心纯函数:生成海报图片 */
export async function generatePosterImage(data: any): Promise<string> {
console.log("start !!!!");
const dpr = Taro.getWindowInfo().pixelRatio;
// const dpr = Taro.getWindowInfo().pixelRatio;
const dpr = 1;
// console.log(dpr, 'dpr')
const width = 600;
const height = 1000;
console.log('width', width, 'height', height)
const canvas = Taro.createOffscreenCanvas({ type: "2d", width: width * dpr, height: height * dpr });
const ctx = canvas.getContext("2d");
ctx.scale(dpr, dpr);
console.log('ctx', ctx)
// 背景渐变
roundRectGradient(ctx, 0, 0, width, height, 24, "#BFFFEF", "#F2FFFC");
console.log('bgUrl', bgUrl)
const bgImg = await loadImage(canvas, bgUrl);
ctx.drawImage(bgImg, 0, 0, width, height);
console.log('bgUrlend', )
roundRotateRect(ctx, 70, 100, width - 140, width - 140, 20, '#fff', deg2rad(-6));
// 顶部图片
const mainImg = await loadImage(canvas, data.mainCoursal);
console.log('mainCoursal', data.mainCoursal)
await drawRotateCoverImage(
ctx,
canvas,
@@ -373,6 +411,8 @@ export async function generatePosterImage(data: any): Promise<string> {
left = 20;
const dateImg = await loadImage(canvas, dateIcon);
console.log('dateIcon', dateIcon)
await drawCoverImage(
ctx,
canvas,
@@ -399,6 +439,7 @@ export async function generatePosterImage(data: any): Promise<string> {
left = 20;
top += 24;
const mapImg = await loadImage(canvas, mapIcon);
await drawCoverImage(ctx, canvas, mapIcon, mapImg, left, top, 40, 40, 12);
@@ -435,11 +476,13 @@ export async function generatePosterImage(data: any): Promise<string> {
ctx.font = "400 20px sans-serif";
ctx.fillText("长按识别二维码,快来加入,有你就有场!", left, height - 30/* top */);
console.log('canvas', canvas)
// 导出图片
const { tempFilePath } = await Taro.canvasToTempFilePath({
canvas,
fileType: 'png',
quality: 1,
quality: 0.7,
});
console.log('tempFilePath', tempFilePath)
return tempFilePath;
}

View File

@@ -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,27 +530,26 @@ 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')
try {
const wxAny: any = (typeof (globalThis as any) !== 'undefined' && (globalThis as any).wx) ? (globalThis as any).wx : null
if (wxAny && typeof wxAny.canvasToTempFilePath === 'function') {
wxAny.canvasToTempFilePath({
canvas: offscreen,
fileType: 'png',
quality: 1,
success: (res: any) => {
console.log('===res666', res)
resolve(res.tempFilePath)
},
fail: reject
})
return
}
} catch { }
reject(new Error('无法导出图片OffscreenCanvas 转文件失败)'))
try {
const wxAny: any = (typeof (globalThis as any) !== 'undefined' && (globalThis as any).wx) ? (globalThis as any).wx : null
if (wxAny && typeof wxAny.canvasToTempFilePath === 'function') {
wxAny.canvasToTempFilePath({
canvas: offscreen,
fileType: 'png',
quality: 1,
success: (res: any) => {
console.log('===res666', res)
resolve(res.tempFilePath)
},
fail: reject
})
return
}
} catch { }
reject(new Error('无法导出图片OffscreenCanvas 转文件失败)'))
console.log('Canvas绘制命令已发送')
} catch (error) {

2
types/global.d.ts vendored
View File

@@ -17,6 +17,8 @@ declare namespace NodeJS {
NODE_ENV: 'development' | 'production',
/** 当前构建的平台 */
TARO_ENV: 'weapp' | 'swan' | 'alipay' | 'h5' | 'rn' | 'tt' | 'quickapp' | 'qq' | 'jd'
/** 应用环境标识 */
APP_ENV: 'dev' | 'dev_local' | 'sit' | 'pr'
/**
* 当前构建的小程序 appid
* @description 若不同环境有不同的小程序,可通过在 env 文件中配置环境变量`TARO_APP_ID`来方便快速切换 appid 而不必手动去修改 dist/project.config.json 文件