商品编辑 页面api 供求页面api

This commit is contained in:
郑茂强 2019-01-02 17:31:07 +08:00
parent 8930358a6d
commit e8931a05a3
16 changed files with 780 additions and 317 deletions

View File

@ -30,6 +30,7 @@ class App extends Component {
'pages/myGoodList/myGoodList',// 我的商品列表页面 'pages/myGoodList/myGoodList',// 我的商品列表页面
'pages/myDemandSupplyEdit/myDemandSupplyEdit',// 我的供求编辑页面 'pages/myDemandSupplyEdit/myDemandSupplyEdit',// 我的供求编辑页面
'pages/supplyDemandView/supplyDemandView',// 查看单个供求页面 'pages/supplyDemandView/supplyDemandView',// 查看单个供求页面
'pages/grabOrderPage/grabOrderPage',// 抢单页面
// 'pages/shopDescription/shopDescription', // 'pages/shopDescription/shopDescription',
], ],
window: { window: {

View File

@ -165,10 +165,12 @@ class GoodsPublish extends Component {
duration: 1000 duration: 1000
}) })
setTimeout(() => { setTimeout(() => {
Taro.navigateTo({
url: '/pages/goods/goods?id=5cf3Ptn5wKQdyPpwsSe2nDKnN4QDFdz8moPTf+QIOm788Q'// 虚拟地址 Taro.navigateTo({
}) url: '/pages/goods/goods?id='+res.data.goods_id
})
}, 1000); }, 1000);
console.log('上传商品', res) console.log('上传商品', res)
} }
) )
@ -290,7 +292,7 @@ class GoodsPublish extends Component {
goods_price: this.state.productPrice, goods_price: this.state.productPrice,
goods_unit: this.state.productUnit, goods_unit: this.state.productUnit,
goods_profiles: this.state.productDescript, goods_profiles: this.state.productDescript,
class_id: "10103",// to be continue class_id: "10103",// to be continue //商品分类的选项
shop_class_id: this.state.shopCategoryCheckedPicker.id, shop_class_id: this.state.shopCategoryCheckedPicker.id,
}) })
},1000)}) },1000)})

View File

@ -0,0 +1,75 @@
//grabOrderPage
import Taro, { Component } from '@tarojs/taro'
import { View, Text } from '@tarojs/components'
import { AtButton, AtIcon } from 'taro-ui'
import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent'
import './grabOrderPage.scss'
class GrabOrderPage extends Component {
config = {
navigationBarTitleText: '抢单页面'
}
componentDidMount() {
}
componentWillReceiveProps(nextProps) {
console.log(this.props, nextProps)
}
componentWillUnmount() { }
componentDidShow() { }
componentDidHide() { }
render() {
return (
<View className='grabOrderPage'>
<View className='type box'>
<Text className='title'>行业分类</Text>
<Text className='content'>{this.state.type}</Text>
</View>
<View className='sd-title box'>
<Text className='title'>业主需求标题</Text>
<Text className='content'>{this.state.title}</Text>
</View>
<View className='browsing-amount box'>
<Text className='title'>浏览量</Text>
<Text className='content'>{this.state.browsing}</Text>
</View>
<View className='contact-name box'>
<Text className='title'>联系人</Text>
<Text className='content'>{this.state.contactName}</Text>
</View>
<View className='phone-number box'>
<Text className='title'>联系电话</Text>
<Text className='content'>{this.state.contactNumber}</Text>
</View>
<View className='address box'>
<Text className='title'>联系地址</Text>
<Text className='content'>{this.state.address}</Text>
</View>
<View className='sd-content box'>
<Text className='title'>业主需求内容</Text>
<Text className='content'>{this.state.content}</Text>
</View>
<View className='button-box'>
<View className='button' onClick={this.goToSDPublishPage.bind(this)}>
<AtButton type='primary' size='small'>
<AtIcon value='close' size='12' color='white'></AtIcon>
抢单</AtButton>
</View>
</View>
<CopyrightComponent></CopyrightComponent>
</View>
)
}
}
export default GrabOrderPage

View File

@ -0,0 +1,31 @@
.grabOrderPage{
padding: 10px 20px;
font-size: 32rpx;
.box{
margin-top: 35px;
}
.title{
font-weight: bold
}
}
.button-box{
display: flex;
flex-wrap: nowrap;
flex-direction: row;
margin: 80px 0;
padding: 0 20px;
.button{
flex:1;
text-align: center;
// margin:2%;
// justify-content:center;
.at-button--primary{
background-color:#FF7142;
border:1PX solid #FF7142;
}
}}

View File

