feat(分享): 为课程和直播分享增加H5链接和富媒体支持
- 在课程详情、直播详情和直播观看页中新增生成H5分享链接的函数
- 将微信分享从纯文本升级为富媒体卡片分享(type: 0),包含标题、描述、链接和缩略图
- 统一处理空ID时的默认跳转链接,使用config.BASE_URL配置
| | |
| | | <script setup lang="ts"> |
| | | import { computed, getCurrentInstance, nextTick, ref } from 'vue' |
| | | import { onHide, onLoad, onShow, onUnload } from '@dcloudio/uni-app' |
| | | import config from '@/config/index.js' |
| | | import { |
| | | favoriteHealthCourse, |
| | | getHealthCourseDetail, |
| | |
| | | } |
| | | |
| | | /** |
| | | * 生成课程 H5 分享链接,供微信好友打开页面详情。 |
| | | */ |
| | | function buildCourseShareUrl() { |
| | | if (!courseId.value) { |
| | | return `${config.BASE_URL}/#/pages/healthCourses/healthCourses` |
| | | } |
| | | return `${config.BASE_URL}/#/pages/courseDetail/courseDetail?id=${encodeURIComponent(courseId.value)}` |
| | | } |
| | | |
| | | /** |
| | | * 通过微信好友聊天场景分享当前课程。 |
| | | */ |
| | | function shareToWechatSession() { |
| | |
| | | return |
| | | } |
| | | weixinService.send({ |
| | | type: 'text', |
| | | type: 0, |
| | | title: courseDetail.value.title.trim() || '养生课程', |
| | | content: buildCourseShareText(), |
| | | href: buildCourseShareUrl(), |
| | | thumbs: courseDetail.value.bannerImages[0] ? [courseDetail.value.bannerImages[0]] : undefined, |
| | | extra: { |
| | | scene: 'WXSceneSession', |
| | | }, |
| | |
| | | import { computed, ref } from 'vue' |
| | | import { onLoad, onShow } from '@dcloudio/uni-app' |
| | | import { getLiveCourseDetail, reserveLiveCourseSession } from './service' |
| | | import config from '@/config/index.js' |
| | | |
| | | type LiveDisplayStatus = 'NOT_STARTED' | 'LIVING' | 'ENDED' |
| | | type LiveActionStatus = 'RESERVABLE' | 'RESERVED' | 'WATCHABLE' | 'CLOSED' |
| | |
| | | } |
| | | |
| | | /** |
| | | * 生成直播详情 H5 分享链接,供微信好友直接打开页面。 |
| | | */ |
| | | function buildLiveShareUrl() { |
| | | const currentCourseId = String(liveDetail.value.courseId || courseId.value || '').trim() |
| | | if (!currentCourseId) { |
| | | return `${config.BASE_URL}/#/pages/home/home` |
| | | } |
| | | return `${config.BASE_URL}/#/pages/liveDetail/liveDetail?id=${encodeURIComponent(currentCourseId)}` |
| | | } |
| | | |
| | | /** |
| | | * 直接拉起微信好友聊天分享当前直播。 |
| | | */ |
| | | function shareToWechatSession() { |
| | |
| | | return |
| | | } |
| | | weixinService.send({ |
| | | type: 'text', |
| | | type: 0, |
| | | title: liveDetail.value.title?.trim() || '养生直播', |
| | | content: buildLiveShareText(), |
| | | href: buildLiveShareUrl(), |
| | | thumbs: liveDetail.value.displayImage || liveDetail.value.coverImage ? [liveDetail.value.displayImage || liveDetail.value.coverImage] : undefined, |
| | | extra: { |
| | | scene: 'WXSceneSession', |
| | | }, |
| | |
| | | import { computed, getCurrentInstance, nextTick, ref } from 'vue'; |
| | | import { onHide, onLoad, onShow, onUnload } from '@dcloudio/uni-app'; |
| | | import { getLiveCourseDetail, getLiveQuizStatus, submitLiveQuiz, uploadLiveWatchRecord } from './service'; |
| | | import config from '@/config/index.js'; |
| | | |
| | | type LiveActionStatus = 'RESERVABLE' | 'RESERVED' | 'WATCHABLE' | 'CLOSED' |
| | | type QuizViewState = 'answering' | 'success' | 'wrong' | 'unopened' |
| | |
| | | } |
| | | |
| | | /** |
| | | * 生成直播观看页 H5 分享链接,供微信好友直接打开页面。 |
| | | */ |
| | | function buildWatchLiveShareUrl() { |
| | | if (!courseId.value) { |
| | | return `${config.BASE_URL}/#/pages/home/home` |
| | | } |
| | | const queryList = [`courseId=${encodeURIComponent(courseId.value)}`] |
| | | if (activeSessionId.value) { |
| | | queryList.push(`sessionId=${encodeURIComponent(activeSessionId.value)}`) |
| | | } |
| | | return `${config.BASE_URL}/#/pages/watchLive/watchLive?${queryList.join('&')}` |
| | | } |
| | | |
| | | /** |
| | | * 直接拉起微信好友聊天分享当前直播。 |
| | | */ |
| | | function shareToWechatSession() { |
| | |
| | | return |
| | | } |
| | | weixinService.send({ |
| | | type: 'text', |
| | | type: 0, |
| | | title: liveDetail.value.title?.trim() || '直播观看', |
| | | content: buildWatchLiveShareText(), |
| | | href: buildWatchLiveShareUrl(), |
| | | thumbs: liveDetail.value.displayImage || liveDetail.value.coverImage ? [liveDetail.value.displayImage || liveDetail.value.coverImage] : undefined, |
| | | extra: { |
| | | scene: 'WXSceneSession', |
| | | }, |