|
@@ -1,13 +1,47 @@
|
1
|
|
-
|
|
1
|
+import { useEffect, useState } from 'react'
|
2
|
2
|
import withLayout from '@/layout'
|
3
|
3
|
import { ScrollView, Image, Swiper, SwiperItem } from '@tarojs/components'
|
4
|
4
|
// import Taro from '@tarojs/taro'
|
5
|
5
|
import { getImgURL } from '@/utils/image'
|
|
6
|
+import { API_COURSE_DETAIL } from '@/constants/api'
|
|
7
|
+import { fetch } from '@/utils/request'
|
|
8
|
+import useFavor from "@/utils/hooks/useFavor";
|
|
9
|
+import useParams from "@/utils/hooks/useParams";
|
|
10
|
+import useShare from "@/utils/hooks/useShare";
|
6
|
11
|
import '@/assets/css/iconfont.css'
|
7
|
12
|
import './index.scss'
|
8
|
13
|
|
|
14
|
+const TYPE_RICH = 0
|
|
15
|
+const TYPE_VIDEO = 1
|
|
16
|
+
|
9
|
17
|
export default withLayout((props) => {
|
10
|
|
- const { List = [] } = props
|
|
18
|
+ const { router, shareContent, trackData, person, page } = props
|
|
19
|
+ const { id } = router.params
|
|
20
|
+
|
|
21
|
+ const [detail, setDetail] = useState({})
|
|
22
|
+ // 本页面分享或者海报参数
|
|
23
|
+ const paramsRef = useParams({
|
|
24
|
+ id,
|
|
25
|
+ person,
|
|
26
|
+ from: `${page.type}_share`,
|
|
27
|
+ });
|
|
28
|
+ useShare(
|
|
29
|
+ {
|
|
30
|
+ title: shareContent.shareContentTitle || detail?.title,
|
|
31
|
+ path: `${router.path}?${paramsRef.current}`,
|
|
32
|
+ image: shareContent.shareContentImg || getImgURL(detail?.curriculumImg),
|
|
33
|
+ },
|
|
34
|
+ trackData
|
|
35
|
+ );
|
|
36
|
+ const [isSaved, handleFavor] = useFavor(detail?.isSaved, { id, ...trackData });
|
|
37
|
+
|
|
38
|
+ useEffect(() => {
|
|
39
|
+ if (id) {
|
|
40
|
+ fetch({ url: `${API_COURSE_DETAIL}/${id}`, spin: true }).then((res) => {
|
|
41
|
+ setDetail(res || {})
|
|
42
|
+ })
|
|
43
|
+ }
|
|
44
|
+ }, [id])
|
11
|
45
|
|
12
|
46
|
return (
|
13
|
47
|
<view className='Page courseDetail'>
|
|
@@ -17,7 +51,7 @@ export default withLayout((props) => {
|
17
|
51
|
{/* 轮播图 or 主图 */}
|
18
|
52
|
<view className='Banner'>
|
19
|
53
|
<view>
|
20
|
|
- <Swiper autoplay interval={2000} indicator-dots>
|
|
54
|
+ {/* <Swiper autoplay interval={2000} indicator-dots>
|
21
|
55
|
{
|
22
|
56
|
List.map((item, index) => (
|
23
|
57
|
<SwiperItem key={`Banner-${index}`}>
|
|
@@ -27,7 +61,8 @@ export default withLayout((props) => {
|
27
|
61
|
</SwiperItem>
|
28
|
62
|
))
|
29
|
63
|
}
|
30
|
|
- </Swiper>
|
|
64
|
+ </Swiper> */}
|
|
65
|
+ <Image mode='aspectFill' className='centerLabel' src={getImgURL(detail.curriculumImg)} />
|
31
|
66
|
</view>
|
32
|
67
|
</view>
|
33
|
68
|
|
|
@@ -36,22 +71,22 @@ export default withLayout((props) => {
|
36
|
71
|
|
37
|
72
|
<view className='flex-h Title'>
|
38
|
73
|
<view className='flex-item'>
|
39
|
|
- <text className='Name'>句容·恒大养生谷</text>
|
|
74
|
+ <text className='Name'>{detail.name}</text>
|
40
|
75
|
<view className='Address flex-h'>
|
41
|
76
|
<view className='flex-item'>
|
42
|
|
- <text>课程内容课程内容课程内容课程内容课程内容课程内容课程内容..</text>
|
|
77
|
+ <text>{detail.remark}</text>
|
43
|
78
|
</view>
|
44
|
79
|
</view>
|
45
|
|
- <text className='Time'>4568人在阅读</text>
|
|
80
|
+ <text className='Time'>{`${detail.lookNum||0}人阅读`}</text>
|
46
|
81
|
</view>
|
47
|
82
|
<view className='Option'>
|
48
|
|
- <view>
|
|
83
|
+ <button openType='share'>
|
49
|
84
|
<text className='iconfont icon-fenxiang1'></text>
|
50
|
85
|
<text>分享</text>
|
51
|
|
- </view>
|
52
|
|
- <view>
|
53
|
|
- <text className='iconfont icon-haibao'></text>
|
54
|
|
- <text>海报</text>
|
|
86
|
+ </button>
|
|
87
|
+ <view onClick={handleFavor}>
|
|
88
|
+ <text className='iconfont icon-shoucang' style={isSaved ? { color: 'red' } : undefined}></text>
|
|
89
|
+ <text>{isSaved ? '已收藏' : '收藏'}</text>
|
55
|
90
|
</view>
|
56
|
91
|
</view>
|
57
|
92
|
</view>
|
|
@@ -63,22 +98,14 @@ export default withLayout((props) => {
|
63
|
98
|
<view className='Title'>
|
64
|
99
|
<text>课程详情</text>
|
65
|
100
|
</view>
|
66
|
|
- <view className='DescContent'></view>
|
67
|
|
- </view>
|
68
|
|
-
|
69
|
|
- <view className='Bottom'>
|
70
|
|
- <view>
|
71
|
|
- <view>
|
72
|
|
- <text className='iconfont icon-shengming'></text>
|
73
|
|
- <text>免责声明</text>
|
74
|
|
- </view>
|
75
|
|
- <view>
|
76
|
|
- <text>  以上价格仅供参考,具体一房一价的信息以售楼处展示为准。房屋位置交通、医疗、教育、商业等配套信息,来源于第三方不作为要约,仅供参考,双方具体权利义务应以法律规定及买卖合同约定为准。本平台对项目周边文化教育的介绍旨在提供相关信息1 意味着信息发布方对就学安排作出承诺。相关教育资首页信息存在调整的可能,应以政府教育主管部门门及办学颁布的政策规定为准。详情请仔细阅读</text>
|
77
|
|
- <text className='active'>《新联宝使用免责条款》</text>
|
78
|
|
- </view>
|
|
101
|
+ <view className='DescContent'>
|
|
102
|
+ {
|
|
103
|
+ detail.type === TYPE_VIDEO ?
|
|
104
|
+ <video src={detail.curriculumUrl} style={{width: '100%'}} /> :
|
|
105
|
+ <rich-text nodes={detail.content} />
|
|
106
|
+ }
|
79
|
107
|
</view>
|
80
|
108
|
</view>
|
81
|
|
-
|
82
|
109
|
</view>
|
83
|
110
|
</ScrollView>
|
84
|
111
|
</view>
|