feat: NTRP测试入口接入
This commit is contained in:
@@ -24,11 +24,11 @@ import {
|
||||
GameManagePopup,
|
||||
Comments,
|
||||
} from "@/components";
|
||||
import {
|
||||
EvaluateType,
|
||||
SceneType,
|
||||
DisplayConditionType,
|
||||
} from "@/components/NTRPEvaluatePopup";
|
||||
// import {
|
||||
// EvaluateType,
|
||||
// SceneType,
|
||||
// DisplayConditionType,
|
||||
// } from "@/components/NTRPEvaluatePopup";
|
||||
import DetailService, {
|
||||
MATCH_STATUS,
|
||||
IsSubstituteSupported,
|
||||
@@ -36,7 +36,9 @@ import DetailService, {
|
||||
import * as LoginService from "@/services/loginService";
|
||||
import OrderService from "@/services/orderService";
|
||||
import { getCurrentLocation, calculateDistance } from "@/utils/locationUtils";
|
||||
// import { getCurrentFullPath } from "@/utils";
|
||||
import { useUserInfo, useUserActions } from "@/store/userStore";
|
||||
import { EvaluateCallback, EvaluateScene } from "@/store/evaluateStore";
|
||||
import img from "@/config/images";
|
||||
import styles from "./style.module.scss";
|
||||
import "./index.scss";
|
||||
@@ -280,7 +282,9 @@ function StickyButton(props) {
|
||||
getCommentCount,
|
||||
} = props;
|
||||
const [commentCount, setCommentCount] = useState(0);
|
||||
const ntrpRef = useRef(null);
|
||||
const ntrpRef = useRef<{
|
||||
show: (evaluateCallback: EvaluateCallback) => void;
|
||||
}>({ show: () => {} });
|
||||
const {
|
||||
id,
|
||||
price,
|
||||
@@ -294,8 +298,22 @@ function StickyButton(props) {
|
||||
const gameManageRef = useRef();
|
||||
|
||||
function handleSelfEvaluate() {
|
||||
// TODO: 打开自评弹窗
|
||||
ntrpRef?.current?.show();
|
||||
ntrpRef?.current?.show({
|
||||
type: EvaluateScene.detail,
|
||||
next: (flag) => {
|
||||
if (flag) {
|
||||
Taro.navigateTo({
|
||||
url: `/order_pages/orderDetail/index?gameId=${id}`,
|
||||
});
|
||||
return;
|
||||
}
|
||||
Taro.redirectTo({ url: `/order_pages/orderDetail/index?gameId=${id}` });
|
||||
},
|
||||
onCancel: () => {
|
||||
// Taro.redirectTo({ url: `/game_pages/detail/index?id=${id}` });
|
||||
Taro.navigateBack();
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
@@ -313,8 +331,8 @@ function StickyButton(props) {
|
||||
return;
|
||||
}
|
||||
const displayPrice = is_organizer ? 0 : price;
|
||||
user_action_status.can_assess = true;
|
||||
user_action_status.can_join = false;
|
||||
// user_action_status.can_assess = true;
|
||||
// user_action_status.can_join = false;
|
||||
// console.log(user_action_status, "user_action");
|
||||
const {
|
||||
can_assess,
|
||||
@@ -385,17 +403,7 @@ function StickyButton(props) {
|
||||
};
|
||||
} else if (can_assess) {
|
||||
return {
|
||||
text: () => (
|
||||
<NTRPEvaluatePopup
|
||||
ref={ntrpRef}
|
||||
types={[EvaluateType.EDIT, EvaluateType.EVALUATE]}
|
||||
scene={SceneType.DETAIL}
|
||||
displayCondition={DisplayConditionType.AUTO}
|
||||
showGuide={false}
|
||||
>
|
||||
<Text>¥{displayPrice} 立即加入</Text>
|
||||
</NTRPEvaluatePopup>
|
||||
),
|
||||
text: () => <Text>¥{displayPrice} 立即加入</Text>,
|
||||
action: handleSelfEvaluate,
|
||||
};
|
||||
}
|
||||
@@ -477,6 +485,7 @@ function StickyButton(props) {
|
||||
</View>
|
||||
</View>
|
||||
<GameManagePopup ref={gameManageRef} />
|
||||
<NTRPEvaluatePopup type={EvaluateScene.detail} ref={ntrpRef} showGuide />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,11 @@ import SearchBar from "@/components/SearchBar";
|
||||
import FilterPopup from "@/components/FilterPopup";
|
||||
import styles from "./index.module.scss";
|
||||
import { useEffect, useRef, useCallback, useState } from "react";
|
||||
import Taro, { usePageScroll, useShareAppMessage, useShareTimeline } from "@tarojs/taro";
|
||||
import Taro, {
|
||||
usePageScroll,
|
||||
useShareAppMessage,
|
||||
useShareTimeline,
|
||||
} from "@tarojs/taro";
|
||||
import { useListStore } from "@/store/listStore";
|
||||
import { useGlobalState } from "@/store/global";
|
||||
import { View } from "@tarojs/components";
|
||||
@@ -13,14 +17,17 @@ import DistanceQuickFilter from "@/components/DistanceQuickFilter";
|
||||
import { withAuth } from "@/components";
|
||||
import { updateUserLocation } from "@/services/userService";
|
||||
// import ShareCardCanvas from "@/components/ShareCardCanvas";
|
||||
import { useUserActions } from "@/store/userStore";
|
||||
import { useDictionaryStore } from "@/store/dictionaryStore";
|
||||
|
||||
const ListPage = () => {
|
||||
|
||||
// 从 store 获取数据和方法
|
||||
const store = useListStore() || {};
|
||||
|
||||
const { statusNavbarHeightInfo, getCurrentLocationInfo } = useGlobalState() || {};
|
||||
const { fetchUserInfo } = useUserActions();
|
||||
|
||||
const { statusNavbarHeightInfo, getCurrentLocationInfo } =
|
||||
useGlobalState() || {};
|
||||
|
||||
const { totalHeight } = statusNavbarHeightInfo || {};
|
||||
const {
|
||||
@@ -49,48 +56,52 @@ const ListPage = () => {
|
||||
filterOptions,
|
||||
distanceQuickFilter,
|
||||
isShowInputCustomerNavBar,
|
||||
pageOption
|
||||
pageOption,
|
||||
} = listPageState || {};
|
||||
|
||||
// 防抖的滚动处理函数
|
||||
const handleScroll = useCallback((res) => {
|
||||
const currentScrollTop = res?.scrollTop || 0;
|
||||
const handleScroll = useCallback(
|
||||
(res) => {
|
||||
const currentScrollTop = res?.scrollTop || 0;
|
||||
|
||||
// 添加缓冲区,避免临界点频繁切换
|
||||
const buffer = 10; // 10px 缓冲区
|
||||
const shouldShowInputNav = currentScrollTop >= (totalHeight + buffer);
|
||||
const shouldHideInputNav = currentScrollTop < (totalHeight - buffer);
|
||||
// 添加缓冲区,避免临界点频繁切换
|
||||
const buffer = 10; // 10px 缓冲区
|
||||
const shouldShowInputNav = currentScrollTop >= totalHeight + buffer;
|
||||
const shouldHideInputNav = currentScrollTop < totalHeight - buffer;
|
||||
|
||||
// 清除之前的定时器
|
||||
if (scrollTimeoutRef.current) {
|
||||
clearTimeout(scrollTimeoutRef.current);
|
||||
}
|
||||
|
||||
// 防抖处理,避免频繁更新状态
|
||||
scrollTimeoutRef.current = setTimeout(() => {
|
||||
// 只有在状态真正需要改变时才更新
|
||||
if (shouldShowInputNav && !isShowInputCustomerNavBar) {
|
||||
updateListPageState({
|
||||
isShowInputCustomerNavBar: true
|
||||
});
|
||||
} else if (shouldHideInputNav && isShowInputCustomerNavBar) {
|
||||
updateListPageState({
|
||||
isShowInputCustomerNavBar: false
|
||||
});
|
||||
// 清除之前的定时器
|
||||
if (scrollTimeoutRef.current) {
|
||||
clearTimeout(scrollTimeoutRef.current);
|
||||
}
|
||||
|
||||
lastScrollTopRef.current = currentScrollTop;
|
||||
}, 16); // 约60fps的防抖间隔
|
||||
}, [totalHeight, isShowInputCustomerNavBar, updateState]);
|
||||
// 防抖处理,避免频繁更新状态
|
||||
scrollTimeoutRef.current = setTimeout(() => {
|
||||
// 只有在状态真正需要改变时才更新
|
||||
if (shouldShowInputNav && !isShowInputCustomerNavBar) {
|
||||
updateListPageState({
|
||||
isShowInputCustomerNavBar: true,
|
||||
});
|
||||
} else if (shouldHideInputNav && isShowInputCustomerNavBar) {
|
||||
updateListPageState({
|
||||
isShowInputCustomerNavBar: false,
|
||||
});
|
||||
}
|
||||
|
||||
lastScrollTopRef.current = currentScrollTop;
|
||||
}, 16); // 约60fps的防抖间隔
|
||||
},
|
||||
[totalHeight, isShowInputCustomerNavBar, updateState]
|
||||
);
|
||||
|
||||
usePageScroll(handleScroll);
|
||||
|
||||
const scrollContextRef = useRef(null)
|
||||
const scrollTimeoutRef = useRef<NodeJS.Timeout | null>(null)
|
||||
const lastScrollTopRef = useRef(0)
|
||||
const scrollContextRef = useRef(null);
|
||||
const scrollTimeoutRef = useRef<NodeJS.Timeout | null>(null);
|
||||
const lastScrollTopRef = useRef(0);
|
||||
|
||||
useEffect(() => {
|
||||
getLocation()
|
||||
getLocation();
|
||||
fetchUserInfo();
|
||||
}, []);
|
||||
|
||||
// 监听数据变化,如果是第一页就滚动到顶部
|
||||
@@ -98,7 +109,7 @@ const ListPage = () => {
|
||||
if (pageOption?.page === 1 && matches?.length > 0) {
|
||||
Taro.pageScrollTo({
|
||||
scrollTop: 0,
|
||||
duration: 300
|
||||
duration: 300,
|
||||
});
|
||||
}
|
||||
}, [matches, pageOption?.page]);
|
||||
@@ -112,7 +123,6 @@ const ListPage = () => {
|
||||
};
|
||||
}, []);
|
||||
|
||||
|
||||
// 监听距离和排序方式变化,自动调用接口
|
||||
// useEffect(() => {
|
||||
// // 只有当 distanceQuickFilter 有值时才调用接口
|
||||
@@ -126,7 +136,7 @@ const ListPage = () => {
|
||||
|
||||
// 获取位置信息
|
||||
const getLocation = async () => {
|
||||
const location = await getCurrentLocationInfo()
|
||||
const location = await getCurrentLocationInfo();
|
||||
|
||||
// 保存位置到全局状态
|
||||
updateState({ location });
|
||||
@@ -136,7 +146,7 @@ const ListPage = () => {
|
||||
try {
|
||||
await updateUserLocation(location.latitude, location.longitude);
|
||||
} catch (error) {
|
||||
console.error('更新用户位置失败:', error);
|
||||
console.error("更新用户位置失败:", error);
|
||||
}
|
||||
}
|
||||
fetchGetGamesCount();
|
||||
@@ -144,7 +154,7 @@ const ListPage = () => {
|
||||
// 页面加载时获取数据
|
||||
getMatchesData();
|
||||
return location;
|
||||
}
|
||||
};
|
||||
|
||||
const refreshMatches = () => {
|
||||
initialFilterSearch(true);
|
||||
@@ -188,7 +198,7 @@ const ListPage = () => {
|
||||
const handleFilterConfirm = () => {
|
||||
toggleShowPopup();
|
||||
getMatchesData();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @description 综合筛选弹框
|
||||
@@ -196,7 +206,7 @@ const ListPage = () => {
|
||||
*/
|
||||
const toggleShowPopup = () => {
|
||||
updateListPageState({
|
||||
isShowFilterPopup: !isShowFilterPopup
|
||||
isShowFilterPopup: !isShowFilterPopup,
|
||||
});
|
||||
};
|
||||
|
||||
@@ -208,7 +218,7 @@ const ListPage = () => {
|
||||
updateFilterOptions(params);
|
||||
};
|
||||
|
||||
const handleSearchChange = () => { };
|
||||
const handleSearchChange = () => {};
|
||||
|
||||
// 距离筛选
|
||||
const handleDistanceOrQuickChange = (name, value) => {
|
||||
@@ -278,10 +288,10 @@ const ListPage = () => {
|
||||
} catch (error) {
|
||||
console.error("初始化字典数据失败:", error);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
initDictionaryData()
|
||||
initDictionaryData();
|
||||
}, []);
|
||||
|
||||
return (
|
||||
@@ -311,9 +321,7 @@ const ListPage = () => {
|
||||
/>
|
||||
</View>
|
||||
)}
|
||||
<View
|
||||
className={`${styles.listTopSearchWrapper}`}
|
||||
>
|
||||
<View className={`${styles.listTopSearchWrapper}`}>
|
||||
<SearchBar
|
||||
handleFilterIcon={toggleShowPopup}
|
||||
isSelect={filterCount > 0}
|
||||
@@ -322,13 +330,14 @@ const ListPage = () => {
|
||||
value={searchValue}
|
||||
onInputClick={handleSearchClick}
|
||||
/>
|
||||
|
||||
</View>
|
||||
{/* 筛选 */}
|
||||
<View className={styles.listTopFilterWrapper}
|
||||
<View
|
||||
className={styles.listTopFilterWrapper}
|
||||
style={{
|
||||
top: totalHeight - 1,
|
||||
}}>
|
||||
}}
|
||||
>
|
||||
<DistanceQuickFilter
|
||||
cityOptions={distanceData}
|
||||
quickOptions={quickFilterData}
|
||||
|
||||
Reference in New Issue
Block a user