This commit is contained in:
张成
2026-02-07 13:08:28 +08:00
parent 5a10c73adf
commit 536619ebfc
8 changed files with 58 additions and 49 deletions

View File

@@ -29,6 +29,7 @@ const ListContainer = (props) => {
collapse = false, collapse = false,
defaultShowNum, defaultShowNum,
evaluateFlag, evaluateFlag,
enableHomeCards = false, // 仅首页需要 banner 和 NTRP 测评卡片
listLoadErrorWrapperHeight, listLoadErrorWrapperHeight,
listLoadErrorWidth, listLoadErrorWidth,
listLoadErrorHeight, listLoadErrorHeight,
@@ -94,10 +95,10 @@ const ListContainer = (props) => {
}; };
}, []); }, []);
// 获取测试结果,判断最近一个月是否有测试记录 // 获取测试结果,判断最近一个月是否有测试记录(仅首页需要)
useEffect(() => { useEffect(() => {
const init = async () => { const init = async () => {
if (!evaluateFlag) return; if (!evaluateFlag || !enableHomeCards) return;
// 先等待静默登录完成 // 先等待静默登录完成
await waitForAuthInit(); await waitForAuthInit();
// 然后再获取用户信息 // 然后再获取用户信息
@@ -112,7 +113,7 @@ const ListContainer = (props) => {
} }
}; };
init(); init();
}, [evaluateFlag, userInfo, lastTestResult, fetchLastTestResult]); }, [evaluateFlag, enableHomeCards, userInfo, lastTestResult, fetchLastTestResult]);
// 从全局状态中获取测试状态 // 从全局状态中获取测试状态
const hasTestInLastMonth = lastTestResult?.has_test_in_last_month || false; const hasTestInLastMonth = lastTestResult?.has_test_in_last_month || false;
@@ -169,8 +170,8 @@ const ListContainer = (props) => {
} }
const memoizedList = useMemo( const memoizedList = useMemo(
() => insertEvaluateCard(data), () => (enableHomeCards ? insertEvaluateCard(data) : data),
[evaluateFlag, data, hasTestInLastMonth, showNumber, bannerListImage, bannerDetailImage, bannerListIndex] [enableHomeCards, evaluateFlag, data, hasTestInLastMonth, showNumber, bannerListImage, bannerDetailImage, bannerListIndex]
); );
// 渲染 banner 卡片 // 渲染 banner 卡片
@@ -226,10 +227,10 @@ const ListContainer = (props) => {
return ( return (
<> <>
{memoizedList.map((match, index) => { {memoizedList.map((match, index) => {
if (match?.type === "banner") { if (enableHomeCards && match?.type === "banner") {
return renderBanner(match, index); return renderBanner(match, index);
} }
if (match?.type === "evaluateCard") { if (enableHomeCards && match?.type === "evaluateCard") {
return ( return (
<NTRPTestEntryCard key={`evaluate-${index}`} type={EvaluateScene.list} /> <NTRPTestEntryCard key={`evaluate-${index}`} type={EvaluateScene.list} />
); );

View File

@@ -128,7 +128,7 @@ export default forwardRef(({ id, from, detail, userInfo }, ref) => {
const endTime = dayjs(end_time); const endTime = dayjs(end_time);
const dayofWeek = DayOfWeekMap.get(startTime.day()); const dayofWeek = DayOfWeekMap.get(startTime.day());
const gameLength = `${endTime.diff(startTime, "hour")}小时`; const gameLength = `${endTime.diff(startTime, "hour")}小时`;
Taro.showLoading({ title: "生成中..." }); // Taro.showLoading({ title: "生成中..." });
const qrCodeUrlRes = await DetailService.getQrCodeUrl({ const qrCodeUrlRes = await DetailService.getQrCodeUrl({
page: "game_pages/detail/index", page: "game_pages/detail/index",
scene: `id=${id}`, scene: `id=${id}`,
@@ -137,6 +137,7 @@ export default forwardRef(({ id, from, detail, userInfo }, ref) => {
qrCodeUrlRes.data.qr_code_base64 qrCodeUrlRes.data.qr_code_base64
); );
await delay(100); await delay(100);
// Taro.showLoading({ title: "生成中..." });
const url = await generatePosterImage({ const url = await generatePosterImage({
playType: play_type, playType: play_type,
ntrp: `NTRP ${genNTRPRequirementText(skill_level_min, skill_level_max)}`, ntrp: `NTRP ${genNTRPRequirementText(skill_level_min, skill_level_max)}`,
@@ -152,7 +153,7 @@ export default forwardRef(({ id, from, detail, userInfo }, ref) => {
time: `${startTime.format("ah")}${gameLength}`, time: `${startTime.format("ah")}${gameLength}`,
qrCodeUrl, qrCodeUrl,
}); });
Taro.hideLoading(); // Taro.hideLoading();
Taro.showShareImageMenu({ Taro.showShareImageMenu({
path: url, path: url,
}); });

View File

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

View File

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

View File

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

View File

@@ -163,7 +163,7 @@ class GameDetailService {
width: number width: number
}>> { }>> {
return httpService.post('/user/generate_qrcode', req, { return httpService.post('/user/generate_qrcode', req, {
showLoading: false showLoading: true
}) })
} }
} }

View File

@@ -129,23 +129,30 @@ class HttpService {
// 隐藏loading支持多个并发请求 // 隐藏loading支持多个并发请求
private hideLoading(): void { private hideLoading(): void {
this.loadingCount = Math.max(0, this.loadingCount - 1) try {
this.loadingCount = Math.max(0, this.loadingCount - 1)
// 只有所有请求都完成时才隐藏loading // 只有所有请求都完成时才隐藏loading
if (this.loadingCount === 0) { if (this.loadingCount === 0) {
// 清除之前的延时器 // 清除之前的延时器
if (this.hideLoadingTimer) { if (this.hideLoadingTimer) {
clearTimeout(this.hideLoadingTimer) clearTimeout(this.hideLoadingTimer)
this.hideLoadingTimer = null 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' url: '/login_pages/index/index'
}) })
reject(new Error('用户不存在')) reject(new Error('用户不存在'))
return response.data return response.data
} }
@@ -187,7 +194,7 @@ class HttpService {
} else { } else {
reject(response.data) reject(response.data)
} }
return response.data return response.data
} }
} }

View File

@@ -534,23 +534,23 @@ const drawShareCard = async (ctx: any, data: ShareCardData, offscreen: any): Pro
ctx.drawImage(locationPath, iconX, locationInfoY, iconSize, iconSize) ctx.drawImage(locationPath, iconX, locationInfoY, iconSize, iconSize)
drawBoldText(ctx, data.venueName, danDaX, locationInfoY + 10, locationFontSize, '#000000') drawBoldText(ctx, data.venueName, danDaX, locationInfoY + 10, locationFontSize, '#000000')
try { try {
const wxAny: any = (typeof (globalThis as any) !== 'undefined' && (globalThis as any).wx) ? (globalThis as any).wx : null const wxAny: any = (typeof (globalThis as any) !== 'undefined' && (globalThis as any).wx) ? (globalThis as any).wx : null
if (wxAny && typeof wxAny.canvasToTempFilePath === 'function') { if (wxAny && typeof wxAny.canvasToTempFilePath === 'function') {
wxAny.canvasToTempFilePath({ wxAny.canvasToTempFilePath({
canvas: offscreen, canvas: offscreen,
fileType: 'png', fileType: 'png',
quality: 1, quality: 1,
success: (res: any) => { success: (res: any) => {
console.log('===res666', res) console.log('===res666', res)
resolve(res.tempFilePath) resolve(res.tempFilePath)
}, },
fail: reject fail: reject
}) })
return return
} }
} catch { } } catch { }
reject(new Error('无法导出图片OffscreenCanvas 转文件失败)')) reject(new Error('无法导出图片OffscreenCanvas 转文件失败)'))
console.log('Canvas绘制命令已发送') console.log('Canvas绘制命令已发送')
} catch (error) { } catch (error) {