diff --git a/src/container/listContainer/index.tsx b/src/container/listContainer/index.tsx
index 23b2647..7e5861e 100644
--- a/src/container/listContainer/index.tsx
+++ b/src/container/listContainer/index.tsx
@@ -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 (
);
diff --git a/src/game_pages/detail/components/SharePopup/index.tsx b/src/game_pages/detail/components/SharePopup/index.tsx
index be2af80..ea181b2 100644
--- a/src/game_pages/detail/components/SharePopup/index.tsx
+++ b/src/game_pages/detail/components/SharePopup/index.tsx
@@ -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,
});
diff --git a/src/main_pages/components/ListPageContent.tsx b/src/main_pages/components/ListPageContent.tsx
index 8bf6a79..641fa63 100644
--- a/src/main_pages/components/ListPageContent.tsx
+++ b/src/main_pages/components/ListPageContent.tsx
@@ -627,6 +627,7 @@ const ListPageContent: React.FC = ({
reload={refreshMatches}
loadMoreMatches={loadMoreMatches}
evaluateFlag
+ enableHomeCards
/>
diff --git a/src/other_pages/favorites/index.tsx b/src/other_pages/favorites/index.tsx
index 94c8903..db08552 100644
--- a/src/other_pages/favorites/index.tsx
+++ b/src/other_pages/favorites/index.tsx
@@ -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'
diff --git a/src/services/commonApi.ts b/src/services/commonApi.ts
index d0b4e73..135264c 100644
--- a/src/services/commonApi.ts
+++ b/src/services/commonApi.ts
@@ -51,7 +51,6 @@ class CommonApiService {
data: results.map(result => result.data)
}
} catch (error) {
- throw error
} finally {
Taro.hideLoading()
}
diff --git a/src/services/detailService.ts b/src/services/detailService.ts
index b5cdd9c..6c5fd6c 100644
--- a/src/services/detailService.ts
+++ b/src/services/detailService.ts
@@ -163,7 +163,7 @@ class GameDetailService {
width: number
}>> {
return httpService.post('/user/generate_qrcode', req, {
- showLoading: false
+ showLoading: true
})
}
}
diff --git a/src/services/httpService.ts b/src/services/httpService.ts
index 664f331..d86885d 100644
--- a/src/services/httpService.ts
+++ b/src/services/httpService.ts
@@ -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
}
}
diff --git a/src/utils/share.ts b/src/utils/share.ts
index 1f2cb87..8e60115 100644
--- a/src/utils/share.ts
+++ b/src/utils/share.ts
@@ -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) {