抢单api 接口

This commit is contained in:
郑茂强 2018-12-21 11:59:24 +08:00
parent 02d26b6694
commit fc5ed758ea
10 changed files with 968 additions and 41 deletions

View File

@ -29,15 +29,18 @@
border-bottom:1px solid #F2F2F2;
display: flex;
.title{
width: 55%;
flex:2;
color: #333;
font-weight: bold;
font-size: 30px;
margin:20px;
text-align: left;
// margin:20px;
}
.consult-voucher-button{
width: 45%;
flex:1;
//margin-top: 20px ;
margin-left: 200px;
display: flex;

View File

@ -42,6 +42,7 @@ class SearchBarComponent extends Component {
onChange={this.onChange.bind(this)}
onActionClick={this.onActionClick.bind(this)}
/>
</View>
</View>

View File

@ -0,0 +1,169 @@
import Taro, { Component } from '@tarojs/taro'
import { View } from '@tarojs/components'
import { AtTabBar, Picker } from 'taro-ui'
import './test3.scss'
class Test3 extends Component {
config = {
navigationBarTitleText: 'test3'
}
constructor() {
super(...arguments);
this.state = {
multiArray: [['无脊柱动物', '脊柱动物'], ['扁性动物', '线形动物', '环节动物', '软体动物', '节肢动物'], ['猪肉绦虫', '吸血虫']],
objectMultiArray: [
[
{
id: 0,
name: '无脊柱动物'
},
{
id: 1,
name: '脊柱动物'
}
], [
{
id: 0,
name: '扁性动物'
},
{
id: 1,
name: '线形动物'
},
{
id: 2,
name: '环节动物'
},
{
id: 3,
name: '软体动物'
},
{
id: 3,
name: '节肢动物'
}
], [
{
id: 0,
name: '猪肉绦虫'
},
{
id: 1,
name: '吸血虫'
}
]
],
multiIndex: [0, 0, 0],
}
}
componentWillReceiveProps(nextProps) {
//console.log(this.props, nextProps)
}
componentWillUnmount() { }
componentDidShow() { }
componentDidHide() { }
bindMultiPickerChange(e) {
console.log('picker发送选择改变携带值为', e.detail.value)
this.setState({
multiIndex: e.detail.value
})
}
bindMultiPickerCol(e) {
console.log('修改的列为', e.detail.column, ',值为', e.detail.value);
var data = {
multiArray: this.state.multiArray,
multiIndex: this.state.multiIndex
};
data.multiIndex[e.detail.column] = e.detail.value;
switch (e.detail.column) {
case 0:
switch (data.multiIndex[0]) {
case 0:
data.multiArray[1] = ['扁性动物', '线形动物', '环节动物', '软体动物', '节肢动物'];
data.multiArray[2] = ['猪肉绦虫', '吸血虫'];
break;
case 1:
data.multiArray[1] = ['鱼', '两栖动物', '爬行动物'];
data.multiArray[2] = ['鲫鱼', '带鱼'];
break;
}
data.multiIndex[1] = 0;
data.multiIndex[2] = 0;
break;
case 1:
switch (data.multiIndex[0]) {
case 0:
switch (data.multiIndex[1]) {
case 0:
data.multiArray[2] = ['猪肉绦虫', '吸血虫'];
break;
case 1:
data.multiArray[2] = ['蛔虫'];
break;
case 2:
data.multiArray[2] = ['蚂蚁', '蚂蟥'];
break;
case 3:
data.multiArray[2] = ['河蚌', '蜗牛', '蛞蝓'];
break;
case 4:
data.multiArray[2] = ['昆虫', '甲壳动物', '蛛形动物', '多足动物'];
break;
}
break;
case 1:
switch (data.multiIndex[1]) {
case 0:
data.multiArray[2] = ['鲫鱼', '带鱼'];
break;
case 1:
data.multiArray[2] = ['青蛙', '娃娃鱼'];
break;
case 2:
data.multiArray[2] = ['蜥蜴', '龟', '壁虎'];
break;
}
break;
}
data.multiIndex[2] = 0;
console.log(data.multiIndex);
break;
}
console.log(data)
this.setState({ multiIndex: data.multiIndex })
}
render() {
return (
<View >
hello
<View class='section'>
<View class='section__title'>多列选择器</View>
<Picker mode='multiSelector' onChange={this.bindMultiPickerChange.bind(this)} onColumnchange={this.bindMultiPickerCol.bind(this)} value={this.state.multiIndex} range={this.state.multiArray}>
<View class='picker'>
当前选择{this.state.multiArray[0][this.state.multiIndex[0]]}{this.state.multiArray[1][this.state.multiIndex[1]]}{this.state.multiArray[2][this.state.multiIndex[2]]}
</View>
</Picker>
</View>
</View>
)
}
}
export default Test3

View File

View File

@ -1,6 +1,6 @@
import Taro, { Component } from '@tarojs/taro'
import { View, Text, Image } from '@tarojs/components'
import { AtInput, AtButton, Picker, AtIcon, AtLoadMore } from 'taro-ui'
import { AtInput, AtButton, Picker, AtIcon, AtLoadMore, AtModal, AtToast } from 'taro-ui'
import copyrightComponent from '../../component/copyrightComponent/copyrightComponent'
import URL from '../../serviceAPI.config'
@ -25,6 +25,11 @@ class AllDemanding extends Component {
industryCateSelected: '全部', // 当前行业分类状态
startDateSel: '2018-04-22',
endDateSel: '2018-04-22',
isOpenedGrabModal: false,
grabOrderId: '',//抢到订单的id
isGrabOrderSuccess: false,// 是否显示轻提示
grabOrderSuccess: '无法显示绑定后的字段',// 抢单成功返回字段
}
}
GetAllDemanding({ curr_page = 1, page_count = 20 }) {
@ -86,7 +91,48 @@ class AllDemanding extends Component {
endDateSel: e.detail.value
})
}
// 抢单接口
GrabDemand({ demandId = 218 }) {
Taro.request({
url: URL.GrabDemand,
method: 'POST',
dataType: 'json',
data: {
demandId: demandId
},
header: {
'content-type': 'application/x-www-form-urlencoded',
'Cookie': 'PFWSSS=' + Taro.getStorageSync('session_id'),
'X-Requested-With': 'XMLHttpRequest'
}
})
.then(res => {
let textTip = res.data.err_msg
this.setState({ grabOrderSuccess: textTip, isGrabOrderSuccess: true }, () => {
setTimeout(() => {
this.setState({ isGrabOrderSuccess: false })
}, 1000)
})
console.log('抢单请求:', res)
})
}
grabOrder(Id) {
this.setState({ isOpenedGrabModal: true, grabOrderId: Id })
}
handleGrabModalClose() {
this.setState({ isOpenedGrabModal: false })
}
handleGrabModalCancel() {
this.setState({ isOpenedGrabModal: false })
}
handleGrabConfirm() {
this.setState({ isOpenedGrabModal: false })
this.GrabDemand({ demandId: this.state.grabOrderId })
}
componentWillReceiveProps(nextProps) {
console.log(this.props, nextProps)
@ -104,8 +150,24 @@ class AllDemanding extends Component {
componentDidHide() { }
render() {
// 提示模态弹窗element
const modalMessageGrab = <AtModal className='modal'
isOpened={this.state.isOpenedGrabModal}
title='提示'
cancelText='取消'
confirmText='确认'
onClose={this.handleGrabModalClose}
onCancel={this.handleGrabModalCancel}
onConfirm={this.handleGrabConfirm.bind(this)}
content='确认抢单?\n'
/>
// 抢单返回轻提示
const grabOrderSuccess = <AtToast
isOpened={this.state.isGrabOrderSuccess}
text={this.state.grabOrderSuccess} // 轻提示字段显示不出来 to be continue
duration={1000}
></AtToast>
const allDemandingElementArray = this.state.supplys ? this.state.supplys.map((item, index) => {
return <View className='demanding-info' key={index}>
<View className='header'>
<AtIcon value='user' size='12' color='#2196F3'></AtIcon>
@ -124,9 +186,8 @@ class AllDemanding extends Component {
<View className='detail'>
<View className='title'>{item.sd_title}</View>
<View className='para'>{item.sd_desc}</View>
<View className='button'>
<AtButton type='primary' size='small'>
抢单</AtButton>
<View className='button' onClick={this.grabOrder.bind(this, item.sd_id)}>
<AtButton type='primary' size='small'> {item.state_name === '在用' ? '抢单' : '已抢单'}</AtButton>
</View>
</View>
</View>
@ -139,6 +200,10 @@ class AllDemanding extends Component {
}) : null
return (
<View className='allDemanding'>
{/* 模态框 */}
{modalMessageGrab}
{/* 轻提示 */}
{grabOrderSuccess}
<View className='page-section'>
{/* 供求状态选择 */}
<View>
@ -155,12 +220,12 @@ class AllDemanding extends Component {
<View className='input-box'>
<Text className='require'>*</Text>
<AtInput
name='value'
title='需求标题:'
type='text'
placeholder='需求标题'
value={this.state.value}
onChange={this.handleChange.bind(this)}
name='value'
title='需求标题:'
type='text'
placeholder='需求标题'
value={this.state.value}
onChange={this.handleChange.bind(this)}
/>
</View>
{/* 开始和结束日期选择 */}
@ -206,10 +271,10 @@ class AllDemanding extends Component {
{allDemandingElementArray}
</View>
<AtLoadMore
onClick={this.handleLoadMore.bind(this)}
status={this.state.isMore}
loadingText='加载中'
noMoreText='没有更多了'
onClick={this.handleLoadMore.bind(this)}
status={this.state.isMore}
loadingText='加载中'
noMoreText='没有更多了'
/>
<copyrightComponent></copyrightComponent>
</View>

View File

@ -104,6 +104,19 @@
padding-right: 20px;
.title{
font-weight: bold;
text-overflow:ellipsis;
height:50px;
white-space:nowrap;
width:400px;
overflow:hidden;
}
.para{
text-overflow:ellipsis;
//height:300px;
white-space:nowrap;
width:400px;
overflow:hidden;
}
.button{
position: absolute;

View File

@ -221,7 +221,6 @@ class GoodsPublish extends Component {
if (middleItem.children.length) {
for (let innerItem of middleItem.children) {
thirdColumn.push({ id: innerItem.class_id, name: innerItem.class_name })
}
}
}

View File

@ -1,11 +1,10 @@
import Taro, { Component } from '@tarojs/taro'
import { View, Button, Text, Swiper, SwiperItem, Image, } from '@tarojs/components'
import { AtModal, AtButton } from 'taro-ui'
import { AtModal, AtButton, AtToast } from 'taro-ui'
import filteredShopComponent from '../../component/filteredShopComponent/filteredShopComponent'
import bottomNav from '../../component/bottomNav/bottomNav'
import URL from '../../serviceAPI.config'
import './home.scss'
class Home extends Component {
config = {
@ -22,6 +21,10 @@ class Home extends Component {
demanding: [],// 业主需求
otherData: [], // 底部导航栏
isOpen: false, // 抢单消息提示
grabOrderId: '',//抢到订单的id
isGrabOrderSuccess: false,// 是否显示轻提示
grabOrderSuccess: '无法显示绑定后的字段',// 抢单成功返回字段
}
}
@ -78,7 +81,7 @@ class Home extends Component {
success(res) {
if (res.code) {
// 发起网络请求
console.log('手机端微信code',res.code)
// console.log('手机端微信code',res.code)
Taro.request({
url: URL.Login,
method: 'POST',
@ -91,12 +94,12 @@ class Home extends Component {
}
})
.then(response => {
console.log('登入', response)
console.log('微信登入成功', response)
//储存后台返回的session_id 到local Storage
Taro.setStorageSync('session_id', response.data.session_id)
Taro.setStorageSync('shopInfo', response.data.shop_info)
Taro.setStorageSync('userInfo', response.data.user_info)
}
)
}
@ -139,11 +142,21 @@ class Home extends Component {
},
header: {
'content-type': 'application/x-www-form-urlencoded',
'Cookie': 'PFWSSS=' + Taro.getStorageSync('session_id'),
'X-Requested-With': 'XMLHttpRequest'
}
})
.then(res => {
this.setState({ grabOrderSuccess: res.data.err_msg,isGrabOrderSuccess: true }, () => {
setTimeout(() => {
console.log(this.state.grabOrderSuccess)
this.setState({ isGrabOrderSuccess: false })
}, 1000)
})
console.log('抢单请求:', res)
})
}
@ -162,9 +175,9 @@ class Home extends Component {
url: '/pages/allDemanding/allDemanding'
})
}
grabOrder() {
this.setState({ isOpen: true })
grabOrderId(Id) {
this.setState({ isOpen: true, grabOrderId: Id })
}
handleGrabModalClose() {
this.setState({ isOpen: false })
@ -175,7 +188,7 @@ class Home extends Component {
handleGrabConfirm() {
this.setState({ isOpen: false })
// 确认抢单之后
this.GrabDemand({})
this.GrabDemand({ demandId: this.state.grabOrderId })
}
componentDidMount() {
@ -197,7 +210,7 @@ class Home extends Component {
componentDidHide() { }
// 微信用户信息
// 微信用户信息
onGotUserInfo(e) {
console.log(e.detail.errMsg)
console.log(e.detail.userInfo)
@ -208,8 +221,8 @@ class Home extends Component {
render() {
// 提示弹窗element
const modalMessageGrab= <AtModal className='modal'
// 提示模态弹窗element
const modalMessageGrab = <AtModal className='modal'
isOpened={this.state.isOpen}
title='提示'
cancelText='取消'
@ -219,11 +232,17 @@ class Home extends Component {
onConfirm={this.handleGrabConfirm.bind(this)}
content='确认抢单?\n'
/>
// 抢单返回轻提示
const grabOrderSuccess = <AtToast
isOpened={this.state.isGrabOrderSuccess}
text={this.state.grabOrderSuccess} // 轻提示字段显示不出来 to be continue
duration={1000}
></AtToast>
const demandingElemensArray = this.state.demanding.length ? this.state.demanding.map((item, index) => {
return < SwiperItem key={index} >
return <SwiperItem key={index} >
<View className='demanding-item'>
<View className='item-tag'>
<Text className='item-tag-text'> {item.class_name}</Text>
@ -237,8 +256,8 @@ class Home extends Component {
<View className='item-name'>
业主{item.user_name}
</View>
<View className='item-button-box' onClick={this.grabOrder.bind(this)}>
<Button className='item-button' >{item.state_name}</Button>
<View className='item-button-box' onClick={this.grabOrderId.bind(this, item.sd_id)}>
<Button className='item-button' > {item.state_name==='在用'?'抢单':'已抢单'}</Button>
</View>
</View>
</SwiperItem >
@ -276,7 +295,9 @@ class Home extends Component {
return (
<View className='home'>
{/* 获取微信用户的信息 */}
{/* 抢单成功预付轻提示 */}
{grabOrderSuccess}
{/* 获取微信用户的信息 */}
{/* <AtButton open-type='getUserInfo' lang='zh_CN' type='primary' size='normal' onGetUserInfo={this.onGotUserInfo.bind(this)}>获取微信用户的信息</AtButton> */}
{modalMessageGrab}
@ -291,7 +312,8 @@ class Home extends Component {
hotizontal
circular
indicatorDots
autoplay>
autoplay
>
{adsImgElementsArray}
</Swiper>
@ -329,7 +351,8 @@ class Home extends Component {
horizontal
circular
indicatorDots
autoplay>
autoplay
>
<SwiperItem>
<Image className='banner-img' src={URL.Base + 'Public/images/xgt.png'} />
</SwiperItem>
@ -387,7 +410,7 @@ class Home extends Component {
{shopCollectionElementsArray}
{this.state.shopsDetails.length !== 0 ? <View className='title'>
沒有更多了...
</View> : < View className='title' >
</View> :<View className='title' >
没有找到...
</View >}
</View>

View File

@ -27,11 +27,9 @@ class Index extends Component {
//http://ihome6.com/Shop-supplyShops
componentDidMount(){
Taro.navigateTo({
// url: '/pages/home/home'
url: '/pages/goodsPublish/goodsPublish'
// url: '/pages/allDemanding/allDemanding'
url: '/pages/home/home'
// url:'/pages/supplyDemandPublish/supplyDemandPublish'
})
}

656
src/pages/test.js Normal file
View File

@ -0,0 +1,656 @@
import Taro, { Component } from '@tarojs/taro'
import { View, Text, Radio, RadioGroup, Label } from '@tarojs/components'
import { AtInput, AtImagePicker, AtTextarea, AtButton, Picker, AtToast } from 'taro-ui'
import SearchBarComponent from '../../component/searchBarComponent/searchBarComponent'
import copyrightComponent from '../../component/copyrightComponent/copyrightComponent'
import Test3 from '../../component/Test3/Test3'
import URL from '../../serviceAPI.config'
import './goodsPublish.scss'
import { throws } from 'assert';
class GoodsPublish extends Component {
config = {
navigationBarTitleText: '商品发布'
}
constructor() {
super(...arguments)
this.state = {
objectMultiArray: [
[
{
id: 0,
name: '无脊柱动物'
},
{
id: 1,
name: '脊柱动物'
}
],
[
{
id: 0,
name: '扁性动物'
},
{
id: 1,
name: '线形动物'
},
{
id: 2,
name: '环节动物'
},
{
id: 3,
name: '软体动物'
},
{
id: 3,
name: '节肢动物'
}
],
[
{
id: 0,
name: '猪肉绦虫'
},
{
id: 1,
name: '吸血虫'
}
]
],
multiIndex: [0, 0, 0],
shopCategoryPicker: [], // 店铺分类选项
shopCategoryCheckedPicker: {name:'选择店铺类型'},
productName: '',
productPrice: '',
productUnit: '',
productDescript: '',
pickerImageUrl: [], // 上传的图片
ImagesInfo: [],// 后台传回来的图片信息
isUploadImageSuccess: false,
uploadImageTextTip: '',
isUploadProductSuccess: false,
uploadProductTextTip: '',
}
}
//商品目录请求api GetShopCategoryList
getProductCateList() {
Taro.request({
url: URL.GetProductCategoryList,
method: 'POST',
dataType: 'json',
header: {
'content-type': 'application/x-www-form-urlencoded',
'Cookie': 'PFWSSS=' + Taro.getStorageSync('session_id'),
'X-Requested-With': 'XMLHttpRequest'
}
})
.then(res => {
if (res.data.err_msg === 'success') {
this.setState({ productCategoryList: res.data.data })
console.log('商品分类目录', res)
this.sortShopCateToState(res.data.data)
}
}
)
.catch(error => {
console.log('商品分类请求错误', error)
})
}
// 店铺分类目录请求 api
getShopCateList() {
Taro.request({
url: URL.GetShopCategoryList,
method: 'POST',
dataType: 'json',
data: {
id: Taro.getStorageSync('shopInfo').shop_id
},
header: {
'content-type': 'application/x-www-form-urlencoded',
'Cookie': 'PFWSSS=' + Taro.getStorageSync('session_id'),
'X-Requested-With': 'XMLHttpRequest'
}
})
.then(res => {
if (res.data.err_msg === 'success') {
this.setState({ shopCategoryList: res.data.data })
const shopCategoryInfo = res.data.data
const shopCategory = []
// 处理后台返回的店铺分类信息
for (let item in shopCategoryInfo) {
const children = shopCategoryInfo[item].c
for (let child in children) {
shopCategory.push({ id: children[child].id, name: children[child].n })
}
}
this.setState({ shopCategoryPicker: shopCategory })
console.log('店铺分类目录', res)
}
}
)
.catch(error => {
console.log('店铺分类请求错误', error)
})
}
// 发布商品api
//{"goods_name":"hellol","goods_price":"1.00","goods_unit":"1","goods_profiles":"111","class_id":"2","shop_class_id":"1928"}
uploadGoods({ goods_name = "test2", goods_price = "1.00", goods_unit = "1", goods_profiles = "test2", class_id = "10103", shop_class_id = "1930" }) {
//定义上传商品的多图片的参数
const uploadProductGoodFileParams = []
if (this.state.ImagesInfo.length) {
for (let i = 0; i < this.state.ImagesInfo.length; i++) {
if (i === 0) {
uploadProductGoodFileParams.push({
file_id:this.state.ImagesInfo[i].file_id,
file_type: 1,
if_cover: 1,
file_sort: 1
})
} else {
uploadProductGoodFileParams.push({
file_id: this.state.ImagesInfo[i].file_id,
file_type: 1,
if_cover: 0,
file_sort: 1
})
}
}
} else {
alert('图片为空')
}
Taro.request({
url: URL.UploadProduct,
method: 'POST',
dataType: 'json',
data: {
deployType: 1,
action: 1,
goods: JSON.stringify({
goods_name: goods_name,
goods_price: goods_price,
goods_unit: goods_unit,
goods_profiles: goods_profiles,
class_id: class_id,
shop_class_id: shop_class_id
}),
goodsFiles: JSON.stringify(uploadProductGoodFileParams)
},
header: {
'content-type': 'application/x-www-form-urlencoded',
'Cookie': 'PFWSSS=' + Taro.getStorageSync('session_id'),
'X-Requested-With': 'XMLHttpRequest'
}
})
.then(res => {
let tipText=res.data.err_msg==='success'?'商品发布成功':res.data.err_msg
this.setState({ uploadProductTextTip: tipText, isUploadProductSuccess: true },()=>{
setTimeout(()=>{
this.setState({isUploadProductSuccess: false})
Taro.navigateTo({
url: '/pages/goodsPublish/goodsPublish'
})
},1000)
})
console.log('上传商品', res) // 提示非法请求 ----- to be continue
}
)
.catch(error => {
this.setState({ uploadProductTextTip: '发布失败', isUploadProductSuccess: true })
})
}
// 整理后台传出来的店铺分类目录
sortShopCateToState(shopData) {
const firstColumn = []
const secondColumn = []
const thirdColumn = []
for (let outterItem of shopData) {
firstColumn.push({ id: outterItem.class_id, name: outterItem.class_name })
if (outterItem.children.length) {
for (let middleItem of outterItem.children) {
secondColumn.push({ id: middleItem.class_id, name: middleItem.class_name })
if (middleItem.children.length) {
for (let innerItem of middleItem.children) {
thirdColumn.push({ id: innerItem.class_id, name: innerItem.class_name })
}
}
}
}
}
// ------- 把新指传给objectMultiArray之后就不可以用了 to be continue
console.log('old',this.state.objectMultiArray)
this.setState({objectMultiArray:[firstColumn,secondColumn,thirdColumn]},()=>{
console.log('new', this.state.objectMultiArray)
})
}
// 改变商品分类状态
onChangeProductType(e) {
this.setState({
selectorChecked: this.state.selector[e.detail.value]
})
}
productNameChange(event) {
this.setState({
productName: event
})
}
productPriceChange(event) {
this.setState({
productPrice: event
})
}
productUnitChange(event) {
this.setState({
productUnit: event
})
}
productDescriptChange(event) {
this.setState({
productDescript: event.target.value
})
}
// 上传图片
onChangeImg(files, operationType, index) {
const that = this
if (operationType === 'add') {
Taro.uploadFile({
url: URL.UploadPorductImage, // 仅为示例,非真实的接口地址
filePath: files[files.length - 1].url,
name: 'file',
formData: {
user: 'test'
},
header: {
'content-type': 'multipart/form-data',
'Cookie': 'PFWSSS=' + Taro.getStorageSync('session_id'),
'X-Requested-With': 'XMLHttpRequest'
},
success(response) {
const data = JSON.parse(response.data)
const imagePath = URL.Base + data.file_path
const newPickerImageUrl = that.state.pickerImageUrl.concat({ url: imagePath })
const newImageInfo = that.state.ImagesInfo.concat(data)
that.setState({ pickerImageUrl: newPickerImageUrl, isUploadImageSuccess: true, uploadImageTextTip: '图片上传成功', ImagesInfo: newImageInfo }, () => {
setTimeout(()=>{that.setState({isUploadImageSuccess: false})},1000)
})
}
})
}
if (operationType === 'remove') {
this.state.pickerImageUrl.splice(index, 1);
this.setState({ files: this.state.pickerImageUrl });
that.setState({ isUploadImageSuccess: true, uploadImageTextTip: '删除成功' },()=>{
setTimeout(()=>{that.setState({isUploadImageSuccess: false})},1000)
})
}
}
// 图片上传失败
onFail(mes) {
console.log(mes)
}
// 删除图片
onImageClick(index) {
}
onClickUploadGoods() {
if (this.state.productName && this.state.productPrice && this.state.productUnit && this.state.ImagesInfo.length) {
this.uploadGoods({
goods_name: this.state.productName,
goods_price: this.state.productPrice,
goods_unit: this.state.productUnit,
goods_profiles: this.state.productDescript,
class_id: "10103",
shop_class_id: this.state.shopCategoryCheckedPicker,
})
} else {
this.setState({ uploadProductTextTip: '请填写完表格', isUploadProductSuccess: true },()=>{
setTimeout(()=>{this.setState({isUploadProductSuccess: false})},1000)
})
}
}
shopCategoryChanged(e) {
this.setState({
shopCategoryCheckedPicker: this.state.shopCategoryPicker[e.detail.value]
}, () => {
console.log(this.state.shopCategoryCheckedPicker)
})
}
componentDidMount() {
this.getProductCateList()
this.getShopCateList()
}
componentWillReceiveProps(nextProps) {
// console.log(this.props, nextProps)
}
componentWillUnmount() { }
componentDidShow() { }
componentDidHide() { }
//--- 三级联动--------------
bindMultiPickerChange(e) {
console.log('picker发送选择改变携带值为', e.detail.value)
this.setState({
multiIndex: e.detail.value
})
}
bindMultiPickerCol(e) {
console.log('修改的列为', e.detail.column, ',值为', e.detail.value)
const data = {
multiArray: this.state.objectMultiArray,
multiIndex: this.state.multiIndex
}
data.multiIndex[e.detail.column] = e.detail.value
switch (e.detail.column) {
case 0:
switch (data.multiIndex[0]) {
case 0:
data.multiArray[1] = [
{
id: 0,
name: '01'
},
{
id: 1,
name: '10a'
}
]
data.multiArray[2] = [{
id: 0,
name: '02'
},
{
id: 1,
name: '02a'
}]
break
case 1:
data.multiArray[1] = [{
id: 0,
name: '11'
},
{
id: 1,
name: '11a'
}]
data.multiArray[2] = [{
id: 0,
name: '12'
},
{
id: 1,
name: '12a'
}]
break
}
data.multiIndex[1] = 0
data.multiIndex[2] = 0
break
case 1:
switch (data.multiIndex[0]) {
case 0:
switch (data.multiIndex[1]) {
case 0:
data.multiArray[2] = [{
id: 0,
name: '无脊柱动物'
},
{
id: 1,
name: '脊柱动物'
}]
break
case 1:
data.multiArray[2] = [
{
id: 1,
name: '脊柱动物'
}]
break
case 2:
data.multiArray[2] = [{
id: 0,
name: '无脊柱动物'
},
{
id: 1,
name: '脊柱动物'
}]
break
case 3:
data.multiArray[2] = [{
id: 0,
name: '无脊柱动物'
},
{
id: 1,
name: '脊柱动物'
}, {
id: 0,
name: '无脊柱动物'
},
{
id: 1,
name: '脊柱动物'
}]
break
case 4:
data.multiArray[2] = [{
id: 0,
name: '无脊柱动物'
},
{
id: 1,
name: '脊柱动物'
}]
break
}
break
case 1:
switch (data.multiIndex[1]) {
case 0:
data.multiArray[2] = [{
id: 0,
name: '蛇'
},
{
id: 1,
name: '青蛙'
}]
break
case 1:
data.multiArray[2] = [{
id: 0,
name: '蛇'
},
{
id: 1,
name: '青蛙'
}, {
id: 0,
name: '蛇'
},
{
id: 1,
name: '青蛙'
}]
break
case 2:
data.multiArray[2] = [{
id: 0,
name: '蛇'
},
{
id: 1,
name: '青蛙'
}]
break
}
break
}
data.multiIndex[2] = 0
break
}
console.log(data.multiIndex)
this.setState({ multiIndex: data.multiIndex })
}
render() {
const imageUploadSuccess = <AtToast
isOpened={this.state.isUploadImageSuccess}
text={this.state.uploadImageTextTip}
duration={1000}
></AtToast>
const productUploadSuccess = <AtToast
isOpened={this.state.isUploadProductSuccess}
text={this.state.uploadProductTextTip}
duration={1000}
></AtToast>
return (
<View className='goods-publish'>
<Test3></Test3>
{imageUploadSuccess}
{productUploadSuccess}
<SearchBarComponent></SearchBarComponent>
<View className='goods-category'>
<View className='page-section'>
<View>
<Picker
range={this.state.objectMultiArray}
onChange={this.bindMultiPickerChange.bind(this)}
rangeKey='name'
mode='multiSelector'
onColumnchange={this.bindMultiPickerCol.bind(this)}
value={this.state.multiIndex}
>
<View className='picker'>
<View className='title-box'>
<Text className='title'><Text className='require'>*</Text>:</Text> <Text className='selected'>
{/* {this.state.multiArray[0][this.state.multiIndex[0]].name}{this.state.multiArray[1][this.state.multiIndex[1]].name}{this.state.multiArray[2][this.state.multiIndex[2]].name} */}
</Text>
</View>
</View>
</Picker>
</View>
</View>
<View className='input-box'>
<Text className='require'>*</Text>
<AtInput
name='value'
title='商品名称:'
type='text'
value={this.state.productName}
onChange={this.productNameChange.bind(this)}
/>
</View>
<View className='input-box'>
<Text className='require'>*</Text>
<AtInput
name='value'
title='商品价格:'
type='number'
placeholder='¥'
value={this.state.productPrice}
onChange={this.productPriceChange.bind(this)}
/>
</View>
<View className='input-box'>
<Text className='require'>*</Text>
<AtInput
name='value'
title='商品单位:'
type='text'
value={this.state.productUnit}
onChange={this.productUnitChange.bind(this)}
/>
</View>
{/* 图片上传 */}
<View className='img-box'>
<View className='title-box'>
<Text className='require'>*</Text>
<Text className='title'>上传图片:</Text>
</View>
<View className='img-container'>
<AtImagePicker
multiple
files={this.state.pickerImageUrl}
onChange={this.onChangeImg.bind(this)}
onFail={this.onFail.bind(this)}
onImageClick={this.onImageClick.bind(this)}
/>
</View>
</View>
<View className='shoptype-box'>
{/* 店铺分类 */}
<View className='title-box page-section'>
<Picker mode='selector' rangeKey='name' range={this.state.shopCategoryPicker} onChange={this.shopCategoryChanged.bind(this)}>
<View className='picker'>
<Text className='require'>*</Text>
<Text className='title'> 店铺分类</Text>
<Text className='selected'>{this.state.shopCategoryCheckedPicker.name}</Text>
</View>
</Picker>
</View>
</View>
<View className='description-box'>
<View className='title-box'>
<Text className='require'></Text>
<Text className='title'>商品简介:</Text>
</View>
<AtTextarea
value={this.state.productDescript}
onChange={this.productDescriptChange.bind(this)}
maxlength='200'
placeholder='你的产品简介'
/>
</View>
</View>
<View className='button-box'>
<View className='button'>
<AtButton type='primary' size='small' >发布</AtButton>
</View>
<View className='button'>
<AtButton type='primary' className='button-a' size='small' onClick={this.onClickUploadGoods.bind(this)}>发布并新增</AtButton>
</View>
<View className='button'>
<AtButton type='primary' className='button-a' size='small'>商品列表</AtButton>
</View>
</View>
<copyrightComponent></copyrightComponent>
</View>
)
}
}
export default GoodsPublish