import React, { Component } from 'react' import Taro, { getCurrentInstance } from '@tarojs/taro' import { View, Text, Image } from '@tarojs/components' import { AtRate } from 'taro-ui' import { SpImage } from '@/components' // import userIcon from '@/assets/imgs/user-icon.png' import './index.scss' export default class GoodsEvaluation extends Component { static options = { addGlobalClass: true } static defaultProps = { info: null, showComment: false } constructor(props) { super(props) this.state = { styles: { height: '200rpx' } } } componentDidMount () { const { windowWidth } = Taro.getSystemInfoSync() let height = (windowWidth * 2 - 169) / 3 + 'rpx' this.setState({ styles: { height } }) } handleSelectEvaluation () { const { info } = this.props this.props.onChange && this.props.onChange(info) } /*handleClickLike () { this.props.onPraiseRate && this.props.onPraiseRate(this.props.info) }*/ handleClickEvaluate () { const { info } = this.props this.props.onReplyRate() && this.props.onReplyRate(info) } fortmatStr (desc) { let desc_info = '颜色分类:' if (desc) { try { const descArr = desc.split(',') descArr.forEach((item, index) => { let [_, value] = item.split(':') if (index === 1) { value = value.substring(0, value.length - 1) } if (index === 2) { value = '尺码:' + value } desc_info += value + ';' }) } catch (error) { } } return desc_info } /*previewImg (url, e) { e.stopPropagation() this.props.onPreviewImg() && this.props.onPreviewImg(url) }*/ render () { const { info, showComment, pathRoute } = this.props const { styles } = this.state if (!info) { return null } if (info.item_spec_desc) { info.item_spec_desc_txt = this.fortmatStr(info.item_spec_desc) } if (pathRoute === 'detail') { if (info && info.picList) { if (info.picList.length > 3) { info.picList = info.picList.slice(0, 3) } } } return ( {/* */} {'匿名用户' || info.anonymous ? '匿名用户' : info.username} {info.item_spec_desc_txt} {info.content} {info.rate_pic_num > 0 && ( {info.picList.map((imgUrl, index) => { return ( ) })} )} {showComment && ( 评论 {info.reply.total_count} )} {showComment && info.reply && info.reply.list && info.reply.list.length > 0 && ( {info.reply.list.map((reply) => { return ( {reply.username}: {reply.content} ) })} )} {/* {info.item_spec_desc} {info.praise_num} 评论 {info.reply.total_count} */} {/* {showComment && info.reply && info.reply.total_count > 0 && { info.reply.list.map(reply => { return ( {reply.username}: {reply.content} ) }) } } */} ) } }