import React from 'react';
import { getComment } from '@/services/comment';
import { CommentContext, DefaultValue } from './context';
import styles from './index.less';
import CommentList from './CommentList';
export class CommentCombine extends React.PureComponent {
constructor(props) {
super(props);
this.state = {
...DefaultValue,
}
}
render() {
return (
)
}
}
export class Comment extends React.PureComponent {
static contextType = CommentContext;
static propTypes = {}
static defaultProps = {}
constructor(props) {
super(props);
this.state = {
comment_data: null,
};
}
componentDidMount = async () => {
const { type, limit, page, bussiness_id } = this.context;
const res = await getComment({
type,
limit,
page,
businessId: bussiness_id,
});
console.log("res:", res);
this.setState({
comment_data: res,
})
}
renderCommentList = (list) => {
// content: "[e101][e102]"
// created: 1582352617
// favor_count: 0
// favored: false
// id: "5e50c8e9818eda000192773d"
// is_speak: false
// medias: null
// replies: []
// reply_count: 0
// user_avatar: "https://links123-images.oss-cn-hangzhou.aliyuncs.com/avatar/2020/2/7/1326acc4b1609c8ecf52e94d58a38384.jpg?x-oss-process=image/resize,h_100"
// user_id: 71770
// user_name: "EvoKou"
return
}
renderComment = () => {
const { comment_data } = this.state;
if (comment_data === null) return "数据载入中";
const { list, total, page } = comment_data;
return (
total: {total}
page: {page}
{
this.renderCommentList(list)
}
)
}
render() {
console.log("context", this.context);
return (
{JSON.stringify(this.context)}
{this.renderComment()}
)
}
}
export default CommentCombine;