Skip to content

Commit

Permalink
文章修改时间,订单显示订金
Browse files Browse the repository at this point in the history
  • Loading branch information
dsaco committed Mar 3, 2017
1 parent f764829 commit 7e7c4dd
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 4 deletions.
7 changes: 6 additions & 1 deletion src/scripts/components/OrderList/OrderList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,12 @@ export default class OrderList extends Component{
<td>{order.items[0]['merchant']}</td>
<td><img style={{width:'40px'}} src={order.items[0].image} /></td>
<td style={{width:'30%'}}>{order.title}</td>
<td><span><strong>¥{order.price.totalPrice}</strong></span><br/>{order.price.totalFreight > 0 ? <small style={{color:'#6c6c6c',fontSize:'10px'}}>含运费:¥&nbsp;{order.price.totalFreight}</small> : <small style={{color:'#6c6c6c',fontSize:'10px'}}>包邮</small>}</td>
<td>
<span><strong>¥{order.price.totalPrice}</strong></span><br/>
{order.price.totalFreight > 0 ? <small style={{color:'#6c6c6c',fontSize:'10px'}}>含运费:¥&nbsp;{order.price.totalFreight}</small> : <small style={{color:'#6c6c6c',fontSize:'10px'}}>包邮</small>}
<br/>
{order.price.prePay ? <small style={{color:'#6c6c6c',fontSize:'10px'}}>订金:¥&nbsp;{order.price.prePay}</small>:null}
</td>
<td>{Moment(order.created).format('MM-DD HH:mm')}</td>
<td>{this.formatStatus(order.status)}</td>
<td>
Expand Down
46 changes: 43 additions & 3 deletions src/scripts/components/PageList/PageList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {Row, Button,Form,FormGroup,InputGroup,FormControl, Modal} from 'react-bo
import Moment from 'moment'
import Request from 'superagent'
import ReactPaginate from 'react-paginate'
import DatePicker from 'react-datepicker'

import PlayAutoSuggest from '../Common/PlayAutoSuggest'
import PlaySwitch from '../Common/playSwitch'
Expand All @@ -16,6 +17,10 @@ export default class PageList extends Component{
showModal:false,
pid:'',
toyId:'',

curPageId:null,
curDate:Moment().startOf('day'),
curTime:'15-30'
}
this.togglePub = (id) => this.props.togglePub(id)
this.toggleRec = (id) => this.props.toggleRec(id)
Expand All @@ -28,6 +33,7 @@ export default class PageList extends Component{
this.search = this._search.bind(this)
//玩具搜索
this.close = () => this.setState({showModal:false,pid:'',toyId:''})
this.setTime = this._setTime.bind(this)
}
componentWillMount() {
const { page,query,filter } = this.props
Expand All @@ -51,6 +57,21 @@ export default class PageList extends Component{
this.context.router.push(`/page?page=0`)
this.props.getPageBy(this.state.filter,this.state.query.trim())
}
_setTime() {
const { curDate, curTime, curPageId } = this.state
if(!curTime.match(/[0-2][0-9]-[0-5][0-9]/)){
return alert('时间格式不对')
}
const arr = curTime.split('-')
const created = curDate.valueOf() + arr[0]*3600000 + arr[1]*60000
Request.post(`/api/page/${curPageId}/created`)
.send({created})
.end((err,res) => {
if(!err) {
this.setState({curPageId:null})
}
})
}
render() {
const inputProps = {
placeholder: '输入玩具关键字',
Expand Down Expand Up @@ -91,8 +112,10 @@ export default class PageList extends Component{
let shareClass = page.forShare ? 'btn bg-orange btn-sm' : 'btn btn-sm'
return (
<tr key={page.id}>
<td style={{display:'flex',flexDirection:'column',width:200}}>
<img src={page.cover} className="img-thumbnail"/>
<td>
<img style={{maxWidth:150}} src={page.cover} className="img-thumbnail"/>
</td>
<td>
{page.title}
</td>
<td><Link to={'/user/'+page.user.id}><img style={{width:'45px'}} src={page.user.avatar} className="img-circle"/></Link></td>
Expand All @@ -115,7 +138,7 @@ export default class PageList extends Component{
}
</td>
<td>{page.counts.views} views</td>
<td>{Moment.unix(page.created / 1000).fromNow()}</td>
<td onClick={() => this.setState({curPageId:page.id})}>{Moment.unix(page.created / 1000).fromNow()}</td>
<td>
<PlaySwitch
on="L"
Expand Down Expand Up @@ -182,6 +205,23 @@ export default class PageList extends Component{
/>
</Modal.Body>
</Modal>
<Modal show={!!this.state.curPageId} onHide={() => this.setState({curPageId:null})}>
<Modal.Header closeButton>
<Modal.Title>修改发布时间</Modal.Title>
</Modal.Header>
<Modal.Body>
<DatePicker
selected={this.state.curDate}
onChange={(date) => this.setState({curDate:date})}
maxDate={Moment()}
dateFormat="YYYY/MM/DD"
/>
<input style={{marginLeft:20}} type="text" value={this.state.curTime} onChange={(e) => this.setState({curTime:e.target.value})}/>
</Modal.Body>
<Modal.Footer>
<Button onClick={this.setTime}>修改</Button>
</Modal.Footer>
</Modal>
</div>
)
}
Expand Down

0 comments on commit 7e7c4dd

Please sign in to comment.