|
@@ -1,68 +1,111 @@
|
1
|
|
-import React, { useState, useEffect } from 'react'
|
2
|
|
-import withLayout from '@/layout'
|
3
|
|
-import './index.scss'
|
4
|
|
-import { ScrollView } from '@tarojs/components'
|
5
|
|
-import '../../../assets/css/iconfont.css'
|
6
|
|
-import { Image, RichText } from '@tarojs/components'
|
|
1
|
+import React, { useState, useEffect } from "react";
|
|
2
|
+import Taro from "@tarojs/taro";
|
|
3
|
+import withLayout from "@/layout";
|
|
4
|
+import "./index.scss";
|
|
5
|
+import { ScrollView, Image, RichText,WebView } from "@tarojs/components";
|
|
6
|
+import "../../../assets/css/iconfont.css";
|
|
7
|
+import {
|
|
8
|
+ addNewsUv,
|
|
9
|
+ favorNews,
|
|
10
|
+ // addNewsShareNum,
|
|
11
|
+ queryNewsDetail,
|
|
12
|
+ cancelFavorNews,
|
|
13
|
+} from "@/services/news";
|
|
14
|
+import getDateFormat from "@/utils/chatDate";
|
7
|
15
|
|
8
|
16
|
export default withLayout((props) => {
|
|
17
|
+ const { id } = props.router.params;
|
9
|
18
|
|
10
|
|
- // const [PageProps] = useState(props)
|
11
|
|
- const [PageList, setPageList] = useState(['', '', '', '', '', '', '', '', '', '', '', '', ''])
|
12
|
|
- const [IsPull, setPull] = useState(false)
|
13
|
|
- const [PullTimer, setPullTimer] = useState(null)
|
|
19
|
+ const [data, setData] = useState(null);
|
|
20
|
+ const [IsPull, setPull] = useState(false);
|
|
21
|
+ const [PullTimer, setPullTimer] = useState(null);
|
14
|
22
|
|
15
|
|
- const PageRefresh = () => { // 页面下拉刷新回调
|
16
|
|
- setPull(true)
|
17
|
|
- }
|
|
23
|
+ const PageRefresh = () => {
|
|
24
|
+ // 页面下拉刷新回调
|
|
25
|
+ setPull(true);
|
|
26
|
+ };
|
18
|
27
|
|
19
|
|
- useEffect(() => { // 下拉刷新触发
|
|
28
|
+ useEffect(() => {
|
|
29
|
+ // 下拉刷新触发
|
20
|
30
|
if (IsPull) {
|
21
|
|
- clearTimeout(PullTimer)
|
22
|
|
- setPullTimer(setTimeout(() => {
|
23
|
|
- setPull(false)
|
24
|
|
- }, 2000))
|
|
31
|
+ clearTimeout(PullTimer);
|
|
32
|
+ setPullTimer(
|
|
33
|
+ setTimeout(() => {
|
|
34
|
+ setPull(false);
|
|
35
|
+ }, 2000)
|
|
36
|
+ );
|
25
|
37
|
}
|
26
|
|
- }, [IsPull])
|
|
38
|
+ }, [IsPull]);
|
27
|
39
|
|
28
|
|
- return (
|
29
|
|
- <view className='Page newsDetail flex-v'>
|
30
|
|
- <view className='flex-item'>
|
31
|
|
- <view>
|
32
|
|
- <ScrollView scroll-y={true} refresher-enabled={true} refresher-triggered={IsPull} onrefresherrefresh={PageRefresh} refresher-background='#fff'>
|
33
|
|
- <view className='PageContent'>
|
|
40
|
+ const getData = (params) => {
|
|
41
|
+ Taro.showLoading();
|
|
42
|
+ queryNewsDetail(params).then((res) => {
|
|
43
|
+
|
|
44
|
+ setData(res);
|
|
45
|
+ Taro.hideLoading();
|
|
46
|
+ });
|
|
47
|
+ };
|
|
48
|
+
|
|
49
|
+ useEffect(() => {
|
|
50
|
+ if (id) {
|
|
51
|
+ getData(id);
|
|
52
|
+ }
|
|
53
|
+ }, [id]);
|
34
|
54
|
|
35
|
|
- <view className='Info'>
|
36
|
|
- <view>
|
37
|
|
- <text className='Title'>公积金又有新变化,附最新南京公积金贷款和提取方法。</text>
|
|
55
|
+ return (
|
|
56
|
+ <view className="Page newsDetail flex-v">
|
|
57
|
+ {data&& (data.newsDetailType === '0' ? <WebView src={data.newsDetail} /> :<>
|
|
58
|
+ <view className="flex-item">
|
|
59
|
+ <view>
|
|
60
|
+ <ScrollView
|
|
61
|
+ scroll-y={true}
|
|
62
|
+ refresher-enabled={true}
|
|
63
|
+ refresher-triggered={IsPull}
|
|
64
|
+ onrefresherrefresh={PageRefresh}
|
|
65
|
+ refresher-background="#fff"
|
|
66
|
+ >
|
|
67
|
+ <view className="PageContent">
|
|
68
|
+ <view className="Info">
|
38
|
69
|
<view>
|
39
|
|
- <text>阅读:28</text>
|
40
|
|
- <text>点赞15</text>
|
41
|
|
- <text>收藏22</text>
|
|
70
|
+ <text className="Title">{data.newsName}</text>
|
|
71
|
+ <view>
|
|
72
|
+ <text>阅读:{data.pvNum || 0}</text>
|
|
73
|
+ <text>点赞{data.favorNum || 0}</text>
|
|
74
|
+ <text>收藏{data.saveNum || 0}</text>
|
|
75
|
+ </view>
|
|
76
|
+ <text className="Time">
|
|
77
|
+ 时间:
|
|
78
|
+ {getDateFormat(
|
|
79
|
+ new Date(data.createDate).valueOf(),
|
|
80
|
+ true,
|
|
81
|
+ "yyyy-M-d"
|
|
82
|
+ )}{" "}
|
|
83
|
+ </text>
|
|
84
|
+ <text className="Share">分享好友</text>
|
42
|
85
|
</view>
|
43
|
|
- <text className='Time'>时间:2019-10-20 10:00 </text>
|
44
|
|
- <text className='Share'>分享好友</text>
|
45
|
86
|
</view>
|
46
|
|
- </view>
|
47
|
87
|
|
48
|
|
- <view className='Content'>
|
49
|
|
- <RichText nodes={'<p>这是内容</p>'}></RichText>
|
|
88
|
+ <view className="Content">
|
|
89
|
+ <RichText nodes={data.newsDetail}></RichText>
|
|
90
|
+ </view>
|
50
|
91
|
</view>
|
51
|
|
-
|
52
|
|
- </view>
|
53
|
|
- </ScrollView>
|
54
|
|
- </view>
|
55
|
|
- </view>
|
56
|
|
- <view className='Bottom'>
|
57
|
|
- <view>
|
58
|
|
- <Image mode='heightFix' src={require('../../../assets/buildingDetail-icon3.png')}></Image>
|
59
|
|
- <text>生成海报</text>
|
|
92
|
+ </ScrollView>
|
|
93
|
+ </view>
|
60
|
94
|
</view>
|
61
|
|
- <view>
|
62
|
|
- <text className='iconfont icon-shoucang'></text>
|
63
|
|
- <text>收藏</text>
|
|
95
|
+ <view className="Bottom">
|
|
96
|
+ <view>
|
|
97
|
+ <Image
|
|
98
|
+ mode="heightFix"
|
|
99
|
+ src={require("../../../assets/buildingDetail-icon3.png")}
|
|
100
|
+ ></Image>
|
|
101
|
+ <text>生成海报</text>
|
|
102
|
+ </view>
|
|
103
|
+ <view>
|
|
104
|
+ <text className="iconfont icon-shoucang"></text>
|
|
105
|
+ <text>收藏</text>
|
|
106
|
+ </view>
|
64
|
107
|
</view>
|
65
|
|
- </view>
|
|
108
|
+ </>)}
|
66
|
109
|
</view>
|
67
|
|
- )
|
68
|
|
-})
|
|
110
|
+ );
|
|
111
|
+});
|