9 Commits

Author SHA1 Message Date
李瑞
4c75368fe8 优化banner逻辑 2026-02-01 23:37:31 +08:00
张成
8abf6e6f2b 1 2026-02-01 18:46:30 +08:00
李瑞
0c83aab053 Merge branch 'feature/juguohong/20260101' 2026-02-01 16:12:48 +08:00
张成
6d57654005 1 2026-01-29 22:56:33 +08:00
筱野
dade2e2491 修改发布页问题 2026-01-27 22:15:28 +08:00
筱野
4a6ac73ad7 修改文本域长度 2026-01-26 22:51:01 +08:00
筱野
de8677c64c 修改样式 2026-01-26 22:13:52 +08:00
筱野
3ab647f7c6 增加发布仅上海地区可发布、发布防抖 2026-01-05 21:26:02 +08:00
张成
fa328f893d 1 2026-01-05 18:34:05 +08:00
20 changed files with 143 additions and 86 deletions

View File

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

View File

@@ -21,6 +21,6 @@ page {
font-family: "Quicksand";
// 注意:此路径来自 @/config/api.ts 中的 OSS_BASE_URL 配置
// 如需修改,请更新配置文件中的 OSS_BASE_URL
src: url("https://bimwe.oss-cn-shanghai.aliyuncs.com/front/ball/other/57dc951f-f10e-45b7-9157-0b1e468187fd.ttf") format("truetype");
src: url("https://youchang2026.oss-cn-shanghai.aliyuncs.com/front/ball/other/57dc951f-f10e-45b7-9157-0b1e468187fd.ttf") format("truetype");
font-display: swap;
}

View File

