Your Name 3 лет назад
Родитель
Сommit
35fa658312

+ 1
- 0
src/constants/api.js Просмотреть файл

20
 
20
 
21
 // 课程
21
 // 课程
22
 export const API_COURSE_LIST = resolvePath('curriculum') // 课程列表
22
 export const API_COURSE_LIST = resolvePath('curriculum') // 课程列表
23
+export const API_COURSE_DETAIL = resolvePath('curriculum') // 课程详情
23
 export const API_MY_COLLECT_COURSE_LIST = resolvePath('curriculum/save') // 我收藏的课程列表
24
 export const API_MY_COLLECT_COURSE_LIST = resolvePath('curriculum/save') // 我收藏的课程列表
24
 
25
 
25
 // 特价房源
26
 // 特价房源

+ 0
- 4
src/pages/index/activityDetail/index.jsx Просмотреть файл

71
     Taro.showLoading();
71
     Taro.showLoading();
72
 
72
 
73
     queryActivityDetail(params).then((res) => {
73
     queryActivityDetail(params).then((res) => {
74
-      // const maxperson =
75
-      //   res.maxEnlistByPerson < 100 ? res.maxEnlistByPerson : 100;
76
-
77
       const maxperson = 10
74
       const maxperson = 10
78
-
79
       setSelector(times(maxperson).map((_, i) => `${i + 1}`));
75
       setSelector(times(maxperson).map((_, i) => `${i + 1}`));
80
 
76
 
81
       setDetail(res);
77
       setDetail(res);

+ 2
- 1
src/pages/index/courseDetail/index.config.js Просмотреть файл

1
 export default {
1
 export default {
2
-  navigationBarTitleText: '课程详情'
2
+  navigationBarTitleText: '课程详情',
3
+  enableShareAppMessage: true
3
 }
4
 }

+ 53
- 26
src/pages/index/courseDetail/index.jsx Просмотреть файл

1
-
1
+import { useEffect, useState } from 'react'
2
 import withLayout from '@/layout'
2
 import withLayout from '@/layout'
3
 import { ScrollView, Image, Swiper, SwiperItem } from '@tarojs/components'
3
 import { ScrollView, Image, Swiper, SwiperItem } from '@tarojs/components'
4
 // import Taro from '@tarojs/taro'
4
 // import Taro from '@tarojs/taro'
5
 import { getImgURL } from '@/utils/image'
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
 import '@/assets/css/iconfont.css'
11
 import '@/assets/css/iconfont.css'
7
 import './index.scss'
12
 import './index.scss'
8
 
13
 
14
+const TYPE_RICH = 0
15
+const TYPE_VIDEO = 1
16
+
9
 export default withLayout((props) => {
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
   return (
46
   return (
13
     <view className='Page courseDetail'>
47
     <view className='Page courseDetail'>
17
           {/* 轮播图 or 主图 */}
51
           {/* 轮播图 or 主图 */}
18
           <view className='Banner'>
52
           <view className='Banner'>
19
             <view>
53
             <view>
20
-              <Swiper autoplay interval={2000} indicator-dots>
54
+              {/* <Swiper autoplay interval={2000} indicator-dots>
21
                 {
55
                 {
22
                   List.map((item, index) => (
56
                   List.map((item, index) => (
23
                     <SwiperItem key={`Banner-${index}`}>
57
                     <SwiperItem key={`Banner-${index}`}>
27
                     </SwiperItem>
61
                     </SwiperItem>
28
                   ))
62
                   ))
29
                 }
63
                 }
30
-              </Swiper>
64
+              </Swiper> */}
65
+              <Image mode='aspectFill' className='centerLabel' src={getImgURL(detail.curriculumImg)} />
31
             </view>
66
             </view>
32
           </view>
67
           </view>
33
 
68
 
36
 
71
 
37
             <view className='flex-h Title'>
72
             <view className='flex-h Title'>
38
               <view className='flex-item'>
73
               <view className='flex-item'>
39
-                <text className='Name'>句容·恒大养生谷</text>
74
+                <text className='Name'>{detail.name}</text>
40
                 <view className='Address flex-h'>
75
                 <view className='Address flex-h'>
41
                   <view className='flex-item'>
76
                   <view className='flex-item'>
42
-                    <text>课程内容课程内容课程内容课程内容课程内容课程内容课程内容..</text>
77
+                    <text>{detail.remark}</text>
43
                   </view>
78
                   </view>
44
                 </view>
79
                 </view>
45
-                <text className='Time'>4568人在阅读</text>
80
+                <text className='Time'>{`${detail.lookNum||0}人阅读`}</text>
46
               </view>
81
               </view>
47
               <view className='Option'>
82
               <view className='Option'>
48
-                <view>
83
+                <button openType='share'>
49
                   <text className='iconfont icon-fenxiang1'></text>
84
                   <text className='iconfont icon-fenxiang1'></text>
50
                   <text>分享</text>
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
                 </view>
90
                 </view>
56
               </view>
91
               </view>
57
             </view>
92
             </view>
63
             <view className='Title'>
98
             <view className='Title'>
64
               <text>课程详情</text>
99
               <text>课程详情</text>
65
             </view>
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>&emsp;&emsp;以上价格仅供参考,具体一房一价的信息以售楼处展示为准。房屋位置交通、医疗、教育、商业等配套信息,来源于第三方不作为要约,仅供参考,双方具体权利义务应以法律规定及买卖合同约定为准。本平台对项目周边文化教育的介绍旨在提供相关信息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
             </view>
107
             </view>
80
           </view>
108
           </view>
81
-
82
         </view>
109
         </view>
83
       </ScrollView>
110
       </ScrollView>
84
     </view>
111
     </view>

+ 1
- 1
src/pages/index/courseDetail/index.scss Просмотреть файл

108
             }
108
             }
109
           }
109
           }
110
           >.Option {
110
           >.Option {
111
-            >view {
111
+            >view, button {
112
               font-size: 0;
112
               font-size: 0;
113
               white-space: nowrap;
113
               white-space: nowrap;
114
               text-align: center;
114
               text-align: center;

+ 2
- 2
src/routes.js Просмотреть файл

235
     name: '课程详情',
235
     name: '课程详情',
236
     page: 'pages/index/courseDetail/index',
236
     page: 'pages/index/courseDetail/index',
237
     pkg: 'main',
237
     pkg: 'main',
238
-    type: 'mine',
238
+    type: 'curriculum',
239
   },
239
   },
240
 
240
 
241
   //视频
241
   //视频
299
     name: '我的课堂',
299
     name: '我的课堂',
300
     page: 'pages/mine/myCourse/index',
300
     page: 'pages/mine/myCourse/index',
301
     pkg: 'main',
301
     pkg: 'main',
302
-    type: 'mine',
302
+    type: 'curriculum',
303
   },
303
   },
304
   {
304
   {
305
     name: '我的活动',
305
     name: '我的活动',