@ -24,8 +24,7 @@ class Home extends Component {
otherData: [], // 底部导航栏 otherData: [], // 底部导航栏
isOpen: false, // 抢单消息提示 isOpen: false, // 抢单消息提示
grabOrderId: '',//抢到订单的id grabOrderId: '',//抢到订单的id
isGrabOrderSuccess: false,// 是否显示轻提示
grabOrderSuccess: '',// 抢单成功返回字段
isMore: 'noMore',// 加载更多店铺 isMore: 'noMore',// 加载更多店铺
userName:'',//用户名字 userName:'',//用户名字
userPhone:'',// 用户电话 userPhone:'',// 用户电话
@ -170,11 +169,12 @@ class Home extends Component {
} }
}) })
.then(res => { .then(res => {
this.setState({ grabOrderSuccess: res.data.err_msg, isGrabOrderSuccess: true }, () => { Taro.showToast({
setTimeout(() => { title: res.data.err_msg,
this.setState({ isGrabOrderSuccess: false }) icon:'none',
}, 2000) duration:1500
}) })
console.log('抢单请求:', res) console.log('抢单请求:', res)
}) })
@ -225,6 +225,14 @@ class Home extends Component {
}, 1000); }, 1000);
} }
// 导航去抢单页面
goToGrabOrderPage(){
Taro.navigateTo({
url:'/pages/grabOrderPage/grabOrderPage'
})
}
componentDidMount() { componentDidMount() {
// 页面加载后 得到首页的基本信息和推荐店铺的信息 // 页面加载后 得到首页的基本信息和推荐店铺的信息
Taro.showLoading({ title: '加载中' }) Taro.showLoading({ title: '加载中' })
@ -269,18 +277,12 @@ class Home extends Component {
// 抢单返回轻提示
const grabOrderSuccessElement = <AtToast
isOpened={this.state.isGrabOrderSuccess}
text={this.state.grabOrderSuccess}
duration={2000}
></AtToast>
const demandingElemensArray = this.state.demanding.length ? this.state.demanding.map((item, index) => { 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='demanding-item' >
<View onClick={this.goToGrabOrderPage.bind(this)}>
<View className='item-tag'> <View className='item-tag'>
<Text className='item-tag-text'> {item.class_name}</Text> <Text className='item-tag-text'> {item.class_name}</Text>
</View> </View>
@ -293,6 +295,7 @@ class Home extends Component {
<View className='item-name'> <View className='item-name'>
业主{item.user_name} 业主{item.user_name}
</View> </View>
</View>
<View className='item-button-box' onClick={this.grabOrderId.bind(this, item.sd_id)}> <View className='item-button-box' onClick={this.grabOrderId.bind(this, item.sd_id)}>
<Button className='item-button' > {item.state_name === '在用' ? '抢单' : '已抢单'}</Button> <Button className='item-button' > {item.state_name === '在用' ? '抢单' : '已抢单'}</Button>
</View> </View>
@ -332,8 +335,7 @@ class Home extends Component {
return ( return (
<View className='home'> <View className='home'>
{/* 抢单成功预付轻提示 */}
{grabOrderSuccessElement}
{/* 获取微信用户的信息 */} {/* 获取微信用户的信息 */}
{/* <AtButton open-type='getUserInfo' lang='zh_CN' type='primary' size='normal' onGetUserInfo={this.onGotUserInfo.bind(this)}>获取微信用户的信息</AtButton> */} {/* <AtButton open-type='getUserInfo' lang='zh_CN' type='primary' size='normal' onGetUserInfo={this.onGotUserInfo.bind(this)}>获取微信用户的信息</AtButton> */}

View File

@ -32,8 +32,9 @@ class Index extends Component {
// url: '/pages/goodsPublish/goodsPublish' // url: '/pages/goodsPublish/goodsPublish'
//url: '/pages/goodsPublish/goodsPublish' //url: '/pages/goodsPublish/goodsPublish'
// url: '/pages/myDemandSupplyEdit/myDemandSupplyEdit' // url: '/pages/myDemandSupplyEdit/myDemandSupplyEdit'
url: '/pages/mySupplyDemand/mySupplyDemand' // url: '/pages/mySupplyDemand/mySupplyDemand'
// url:'/pages/supplyDemandPublish/supplyDemandPublish' // url:'/pages/grabOrderPage/grabOrderPage'
url:'/pages/home/home'
}) })
} }
componentWillReceiveProps (nextProps) { componentWillReceiveProps (nextProps) {

View File

@ -19,10 +19,10 @@ class MyDemandSupplyEdit extends Component {
constructor() { constructor() {
super(...arguments) super(...arguments)
this.state = { this.state = {
demandingSupplyCate: ['需求', '供应', '人才'], //供求类型选择 demandingSupplyCate: [{ name: '需求', id: '1' }, { name: '供求', id: '2' }, { name: '人才', id: '3' }], //供求类型选择,
demandingSupplyCateSelected: '需求',// 当前供求类型 demandingSupplyCateSelected: { name: '需求', id: '1' },// 当前供求类型
demandingSupplyState: ['上架', '下架'], // 状态选择 demandingSupplyState: [{ name: '上架', id: '1' }, { name: '下架', id: '0' }], // 状态选择
demandingSupplyStateSelected: '上架',// 当前状态 demandingSupplyStateSelected: { name: '上架', id: '1' },// 当前状态
title: '', title: '',
contactName: '', contactName: '',
contactNumber: '', contactNumber: '',
@ -38,10 +38,49 @@ class MyDemandSupplyEdit extends Component {
} }
} }
//获取商品信息api GetProductInfo
getSupplyDemandInfo() {
Taro.request({
url: URL.GetSupplyDemandInfo,
method: 'GET',
dataType: 'json',
data: {
sdID: this.$router.params.sdId,
},
header: {
'content-type': 'application/x-www-form-urlencoded',
'Cookie': 'PFWSSS=' + Taro.getStorageSync('session_id'),
'X-Requested-With': 'XMLHttpRequest'
}
})
.then(res => {
console.log('供求详情获取成功', res)
const selectedType = this.state.demandingSupplyCate.filter(item => item.id == res.data.sdInfo.sd_type)[0]
const selectedState = this.state.demandingSupplyState.filter(item => item.id == res.data.sdInfo.state)[0]
const imageFile = res.data.sdInfo.file_path.map(item => { return { url: URL.Base + item.file_path } })
this.setState({
demandingSupplyCateSelected: selectedType,
title: res.data.sdInfo.sd_title,
contactName: res.data.sdInfo.user_name,
contactNumber: res.data.sdInfo.user_phone,
contactAddress: res.data.sdInfo.user_address,
content: res.data.sdInfo.sd_desc,
demandingSupplyStateSelected: selectedState,
pickerImageUrl: imageFile,
ImagesInfo:res.data.sdInfo.file_path,
})
Taro.hideLoading()
}
)
.catch(error => {
console.log('供求详情获取失败', error)
})
}
// 上传供求api // 上传供求api
uploadSupplyDemand() { uploadSupplyDemand() {
if (this.state.demandingSupplyCateSelected && this.state.title && this.state.contactName && this.state.contactNumber && this.state.contactAddress && this.state.content && this.state.demandingSupplyStateSelected) { if (this.state.demandingSupplyCateSelected && this.state.title && this.state.contactName && this.state.contactNumber && this.state.content && this.state.demandingSupplyStateSelected) {
this.uploadDemSup({}) this.uploadDemSup({})
} else { } else {
this.setState({ uploadDemSupTextTip: '请填写完表格', isUploadDemSupSuccess: true }, () => { this.setState({ uploadDemSupTextTip: '请填写完表格', isUploadDemSupSuccess: true }, () => {
@ -69,8 +108,75 @@ class MyDemandSupplyEdit extends Component {
// ) // )
} }
// 这个需要写一个uploadDemSup 上传供求 的api // uploadDemSup 上传供求 的api
uploadDemSup({ sd_type = this.state.demandingSupplyCateSelected.id,
sd_title = this.state.title,
user_name = this.state.contactName,
user_phone = this.state.contactNumber,
user_address = this.state.contactAddress,
sd_desc = this.state.content,
state = this.state.demandingSupplyStateSelected.id }) {
const file_path = [];
this.state.ImagesInfo.forEach((item) => {
file_path.push({
file_name: item.file_name,
file_size: item.file_size,
file_path: item.file_path,
thumb_path: item.thumb_path
})
})
Taro.request({
url: URL.UploadSupplyDemand,
method: 'POST',
dataType: 'json',
data: {
action: 2,
sdInfo: JSON.stringify({
sd_id:this.$router.params.sdId,
sd_type: sd_type,
sd_title: sd_title,
user_name: user_name,
user_phone: user_phone,
user_address: user_address,
sd_desc: sd_desc,
state: state,
file_path: file_path
})
},
header: {
'content-type': 'application/x-www-form-urlencoded',
'Cookie': 'PFWSSS=' + Taro.getStorageSync('session_id'),
'X-Requested-With': 'XMLHttpRequest'
}
})
.then(res => {
console.log('上传供求', res)
if (res.data.err_msg === 'success') {
Taro.showToast({
title: '上传成功',
icon: 'success',
duration: 1500
}).then(()=>{
setTimeout(() => {
Taro.navigateTo({
url: '/pages/mySupplyDemand/mySupplyDemand'
})
}, 1500);
})
} else {
Taro.showToast({
title: res.data.err_msg,
icon: 'none',
duration: 1500
})
}
}
)
}
// 上传图片 // 上传图片
onChangeImg(files, operationType, index) { onChangeImg(files, operationType, index) {
@ -90,22 +196,30 @@ class MyDemandSupplyEdit extends Component {
const imagePath = URL.Base + data.file_path const imagePath = URL.Base + data.file_path
const newPickerImageUrl = that.state.pickerImageUrl.concat({ url: imagePath }) const newPickerImageUrl = that.state.pickerImageUrl.concat({ url: imagePath })
const newImageInfo = that.state.ImagesInfo.concat(data) const newImageInfo = that.state.ImagesInfo.concat(data)
that.setState({ pickerImageUrl: newPickerImageUrl, isUploadImageSuccess: true, uploadImageTextTip: '图片上传成功', ImagesInfo: newImageInfo }, () => { that.setState({
setTimeout(() => { pickerImageUrl: newPickerImageUrl,
that.setState({ isUploadImageSuccess: false }) ImagesInfo: newImageInfo
}, 2000)
}) })
Taro.showToast({
title: '上传成功',
icon: 'success',
duration: 1500
})
} }
}) })
} }
if (operationType === 'remove') { if (operationType === 'remove') {
this.state.pickerImageUrl.splice(index, 1); this.state.ImagesInfo.splice(index, 1) // 删除显示的图片
this.setState({ files: this.state.pickerImageUrl }); this.state.pickerImageUrl.splice(index, 1)// 删除图片param
that.setState({ isUploadImageSuccess: true, uploadImageTextTip: '删除成功' }, () => { that.setState({
setTimeout(() => { pockerImageUrl:this.state.pickerImageUrl,
that.setState({ isUploadImageSuccess: false }) ImagesInfo:this.state.ImagesInfo,
}, 2000) })
}) Taro.showToast({
title: '删除成功',
icon: 'success',
duration: 1500
})
} }
} }
// 修改供求类型 // 修改供求类型
@ -136,15 +250,17 @@ class MyDemandSupplyEdit extends Component {
contentChange(event) { contentChange(event) {
this.setState({ content: event.target.value }) this.setState({ content: event.target.value })
} }
goToMyDemSupPage(){ goToMyDemSupPage() {
Taro.navigateTo({ Taro.navigateTo({
url: '/pages/mySupplyDemand/mySupplyDemand' url: '/pages/mySupplyDemand/mySupplyDemand'
}) })
} }
componentDidMount() { componentDidMount() {
// this.uploadSupplyDemand() // console.log('this.$router.params.sdId',this.$router.params.sdId)
Taro.showLoading({title:'加载中'})
this.getSupplyDemandInfo()
} }
componentWillReceiveProps(nextProps) { componentWillReceiveProps(nextProps) {
console.log(this.props, nextProps) console.log(this.props, nextProps)
@ -158,14 +274,14 @@ class MyDemandSupplyEdit extends Component {
render() { render() {
const imageUploadSuccessElement = <AtToast const imageUploadSuccessElement = <AtToast
isOpened={this.state.isUploadImageSuccess} isOpened={this.state.isUploadImageSuccess}
text={this.state.uploadImageTextTip} text={this.state.uploadImageTextTip}
duration={2000} duration={2000}
></AtToast> ></AtToast>
const demandSupplyUploadSuccessElement = <AtToast const demandSupplyUploadSuccessElement = <AtToast
isOpened={this.state.isUploadDemSupSuccess} isOpened={this.state.isUploadDemSupSuccess}
text={this.state.uploadDemSupTextTip} text={this.state.uploadDemSupTextTip}
duration={2000} duration={2000}
></AtToast> ></AtToast>
return ( return (
<View className='supply-demand'> <View className='supply-demand'>
@ -173,13 +289,13 @@ class MyDemandSupplyEdit extends Component {
{imageUploadSuccessElement} {imageUploadSuccessElement}
{/* 商品发布模态框 */} {/* 商品发布模态框 */}
{demandSupplyUploadSuccessElement} {demandSupplyUploadSuccessElement}
<View className='page-section'> <View className='page-section'>
<View> <View>
<Picker mode='selector' range={this.state.demandingSupplyCate} onChange={this.demandingSupplyCate.bind(this)}> <Picker mode='selector' rangeKey='name' range={this.state.demandingSupplyCate} onChange={this.demandingSupplyCate.bind(this)}>
<View className='picker'> <View className='picker'>
<View className='title-box'> <View className='title-box'>
<Text className='title'><Text className='require'>*</Text>:</Text> <Text className='selected'>{this.state.demandingSupplyCateSelected}</Text> <Text className='title'><Text className='require'>*</Text>:</Text> <Text className='selected'>{this.state.demandingSupplyCateSelected.name}</Text>
</View> </View>
</View> </View>
@ -188,31 +304,31 @@ class MyDemandSupplyEdit extends Component {
</View> </View>
<View className='border-box'> <View className='border-box'>
<Text className='require'>*</Text><AtInput <Text className='require'>*</Text><AtInput
name='value' name='value'
title='需求标题:' title='需求标题:'
type='text' type='text'
value={this.state.title} value={this.state.title}
onChange={this.titleChange.bind(this)} onChange={this.titleChange.bind(this)}
/> />
</View> </View>
<View className='input-box'> <View className='input-box'>
<Text className='require'>*</Text> <Text className='require'>*</Text>
<AtInput <AtInput
name='value' name='value'
title='联系人:' title='联系人:'
type='text' type='text'
value={this.state.contactName} value={this.state.contactName}
onChange={this.contactNameChange.bind(this)} onChange={this.contactNameChange.bind(this)}
/> />
</View> </View>
<View className='input-box'> <View className='input-box'>
<Text className='require'>*</Text> <Text className='require'>*</Text>
<AtInput <AtInput
name='value' name='value'
title='联系电话:' title='联系电话:'
type='number' type='number'
value={this.state.contactNumber} value={this.state.contactNumber}
onChange={this.contactNumberChange.bind(this)} onChange={this.contactNumberChange.bind(this)}
/> />
</View> </View>
<View className='demanding-box'> <View className='demanding-box'>
@ -221,10 +337,10 @@ class MyDemandSupplyEdit extends Component {
</View> </View>
<AtTextarea <AtTextarea
value={this.state.contactAddress} value={this.state.contactAddress}
onChange={this.contactAddressChange.bind(this)} onChange={this.contactAddressChange.bind(this)}
maxlength='200' maxlength='200'
placeholder='联系地址' placeholder='联系地址'
/> />
</View> </View>
<View className='demanding-box'> <View className='demanding-box'>
@ -232,10 +348,10 @@ class MyDemandSupplyEdit extends Component {
<Text className='title'><Text className='require'>*</Text>:</Text> <Text className='title'><Text className='require'>*</Text>:</Text>
</View> </View>
<AtTextarea <AtTextarea
value={this.state.content} value={this.state.content}
onChange={this.contentChange.bind(this)} onChange={this.contentChange.bind(this)}
maxlength='200' maxlength='200'
placeholder='' placeholder=''
/> />
</View> </View>
<View className='img-box'> <View className='img-box'>
@ -246,12 +362,12 @@ class MyDemandSupplyEdit extends Component {
<View className='img-container'> <View className='img-container'>
<AtImagePicker <AtImagePicker
multiple multiple
showAddBtn={this.state.pickerImageUrl.length<4} showAddBtn={this.state.pickerImageUrl.length < 4}
files={this.state.pickerImageUrl} files={this.state.pickerImageUrl}
onChange={this.onChangeImg.bind(this)} onChange={this.onChangeImg.bind(this)}
onFail={this.onFail.bind(this)} onFail={this.onFail.bind(this)}
onImageClick={this.onImageClick.bind(this)} onImageClick={this.onImageClick.bind(this)}
/> />
</View> </View>
@ -259,10 +375,10 @@ class MyDemandSupplyEdit extends Component {
<View className='page-section'> <View className='page-section'>
<View> <View>
<Picker mode='selector' range={this.state.demandingSupplyState} onChange={this.demSupplyStateChange}> <Picker mode='selector' rangeKey='name' range={this.state.demandingSupplyState} onChange={this.demSupplyStateChange}>
<View className='picker'> <View className='picker'>
<View className='title-box'> <View className='title-box'>
<Text className='title'> <Text className='require'>*</Text>:</Text> <Text className='selected'>{this.state.demandingSupplyStateSelected}</Text> <Text className='title'> <Text className='require'>*</Text>:</Text> <Text className='selected'>{this.state.demandingSupplyStateSelected.name}</Text>
</View> </View>
</View> </View>

View File

@ -1,6 +1,6 @@
import Taro, { Component } from '@tarojs/taro' import Taro, { Component } from '@tarojs/taro'
import { View, Radio, } from '@tarojs/components' import { View, Radio, } from '@tarojs/components'
import { AtInput, Text, AtButton, AtIcon, Picker, Image, AtPagination, AtToast } from 'taro-ui' import { AtInput, Text, AtButton, AtIcon, Picker, Image, AtPagination, } from 'taro-ui'
import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent' import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent'
import URL from '../../serviceAPI.config' import URL from '../../serviceAPI.config'
@ -41,8 +41,7 @@ class MyGoodList extends Component {
currPageParam: 1,// 当前页面 参数 currPageParam: 1,// 当前页面 参数
isCheckAll: false,// 是否checked isCheckAll: false,// 是否checked
goodsIdList: [],//商品Id 列表 goodsIdList: [],//商品Id 列表
isToast: false,// 是否显示轻提示
toastText: ''// 轻提示字段
} }
@ -208,17 +207,25 @@ class MyGoodList extends Component {
} }
}).then(res => { }).then(res => {
if (res.statusCode === 200) { if (res.statusCode === 200) {
console.log('商品状态返回', res) Taro.showToast({
this.setState({ isToast: true, toastText: '下架成功' }, () => { title:'下架成功',
icon:'success',
duration:1500
}).then(()=>{
setTimeout(() => { setTimeout(() => {
this.setState({ isToast: false }) this.setState({isCheckAll:false})
this.getMyGoodListApi({})// 从新获取商品列表数据 this.getMyGoodListApi({})
}, 2000); }, 1500);
}) })
} else { } else {
console.log('我的商品列表获取失败') Taro.showToast({
title:'下架失败',
icon:'none',
duration:1500
})
this.setState({isCheckAll:false})
} }
@ -244,17 +251,26 @@ class MyGoodList extends Component {
}).then(res => { }).then(res => {
if (res.statusCode === 200) { if (res.statusCode === 200) {
console.log('商品删除返回', res) console.log('商品删除返回', res)
this.setState({ isToast: true, toastText: '删除成功' }, () => { Taro.showToast({
title:'删除成功',
icon:'success',
duration:1500
}).then(()=>{
setTimeout(() => { setTimeout(() => {
this.setState({ isToast: false }) this.setState({isCheckAll:false})
this.getMyGoodListApi({})// 从新获取商品列表数据 this.getMyGoodListApi({})
}, 2000); }, 1500);
}) })
} else { } else {
console.log('我的商品列表获取失败') Taro.showToast({
title:'删除失败',
icon:'none',
duration:1500
})
this.setState({isCheckAll:false})
} }
@ -381,16 +397,18 @@ class MyGoodList extends Component {
} }
// 删除商品 // 删除商品
deleteGoodsHandler() { deleteGoodsHandler() {
const checkedGoodsId = [] const checkedGoodsId = []
this.state.myGoodList.forEach(item => { this.state.myGoodList.forEach(item => {
if (item.checked) { if (item.checked) {
checkedGoodsId.push(item.goods_id) checkedGoodsId.push(item.goods_id)
} }
}); });
checkedGoodsId.length ? this.deleteGood({ goodsID: checkedGoodsId }) : this.setState({ isToast: true, toastText: '请选择要删除的商品' }, () => {
setTimeout(() => { checkedGoodsId.length ? this.deleteGood({ goodsID: checkedGoodsId }) : Taro.showToast({
this.setState({ isToast: false }) title:'请选择要删除的商品',
}, 2000); icon:'none',
duration:1500
}) })
} }
@ -416,7 +434,7 @@ class MyGoodList extends Component {
} }
goToGoodspage(goodId){ goToGoodspage(goodId){
Taro.navigateTo({ Taro.navigateTo({
url: '/pages/goods/goods?id='+goodId// 虚拟地址 url: '/pages/goods/goods?id='+goodId
}) })
} }
@ -436,12 +454,7 @@ class MyGoodList extends Component {
componentDidHide() { } componentDidHide() { }
render() { render() {
// 轻提示
const toastElement = <AtToast
isOpened={this.state.isToast}
text={this.state.toastText}
></AtToast>
//等待接口数据 <Radio className='radio-list__radio' value={item.value} checked={item.checked}>{item.text}</Radio> //等待接口数据 <Radio className='radio-list__radio' value={item.value} checked={item.checked}>{item.text}</Radio>
const goodListElementArray = this.state.myGoodList.map((item, index) => { const goodListElementArray = this.state.myGoodList.map((item, index) => {
@ -475,7 +488,7 @@ class MyGoodList extends Component {
return ( return (
<View className='MyGoodList'> <View className='MyGoodList'>
{toastElement}
<View className='border-box'> <View className='border-box'>
<AtInput <AtInput
name='value' name='value'

View File

@ -14,7 +14,7 @@ class MyGoodsEdit extends Component {
constructor() { constructor() {
super(...arguments) super(...arguments)
this.state = { this.state = {
shopCategoryPicker: [], // 店铺分类选项 shopCategoryList: [], // 店铺分类选项
shopCategoryCheckedPicker: { name: '选择店铺类型', id: '' }, shopCategoryCheckedPicker: { name: '选择店铺类型', id: '' },
productName: '', productName: '',
productPrice: '', productPrice: '',
@ -22,7 +22,10 @@ class MyGoodsEdit extends Component {
productDescript: '', productDescript: '',
pickerImageUrl: [], // 上传的图片 pickerImageUrl: [], // 上传的图片
ImagesInfo: [],// 后台传回来的图片信息 ImagesInfo: [],// 后台传回来的图片信息
shopCategoryList: [], goodsTypeParam: '',//商品分类参数
goodId: '',//商品id
} }
} }
@ -44,23 +47,25 @@ class MyGoodsEdit extends Component {
}) })
.then(res => { .then(res => {
console.log('商品详情获取成功', res) console.log('商品详情获取成功', res)
const imageFile = res.data.goodsFiles.map((item) => { const imageFile = res.data.goodsFiles.map((item) => {
return { url: URL.Base + item.files.file_path } return { url: URL.Base + item.files.file_path }
}) })
const shopTypeId = res.data.goods.shop_class_id
const selectedShopCateId=res.data.goods.shop_class_id const shopTypeName = this.state.shopCategoryList.filter(item => {
const selectedShopCate=this.state.shopCategoryPicker.filter(item=>{ return item.id === shopTypeId
return item.id===selectedShopCateId
}) })
console.log('abc',selectedShopCate)
this.setState({ this.setState({
productName: res.data.goods.goods_name, productName: res.data.goods.goods_name,
productPrice: res.data.goods.goods_price, productPrice: res.data.goods.goods_price,
productUnit: res.data.goods.goods_unit, productUnit: res.data.goods.goods_unit,
productDescript: res.data.goods.goods_profiles, productDescript: res.data.goods.goods_profiles,
shopCategoryCheckedPicker:selectedShopCate[0], pickerImageUrl: imageFile,
pickerImageUrl: imageFile ImagesInfo: res.data.goodsFiles,
shopCategoryCheckedPicker: shopTypeName[0],
goodsTypeParam: res.data.goods.class_id,
goodId: res.data.goods.goods_id,
}) })
} }
) )
@ -86,7 +91,7 @@ class MyGoodsEdit extends Component {
}) })
.then(res => { .then(res => {
if (res.data.err_msg === 'success') { if (res.data.err_msg === 'success') {
this.setState({ shopCategoryList: res.data.data })
const shopCategoryInfo = res.data.data const shopCategoryInfo = res.data.data
const shopCategory = [] const shopCategory = []
// 处理后台返回的店铺分类信息 // 处理后台返回的店铺分类信息
@ -96,7 +101,9 @@ class MyGoodsEdit extends Component {
shopCategory.push({ id: children[child].id, name: children[child].n }) shopCategory.push({ id: children[child].id, name: children[child].n })
} }
} }
this.setState({ shopCategoryPicker: shopCategory }) this.setState({ shopCategoryList: shopCategory }, () => {
})
console.log('店铺分类目录', res) console.log('店铺分类目录', res)
return return
} }
@ -108,7 +115,13 @@ class MyGoodsEdit extends Component {
} }
// 发布商品api // 发布商品api
uploadGoods({ goods_name = "test2", goods_price = "1.00", goods_unit = "1", goods_profiles = "test2", class_id = "10103", shop_class_id = "1930" }) { uploadGoods({ goods_name = "test2",
goods_price = "1.00",
goods_unit = "1",
goods_profiles = "test2",
class_id = "10103",
shop_class_id = "1930",
goods_id = '123' }) {
// 上传图片的参数 // 上传图片的参数
const uploadProductGoodFileParams = [] const uploadProductGoodFileParams = []
@ -140,14 +153,15 @@ class MyGoodsEdit extends Component {
dataType: 'json', dataType: 'json',
data: { data: {
deployType: 1, deployType: 1,
action: 1, action: 2,
goods: JSON.stringify({ goods: JSON.stringify({
goods_name: goods_name, goods_name: goods_name,
goods_price: goods_price, goods_price: goods_price,
goods_unit: goods_unit, goods_unit: goods_unit,
goods_profiles: goods_profiles, goods_profiles: goods_profiles,
class_id: class_id, class_id: class_id,
shop_class_id: shop_class_id shop_class_id: shop_class_id,
goods_id: goods_id,
}), }),
goodsFiles: JSON.stringify(uploadProductGoodFileParams) goodsFiles: JSON.stringify(uploadProductGoodFileParams)
}, },
@ -166,10 +180,9 @@ class MyGoodsEdit extends Component {
}) })
setTimeout(() => { setTimeout(() => {
Taro.navigateTo({ Taro.navigateTo({
url: '/pages/goods/goods?id=5cf3Ptn5wKQdyPpwsSe2nDKnN4QDFdz8moPTf+QIOm788Q'// 虚拟地址 url: '/pages/goods/goods?id='+this.$router.params.id
}) })
}, 1000); }, 1000);
console.log('上传商品', res) console.log('上传商品', res)
} }
) )
@ -223,11 +236,16 @@ class MyGoodsEdit extends Component {
'X-Requested-With': 'XMLHttpRequest' 'X-Requested-With': 'XMLHttpRequest'
}, },
success(response) { success(response) {
const data = JSON.parse(response.data) const data = JSON.parse(response.data)
const imagePath = URL.Base + data.file_path const imagePath = URL.Base + data.file_path
const newPickerImageUrl = that.state.pickerImageUrl.concat({ url: imagePath }) const newPickerImageUrl = that.state.pickerImageUrl.concat({ url: imagePath })
const newImageInfo = that.state.ImagesInfo.concat(data) const newImageInfo = that.state.ImagesInfo.concat(data)
that.setState({ pickerImageUrl: newPickerImageUrl, ImagesInfo: newImageInfo }, () => {
that.setState({
pickerImageUrl: newPickerImageUrl,
ImagesInfo: newImageInfo
}, () => {
Taro.showToast({ Taro.showToast({
title: '上传成功', title: '上传成功',
icon: 'success', icon: 'success',
@ -238,8 +256,13 @@ class MyGoodsEdit extends Component {
}) })
} }
if (operationType === 'remove') { if (operationType === 'remove') {
this.state.pickerImageUrl.splice(index, 1); this.state.pickerImageUrl.splice(index, 1);// 删除图片param
this.setState({ files: this.state.pickerImageUrl }); this.state.ImagesInfo.splice(index, 1) // 删除显示的图片
this.setState({
pickerImageUrl: this.state.pickerImageUrl,
ImagesInfo: this.state.ImagesInfo
});
Taro.showToast({ Taro.showToast({
title: '删除成功', title: '删除成功',
@ -253,9 +276,7 @@ class MyGoodsEdit extends Component {
onFail(mes) { onFail(mes) {
console.log(mes) console.log(mes)
} }
// 删除图片
onImageClick(index) {
}
onClickUploadGoods() { onClickUploadGoods() {
if (this.state.productName && this.state.productPrice && this.state.productUnit && this.state.ImagesInfo.length && this.state.shopCategoryCheckedPicker.id) { if (this.state.productName && this.state.productPrice && this.state.productUnit && this.state.ImagesInfo.length && this.state.shopCategoryCheckedPicker.id) {
Taro.showLoading({ title: '保存中' }).then(() => { Taro.showLoading({ title: '保存中' }).then(() => {
@ -265,7 +286,9 @@ class MyGoodsEdit extends Component {
goods_price: this.state.productPrice, goods_price: this.state.productPrice,
goods_unit: this.state.productUnit, goods_unit: this.state.productUnit,
goods_profiles: this.state.productDescript, goods_profiles: this.state.productDescript,
shop_class_id: this.state.shopCategoryCheckedPicker, shop_class_id: this.state.shopCategoryCheckedPicker.id,
class_id: this.state.goodsTypeParam,
goods_id: this.state.goodId,
}) })
}, 1000); }, 1000);
}) })
@ -280,7 +303,7 @@ class MyGoodsEdit extends Component {
} }
shopCategoryChanged(e) { shopCategoryChanged(e) {
this.setState({ this.setState({
shopCategoryCheckedPicker: this.state.shopCategoryPicker[e.detail.value] shopCategoryCheckedPicker: this.state.shopCategoryList[e.detail.value]
}, () => { }, () => {
console.log(this.state.shopCategoryCheckedPicker) console.log(this.state.shopCategoryCheckedPicker)
}) })
@ -296,6 +319,7 @@ class MyGoodsEdit extends Component {
this.getShopCateList().then(() => { this.getShopCateList().then(() => {
this.getGoodsInfo() this.getGoodsInfo()
}) })
} }
@ -315,40 +339,36 @@ class MyGoodsEdit extends Component {
return ( return (
<View className='goods-publish'> <View className='goods-publish'>
<View className='goods-category'> <View className='goods-category'>
<View className='input-box'> <View className='input-box'>
<Text className='require'>*</Text> <Text className='require'>*</Text>
<AtInput <AtInput
name='productName' name='productName'
title='商品名称:' title='商品名称:'
type='text' type='text'
value={this.state.productName} value={this.state.productName}
onChange={this.productNameChange.bind(this)} onChange={this.productNameChange.bind(this)}
/> />
</View> </View>
<View className='input-box'> <View className='input-box'>
<Text className='require'>*</Text> <Text className='require'>*</Text>
<AtInput <AtInput
name='productPrice' name='productPrice'
title='商品价格:' title='商品价格:'
type='number' type='number'
placeholder='¥' placeholder='¥'
value={this.state.productPrice} value={this.state.productPrice}
onChange={this.productPriceChange.bind(this)} onChange={this.productPriceChange.bind(this)}
/> />
</View> </View>
<View className='input-box'> <View className='input-box'>
<Text className='require'>*</Text> <Text className='require'>*</Text>
<AtInput <AtInput
name='productUnit' name='productUnit'
title='商品单位:' title='商品单位:'
type='text' type='text'
value={this.state.productUnit} value={this.state.productUnit}
onChange={this.productUnitChange.bind(this)} onChange={this.productUnitChange.bind(this)}
/> />
</View> </View>
{/* 图片上传 */} {/* 图片上传 */}
@ -359,18 +379,18 @@ class MyGoodsEdit extends Component {
</View> </View>
<View className='img-container'> <View className='img-container'>
<AtImagePicker <AtImagePicker
multiple multiple
files={this.state.pickerImageUrl} files={this.state.pickerImageUrl}
onChange={this.onChangeImg.bind(this)} onChange={this.onChangeImg.bind(this)}
onFail={this.onFail.bind(this)} onFail={this.onFail.bind(this)}
onImageClick={this.onImageClick.bind(this)} onImageClick={this.onImageClick.bind(this)}
/> />
</View> </View>
</View> </View>
<View className='shoptype-box'> <View className='shoptype-box'>
{/* 店铺分类 */} {/* 店铺分类 */}
<View className='title-box page-section'> <View className='title-box page-section'>
<Picker mode='selector' rangeKey='name' range={this.state.shopCategoryPicker} onChange={this.shopCategoryChanged.bind(this)}> <Picker mode='selector' rangeKey='name' range={this.state.shopCategoryList} onChange={this.shopCategoryChanged.bind(this)}>
<View className='picker'> <View className='picker'>
<Text className='require'>*</Text> <Text className='require'>*</Text>
<Text className='title'> 店铺分类</Text> <Text className='title'> 店铺分类</Text>
@ -390,10 +410,10 @@ class MyGoodsEdit extends Component {
</View> </View>
<AtTextarea <AtTextarea
value={this.state.productDescript} value={this.state.productDescript}
onChange={this.productDescriptChange.bind(this)} onChange={this.productDescriptChange.bind(this)}
maxlength='200' maxlength='200'
placeholder='你的产品简介' placeholder='你的产品简介'
/> />
</View> </View>

View File

@ -1,6 +1,6 @@
import Taro, { Component } from '@tarojs/taro' import Taro, { Component } from '@tarojs/taro'
import { View, Text, Button } from '@tarojs/components' import { View, Text, Button } from '@tarojs/components'
import { AtInput, AtButton, Picker, AtIcon, AtModal, AtModalHeader, AtModalContent, AtModalAction } from 'taro-ui' import { AtInput, AtButton, Picker, AtIcon, AtModal, AtModalHeader, AtModalContent, AtModalAction,AtPagination } from 'taro-ui'
import URL from '../../serviceAPI.config' import URL from '../../serviceAPI.config'
import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent' import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent'
@ -25,17 +25,17 @@ class MySupplyDemand extends Component {
startDateSel: '', startDateSel: '',
endDateSel: '', endDateSel: '',
allDemandSupply: [], allDemandSupply: [],
totalDemandSupply: '',
isConfirmWindow: false, // 是否显示确认弹窗 isConfirmWindow: false, // 是否显示确认弹窗
demandSupplyItemName: '',// 确认框提示时 使用的供求名 demandSupplyItemName: '',// 确认框提示时 使用的供求名
demandSupplyId: '',// 删除我的供求时的供求id demandSupplyId: '',// 删除我的供求时的供求id
totalDemandSupply:'',//所有供求
currentPage:1 //当前页数
} }
} }
//获取我的供求API //获取我的供求API
getMySupplyDemand({ curr_page = 1, page_count = 20 }) { getMySupplyDemand({ curr_page = 1, page_count = 10 }) {
Taro.request({ Taro.request({
url: URL.MySupplyDemand, url: URL.MySupplyDemand,
method: 'POST', method: 'POST',
@ -95,14 +95,15 @@ class MySupplyDemand extends Component {
}) })
} }
onSearchButtonHandler(){ onSearchButtonHandler() {
Taro.showLoading({title:'加载中'}) .then(() => { Taro.showLoading({ title: '加载中' }).then(() => {
setTimeout(() => { setTimeout(() => {
this.searchDemandSupply({}) this.searchDemandSupply({})
this.setState({currentPage:1})
}, 1000); }, 1000);
}) })
} }
// 删除我的供求api // 删除我的供求api
@ -211,33 +212,36 @@ class MySupplyDemand extends Component {
// 编辑我的供求 // 编辑我的供求
// 跳转到我的供求编辑页面 // 跳转到我的供求编辑页面
goToMyDSEditPage() { goToMyDSEditPage(sdId) {
Taro.navigateTo({ Taro.navigateTo({
url: '/pages/myDemandSupplyEdit/myDemandSupplyEdit' url: '/pages/myDemandSupplyEdit/myDemandSupplyEdit?sdId=' + sdId
}) })
} }
// 转到供求查看页面 // 转到供求查看页面
goToSupplyDemandPage(){ goToSupplyDemandPage(sdId) {
Taro.navigateTo({ Taro.navigateTo({
url: '/pages/supplyDemandView/supplyDemandView' url: '/pages/supplyDemandView/supplyDemandView?sdId=' + sdId
}) // url: '/pages/goods/goods?sdId='+goodId// 虚拟地址
})
} }
// 翻页导航
paginationNav(type) {
this.setState({ currentPage: type.current, }, () => {
this. getMySupplyDemand({ curr_page :this.state.currentPage})
})
//查看我的供求 }
componentWillReceiveProps(nextProps) { componentWillReceiveProps(nextProps) {
console.log(this.props, nextProps) console.log(this.props, nextProps)
} }
componentDidMount() { componentDidMount() {
Taro.showLoading({ title: '加载中' }).then(() => {
this.getMySupplyDemand({})
Taro.showLoading({title:'加载中'}) .then(() => { })
this.getMySupplyDemand({})
})
} }
componentWillUnmount() { } componentWillUnmount() { }
@ -256,9 +260,14 @@ class MySupplyDemand extends Component {
</AtModalContent> </AtModalContent>
<AtModalAction> <Button onClick={this.handleWindowModCancel.bind(this)}>取消</Button> <Button className='orange' onClick={this.handleWindowConfirm.bind(this)}></Button> </AtModalAction> <AtModalAction> <Button onClick={this.handleWindowModCancel.bind(this)}>取消</Button> <Button className='orange' onClick={this.handleWindowConfirm.bind(this)}></Button> </AtModalAction>
</AtModal> </AtModal>
const demandSupplyElementArray = this.state.allDemandSupply.length ? this.state.allDemandSupply.map((item, index) => { const demandSupplyElementArray = this.state.allDemandSupply.length ? this.state.allDemandSupply.map((item, index) => {
return <View key={index} className='info-container'> const SDState=this.state.demandSupplyState.filter(stateItem=>{
return stateItem.id==item.state
})[0].name
return <View key={index} className='info-container'>
<View className='type'> <View className='type'>
<Text className='title'>需求类型</Text> <Text className='title'>需求类型</Text>
<Text className='info'>{item.type_name}</Text> <Text className='info'>{item.type_name}</Text>
@ -277,17 +286,17 @@ class MySupplyDemand extends Component {
</View> </View>
<View className='demand-status'> <View className='demand-status'>
<Text className='title'>需求状态</Text> <Text className='title'>需求状态</Text>
<Text className='info'>{item.state}</Text> <Text className='info'>{SDState}</Text>
</View> </View>
<View className='update-time'> <View className='update-time'>
<Text className='title'>更新时间</Text> <Text className='title'>更新时间</Text>
<Text className='info'>{item.update_date}</Text> <Text className='info'>{item.update_date}</Text>
</View> </View>
<View className='info-button-box'> <View className='info-button-box'>
<View className='button' onClick={this.goToSupplyDemandPage.bind(this)}> <View className='button' onClick={this.goToSupplyDemandPage.bind(this, item.sd_id)}>
<AtButton type='primary' size='small'>查看</AtButton> <AtButton type='primary' size='small'>查看</AtButton>
</View> </View>
<View className='button' onClick={this.goToMyDSEditPage.bind(this)} > <View className='button' onClick={this.goToMyDSEditPage.bind(this, item.sd_id)} >
<AtButton type='primary' size='small'>编辑</AtButton> <AtButton type='primary' size='small'>编辑</AtButton>
</View> </View>
<View className='button' onClick={this.handleOnDelete.bind(this, item.sd_id, item.sd_title)}> <View className='button' onClick={this.handleOnDelete.bind(this, item.sd_id, item.sd_title)}>
@ -304,7 +313,7 @@ class MySupplyDemand extends Component {
<View className='mySupplyDemand'> <View className='mySupplyDemand'>
{/* 是否删除供求确认框 */} {/* 是否删除供求确认框 */}
{modalMessageConfirmElement} {modalMessageConfirmElement}
@ -385,6 +394,16 @@ class MySupplyDemand extends Component {
<View className='info-box'> <View className='info-box'>
{demandSupplyElementArray} {demandSupplyElementArray}
</View> </View>
<View className='pagination-box'>
<AtPagination
total={this.state.totalDemandSupply}
pageSize={10}
current={this.state.currentPage}
onPageChange={this.state.paginationNav.bind(this)}
>
</AtPagination>
</View>

View File

@ -132,4 +132,7 @@ $themeColor:#FF7142;
text-align: center; text-align: center;
font-size: 35px; font-size: 35px;
}
.pagination-box{
margin: 50px 0;
} }

View File

@ -19,10 +19,10 @@ class SupplyDemand extends Component {
constructor() { constructor() {
super(...arguments) super(...arguments)
this.state = { this.state = {
demandingSupplyCate: [{name:'需求',id:1}, {name:'供应',id:2}, {name:'人才',id:3}], //供求类型选择 demandingSupplyCate: [{ name: '需求', id: '1' }, { name: '供应', id: '2' }, { name: '人才', id: '3' }], //供求类型选择
demandingSupplyCateSelected: {name:'需求',id:1},// 当前供求类型 demandingSupplyCateSelected: { name: '需求', id: '1' },// 当前供求类型
demandingSupplyState: [{name:'上架',id:1}, {name:'下架',id:0}], // 状态选择 demandingSupplyState: [{ name: '上架', id: '1' }, { name: '下架', id: '0' }], // 状态选择
demandingSupplyStateSelected: {name:'上架',id:1},// 当前状态 demandingSupplyStateSelected: { name: '上架', id: '1' },// 当前状态
title: '', title: '',
contactName: '', contactName: '',
contactNumber: '', contactNumber: '',
@ -30,50 +30,47 @@ class SupplyDemand extends Component {
content: '', content: '',
pickerImageUrl: [], // 上传的图片 pickerImageUrl: [], // 上传的图片
ImagesInfo: [],// 后台传回来的图片信息 ImagesInfo: [],// 后台传回来的图片信息
isUploadImageSuccess: false,
uploadImageTextTip: '',
isFormCompleted: false, isFormCompleted: false,
isUploadDemSupSuccess: false,
uploadDemSupTextTip: '',
} }
} }
// 上传供求api // 上传供求api
uploadSupplyDemand() { uploadSupplyDemand() {
console.log(this.state.ImagesInfo) console.log(this.state.ImagesInfo)
if (this.state.demandingSupplyCateSelected && this.state.title && this.state.contactName && this.state.contactNumber && this.state.contactAddress && this.state.content && this.state.demandingSupplyStateSelected) { if (this.state.demandingSupplyCateSelected && this.state.title && this.state.contactName && this.state.contactNumber && this.state.content && this.state.demandingSupplyStateSelected) {
this.uploadDemSup({ this.uploadDemSup({})
sd_type:this.state.demandingSupplyCateSelected,
sd_title:this.state.title,
user_name:this.state.contactName,
user_phone:this.state.contactNumber,
user_address:this.state.contactAddress,
sd_desc:this.state.content,
state:this.state.demandingSupplyStateSelected})
} else { } else {
this.setState({ uploadDemSupTextTip: '请填写完表格', isUploadDemSupSuccess: true }, () => { Taro.showToast({
setTimeout(() => { title:'请填写完表格',
this.setState({ isUploadDemSupSuccess: false }) icon:'none',
}, 2000) duration:1500
}) })
} }
} }
// 这个需要写一个uploadDemSup 上传供求 的api // 这个需要写一个uploadDemSup 上传供求 的api
uploadDemSup({sd_type="2",sd_title="第4方",user_name="郑燕彬",user_phone="13509302402",user_address="",sd_desc="但是发射点",state="1"}){ uploadDemSup({ sd_type = this.state.demandingSupplyCateSelected.id,
const file_path=[]; sd_title = this.state.title,
this.state.ImagesInfo.forEach((item)=>{ user_name = this.state.contactName,
file_path.push({ user_phone = this.state.contactNumber,
file_name: item.file_name, user_address = this.state.contactAddress,
file_size: item.file_size, sd_desc = this.state.content,
file_path: item.file_path, state = this.state.demandingSupplyStateSelected.id }) {
thumb_path:item.thumb_path const file_path = [];
}) this.state.ImagesInfo.forEach((item) => {
file_path.push({
file_name: item.file_name,
file_size: item.file_size,
file_path: item.file_path,
thumb_path: item.thumb_path
}) })
Taro.request({ })
Taro.request({
url: URL.UploadSupplyDemand, url: URL.UploadSupplyDemand,
method: 'POST', method: 'POST',
dataType: 'json', dataType: 'json',
@ -82,12 +79,13 @@ class SupplyDemand extends Component {
sdInfo: JSON.stringify({ sdInfo: JSON.stringify({
sd_type: sd_type, sd_type: sd_type,
sd_title: sd_title, sd_title: sd_title,
user_name: user_name, user_name: user_name,
user_phone: user_phone, user_phone: user_phone,
user_address: user_address, user_address: user_address,
sd_desc: sd_desc, sd_desc: sd_desc,
state: state, state: state,
file_path:file_path}) file_path: file_path
})
}, },
header: { header: {
'content-type': 'application/x-www-form-urlencoded', 'content-type': 'application/x-www-form-urlencoded',
@ -97,18 +95,24 @@ class SupplyDemand extends Component {
}) })
.then(res => { .then(res => {
console.log('上传供求', res) console.log('上传供求', res)
if(res.data.err_msg==='success'){ if (res.data.err_msg === 'success') {
console.log(11111) Taro.showToast({
this.setState({ uploadDemSupTextTip: '上传成功', isUploadDemSupSuccess: true }, () => { title: '上传成功',
icon: 'success',
duration: 1500
}).then(() => {
setTimeout(() => { setTimeout(() => {
this.setState({ isUploadDemSupSuccess: false })
Taro.navigateTo({ Taro.navigateTo({
url: '/pages/mySupplyDemand/mySupplyDemand' url: '/pages/mySupplyDemand/mySupplyDemand'
}) })
}, 2000) }, 1500);
})
} else {
Taro.showToast({
title: '上传失败',
icon: 'none',
duration: 1500
}) })
}else{
console.log('上传供求失败')
} }
} }
@ -125,7 +129,6 @@ class SupplyDemand extends Component {
url: URL.UploadDSPorductImage, url: URL.UploadDSPorductImage,
filePath: files[files.length - 1].url, filePath: files[files.length - 1].url,
name: 'file', name: 'file',
header: { header: {
'content-type': 'multipart/form-data; boundary=----WebKitFormBoundaryAWxeadaAVmRVQCiz', 'content-type': 'multipart/form-data; boundary=----WebKitFormBoundaryAWxeadaAVmRVQCiz',
'Cookie': 'PFWSSS=' + Taro.getStorageSync('session_id'), 'Cookie': 'PFWSSS=' + Taro.getStorageSync('session_id'),
@ -136,23 +139,30 @@ class SupplyDemand extends Component {
const imagePath = URL.Base + data.file_path const imagePath = URL.Base + data.file_path
const newPickerImageUrl = that.state.pickerImageUrl.concat({ url: imagePath }) const newPickerImageUrl = that.state.pickerImageUrl.concat({ url: imagePath })
const newImageInfo = that.state.ImagesInfo.concat(data) const newImageInfo = that.state.ImagesInfo.concat(data)
that.setState({ pickerImageUrl: newPickerImageUrl, isUploadImageSuccess: true, uploadImageTextTip: '图片上传成功', ImagesInfo: newImageInfo }, () => {
setTimeout(() => {
that.setState({ isUploadImageSuccess: false }) that.setState({ pickerImageUrl: newPickerImageUrl, ImagesInfo: newImageInfo })
}, 2000) Taro.showToast({
}) title: '上传成功',
icon: 'success',
duration: 1500
})
} }
}) })
} }
if (operationType === 'remove') { if (operationType === 'remove') {
this.state.pickerImageUrl.splice(index, 1); this.state.ImagesInfo.splice(index, 1) // 删除显示的图片
this.setState({ files: this.state.pickerImageUrl }); this.state.pickerImageUrl.splice(index, 1)// 删除图片param
that.setState({ isUploadImageSuccess: true, uploadImageTextTip: '删除成功' }, () => { that.setState({
setTimeout(() => { pockerImageUrl:this.state.pickerImageUrl,
that.setState({ isUploadImageSuccess: false }) ImagesInfo:this.state.ImagesInfo,
}, 2000) })
}) Taro.showToast({
} title: '删除成功',
icon: 'success',
duration: 1500
})
}
} }
// 修改供求类型 // 修改供求类型
demandingSupplyCate = e => { demandingSupplyCate = e => {
@ -182,10 +192,10 @@ class SupplyDemand extends Component {
contentChange(event) { contentChange(event) {
this.setState({ content: event.target.value }) this.setState({ content: event.target.value })
} }
goToMyDemSupPage(){ goToMyDemSupPage() {
Taro.navigateTo({ Taro.navigateTo({
url: '/pages/mySupplyDemand/mySupplyDemand' url: '/pages/mySupplyDemand/mySupplyDemand'
}) })
} }
@ -203,24 +213,12 @@ class SupplyDemand extends Component {
componentDidHide() { } componentDidHide() { }
render() { render() {
const imageUploadSuccessElement = <AtToast
isOpened={this.state.isUploadImageSuccess}
text={this.state.uploadImageTextTip}
duration={2000}
></AtToast>
const demandSupplyUploadSuccessElement = <AtToast
isOpened={this.state.isUploadDemSupSuccess}
text={this.state.uploadDemSupTextTip}
duration={2000}
></AtToast>
return ( return (
<View className='supply-demand'> <View className='supply-demand'>
{/* 图片上传模态框 */}
{imageUploadSuccessElement}
{/* 商品发布模态框 */}
{demandSupplyUploadSuccessElement}
<View className='page-section'> <View className='page-section'>
<View> <View>
<Picker mode='selector' rangeKey='name' range={this.state.demandingSupplyCate} onChange={this.demandingSupplyCate.bind(this)}> <Picker mode='selector' rangeKey='name' range={this.state.demandingSupplyCate} onChange={this.demandingSupplyCate.bind(this)}>
@ -235,43 +233,43 @@ class SupplyDemand extends Component {
</View> </View>
<View className='border-box'> <View className='border-box'>
<Text className='require'>*</Text><AtInput <Text className='require'>*</Text><AtInput
name='value' name='value'
title='需求标题:' title='需求标题:'
type='text' type='text'
value={this.state.title} value={this.state.title}
onChange={this.titleChange.bind(this)} onChange={this.titleChange.bind(this)}
/> />
</View> </View>
<View className='input-box'> <View className='input-box'>
<Text className='require'>*</Text> <Text className='require'>*</Text>
<AtInput <AtInput
name='value' name='value'
title='联系人:' title='联系人:'
type='text' type='text'
value={this.state.contactName} value={this.state.contactName}
onChange={this.contactNameChange.bind(this)} onChange={this.contactNameChange.bind(this)}
/> />
</View> </View>
<View className='input-box'> <View className='input-box'>
<Text className='require'>*</Text> <Text className='require'>*</Text>
<AtInput <AtInput
name='value' name='value'
title='联系电话:' title='联系电话:'
type='number' type='number'
value={this.state.contactNumber} value={this.state.contactNumber}
onChange={this.contactNumberChange.bind(this)} onChange={this.contactNumberChange.bind(this)}
/> />
</View> </View>
<View className='demanding-box'> <View className='demanding-box'>
<View className='title-box'> <View className='title-box'>
<Text className='title'><Text className='require'>*</Text>:</Text> <Text className='title'>联系地址:</Text>
</View> </View>
<AtTextarea <AtTextarea
value={this.state.contactAddress} value={this.state.contactAddress}
onChange={this.contactAddressChange.bind(this)} onChange={this.contactAddressChange.bind(this)}
maxlength='200' maxlength='200'
placeholder='联系地址' placeholder='联系地址'
/> />
</View> </View>
<View className='demanding-box'> <View className='demanding-box'>
@ -279,10 +277,10 @@ class SupplyDemand extends Component {
<Text className='title'><Text className='require'>*</Text>:</Text> <Text className='title'><Text className='require'>*</Text>:</Text>
</View> </View>
<AtTextarea <AtTextarea
value={this.state.content} value={this.state.content}
onChange={this.contentChange.bind(this)} onChange={this.contentChange.bind(this)}
maxlength='200' maxlength='200'
placeholder='' placeholder=''
/> />
</View> </View>
<View className='img-box'> <View className='img-box'>
@ -293,12 +291,12 @@ class SupplyDemand extends Component {
<View className='img-container'> <View className='img-container'>
<AtImagePicker <AtImagePicker
multiple multiple
showAddBtn={this.state.pickerImageUrl.length<4} showAddBtn={this.state.pickerImageUrl.length < 4}
files={this.state.pickerImageUrl} files={this.state.pickerImageUrl}
onChange={this.onChangeImg.bind(this)} onChange={this.onChangeImg.bind(this)}
onFail={this.onFail.bind(this)} onFail={this.onFail.bind(this)}
onImageClick={this.onImageClick.bind(this)} onImageClick={this.onImageClick.bind(this)}
/> />
</View> </View>

View File

@ -1,7 +1,10 @@
//supplyDemandItemView
import Taro, { Component } from '@tarojs/taro' import Taro, { Component } from '@tarojs/taro'
import { View } from '@tarojs/components' import { View, Text, Image } from '@tarojs/components'
import { AtButton, AtIcon } from 'taro-ui'
import URL from '../../serviceAPI.config'
import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent'
import './supplyDemandView.scss' import './supplyDemandView.scss'
@ -9,28 +12,169 @@ import './supplyDemandView.scss'
class SupplyDemandView extends Component { class SupplyDemandView extends Component {
config = { config = {
navigationBarTitleText: '单独供求' navigationBarTitleText: '供求查看'
} }
componentDidMount(){ constructor() {
super(...arguments)
this.state = {
demandingSupplyCate: [{name:'需求',id:'1'}, {name:'供求',id:'2'}, {name:'人才',id:'3'}], //供求类型选择
type: '',
title: '',
browsing: '',
contactName: '',
contactNumber: '',
address: '',
content: '',
images: [],
}
} }
componentWillReceiveProps (nextProps) { //获取商品信息api GetProductInfo
getSupplyDemandInfo() {
Taro.request({
url: URL.GetSupplyDemandInfo,
method: 'GET',
dataType: 'json',
data: {
sdID: this.$router.params.sdId,
},
header: {
'content-type': 'application/x-www-form-urlencoded',
'Cookie': 'PFWSSS=' + Taro.getStorageSync('session_id'),
'X-Requested-With': 'XMLHttpRequest'
}
})
.then(res => {
console.log('供求详情获取成功', res)
const selectedType=this.state.demandingSupplyCate.filter(item=> item.id===res.data.sdInfo.sd_type)[0].name
this.setState({
type: selectedType,
title: res.data.sdInfo.sd_title,
browsing: res.data.sdInfo.browse_times,
contactName: res.data.sdInfo.user_name,
contactNumber: res.data.sdInfo.user_phone,
address: res.data.sdInfo.user_address,
content: res.data.sdInfo.sd_desc,
images: res.data.sdInfo.file_path,
})
Taro.hideLoading()
}
)
.catch(error => {
console.log('供求详情获取失败', error)
})
}
goToSDPublishPage() {
Taro.navigateTo({
url: '/pages/supplyDemandPublish/supplyDemandPublish',// 供求发布页面
})
}
goToSDEditPage() {
console.log('edit page')
// Taro.navigateTo({
// url: 'pages/supplyDemandPublish/supplyDemandPublish',// 供求发布页面
// })
}
goToMySDPage() {
Taro.navigateTo({
url: '/pages/mySupplyDemand/mySupplyDemand',//我的供求页面
})
}
deleteSD() {
console.log('删除供求')
}
componentDidMount() {
Taro.showLoading({title:'加载中'})
this.getSupplyDemandInfo()
}
componentWillReceiveProps(nextProps) {
console.log(this.props, nextProps) console.log(this.props, nextProps)
} }
componentWillUnmount () { } componentWillUnmount() { }
componentDidShow () { } componentDidShow() { }
componentDidHide () { } componentDidHide() { }
render () { render() {
const imageElementArray = this.state.images.map((item, index) => {
return <View key={index} className='image-box'>
<Image mode='aspectFit' style='width: 100%;'
src={URL.Base + item.file_path}
/>
</View>
})
return ( return (
<View className='SupplyDemandItemView'> <View className='SupplyDemandItemView'>
单独供求 <View className='type box'>
<Text className='title'>供求类型</Text>
<Text className='content'>{this.state.type}</Text>
</View>
<View className='needed-title box'>
<Text className='title'>需求标题</Text>
<Text className='content'>{this.state.title}</Text>
</View>
<View className='browsing-amount box'>
<Text className='title'>浏览量</Text>
<Text className='content'>{this.state.browsing}</Text>
</View>
<View className='contact-name box'>
<Text className='title'>联系人</Text>
<Text className='content'>{this.state.contactName}</Text>
</View>
<View className='phone-number box'>
<Text className='title'>联系电话</Text>
<Text className='content'>{this.state.contactNumber}</Text>
</View>
<View className='address box'>
<Text className='title'>联系地址</Text>
<Text className='content'>{this.state.address}</Text>
</View>
<View className='needed-content box'>
<Text className='title'>需求内容</Text>
<Text className='content'>{this.state.content}</Text>
</View>
<View className='needed-content box'>
<Text className='title'>需求图片</Text>
<View className='image-container'>
{imageElementArray}
</View>
</View>
<View className='button-box'>
<View className='button' onClick={this.goToSDPublishPage.bind(this)}>
<AtButton type='primary' size='small'>
<AtIcon value='add' size='12' color='white'></AtIcon>
新增</AtButton>
</View>
<View className='button' onClick={this.goToSDEditPage.bind(this)}>
<AtButton type='primary' className='button' size='small'>
<AtIcon value='settings' size='12' color='white'></AtIcon>
修改</AtButton>
</View>
<View className='button' onClick={this.goToMySDPage.bind(this)}>
<AtButton type='primary' className='button' size='small'>
<AtIcon value='' size='12' color='white'></AtIcon>
我的供求</AtButton>
</View>
<View className='button' onClick={this.deleteSD.bind(this)}>
<AtButton type='primary' className='button-a' size='small'>
<AtIcon value='close' size='12' color='white'></AtIcon>
删除</AtButton>
</View>
</View>
<CopyrightComponent></CopyrightComponent>
</View> </View>
) )
} }
} }

View File

@ -0,0 +1,36 @@
$themeColor:#FF7142;
.SupplyDemandItemView{
padding: 10px 20px;
font-size: 32rpx;
.box{
margin-top: 35px;
}
.title{
font-weight: bold
}
}
.button-box{
display: flex;
flex-wrap: nowrap;
flex-direction: row;
margin: 40px 0;
padding: 0 20px;
.button{
flex:1;
text-align: center;
// margin:2%;
// justify-content:center;
.at-button--primary{
background-color:$themeColor;
border:1PX solid $themeColor;
}
.button-a{
background-color:#d9534f;
border:1PX solid #d9534f;
}
}
}

View File

@ -43,9 +43,10 @@ const URL = {
// 我的供求页面接口Supply-myList // 我的供求页面接口Supply-myList
SearchDemandSupply: LOCALURL + 'Supply-myList',// 搜索我的供求接口 SearchDemandSupply: LOCALURL + 'Supply-myList',// 搜索我的供求接口
DeleteDemandSupply: LOCALURL + 'Supply-delete',// 删除我的供求接口 DeleteDemandSupply: LOCALURL + 'Supply-delete',// 删除我的供求接口
GetSupplyDemandInfo: LOCALURL + 'Supply-wxEditDeploy',// 获取单个供求信息
// 商品编辑页面 Goods-wxEditPhoneDeploy // 商品编辑页面 Goods-wxEditPhoneDeploy
GetProductInfo: LOCALURL + 'Goods-wxEditPhoneDeploy',// 获取商品信息 GetProductInfo: LOCALURL + 'Goods-wxEditPhoneDeploy',// 获取单个商品信息

View File

@ -11,8 +11,7 @@ todo list
行业分类--等待后台接口--搜索 二级联动-- 行业分类--等待后台接口--搜索 二级联动--
我的供求页面: 我的供求页面:
我的供求查看页面
我的供求编辑页面--等待后台接口数据
我的商品列表页面 我的商品列表页面
商品价格无法设定为数字 // 有bug 商品价格无法设定为数字 // 有bug
@ -20,8 +19,10 @@ todo list
商品编辑页面 商品编辑页面
店铺分类--二级联动 店铺分类--二级联动
接口问题: 接口问题:
优惠卷和询价 优惠卷和询价
bug 商品编辑 增加图片后 图片顺序乱了
我的商品 删除提示