UNPKG

yylib-quick-mobile

Version:

yylib-quick-mobile

92 lines (90 loc) 2.59 kB
import React from 'react'; import { List, TextareaItem,Modal,Icon,Toast } from 'antd-mobile'; import YYIcon from '../icon/YYIcon' import { createForm } from 'rc-form'; var _ = require('lodash'); import './YYReply.less'; class YYComment extends React.Component{ constructor(props) { super(props); this.state = { visible:false } } send(item) { const { getFieldValue } = this.props.form; let {selectRow} = this.props; var value = getFieldValue('comment'); if (!_.isEmpty(item)) { var param = { content:value, pid:item.id, replyId:item.userid, replyName:item.username } this.props.send(param); } else { var param = { content:value, sourceBillType:selectRow.billType, sourceBillId:selectRow.id, } this.props.send(param); } this.setState({visible:false}); } liked(item) { this.props.liked(item.id); } onReply() { this.setState({ visible:true }); } onClose =() => { this.setState({ visible: false, }); } render() { const { getFieldProps,getFieldValue } = this.props.form; let {item,position} = this.props; let value = getFieldValue('comment'); let sendClass = 'send'; if (value&&value.length) { sendClass = 'send'; } else { sendClass = 'send disable' } return ( <div className={`commtents comment-operation-${position}`}> <div className='comment-operation'> <span className='comment' onClick={this.onReply.bind(this,item)}> <YYIcon type="huifu" />{position&&<span className='pinglun'>评论</span>} </span> {!_.isEmpty(item)?<span className={item.liked&&'liked'} onClick={this.liked.bind(this,item)}><YYIcon type="dianzan1" /></span>:null} {!_.isEmpty(item)?<span className='count'>{item.likeCount}</span>:null} </div> <Modal popup transparent animationType="slide-up" onClose={this.onClose} visible={this.state.visible}> <TextareaItem className='comment-text' {...getFieldProps('comment', { initialValue: '', })} rows={2}/> <span className={sendClass} onClick={value&&value.length?this.send.bind(this,item):null}>发送</span> </Modal> </div>) } } YYComment.defaultProps={ item: {} } export default createForm()(YYComment)