Your Name преди 3 години
родител
ревизия
35fa658312

+ 1
- 0
src/constants/api.js Целия файл

@@ -20,6 +20,7 @@ export const API_GET_CUSTOMER_INFO = resolvePath('customerInfo/') // 查询客
20 20
 
21 21
 // 课程
22 22
 export const API_COURSE_LIST = resolvePath('curriculum') // 课程列表
23
+export const API_COURSE_DETAIL = resolvePath('curriculum') // 课程详情
23 24
 export const API_MY_COLLECT_COURSE_LIST = resolvePath('curriculum/save') // 我收藏的课程列表
24 25
 
25 26
 // 特价房源

+ 0
- 4
src/pages/index/activityDetail/index.jsx Целия файл

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

+ 2
- 1
src/pages/index/courseDetail/index.config.js Целия файл

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

+ 53
- 26
src/pages/index/courseDetail/index.jsx Целия файл

@@ -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>&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 107
             </view>
80 108
           </view>
81
-
82 109
         </view>
83 110
       </ScrollView>
84 111
     </view>

+ 1
- 1
src/pages/index/courseDetail/index.scss Целия файл

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

+ 2
- 2
src/routes.js Целия файл

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