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,
defaultShowNum,
evaluateFlag,
enableHomeCards = false, // 仅首页需要 banner 和 NTRP 测评卡片
listLoadErrorWrapperHeight,
listLoadErrorWidth,
listLoadErrorHeight,
@@ -94,10 +95,10 @@ const ListContainer = (props) => {
};
}, []);
// 获取测试结果,判断最近一个月是否有测试记录
// 获取测试结果,判断最近一个月是否有测试记录(仅首页需要)
useEffect(() => {
const init = async () => {
if (!evaluateFlag) return;
if (!evaluateFlag || !enableHomeCards) return;
// 先等待静默登录完成
await waitForAuthInit();
// 然后再获取用户信息
@@ -112,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;
@@ -169,8 +170,8 @@ const ListContainer = (props) => {
}
const memoizedList = useMemo(
() => insertEvaluateCard(data),
[evaluateFlag, data, hasTestInLastMonth, showNumber, bannerListImage, bannerDetailImage, bannerListIndex]
() => (enableHomeCards ? insertEvaluateCard(data) : data),
[enableHomeCards, evaluateFlag, data, hasTestInLastMonth, showNumber, bannerListImage, bannerDetailImage, bannerListIndex]
);
// 渲染 banner 卡片
@@ -226,10 +227,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

@@ -128,7 +128,7 @@ 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}`,
@@ -137,6 +137,7 @@ export default forwardRef(({ id, from, detail, userInfo }, ref) => {
qrCodeUrlRes.data.qr_code_base64
);
await delay(100);
// Taro.showLoading({ title: "生成中..." });
const url = await generatePosterImage({
playType: play_type,
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}`,
qrCodeUrl,
});
Taro.hideLoading();
// Taro.hideLoading();
Taro.showShareImageMenu({
path: url,
});

View File

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

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

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

View File

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

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

@@ -534,23 +534,23 @@ const drawShareCard = async (ctx: any, data: ShareCardData, offscreen: any): Pro
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) {