hejianhao
2026-08-20 8febc5170850e98f99568f8fd6a367c9569ae2c0
feat0806: 解决首页直播间不能跳转
1个文件已修改
29 ■■■■■ 已修改文件
traditionalApp/pages/home/home.vue 29 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
traditionalApp/pages/home/home.vue
@@ -331,7 +331,7 @@
    /**
     * 跳转后台配置的微赞直播 H5 页面。
     */
    const goWeiZanLive = async () => {
    const goWeiZanLive = () => {
        if (!weiZanLiveH5Url.value.trim()) {
            uni.showToast({ title: '直播间地址暂未配置', icon: 'none' });
            return;
@@ -340,37 +340,12 @@
            return;
        }
        weiZanLiveOpening.value = true;
        uni.showLoading({ title: '正在进入直播间', mask: true });
        try {
            const cachedUser = uni.getStorageSync('appUserInfo');
            const userId = cachedUser?.id;
            if (!userId) {
                uni.showToast({ title: '请先登录', icon: 'none' });
                return;
            }
            const res = await createLiveRoomEntry(userId);
            const targetUrl = res?.data?.url?.trim();
            if (res?.code !== 0 || !targetUrl || !isValidLiveRoomUrl(targetUrl)) {
                uni.showToast({ title: res?.msg || '获取直播间地址失败', icon: 'none' });
                return;
            }
            uni.navigateTo({
                url: `/pages/webview/webview?url=${encodeURIComponent(targetUrl)}&title=${encodeURIComponent('微赞直播')}`
                url: `/pages/webview/webview?url=${encodeURIComponent(weiZanLiveH5Url.value)}&title=${encodeURIComponent('微赞直播')}`
            });
        } catch {
            uni.showToast({ title: '获取直播间地址失败', icon: 'none' });
        } finally {
            uni.hideLoading();
            weiZanLiveOpening.value = false;
        }
    };
    const isValidLiveRoomUrl = (targetUrl : string) => {
        try {
            const parsedUrl = new URL(targetUrl);
            return parsedUrl.protocol === 'https:';
        } catch {
            return false;
        }
    };