@@ -7,7 +7,8 @@
border-radius: 20px 20px 0 0 !important;
}
.common-popup__drag-handle-container {
position: position;
position: relative;
height: 0;
}
.common-popup__drag-handle {

View File

@@ -7,6 +7,8 @@ import {
EvaluateCallback,
EvaluateScene,
} from "@/store/evaluateStore";
import { useListState } from "@/store/listStore";
import { navigateTo, redirectTo, navigateBack } from "@/utils/navigation";
import { requireLoginWithPhone } from "@/utils/helper";
import styles from "./index.module.scss";
@@ -24,6 +26,11 @@ const PublishMenu: React.FC<PublishMenuProps> = (props) => {
const { onVisibleChange } = props;
const [isVisible, setIsVisible] = useState(false);
const {
area
} = useListState();
// 使用 useEffect 监听 isVisible 变化,确保所有情况都能触发回调
useEffect(() => {
onVisibleChange?.(isVisible);
@@ -59,6 +66,16 @@ const PublishMenu: React.FC<PublishMenuProps> = (props) => {
});
};
const handleMenuItemClick = (type: "individual" | "group" | "ai") => {
const [_, address] = area;
if (address !== '上海') {
(Taro as any).showModal({
title: '提示',
content: '仅上海地区开放,您可加入社群或切换城市',
showCancel: false,
confirmText: '知道了'
})
return;
}
if (!userInfo.ntrp_level) {
ntrpRef.current.show({
type: EvaluateScene.publish,

View File

@@ -29,8 +29,10 @@ const TextareaTag: React.FC<TextareaTagProps> = ({
// 处理文本输入变化
const handleTextChange = useCallback((val: string) => {
console.log(val,'e.detail.value')
onChange({...value, description: val})
}, [onChange])
const maxAllowedLength = Math.floor(maxLength * 1.2)
const truncatedVal = val.length > maxAllowedLength ? val.slice(0, maxAllowedLength) : val
onChange({...value, description: truncatedVal})
}, [onChange, maxLength, value])
// 处理标签选择变化
const handleTagChange = useCallback((selectedTags: string[]) => {

View File

@@ -1,7 +1,7 @@
import envConfig from './env'// API配置
// OSS 基础路径配置
export const OSS_BASE_URL = 'https://bimwe.oss-cn-shanghai.aliyuncs.com/front/ball'
export const OSS_BASE_URL = 'https://youchang2026.oss-cn-shanghai.aliyuncs.com/front/ball'
export const API_CONFIG = {
// 基础URL

View File

@@ -85,7 +85,7 @@ export default function Participants(props) {
// id: 18,
// nickname: "小猫开刀削面店往猫毛里面下面条",
// avatar_url:
// "https://bimwe.oss-cn-shanghai.aliyuncs.com/front/ball/images/d284060f-248b-4d58-a153-4d37c0ca77c8.jpg",
// "https://youchang2026.oss-cn-shanghai.aliyuncs.com/front/ball/images/d284060f-248b-4d58-a153-4d37c0ca77c8.jpg",
// phone: "18513125687",
// ntrp_level: "1.5",
// },

View File

@@ -64,11 +64,17 @@ const MessagePageContent: React.FC<MessagePageContentProps> = ({ isActive = true
}
};
// 只有当页面激活且未加载过数据时才加载接口
// 当切换到消息 tab 时,调用红点信息接口
useEffect(() => {
if (isActive) {
fetchReddotInfo();
}
}, [isActive]);
// 只有当页面激活且未加载过数据时才加载通知列表
useEffect(() => {
if (isActive && !hasLoaded) {
getNoticeList();
fetchReddotInfo();
setHasLoaded(true);
}
}, [isActive, hasLoaded]);

View File

@@ -13,6 +13,7 @@ import MessagePageContent from "./components/MessagePageContent";
import MyselfPageContent from "./components/MyselfPageContent";
import "./index.scss";
import FamilyContext from "@/context";
import { useDictionaryStore } from "@/store/dictionaryStore";
type TabType = "list" | "message" | "personal";
@@ -66,6 +67,12 @@ 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);
}

View File

@@ -71,14 +71,12 @@ const CommentReply = () => {
setCommentList(mappedList);
// 获取未读评论ID并标记已读
const unreadIds = res.data.rows
.filter((item: any) => item.is_read === 0)
.map((item: any) => item.id);
// 获取所有评论ID列表并标记已读传入所有ID包括已读和未读
const allCommentIds = res.data.rows.map((item: any) => item.id);
if (unreadIds.length > 0) {
// 使用统一接口标记已读
messageService.markAsRead('comment', unreadIds).catch(e => {
if (allCommentIds.length > 0) {
// 使用统一接口标记已读传入所有评论ID
messageService.markAsRead('comment', allCommentIds).catch(e => {
console.error("标记评论已读失败:", e);
});
}
@@ -217,6 +215,15 @@ const CommentReply = () => {
}));
setCommentList(mappedList);
// 获取所有评论ID列表并标记已读传入所有ID
const allCommentIds = res.data.rows.map((item: any) => item.id);
if (allCommentIds.length > 0) {
messageService.markAsRead('comment', allCommentIds).catch(e => {
console.error("标记评论已读失败:", e);
});
}
}
} catch (e) {
Taro.showToast({

View File

@@ -56,14 +56,12 @@ const NewFollow = () => {
setFollowList(mappedList);
// 获取未读关注ID并标记已读
const unreadFanIds = res.list
.filter((item: any) => item.is_read === 0)
.map((item: any) => item.id);
// 获取所有关注ID列表并标记已读传入所有ID包括已读和未读
const allFanIds = res.list.map((item: any) => item.id);
if (unreadFanIds.length > 0) {
// 使用统一接口标记已读
messageService.markAsRead('follow', unreadFanIds).catch(e => {
if (allFanIds.length > 0) {
// 使用统一接口标记已读传入所有关注者ID
messageService.markAsRead('follow', allFanIds).catch(e => {
console.error("标记关注已读失败:", e);
});
}
@@ -164,6 +162,15 @@ const NewFollow = () => {
}));
setFollowList(mappedList);
// 获取所有关注者ID列表并标记已读传入所有ID
const allFanIds = res.list.map((item: any) => item.id);
if (allFanIds.length > 0) {
messageService.markAsRead('follow', allFanIds).catch(e => {
console.error("标记关注已读失败:", e);
});
}
} else {
// 如果没有数据,设置为空数组以显示空状态
setFollowList([]);

View File

@@ -9,7 +9,7 @@
flex-direction: column;
overflow: hidden;
padding-bottom: env(safe-area-inset-bottom);
box-sizing: border-box;
// 搜索区域
.search-section {
background: #f5f5f5;

View File

@@ -106,8 +106,15 @@ const SelectStadium: React.FC<SelectStadiumProps> = ({
})
setShowDetail(true)
},
fail: (err) => {
fail: (err: { errMsg: string }) => {
console.error('选择位置失败:', err)
const { errMsg } = err || {};
if (!errMsg.includes('fail cancel')) {
Taro.showToast({
title: errMsg,
icon: "none",
});
}
}
})
}

View File

@@ -145,12 +145,15 @@ const StadiumDetail = forwardRef<StadiumDetailRef, StadiumDetailProps>(({
istance: null
})
},
fail: (err) => {
fail: (err: { errMsg: string }) => {
console.error('选择位置失败:', err)
Taro.showToast({
title: '位置选择失败',
icon: 'error'
})
const { errMsg } = err || {};
if (!errMsg.includes('fail cancel')) {
Taro.showToast({
title: errMsg,
icon: "none",
});
}
}
})
}

View File

@@ -1,3 +1,5 @@
export default definePageConfig({
navigationStyle: 'custom'
})
navigationStyle: 'custom',
// 禁止原生页面滚动,改用内部自定义滚动容器,避免顶部/底部回弹后中间无法继续滚动的问题
disableScroll: true,
})

View File

@@ -85,6 +85,7 @@ const PublishBall: React.FC = () => {
defaultFormData,
]);
const [checked, setChecked] = useState(true);
const [publishLoading, setPublishLoading] = useState(false);
const [titleBar, setTitleBar] = useState("发布球局");
// 控制是否响应全局键盘(由具体输入框 focus/blur 控制)
const [shouldReactToKeyboard, setShouldReactToKeyboard] = useState(false);
@@ -372,9 +373,10 @@ const PublishBall: React.FC = () => {
const { republish } = params || {};
if (activityType === "individual") {
const isValid = validateFormData(formData[0]);
if (!isValid) {
if (!isValid || publishLoading) {
return;
}
setPublishLoading(true);
const {
activityInfo,
descriptionInfo,
@@ -435,13 +437,15 @@ const PublishBall: React.FC = () => {
title: res.message,
icon: "none",
});
setPublishLoading(false);
}
}
if (activityType === "group") {
const isValid = formData.every((item) => validateFormData(item));
if (!isValid) {
if (!isValid || publishLoading) {
return;
}
setPublishLoading(true);
if (checkAdjacentDataSame(formData)) {
Taro.showToast({
title: "信息不可与前序场完全一致",
@@ -505,6 +509,7 @@ const PublishBall: React.FC = () => {
title: res.message,
icon: "none",
});
setPublishLoading(false);
}
}
};

View File

@@ -14,6 +14,13 @@ interface DictionaryState {
fetchDictionary: () => Promise<void>
getDictionaryValue: (key: string, defaultValue?: any) => any
clearDictionary: () => void
// banner 字典(单独管理,保持原始值)
bannerDict: {
bannerListImage: string
bannerDetailImage: string
bannerListIndex: string
} | null
fetchBannerDictionary: () => Promise<void>
}
// 创建字典Store
@@ -22,6 +29,7 @@ export const useDictionaryStore = create<DictionaryState>()((set, get) => ({
dictionaryData: {},
isLoading: false,
error: null,
bannerDict: null,
// 获取字典数据
fetchDictionary: async () => {
@@ -56,6 +64,27 @@ 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) => {
const { dictionaryData } = get()

View File

@@ -11,7 +11,8 @@ import {
getCityQrCode,
getDistricts,
} from "../services/listApi";
import commonApi from "../services/commonApi";
// 不再在这里请求 banner 字典,统一由 dictionaryStore 启动时获取
import { useDictionaryStore } from "./dictionaryStore";
import {
ListActions,
IFilterOptions,
@@ -19,17 +20,16 @@ import {
IPayload,
} from "../../types/list/types";
// 将 banner 按索引插入到 rows 的工具方法
// 将 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;
// 固定采用 0 基索引
const parsed = parseInt(indexRaw, 10);
const normalized = Number.isFinite(parsed) ? parsed : 0;
const resultRows = [...rows];
// 先移除已有的 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",
@@ -272,10 +272,14 @@ 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: newData,
data: processedData,
isHasMoreData,
isShowNoData: newData?.length === 0,
// 使用插入后的最终数据判断是否显示空状态,避免有 banner 时仍显示空
isShowNoData: processedData?.length === 0,
});
set({
@@ -318,30 +322,8 @@ export const useListStore = create<TennisStore>()((set, get) => ({
}
}
// 并发请求:列表接口 + 字典接口(仅第一页且非追加时插入 Banner
const shouldInsertBanner = (currentPageState?.pageOption?.page || 1) === 1 && !isAppend;
const keys = "bannerListImage,bannerDetailImage,bannerListIndex";
let resData: any = {};
let dictData: any = null;
if (shouldInsertBanner) {
const [listResult, dictResult] = await Promise.allSettled([
fetchFn(reqParams),
commonApi.getDictionaryManyKey(keys),
]);
// 列表接口请求成功
if (listResult.status === "fulfilled") {
resData = listResult.value || {};
} else {
throw listResult.reason || new Error("获取数据失败");
}
// 字典接口请求成功
if (dictResult.status === "fulfilled" && (dictResult.value as any)?.code === 0) {
dictData = (dictResult.value as any)?.data || null;
}
} else {
resData = (await fetchFn(reqParams)) || {};
}
resData = (await fetchFn(reqParams)) || {};
const { data = {}, code } = resData;
if (code !== 0) {
@@ -357,11 +339,6 @@ export const useListStore = create<TennisStore>()((set, get) => ({
const { count } = data;
let { rows } = data as any;
// 将 banner 插入到指定位置(仅第一页且非追加)
if (shouldInsertBanner && Array.isArray(rows) && dictData) {
rows = insertBannersToRows(rows, dictData);
}
setListData({
error: '',
data: rows || [],
@@ -397,10 +374,9 @@ export const useListStore = create<TennisStore>()((set, get) => ({
try {
const searchParams = getSearchParams() || {};
const keys = "bannerListImage,bannerDetailImage,bannerListIndex";
// 并发请求:常规列表、智能排序列表、字典
const [listResSettled, integrateResSettled, dictSettled] = await Promise.allSettled([
// 并发请求:常规列表、智能排序列表
const [listResSettled, integrateResSettled] = await Promise.allSettled([
getGamesList({
...searchParams,
order: searchParams.order || "distance",
@@ -413,14 +389,10 @@ export const useListStore = create<TennisStore>()((set, get) => ({
isRefresh: true,
},
}),
commonApi.getDictionaryManyKey(keys),
]);
const listRes = listResSettled.status === "fulfilled" ? listResSettled.value : null;
const integrateRes = integrateResSettled.status === "fulfilled" ? integrateResSettled.value : null;
const dictData = dictSettled.status === "fulfilled" && (dictSettled.value as any)?.code === 0
? (dictSettled.value as any)?.data
: null;
// 根据当前排序方式更新对应的数据
const currentPageState = state.isSearchResult ? state.searchPageState : state.listPageState;
@@ -430,10 +402,6 @@ export const useListStore = create<TennisStore>()((set, get) => ({
if (listRes?.code === 0 && listRes?.data) {
const { count } = listRes.data;
let { rows } = listRes.data as any;
// 插入 banner当为第一页时
if ((currentPageState?.pageOption?.page || 1) === 1 && Array.isArray(rows) && dictData) {
rows = insertBannersToRows(rows, dictData);
}
if (!isIntegrate) {
// 如果当前是常规排序,更新常规列表数据
setListData({
@@ -449,10 +417,6 @@ export const useListStore = create<TennisStore>()((set, get) => ({
if (integrateRes?.code === 0 && integrateRes?.data) {
const { count } = integrateRes.data;
let { rows, recommendList } = integrateRes.data as any;
// 插入 banner当为第一页时
if ((currentPageState?.pageOption?.page || 1) === 1 && Array.isArray(rows) && dictData) {
rows = insertBannersToRows(rows, dictData);
}
if (isIntegrate) {
// 如果当前是智能排序,更新智能排序列表数据
setListData({

View File

@@ -76,7 +76,7 @@
}
.btn {
width: 78px;
width: 90px;
height: 24px;
border: 1px solid rgba(0, 0, 0, 0.06);
display: flex;

View File

@@ -64,7 +64,7 @@
}
.btn {
width: 78px;
width: 90px;
height: 24px;
border: 1px solid rgba(0, 0, 0, 0.06);
display: flex;