|
@@ -2,19 +2,20 @@ import { useState, useEffect } from "react";
|
2
|
2
|
import Taro from "@tarojs/taro";
|
3
|
3
|
import withLayout from "@/layout";
|
4
|
4
|
import { ScrollView, Image, RichText, WebView } from "@tarojs/components";
|
|
5
|
+import useParams from '@/utils/hooks/useParams'
|
5
|
6
|
import useFavor from "@/utils/hooks/useFavor";
|
6
|
7
|
import { queryNewsDetail } from "@/services/news";
|
7
|
8
|
import { formatDate } from "@/utils/chatDate";
|
|
9
|
+import useShare from "@/utils/hooks/useShare";
|
8
|
10
|
import "@/assets/css/iconfont.css";
|
9
|
11
|
import "./index.scss";
|
10
|
12
|
|
11
|
13
|
export default withLayout((props) => {
|
12
|
|
- const { trackData } = props
|
|
14
|
+ const { router, shareContent, person, trackData, page, showShareTimeline } = props
|
13
|
15
|
const { id } = props.router.params;
|
14
|
16
|
|
|
17
|
+ const paramsRef = useParams({person, from: `${page.type}_share`})
|
15
|
18
|
const [data, setData] = useState(null);
|
16
|
|
- const [IsPull, setPull] = useState(false);
|
17
|
|
- const [PullTimer, setPullTimer] = useState(null);
|
18
|
19
|
|
19
|
20
|
|
20
|
21
|
const [isSave, handleFavor] = useFavor(data?.isSave, {
|
|
@@ -22,23 +23,17 @@ export default withLayout((props) => {
|
22
|
23
|
buildingId: data?.buildingId,
|
23
|
24
|
...trackData,
|
24
|
25
|
});
|
25
|
|
-
|
26
|
|
- const PageRefresh = () => {
|
27
|
|
- // 页面下拉刷新回调
|
28
|
|
- setPull(true);
|
29
|
|
- };
|
30
|
|
-
|
31
|
|
- useEffect(() => {
|
32
|
|
- // 下拉刷新触发
|
33
|
|
- if (IsPull) {
|
34
|
|
- clearTimeout(PullTimer);
|
35
|
|
- setPullTimer(
|
36
|
|
- setTimeout(() => {
|
37
|
|
- setPull(false);
|
38
|
|
- }, 2000)
|
39
|
|
- );
|
40
|
|
- }
|
41
|
|
- }, [IsPull]);
|
|
26
|
+
|
|
27
|
+ const fullTrackData = { ...trackData, buildingId: data?.buildingId };
|
|
28
|
+
|
|
29
|
+ useShare(
|
|
30
|
+ {
|
|
31
|
+ title: shareContent.shareContentTitle || data?.newsName,
|
|
32
|
+ path: `${router.path}?${paramsRef.current}`,
|
|
33
|
+ image: shareContent.shareContentImg,
|
|
34
|
+ },
|
|
35
|
+ fullTrackData
|
|
36
|
+ );
|
42
|
37
|
|
43
|
38
|
const getData = (params) => {
|
44
|
39
|
Taro.showLoading();
|
|
@@ -49,14 +44,6 @@ export default withLayout((props) => {
|
49
|
44
|
});
|
50
|
45
|
};
|
51
|
46
|
|
52
|
|
- const shareTimeline = () => {
|
53
|
|
- Taro.showToast({
|
54
|
|
- title: '请点击右上角分享到朋友圈',
|
55
|
|
- icon: 'none',
|
56
|
|
- duration: 3000,
|
57
|
|
- })
|
58
|
|
- }
|
59
|
|
-
|
60
|
47
|
useEffect(() => {
|
61
|
48
|
if (id) {
|
62
|
49
|
getData(id);
|
|
@@ -68,13 +55,7 @@ export default withLayout((props) => {
|
68
|
55
|
{data && (data.newsDetailType === '0' ? <WebView src={data.newsDetail} /> : <>
|
69
|
56
|
<view className='flex-item'>
|
70
|
57
|
<view>
|
71
|
|
- <ScrollView
|
72
|
|
- scroll-y
|
73
|
|
- refresher-enabled
|
74
|
|
- refresher-triggered={IsPull}
|
75
|
|
- onrefresherrefresh={PageRefresh}
|
76
|
|
- refresher-background='#fff'
|
77
|
|
- >
|
|
58
|
+ <ScrollView scrollY>
|
78
|
59
|
<view className='PageContent'>
|
79
|
60
|
<view className='Info'>
|
80
|
61
|
<view>
|
|
@@ -99,9 +80,9 @@ export default withLayout((props) => {
|
99
|
80
|
</view>
|
100
|
81
|
</view>
|
101
|
82
|
<view className='Bottom'>
|
102
|
|
- <view>
|
103
|
|
- <text onClick={shareTimeline} className='iconfont icon-pengyouquan1'></text>
|
104
|
|
- <text onClick={shareTimeline}>分享朋友圈</text>
|
|
83
|
+ <view onClick={() => showShareTimeline(true)}>
|
|
84
|
+ <text className='iconfont icon-pengyouquan1'></text>
|
|
85
|
+ <text>分享朋友圈</text>
|
105
|
86
|
</view>
|
106
|
87
|
<view>
|
107
|
88
|
<text className='iconfont icon-shoucang' style={isSave ? { color: 'red' } : undefined} onClick={handleFavor}></text>
|