Commit fe54f9d5 authored by GuanHua's avatar GuanHua

feat:资讯详情的收藏接口对接

parent ae6a9d38
......@@ -78,8 +78,6 @@
&_main {
padding: 0 24px;
}
}
.information_detail_content {
......@@ -87,8 +85,26 @@
padding: 20px 0;
}
.information_common_tag_list_wrap {
display: flex;
.information_common_tag_right {
.collection_state {
position: relative;
cursor: pointer;
color: var(--mall_main_color);
&>label {
margin-left: 4px;
cursor: pointer;
}
}
}
}
.information_common_tag_list {
display: flex;
flex: 1;
margin-bottom: 20px;
&_item {
......
......@@ -3,12 +3,15 @@ import BreadCrumbs from './components/breadCrumbs'
import InformationRight from './components/informationRight'
import cx from 'classnames'
import { Link } from 'umi'
import { message } from 'antd'
import { StarFilled, StarOutlined } from '@ant-design/icons'
import ImageBox from '@/components/ImageBox'
import { ClockCircleOutlined, EyeOutlined } from '@ant-design/icons'
import informationImg2 from '@/assets/imgs/information_2.png'
import { PublicApi } from '@/services/api'
import { GetManageContentInformationFindByIdResponse } from '@/services/PassApi'
import { numFormat } from '@/utils/numberFomat'
import { getAuth } from '@/utils/auth'
import moment from 'moment'
import styles from './detail.less'
......@@ -19,7 +22,7 @@ interface InformationDetailPropsType {
const InformationDetail: React.FC<InformationDetailPropsType> = (props) => {
const { query: { id } } = props.location
const [newsDetail, setNewsDetail] = useState<GetManageContentInformationFindByIdResponse>()
let collectFlg = true
useEffect(() => {
if (id) {
fetchNewsDetail()
......@@ -37,6 +40,43 @@ const InformationDetail: React.FC<InformationDetailPropsType> = (props) => {
})
}
const handleCollection = () => {
if (getAuth()) {
if (collectFlg) {
collectFlg = false
const status = newsDetail.collectStatus ? false : true
let param = {
informationId: newsDetail.id,
status
}
PublicApi.postManageContentInformationCollect(param).then(res => {
if (res.code === 1000) {
message.destroy()
if (status) {
message.success("收藏成功")
} else {
message.success("取消收藏成功")
}
fetchNewsDetail()
}
collectFlg = true
}).catch(() => {
collectFlg = true
})
}
} else {
if (collectFlg) {
collectFlg = false
message.info("请先进行登录")
setTimeout(() => {
collectFlg = true
window.location.replace(`/user/login?redirect=${btoa(encodeURIComponent(String(window.location)))}`)
}, 1500);
}
}
}
return (
<div className={styles.information_detail}>
<div className={styles.information_detail_container}>
......@@ -68,12 +108,22 @@ const InformationDetail: React.FC<InformationDetailPropsType> = (props) => {
<div className={styles.information_detail_content}>
<div dangerouslySetInnerHTML={{ __html: newsDetail.content }}></div>
</div>
<div className={styles.information_common_tag_list}>
{
newsDetail.contentLabelList && newsDetail.contentLabelList.map((labelItem: any) => (
<div className={styles.information_common_tag_list_item} key={`information_common_tag_list_item-${labelItem.id}`}>{labelItem.name}</div>
))
}
<div className={styles.information_common_tag_list_wrap}>
<div className={styles.information_common_tag_list}>
{
newsDetail.contentLabelList && newsDetail.contentLabelList.map((labelItem: any) => (
<div className={styles.information_common_tag_list_item} key={`information_common_tag_list_item-${labelItem.id}`}>{labelItem.name}</div>
))
}
</div>
<div className={styles.information_common_tag_right}>
<div className={cx(styles.collection_state)} onClick={() => handleCollection()}>
{
newsDetail.collectStatus ? <StarFilled /> : <StarOutlined />
}
<label>收藏</label>
</div>
</div>
</div>
<div className={styles.information_detail_split}></div>
<div className={styles.information_detail_pagination}>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment