| | |
| | | /** |
| | | * 跳转后台配置的微赞直播 H5 页面。 |
| | | */ |
| | | const goWeiZanLive = () => { |
| | | const goWeiZanLive = async () => { |
| | | console.log('[goWeiZanLive] 点击微赞直播入口'); |
| | | console.log('[goWeiZanLive] weiZanLiveH5Url:', weiZanLiveH5Url.value); |
| | | |
| | | if (!weiZanLiveH5Url.value.trim()) { |
| | | console.log('[goWeiZanLive] 直播间地址未配置'); |
| | | uni.showToast({ title: '直播间地址暂未配置', icon: 'none' }); |
| | | return; |
| | | } |
| | | if (weiZanLiveOpening.value) { |
| | | console.log('[goWeiZanLive] 正在打开中,防止重复点击'); |
| | | return; |
| | | } |
| | | 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)); |
| | | |
| | | const targetUrl = res?.data?.url?.trim(); |
| | | console.log('[goWeiZanLive] 解析目标URL:', targetUrl); |
| | | |
| | | if (res?.code !== 0 || !targetUrl) { |
| | | console.log('[goWeiZanLive] 获取跳转地址失败,code:', res?.code, 'msg:', res?.msg); |
| | | uni.showToast({ title: res?.msg || '获取直播间地址失败', icon: 'none' }); |
| | | return; |
| | | } |
| | | |
| | | const webviewUrl = `/pages/webview/webview?url=${encodeURIComponent(targetUrl)}&title=${encodeURIComponent('微赞直播')}`; |
| | | console.log('[goWeiZanLive] 准备跳转 WebView:', webviewUrl); |
| | | |
| | | uni.navigateTo({ |
| | | url: `/pages/webview/webview?url=${encodeURIComponent(weiZanLiveH5Url.value)}&title=${encodeURIComponent('微赞直播')}` |
| | | url: webviewUrl |
| | | }); |
| | | console.log('[goWeiZanLive] navigateTo 调用完成'); |
| | | } catch (error) { |
| | | console.error('[goWeiZanLive] 异常捕获:', error); |
| | | uni.showToast({ title: '获取直播间地址失败', icon: 'none' }); |
| | | } finally { |
| | | uni.hideLoading(); |
| | | weiZanLiveOpening.value = false; |
| | | console.log('[goWeiZanLive] 流程结束'); |
| | | } |
| | | }; |
| | | |