hejianhao
2026-08-21 618d7a9fae4beb110202b31d6567ca9404e6b618
fix0806: APP首页微赞直播,养生直播不登录不能看
1个文件已修改
43 ■■■■■ 已修改文件
traditionalApp/pages/home/home.vue 43 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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);
    };