Yansen 2 years ago
parent
commit
6aafd5678f
2 changed files with 27 additions and 6 deletions
  1. 19
    2
      src/pages/notice/detail/index.jsx
  2. 8
    4
      src/pages/notice/detail/style.module.less

+ 19
- 2
src/pages/notice/detail/index.jsx View File

@@ -1,6 +1,6 @@
1 1
 import React from 'react';
2 2
 import Taro from '@tarojs/taro';
3
-import { View, Image } from '@tarojs/components';
3
+import { View, Image, RichText } from '@tarojs/components';
4 4
 import Page from '@/layouts/index';
5 5
 import { getTaNoticeById } from '@/services/tanotice';
6 6
 import { getDtStr } from '@/utils/date';
@@ -15,11 +15,27 @@ export default (props) => {
15 15
   const router = Taro.useRouter();
16 16
   const { id } = router.params;
17 17
 
18
+  const onPreview = () => {
19
+    if (!detail?.thumb) return;
20
+
21
+    Taro.previewMedia({
22
+      sources: [
23
+        {
24
+          url: detail.thumb,
25
+        },        
26
+      ],
27
+      current: 0,
28
+    })
29
+  }
30
+
18 31
   React.useEffect(() => {
19 32
     if (id) {
20 33
       setLoading(true);
21 34
       getTaNoticeById(id).then((res) => {
22 35
         setDetail(res);
36
+        Taro.setNavigationBarTitle({
37
+          title: res.title,
38
+        })
23 39
         setLoading(false);
24 40
       }).catch(er => {
25 41
         console.error(er);
@@ -37,7 +53,8 @@ export default (props) => {
37 53
           <View className={style['notice-hd2']}>{dateStr}</View>
38 54
         </View>
39 55
         <View className={style['notice-bd']}>
40
-          <Image></Image>
56
+          <Image src={detail?.thumb} onClick={onPreview}></Image>
57
+          <RichText nodes={detail?.content} />
41 58
         </View>
42 59
         <View className={style['notice-ft']}>
43 60
 

+ 8
- 4
src/pages/notice/detail/style.module.less View File

@@ -1,5 +1,6 @@
1 1
 .notice-wrapper {
2 2
   height: 100%;
3
+  overflow-y: auto;
3 4
   padding: var(--main-space);
4 5
 
5 6
   .notice-hd {
@@ -15,12 +16,15 @@
15 16
   }
16 17
 
17 18
   .notice-bd {
18
-    flex: 1;
19
-    overflow: hidden;
20
-    margin: var(--main-space);
19
+    image {
20
+      width: 100%;
21
+    }
22
+
23
+    rich-text {
24
+      line-height: 2em;
25
+    }
21 26
   }
22 27
 
23 28
   .notice-ft {
24
-    flex: none;
25 29
   }
26 30
 }