detail.js
3.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import { Component, Fragment } from 'react';
import { connect } from 'dva';
import moment from 'moment';
import $ from 'jquery';
import share from '../../utils/share';
import shareHide from "../../utils/shareHide";
import {urlGetParams} from '../../utils/dataFilter'
import css from './css.less';
class Detail extends Component{
constructor(props) {
super(props);
this.state = {
data:null
}
}
componentDidMount() {
document.title = '行业动态';
const { search } = this.props.location;
const params = urlGetParams(window.location.href);
const _this = this;
if (params.id) {
let id = search.substr(4)
this.props.dispatch({
type: 'industrynews/getNews',
payload: {
id:params.id,
reqType:0
},
callback(res) {
_this.setState({data:res})
let htm = res.html.replace(/<figure class="image"><img src="http:\/\/zmtoss\.ihxlife\.com\/polysoft\/o2o_industrynews_audit_1561000223813\.png.*?<figcaption>(.+?)<\/figcaption><\/figure>/g, `<div style="clear:both"><video src=$1 controls="controls"></video></div>`);
$('.ck-content').html(htm);
let urlShare = "";
if(params.isShare){//处理多次转发参数问题
urlShare = window.location.href;
}else{
urlShare = window.location.href+`&isShare=t&phoneNum=${localStorage.getItem('number')}`;
}
share({
decodeUrl: window.location.href.split('#')[0],
title: res.title,
desc: $('.ck-content').text().substr(0,100),
shareUrl: urlShare,
thumbnail: res.imgUrl,
record:{
"operCode": res.id,
"operTitle": res.title,
"operFunction": 100110,
"operType": 202,
"phoneNum": params.isShare ? params.phoneNum : ""
}
});
//点击记录一次
_this.props.dispatch({
type:"home/setClickRecord",
payload: {
"operCode": res.id,
"operFunction": 100110,
"operTitle": res.title,
"operType": 201,
"phoneNum": params.isShare ? params.phoneNum : ""
},
callback(data){
console.log('点击分享链接,记录一次')
}
})
}
})
}
shareHide(false);
}
render() {
const { data } = this.state;
return (
<div className={css.detailWrap}>
{
data && <Fragment>
<div className={css.detailTitle}>{data.title}</div>
<div className={css.detailInfo}>
<div className={css.author}>来源:{data.author}</div>
<div className={css.time}>{moment(data.modifyTime).format('YYYY-MM-DD')}</div>
</div>
</Fragment>
}
<div className="ck-content"></div>
<div className={css.detailInfo}>
<div className={css.viewCount}>{data && data.viewCount}</div>
</div>
</div>
)
}
}
export default connect()(Detail);