2018-12-06 17:24:34 +08:00
|
|
|
import Taro, { Component } from '@tarojs/taro'
|
2018-12-18 17:37:23 +08:00
|
|
|
import { View, Text, Radio, RadioGroup, Label } from '@tarojs/components'
|
|
|
|
import { AtInput, AtImagePicker, AtTextarea, AtButton, Picker } from 'taro-ui'
|
2018-12-06 17:24:34 +08:00
|
|
|
|
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-18 17:37:23 +08:00
|
|
|
import URL from '../../serviceAPI.config'
|
2018-12-06 17:24:34 +08:00
|
|
|
|
|
|
|
|
|
|
|
import './goodsPublish.scss'
|
|
|
|
|
|
|
|
class GoodsPublish extends Component {
|
|
|
|
|
|
|
|
config = {
|
|
|
|
navigationBarTitleText: '商品发布'
|
|
|
|
}
|
|
|
|
constructor() {
|
|
|
|
super(...arguments)
|
|
|
|
this.state = {
|
2018-12-11 17:34:06 +08:00
|
|
|
selector: ['需求', '供应', '人才'], // 应该是树型结构,需要修改
|
2018-12-10 17:38:17 +08:00
|
|
|
selectorChecked: '需求',
|
2018-12-18 17:37:23 +08:00
|
|
|
productName: '',
|
|
|
|
productPrice: '',
|
|
|
|
productUnit: '',
|
|
|
|
productDescript: '',
|
2018-12-06 17:24:34 +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-11 17:34:06 +08:00
|
|
|
}], // 上传的图片
|
2018-12-06 17:24:34 +08:00
|
|
|
list: [
|
|
|
|
{
|
|
|
|
value: '美国',
|
|
|
|
text: '美国',
|
|
|
|
checked: false
|
|
|
|
},
|
|
|
|
{
|
|
|
|
value: '中国',
|
|
|
|
text: '中国',
|
|
|
|
checked: true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
value: '巴西',
|
|
|
|
text: '巴西',
|
|
|
|
checked: false
|
|
|
|
},
|
|
|
|
{
|
|
|
|
value: '日本',
|
|
|
|
text: '日本',
|
|
|
|
checked: false
|
|
|
|
}
|
2018-12-18 17:37:23 +08:00
|
|
|
|
2018-12-11 17:34:06 +08:00
|
|
|
] // 店铺分类选项
|
2018-12-06 17:24:34 +08:00
|
|
|
}
|
|
|
|
}
|
2018-12-18 17:37:23 +08:00
|
|
|
|
|
|
|
// 发布商品api
|
|
|
|
uploadGoods() {
|
|
|
|
Taro.request({
|
|
|
|
url: URL.UploadProduct,
|
|
|
|
method: 'POST',
|
|
|
|
dataType: 'json',
|
|
|
|
data: {
|
|
|
|
deployType: 1,
|
|
|
|
action: 1,
|
|
|
|
goods: JSON.stringify({ "goods_name": "test2", "goods_price": "1.00", "goods_unit": "1", "goods_profiles": "test2", "class_id": "10103", "shop_class_id": "1899" }),
|
|
|
|
goodsFiles: JSON.stringify([{ "file_id": "27959", "file_type": 1, "if_cover": 1, "file_sort": 1 }])
|
|
|
|
},
|
|
|
|
header: {
|
|
|
|
'content-type': 'application/x-www-form-urlencoded',
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.then(res => {
|
|
|
|
console.log('上传商品', res) // 提示非法请求 ----- to be continue
|
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|
|
|
|
// 上传商品图片api
|
|
|
|
uploadGoodsImage() {
|
|
|
|
Taro.request({
|
|
|
|
url: URL.UploadPorductImage,
|
|
|
|
method: 'POST',
|
|
|
|
dataType: 'json',
|
|
|
|
data: {
|
|
|
|
file: 1,
|
|
|
|
},
|
|
|
|
header: {
|
|
|
|
'content-type': 'application/x-www-form-urlencoded',
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.then(res => {
|
|
|
|
console.log('上传商品图片', res)
|
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|
2018-12-11 17:34:06 +08:00
|
|
|
// 改变商品分类状态
|
2018-12-18 17:37:23 +08:00
|
|
|
onChange(e) {
|
2018-12-10 17:38:17 +08:00
|
|
|
this.setState({
|
|
|
|
selectorChecked: this.state.selector[e.detail.value]
|
|
|
|
})
|
|
|
|
}
|
2018-12-18 17:37:23 +08:00
|
|
|
productNameChange(event) {
|
2018-12-06 17:24:34 +08:00
|
|
|
this.setState({
|
2018-12-11 17:34:06 +08:00
|
|
|
productName: event
|
2018-12-06 17:24:34 +08:00
|
|
|
})
|
|
|
|
}
|
2018-12-18 17:37:23 +08:00
|
|
|
productPriceChange(event) {
|
2018-12-11 17:34:06 +08:00
|
|
|
this.setState({
|
|
|
|
productPrice: event
|
|
|
|
})
|
|
|
|
}
|
2018-12-18 17:37:23 +08:00
|
|
|
productUnitChange(event) {
|
2018-12-11 17:34:06 +08:00
|
|
|
this.setState({
|
|
|
|
productUnit: event
|
|
|
|
})
|
|
|
|
}
|
2018-12-18 17:37:23 +08:00
|
|
|
productDescriptChange(event) {
|
2018-12-11 17:34:06 +08:00
|
|
|
this.setState({
|
|
|
|
productDescript: event.target.value
|
|
|
|
})
|
|
|
|
}
|
|
|
|
// 上传图片
|
2018-12-18 17:37:23 +08:00
|
|
|
onChangeImg(files, operationType,index) {
|
2018-12-11 17:34:06 +08:00
|
|
|
if (operationType === 'add') {
|
|
|
|
this.setState({
|
|
|
|
files
|
|
|
|
})
|
|
|
|
}
|
|
|
|
if (operationType === 'remove') {
|
|
|
|
this.state.files.splice(index, 1);
|
|
|
|
this.setState({ files: this.state.files });
|
|
|
|
}
|
2018-12-18 17:37:23 +08:00
|
|
|
|
2018-12-11 17:34:06 +08:00
|
|
|
}
|
|
|
|
// 图片上传失败
|
2018-12-06 17:24:34 +08:00
|
|
|
onFail(mes) {
|
|
|
|
console.log(mes)
|
|
|
|
}
|
2018-12-11 17:34:06 +08:00
|
|
|
// 删除图片
|
|
|
|
onImageClick(index) {
|
2018-12-18 17:37:23 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
componentDidMount(){
|
|
|
|
|
2018-12-06 17:24:34 +08:00
|
|
|
}
|
2018-12-18 17:37:23 +08:00
|
|
|
|
2018-12-06 17:24:34 +08:00
|
|
|
componentWillReceiveProps(nextProps) {
|
|
|
|
console.log(this.props, nextProps)
|
|
|
|
}
|
|
|
|
|
|
|
|
componentWillUnmount() { }
|
|
|
|
|
|
|
|
componentDidShow() { }
|
|
|
|
|
|
|
|
componentDidHide() { }
|
|
|
|
|
|
|
|
render() {
|
|
|
|
return (
|
|
|
|
<View className='goods-publish'>
|
2018-12-10 17:38:17 +08:00
|
|
|
<SearchBarComponent></SearchBarComponent>
|
2018-12-06 17:24:34 +08:00
|
|
|
<View className='goods-category'>
|
2018-12-10 17:38:17 +08:00
|
|
|
<View className='page-section'>
|
|
|
|
|
|
|
|
<View>
|
2018-12-11 17:34:06 +08:00
|
|
|
<Picker mode='selector' range={this.state.selector} onChange={this.onChange}>
|
2018-12-10 17:38:17 +08:00
|
|
|
<View className='picker'>
|
|
|
|
<View className='title-box'>
|
|
|
|
<Text className='title'><Text className='require'>*</Text>商品分类:</Text> <Text className='selected'>{this.state.selectorChecked}</Text>
|
|
|
|
</View>
|
|
|
|
|
|
|
|
</View>
|
|
|
|
</Picker>
|
|
|
|
</View>
|
|
|
|
</View>
|
|
|
|
|
|
|
|
<View className='input-box'>
|
|
|
|
<Text className='require'>*</Text>
|
2018-12-06 17:24:34 +08:00
|
|
|
<AtInput
|
2018-12-18 17:37:23 +08:00
|
|
|
name='value'
|
|
|
|
title='商品名称:'
|
|
|
|
type='text'
|
|
|
|
value={this.state.productName}
|
|
|
|
onChange={this.productNameChange.bind(this)}
|
2018-12-06 17:24:34 +08:00
|
|
|
/>
|
|
|
|
</View>
|
2018-12-10 17:38:17 +08:00
|
|
|
<View className='input-box'>
|
|
|
|
<Text className='require'>*</Text>
|
2018-12-18 17:37:23 +08:00
|
|
|
<AtInput
|
|
|
|
name='value'
|
|
|
|
title='商品价格:'
|
|
|
|
type='number'
|
|
|
|
placeholder='¥'
|
|
|
|
value={this.state.productPrice}
|
|
|
|
onChange={this.productPriceChange.bind(this)}
|
|
|
|
/>
|
|
|
|
</View>
|
2018-12-10 17:38:17 +08:00
|
|
|
<View className='input-box'>
|
|
|
|
<Text className='require'>*</Text>
|
2018-12-18 17:37:23 +08:00
|
|
|
<AtInput
|
|
|
|
name='value'
|
|
|
|
title='商品单位:'
|
|
|
|
type='text'
|
|
|
|
value={this.state.productUnit}
|
|
|
|
onChange={this.productUnitChange.bind(this)}
|
|
|
|
/>
|
2018-12-10 17:38:17 +08:00
|
|
|
</View>
|
2018-12-11 17:34:06 +08:00
|
|
|
{/* 图片上传 */}
|
2018-12-06 17:24:34 +08:00
|
|
|
<View className='img-box'>
|
|
|
|
<View className='title-box'>
|
2018-12-10 17:38:17 +08:00
|
|
|
<Text className='require'>*</Text>
|
2018-12-06 17:24:34 +08:00
|
|
|
<Text className='title'>上传图片:</Text>
|
|
|
|
</View>
|
|
|
|
<View className='img-container'>
|
|
|
|
<AtImagePicker
|
2018-12-18 17:37:23 +08:00
|
|
|
multiple
|
|
|
|
files={this.state.files}
|
|
|
|
onChange={this.onChangeImg.bind(this)}
|
|
|
|
onFail={this.onFail.bind(this)}
|
|
|
|
onImageClick={this.onImageClick.bind(this)}
|
2018-12-06 17:24:34 +08:00
|
|
|
/>
|
|
|
|
</View>
|
|
|
|
</View>
|
|
|
|
<View className='shoptype-box'>
|
2018-12-18 17:37:23 +08:00
|
|
|
{/* 店铺分类 */}
|
2018-12-06 17:24:34 +08:00
|
|
|
<View className='title-box'>
|
2018-12-10 17:38:17 +08:00
|
|
|
<Text className='require'>*</Text>
|
|
|
|
<Text className='title'>店铺分类:</Text>
|
2018-12-06 17:24:34 +08:00
|
|
|
</View>
|
|
|
|
<View className='shoptype-container'>
|
|
|
|
<View className='title-box'>
|
|
|
|
<Text className='title'>国家:</Text>
|
|
|
|
</View>
|
|
|
|
<View className='radio-box'>
|
|
|
|
<RadioGroup>
|
|
|
|
{this.state.list.map((item, i) => {
|
|
|
|
return (
|
|
|
|
<Label className='radio-list__label' for={i} key={i}>
|
|
|
|
<Radio color='#FF9500' className='radio-list__radio' value={item.value} checked={item.checked}>{item.text}</Radio>
|
|
|
|
</Label>
|
|
|
|
)
|
|
|
|
})}
|
|
|
|
</RadioGroup>
|
|
|
|
</View>
|
|
|
|
<View className='title-box'>
|
|
|
|
<Text className='title'>国家:</Text>
|
|
|
|
</View>
|
|
|
|
<View className='radio-box'>
|
|
|
|
<RadioGroup>
|
|
|
|
{this.state.list.map((item, i) => {
|
|
|
|
return (
|
|
|
|
<Label className='radio-list__label' for={i} key={i}>
|
|
|
|
<Radio color='#FF9500' className='radio-list__radio' value={item.value} checked={item.checked}>{item.text}</Radio>
|
|
|
|
</Label>
|
|
|
|
)
|
|
|
|
})}
|
|
|
|
</RadioGroup>
|
|
|
|
</View>
|
|
|
|
<View className='title-box'>
|
|
|
|
<Text className='title'>国家:</Text>
|
|
|
|
</View>
|
|
|
|
<View className='radio-box'>
|
|
|
|
<RadioGroup>
|
|
|
|
{this.state.list.map((item, i) => {
|
|
|
|
return (
|
|
|
|
<Label className='radio-list__label' for={i} key={i}>
|
|
|
|
<Radio color='#FF9500' className='radio-list__radio' value={item.value} checked={item.checked}>{item.text}</Radio>
|
|
|
|
</Label>
|
|
|
|
)
|
|
|
|
})}
|
|
|
|
</RadioGroup>
|
|
|
|
</View>
|
|
|
|
|
|
|
|
</View>
|
2018-12-18 17:37:23 +08:00
|
|
|
|
2018-12-06 17:24:34 +08:00
|
|
|
</View>
|
2018-12-18 17:37:23 +08:00
|
|
|
|
2018-12-06 17:24:34 +08:00
|
|
|
<View className='description-box'>
|
|
|
|
<View className='title-box'>
|
2018-12-11 17:34:06 +08:00
|
|
|
<Text className='require'></Text>
|
2018-12-06 17:24:34 +08:00
|
|
|
<Text className='title'>商品简介:</Text>
|
|
|
|
</View>
|
2018-12-18 17:37:23 +08:00
|
|
|
|
2018-12-06 17:24:34 +08:00
|
|
|
<AtTextarea
|
2018-12-18 17:37:23 +08:00
|
|
|
value={this.state.productDescript}
|
|
|
|
onChange={this.productDescriptChange.bind(this)}
|
|
|
|
maxlength='200'
|
|
|
|
placeholder='你的产品简介'
|
2018-12-06 17:24:34 +08:00
|
|
|
/>
|
|
|
|
|
|
|
|
</View>
|
|
|
|
</View>
|
|
|
|
<View className='button-box'>
|
|
|
|
<View className='button'>
|
|
|
|
<AtButton type='primary' size='small'>发布</AtButton>
|
|
|
|
</View>
|
|
|
|
<View className='button'>
|
2018-12-18 17:37:23 +08:00
|
|
|
<AtButton type='primary' className='button-a' size='small'>发布并新增</AtButton>
|
2018-12-06 17:24:34 +08:00
|
|
|
</View>
|
|
|
|
<View className='button'>
|
2018-12-18 17:37:23 +08:00
|
|
|
<AtButton type='primary' className='button-a' size='small'>商品列表</AtButton>
|
2018-12-06 17:24:34 +08:00
|
|
|
</View>
|
2018-12-18 17:37:23 +08:00
|
|
|
|
|
|
|
|
2018-12-06 17:24:34 +08:00
|
|
|
|
|
|
|
</View>
|
|
|
|
|
2018-12-07 17:17:46 +08:00
|
|
|
<copyrightComponent></copyrightComponent>
|
|
|
|
|
2018-12-06 17:24:34 +08:00
|
|
|
</View>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default GoodsPublish
|