2018-12-07 17:17:46 +08:00
|
|
|
|
|
|
|
import Taro, { Component } from '@tarojs/taro'
|
|
|
|
import { View, Button, Text } from '@tarojs/components'
|
|
|
|
import { AtInput, AtForm, AtImagePicker, AtTextarea, AtRadio, AtButton, Picker} from 'taro-ui'
|
2018-12-10 17:38:17 +08:00
|
|
|
import SearchBarComponent from '../../component/searchBarComponent/searchBarComponent'
|
|
|
|
|
2018-12-07 17:17:46 +08:00
|
|
|
import copyrightComponent from '../../component/copyrightComponent/copyrightComponent'
|
|
|
|
|
|
|
|
|
2018-12-11 17:34:06 +08:00
|
|
|
import './supplyDemandPublish.scss'
|
2018-12-07 17:17:46 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class SupplyDemand extends Component {
|
|
|
|
|
|
|
|
config = {
|
|
|
|
navigationBarTitleText: '供求发布'
|
|
|
|
}
|
|
|
|
constructor() {
|
|
|
|
super(...arguments)
|
|
|
|
this.state = {
|
2018-12-11 17:34:06 +08:00
|
|
|
demandingSupplyCate: ['需求', '供应', '人才'], //供求类型选择
|
|
|
|
demandingSupplyCateSelected: '需求',// 当前供求类型
|
|
|
|
demandingSupplyState: ['上架', '下架'], // 状态选择
|
|
|
|
demandingSupplyStateSelected: '上架',// 当前状态
|
|
|
|
title:'',
|
|
|
|
contactName:'',
|
|
|
|
contactNumber:'',
|
|
|
|
contactAddress:'',
|
|
|
|
content:'',
|
|
|
|
addImg:true, // 是否支持添加图片
|
2018-12-10 17:38:17 +08:00
|
|
|
files: [{
|
|
|
|
url: 'https://jimczj.gitee.io/lazyrepay/aragaki1.jpeg',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
url: 'https://jimczj.gitee.io/lazyrepay/aragaki2.jpeg',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
url: 'https://jimczj.gitee.io/lazyrepay/aragaki3.png',
|
|
|
|
}]
|
2018-12-07 17:17:46 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
2018-12-11 17:34:06 +08:00
|
|
|
// 修改供求类型
|
|
|
|
demandingSupplyCate = e => {
|
2018-12-07 17:17:46 +08:00
|
|
|
this.setState({
|
2018-12-11 17:34:06 +08:00
|
|
|
demandingSupplyCateSelected: this.state.demandingSupplyCate[e.detail.value]
|
2018-12-07 17:17:46 +08:00
|
|
|
})
|
|
|
|
}
|
2018-12-11 17:34:06 +08:00
|
|
|
// 修改供求状态
|
|
|
|
demSupplyStateChange = e => {
|
|
|
|
this.setState({
|
|
|
|
demandingSupplyStateSelected: this.state.demandingSupplyState[e.detail.value]
|
|
|
|
})
|
|
|
|
}
|
|
|
|
//改标题
|
|
|
|
titleChange(event){
|
|
|
|
this.setState({title:event})
|
|
|
|
}
|
|
|
|
contactNameChange(event){
|
|
|
|
this.setState({contactName:event})
|
|
|
|
}
|
|
|
|
contactNumberChange(event){
|
|
|
|
this.setState({contactNumber:event})
|
|
|
|
}
|
|
|
|
contactAddressChange(event){
|
|
|
|
this.setState({contactAddress:event.target.value})
|
|
|
|
}
|
|
|
|
contentChange(event){
|
|
|
|
this.setState({ content: event.target.value})
|
|
|
|
}
|
|
|
|
// 添加图片
|
2018-12-10 17:38:17 +08:00
|
|
|
onChange(files, operationType,index) {
|
|
|
|
if (operationType==='add'){
|
|
|
|
this.setState({
|
|
|
|
files
|
|
|
|
}, () => {
|
|
|
|
if (this.state.files.length === 4) {
|
|
|
|
this.setState({ addImg: false })
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
if (operationType === 'remove'){
|
|
|
|
this.state.files.splice(index, 1);
|
|
|
|
this.setState({ files: this.state.files });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
onFail(mes) {
|
|
|
|
console.log(mes)
|
|
|
|
}
|
|
|
|
onImageClick(index, file) {
|
|
|
|
console.log(index, file)
|
|
|
|
}
|
2018-12-07 17:17:46 +08:00
|
|
|
componentWillReceiveProps(nextProps) {
|
|
|
|
console.log(this.props, nextProps)
|
|
|
|
}
|
|
|
|
|
|
|
|
componentWillUnmount() { }
|
|
|
|
|
|
|
|
componentDidShow() { }
|
|
|
|
|
|
|
|
componentDidHide() { }
|
|
|
|
|
|
|
|
render() {
|
|
|
|
return (
|
|
|
|
<View className='supply-demand'>
|
2018-12-10 17:38:17 +08:00
|
|
|
<SearchBarComponent></SearchBarComponent>
|
2018-12-07 17:17:46 +08:00
|
|
|
<View className='page-section'>
|
|
|
|
|
|
|
|
<View>
|
2018-12-11 17:34:06 +08:00
|
|
|
<Picker mode='selector' range={this.state.demandingSupplyCate} onChange={this.demandingSupplyCate.bind(this)}>
|
2018-12-07 17:17:46 +08:00
|
|
|
<View className='picker'>
|
|
|
|
<View className='title-box'>
|
2018-12-11 17:34:06 +08:00
|
|
|
<Text className='title'><Text className='require'>*</Text>供求类型:</Text> <Text className='selected'>{this.state.demandingSupplyCateSelected}</Text>
|
2018-12-07 17:17:46 +08:00
|
|
|
</View>
|
|
|
|
|
|
|
|
</View>
|
|
|
|
</Picker>
|
|
|
|
</View>
|
|
|
|
</View>
|
|
|
|
<View className='border-box'>
|
|
|
|
<Text className='require'>*</Text><AtInput
|
|
|
|
name='value'
|
|
|
|
title='需求标题:'
|
|
|
|
type='text'
|
2018-12-11 17:34:06 +08:00
|
|
|
value={this.state.title}
|
|
|
|
onChange={this.titleChange.bind(this)}
|
2018-12-07 17:17:46 +08:00
|
|
|
/>
|
|
|
|
</View>
|
|
|
|
<View className='input-box'>
|
|
|
|
<Text className='require'>*</Text>
|
|
|
|
<AtInput
|
|
|
|
name='value'
|
|
|
|
title='联系人:'
|
|
|
|
type='text'
|
2018-12-11 17:34:06 +08:00
|
|
|
value={this.state.contactName}
|
|
|
|
onChange={this.contactNameChange.bind(this)}
|
2018-12-07 17:17:46 +08:00
|
|
|
/>
|
|
|
|
</View>
|
|
|
|
<View className='input-box'>
|
|
|
|
<Text className='require'>*</Text>
|
|
|
|
<AtInput
|
|
|
|
name='value'
|
|
|
|
title='联系电话:'
|
|
|
|
type='number'
|
2018-12-11 17:34:06 +08:00
|
|
|
value={this.state.contactNumber}
|
|
|
|
onChange={this.contactNumberChange.bind(this)}
|
2018-12-07 17:17:46 +08:00
|
|
|
/>
|
|
|
|
</View>
|
2018-12-10 17:38:17 +08:00
|
|
|
<View className='demanding-box'>
|
2018-12-11 17:34:06 +08:00
|
|
|
<View className='title-box'>
|
|
|
|
<Text className='title'><Text className='require'>*</Text>联系地址:</Text>
|
|
|
|
</View>
|
2018-12-07 17:17:46 +08:00
|
|
|
|
|
|
|
<AtTextarea
|
2018-12-11 17:34:06 +08:00
|
|
|
value={this.state.contactAddress}
|
|
|
|
onChange={this.contactAddressChange.bind(this)}
|
2018-12-07 17:17:46 +08:00
|
|
|
maxlength='200'
|
2018-12-10 17:38:17 +08:00
|
|
|
placeholder='联系地址'
|
2018-12-07 17:17:46 +08:00
|
|
|
/>
|
|
|
|
</View>
|
|
|
|
<View className='demanding-box'>
|
|
|
|
<View className='title-box'>
|
|
|
|
<Text className='title'><Text className='require'>*</Text>需求内容:</Text>
|
|
|
|
</View>
|
|
|
|
<AtTextarea
|
2018-12-11 17:34:06 +08:00
|
|
|
value={this.state.content}
|
|
|
|
onChange={this.contentChange.bind(this)}
|
2018-12-07 17:17:46 +08:00
|
|
|
maxlength='200'
|
2018-12-10 17:38:17 +08:00
|
|
|
placeholder=''
|
2018-12-07 17:17:46 +08:00
|
|
|
/>
|
|
|
|
</View>
|
|
|
|
<View className='img-box'>
|
|
|
|
<View className='title-box'>
|
|
|
|
<Text className='title'>需求图片:</Text>
|
|
|
|
<View className='warn'>(最多4张)</View>
|
|
|
|
</View>
|
|
|
|
|
|
|
|
<View className='img-container'>
|
|
|
|
<AtImagePicker
|
2018-12-11 17:34:06 +08:00
|
|
|
showAddBtn={this.state.addImg}
|
|
|
|
files={this.state.files}
|
|
|
|
onChange={this.onChange.bind(this)}
|
|
|
|
onFail={this.onFail.bind(this)}
|
|
|
|
onImageClick={this.onImageClick.bind(this)}
|
2018-12-07 17:17:46 +08:00
|
|
|
/>
|
|
|
|
</View>
|
|
|
|
|
|
|
|
</View>
|
|
|
|
<View className='page-section'>
|
|
|
|
|
|
|
|
<View>
|
2018-12-11 17:34:06 +08:00
|
|
|
<Picker mode='selector' range={this.state.demandingSupplyState} onChange={this.demSupplyStateChange}>
|
2018-12-07 17:17:46 +08:00
|
|
|
<View className='picker'>
|
|
|
|
<View className='title-box'>
|
2018-12-11 17:34:06 +08:00
|
|
|
<Text className='title'> <Text className='require'>*</Text>状态:</Text> <Text className='selected'>{this.state.demandingSupplyStateSelected}</Text>
|
2018-12-07 17:17:46 +08:00
|
|
|
</View>
|
|
|
|
|
|
|
|
</View>
|
|
|
|
</Picker>
|
|
|
|
</View>
|
|
|
|
</View>
|
|
|
|
|
|
|
|
<View className='button-box'>
|
|
|
|
<View className='button'>
|
|
|
|
<AtButton type='primary' size='small'>发布</AtButton>
|
|
|
|
</View>
|
|
|
|
<View className='button'>
|
2018-12-10 17:38:17 +08:00
|
|
|
|
|
|
|
<AtButton type='primary' className='button-a' size='small'>发布并新增</AtButton>
|
2018-12-07 17:17:46 +08:00
|
|
|
</View>
|
|
|
|
<View className='button'>
|
2018-12-10 17:38:17 +08:00
|
|
|
<AtButton type='primary' className='button-a' size='small'>商品列表</AtButton>
|
2018-12-07 17:17:46 +08:00
|
|
|
</View>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</View>
|
|
|
|
<copyrightComponent></copyrightComponent>
|
|
|
|
|
|
|
|
|
|
|
|
</View>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default SupplyDemand
|