代码支持
Some checks failed
Deploy to Server / deploy (push) Has been cancelled

This commit is contained in:
jeremygan2021
2026-03-01 17:39:36 +08:00
parent b31e8fff09
commit 84e30d26af
10 changed files with 97 additions and 17 deletions

View File

@@ -7,6 +7,7 @@ export default defineAppConfig({
'pages/courses/detail',
'pages/forum/index',
'pages/goods/detail',
'pages/webview/index',
'pages/cart/cart',
'pages/order/checkout',
'pages/order/payment',

View File

@@ -71,6 +71,19 @@ export default function CourseDetail() {
return `${year}/${month}/${day} ${hour}:${minute}`
}
const extractIframeSrc = (html: string) => {
if (!html) return null
const match = html.match(/src=["'](.*?)["']/)
return match ? match[1] : null
}
const handleOpenWebview = (url: string) => {
if (!url) return
Taro.navigateTo({
url: `/pages/webview/index?url=${encodeURIComponent(url)}`
})
}
return (
<View className='page-container'>
<ScrollView scrollY className='scroll-content'>
@@ -94,7 +107,19 @@ export default function CourseDetail() {
{detail.is_video_course && (
<View className='section video-section'>
<Text className='section-title'></Text>
{detail.video_url ? (
{detail.video_embed_code ? (
<View className='video-locked' onClick={() => {
const src = extractIframeSrc(detail.video_embed_code)
if (src) handleOpenWebview(src)
else Taro.showToast({ title: '无法解析视频地址', icon: 'none' })
}}>
<Image src={detail.cover_image_url} className='locked-bg' mode='aspectFill' />
<View className='locked-overlay'>
<View className='lock-icon' style={{fontSize: '40px'}}></View>
<Text className='lock-text'></Text>
</View>
</View>
) : detail.video_url ? (
<Video
src={detail.video_url}
className='course-video'

View File

@@ -0,0 +1,3 @@
export default {
navigationBarTitleText: '加载中...'
}

View File

@@ -0,0 +1,14 @@
import { WebView } from '@tarojs/components'
import { useRouter } from '@tarojs/taro'
export default function WebViewPage() {
const router = useRouter()
const { url } = router.params
if (!url) return null
// Ensure url has protocol if missing (e.g. starts with //)
const fullUrl = url.startsWith('//') ? `https:${url}` : url
return <WebView src={fullUrl} />
}