From 618d7a9fae4beb110202b31d6567ca9404e6b618 Mon Sep 17 00:00:00 2001
From: hejianhao <15708179461@qq.com>
Date: 星期五, 21 八月 2026 15:28:39 +0800
Subject: [PATCH] fix0806: APP首页微赞直播,养生直播不登录不能看

---
 traditionalApp/pages/home/home.vue |   43 ++++++++++++++++++++++++++++++-------------
 1 files changed, 30 insertions(+), 13 deletions(-)

diff --git a/traditionalApp/pages/home/home.vue b/traditionalApp/pages/home/home.vue
index cc71964..0237f11 100644
--- a/traditionalApp/pages/home/home.vue
+++ b/traditionalApp/pages/home/home.vue
@@ -142,6 +142,7 @@
 	import { computed, ref, onMounted } from "vue";
 	import { onPullDownRefresh, onShow } from "@dcloudio/uni-app";
 	import { createLiveRoomEntry, getBannerList, getHomeFeaturedContent, getHomeLiveCourseList, getLiveRoomSetting } from "./service";
+	import { resolveCurrentAppUserId } from "@/utils/app-user.js";
 
 	interface HomeBannerItem {
 		id : number | string;
@@ -284,6 +285,15 @@
 		}
 	};
 
+	/**
+	 * 未登录时直接跳转登录页,不做任何弹窗提示。
+	 */
+	const goLoginPage = () => {
+		uni.navigateTo({
+			url: '/pages/login/login'
+		});
+	};
+
 	//跳转海诊通小程序
 	const goMiniProgram = () => {
 		plus.share.getServices((services) => {
@@ -335,9 +345,17 @@
 		console.log('[goWeiZanLive] 点击微赞直播入口');
 		console.log('[goWeiZanLive] weiZanLiveH5Url:', weiZanLiveH5Url.value);
 
+		// 未登录直接跳转登录页,不弹「请先登录」提示。
+		const userId = resolveCurrentAppUserId();
+		if (!userId) {
+			console.log('[goWeiZanLive] 用户未登录,跳转登录页');
+			goLoginPage();
+			return;
+		}
+
+		// 直播间地址未配置时静默处理,不弹「直播间地址暂未配置」提示。
 		if (!weiZanLiveH5Url.value.trim()) {
-			console.log('[goWeiZanLive] 直播间地址未配置');
-			uni.showToast({ title: '直播间地址暂未配置', icon: 'none' });
+			console.log('[goWeiZanLive] 直播间地址未配置,忽略点击');
 			return;
 		}
 		if (weiZanLiveOpening.value) {
@@ -347,16 +365,7 @@
 		weiZanLiveOpening.value = true;
 		uni.showLoading({ title: '正在进入直播间', mask: true });
 		try {
-			const cachedUser = uni.getStorageSync('appUserInfo');
-			const userId = cachedUser?.id;
 			console.log('[goWeiZanLive] 当前用户ID:', userId);
-
-			if (!userId) {
-				console.log('[goWeiZanLive] 用户未登录');
-				uni.showToast({ title: '请先登录', icon: 'none' });
-				return;
-			}
-
 			console.log('[goWeiZanLive] 开始调用 createLiveRoomEntry 接口');
 			const res = await createLiveRoomEntry(userId);
 			console.log('[goWeiZanLive] createLiveRoomEntry 返回:', JSON.stringify(res));
@@ -554,16 +563,24 @@
 	};
 
 	/**
-	 * 点击直播图片时统一进入直播详情页。
+	 * 点击直播图片时统一进入直播详情页,未登录直接跳转登录页。
 	 */
 	const handleLiveImageClick = (item : HomeLiveCourseItem) => {
+		if (!resolveCurrentAppUserId()) {
+			goLoginPage();
+			return;
+		}
 		goLiveDetail(item.courseId);
 	};
 
 	/**
-	 * 点击直播名称时统一跳转直播介绍页。
+	 * 点击直播名称时统一跳转直播介绍页,未登录直接跳转登录页。
 	 */
 	const handleLiveTitleClick = (item : HomeLiveCourseItem) => {
+		if (!resolveCurrentAppUserId()) {
+			goLoginPage();
+			return;
+		}
 		goLiveDetail(item.courseId);
 	};
 

--
Gitblit v1.7.1