商品编辑 页面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/myDemandSupplyEdit/myDemandSupplyEdit',// 我的供求编辑页面
'pages/supplyDemandView/supplyDemandView',// 查看单个供求页面
'pages/grabOrderPage/grabOrderPage',// 抢单页面
// 'pages/shopDescription/shopDescription',
],
window: {

View File

@ -165,10 +165,12 @@ class GoodsPublish extends Component {
duration: 1000
})
setTimeout(() => {
Taro.navigateTo({
url: '/pages/goods/goods?id=5cf3Ptn5wKQdyPpwsSe2nDKnN4QDFdz8moPTf+QIOm788Q'// 虚拟地址
url: '/pages/goods/goods?id='+res.data.goods_id
})
}, 1000);
console.log('上传商品', res)
}
)
@ -290,7 +292,7 @@ class GoodsPublish extends Component {
goods_price: this.state.productPrice,
goods_unit: this.state.productUnit,
goods_profiles: this.state.productDescript,
class_id: "10103",// to be continue
class_id: "10103",// to be continue //商品分类的选项
shop_class_id: this.state.shopCategoryCheckedPicker.id,
})
},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: [], // 底部导航栏
isOpen: false, // 抢单消息提示
grabOrderId: '',//抢到订单的id
isGrabOrderSuccess: false,// 是否显示轻提示
grabOrderSuccess: '',// 抢单成功返回字段
isMore: 'noMore',// 加载更多店铺
userName:'',//用户名字
userPhone:'',// 用户电话
@ -170,11 +169,12 @@ class Home extends Component {
}
})
.then(res => {
this.setState({ grabOrderSuccess: res.data.err_msg, isGrabOrderSuccess: true }, () => {
setTimeout(() => {
this.setState({ isGrabOrderSuccess: false })
}, 2000)
Taro.showToast({
title: res.data.err_msg,
icon:'none',
duration:1500
})
console.log('抢单请求:', res)
})
@ -225,6 +225,14 @@ class Home extends Component {
}, 1000);
}
// 导航去抢单页面
goToGrabOrderPage(){
Taro.navigateTo({
url:'/pages/grabOrderPage/grabOrderPage'
})
}
componentDidMount() {
// 页面加载后 得到首页的基本信息和推荐店铺的信息
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) => {
return <SwiperItem key={index} >
<View className='demanding-item'>
<View className='demanding-item' >
<View onClick={this.goToGrabOrderPage.bind(this)}>
<View className='item-tag'>
<Text className='item-tag-text'> {item.class_name}</Text>
</View>
@ -293,6 +295,7 @@ class Home extends Component {
<View className='item-name'>
业主{item.user_name}
</View>
</View>
<View className='item-button-box' onClick={this.grabOrderId.bind(this, item.sd_id)}>
<Button className='item-button' > {item.state_name === '在用' ? '抢单' : '已抢单'}</Button>
</View>
@ -332,8 +335,7 @@ class Home extends Component {
return (
<View className='home'>
{/* 抢单成功预付轻提示 */}
{grabOrderSuccessElement}
{/* 获取微信用户的信息 */}
{/* <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/myDemandSupplyEdit/myDemandSupplyEdit'
url: '/pages/mySupplyDemand/mySupplyDemand'
// url:'/pages/supplyDemandPublish/supplyDemandPublish'
// url: '/pages/mySupplyDemand/mySupplyDemand'
// url:'/pages/grabOrderPage/grabOrderPage'
url:'/pages/home/home'
})
}
componentWillReceiveProps (nextProps) {

View File

@ -19,10 +19,10 @@ class MyDemandSupplyEdit extends Component {
constructor() {
super(...arguments)
this.state = {
demandingSupplyCate: ['需求', '供应', '人才'], //供求类型选择
demandingSupplyCateSelected: '需求',// 当前供求类型
demandingSupplyState: ['上架', '下架'], // 状态选择
demandingSupplyStateSelected: '上架',// 当前状态
demandingSupplyCate: [{ name: '需求', id: '1' }, { name: '供求', id: '2' }, { name: '人才', id: '3' }], //供求类型选择,
demandingSupplyCateSelected: { name: '需求', id: '1' },// 当前供求类型
demandingSupplyState: [{ name: '上架', id: '1' }, { name: '下架', id: '0' }], // 状态选择
demandingSupplyStateSelected: { name: '上架', id: '1' },// 当前状态
title: '',
contactName: '',
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
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({})
} else {
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) {
@ -90,21 +196,29 @@ class MyDemandSupplyEdit extends Component {
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 })
}, 2000)
that.setState({
pickerImageUrl: newPickerImageUrl,
ImagesInfo: newImageInfo
})
Taro.showToast({
title: '上传成功',
icon: 'success',
duration: 1500
})
}
})
}
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 })
}, 2000)
this.state.ImagesInfo.splice(index, 1) // 删除显示的图片
this.state.pickerImageUrl.splice(index, 1)// 删除图片param
that.setState({
pockerImageUrl:this.state.pickerImageUrl,
ImagesInfo:this.state.ImagesInfo,
})
Taro.showToast({
title: '删除成功',
icon: 'success',
duration: 1500
})
}
}
@ -136,7 +250,7 @@ class MyDemandSupplyEdit extends Component {
contentChange(event) {
this.setState({ content: event.target.value })
}
goToMyDemSupPage(){
goToMyDemSupPage() {
Taro.navigateTo({
url: '/pages/mySupplyDemand/mySupplyDemand'
})
@ -144,7 +258,9 @@ class MyDemandSupplyEdit extends Component {
componentDidMount() {
// this.uploadSupplyDemand()
// console.log('this.$router.params.sdId',this.$router.params.sdId)
Taro.showLoading({title:'加载中'})
this.getSupplyDemandInfo()
}
componentWillReceiveProps(nextProps) {
console.log(this.props, nextProps)
@ -176,10 +292,10 @@ class MyDemandSupplyEdit extends Component {
<View className='page-section'>
<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='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>
@ -247,7 +363,7 @@ class MyDemandSupplyEdit extends Component {
<View className='img-container'>
<AtImagePicker
multiple
showAddBtn={this.state.pickerImageUrl.length<4}
showAddBtn={this.state.pickerImageUrl.length < 4}
files={this.state.pickerImageUrl}
onChange={this.onChangeImg.bind(this)}
onFail={this.onFail.bind(this)}
@ -259,10 +375,10 @@ class MyDemandSupplyEdit extends Component {
<View className='page-section'>
<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='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 File

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

View File

@ -14,7 +14,7 @@ class MyGoodsEdit extends Component {
constructor() {
super(...arguments)
this.state = {
shopCategoryPicker: [], // 店铺分类选项
shopCategoryList: [], // 店铺分类选项
shopCategoryCheckedPicker: { name: '选择店铺类型', id: '' },
productName: '',
productPrice: '',
@ -22,7 +22,10 @@ class MyGoodsEdit extends Component {
productDescript: '',
pickerImageUrl: [], // 上传的图片
ImagesInfo: [],// 后台传回来的图片信息
shopCategoryList: [],
goodsTypeParam: '',//商品分类参数
goodId: '',//商品id
}
}
@ -44,23 +47,25 @@ class MyGoodsEdit extends Component {
})
.then(res => {
console.log('商品详情获取成功', res)
const imageFile = res.data.goodsFiles.map((item) => {
return { url: URL.Base + item.files.file_path }
})
const selectedShopCateId=res.data.goods.shop_class_id
const selectedShopCate=this.state.shopCategoryPicker.filter(item=>{
return item.id===selectedShopCateId
const shopTypeId = res.data.goods.shop_class_id
const shopTypeName = this.state.shopCategoryList.filter(item => {
return item.id === shopTypeId
})
console.log('abc',selectedShopCate)
this.setState({
productName: res.data.goods.goods_name,
productPrice: res.data.goods.goods_price,
productUnit: res.data.goods.goods_unit,
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 => {
if (res.data.err_msg === 'success') {
this.setState({ shopCategoryList: res.data.data })
const shopCategoryInfo = res.data.data
const shopCategory = []
// 处理后台返回的店铺分类信息
@ -96,7 +101,9 @@ class MyGoodsEdit extends Component {
shopCategory.push({ id: children[child].id, name: children[child].n })
}
}
this.setState({ shopCategoryPicker: shopCategory })
this.setState({ shopCategoryList: shopCategory }, () => {
})
console.log('店铺分类目录', res)
return
}
@ -108,7 +115,13 @@ class MyGoodsEdit extends Component {
}
// 发布商品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 = []
@ -140,14 +153,15 @@ class MyGoodsEdit extends Component {
dataType: 'json',
data: {
deployType: 1,
action: 1,
action: 2,
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
shop_class_id: shop_class_id,
goods_id: goods_id,
}),
goodsFiles: JSON.stringify(uploadProductGoodFileParams)
},
@ -166,10 +180,9 @@ class MyGoodsEdit extends Component {
})
setTimeout(() => {
Taro.navigateTo({
url: '/pages/goods/goods?id=5cf3Ptn5wKQdyPpwsSe2nDKnN4QDFdz8moPTf+QIOm788Q'// 虚拟地址
url: '/pages/goods/goods?id='+this.$router.params.id
})
}, 1000);
console.log('上传商品', res)
}
)
@ -223,11 +236,16 @@ class MyGoodsEdit extends Component {
'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, ImagesInfo: newImageInfo }, () => {
that.setState({
pickerImageUrl: newPickerImageUrl,
ImagesInfo: newImageInfo
}, () => {
Taro.showToast({
title: '上传成功',
icon: 'success',
@ -238,8 +256,13 @@ class MyGoodsEdit extends Component {
})
}
if (operationType === 'remove') {
this.state.pickerImageUrl.splice(index, 1);
this.setState({ files: this.state.pickerImageUrl });
this.state.pickerImageUrl.splice(index, 1);// 删除图片param
this.state.ImagesInfo.splice(index, 1) // 删除显示的图片
this.setState({
pickerImageUrl: this.state.pickerImageUrl,
ImagesInfo: this.state.ImagesInfo
});
Taro.showToast({
title: '删除成功',
@ -253,9 +276,7 @@ class MyGoodsEdit extends Component {
onFail(mes) {
console.log(mes)
}
// 删除图片
onImageClick(index) {
}
onClickUploadGoods() {
if (this.state.productName && this.state.productPrice && this.state.productUnit && this.state.ImagesInfo.length && this.state.shopCategoryCheckedPicker.id) {
Taro.showLoading({ title: '保存中' }).then(() => {
@ -265,7 +286,9 @@ class MyGoodsEdit extends Component {
goods_price: this.state.productPrice,
goods_unit: this.state.productUnit,
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);
})
@ -280,7 +303,7 @@ class MyGoodsEdit extends Component {
}
shopCategoryChanged(e) {
this.setState({
shopCategoryCheckedPicker: this.state.shopCategoryPicker[e.detail.value]
shopCategoryCheckedPicker: this.state.shopCategoryList[e.detail.value]
}, () => {
console.log(this.state.shopCategoryCheckedPicker)
})
@ -296,6 +319,7 @@ class MyGoodsEdit extends Component {
this.getShopCateList().then(() => {
this.getGoodsInfo()
})
}
@ -315,11 +339,7 @@ class MyGoodsEdit extends Component {
return (
<View className='goods-publish'>
<View className='goods-category'>
<View className='input-box'>
<Text className='require'>*</Text>
<AtInput
@ -370,7 +390,7 @@ class MyGoodsEdit extends Component {
<View className='shoptype-box'>
{/* 店铺分类 */}
<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'>
<Text className='require'>*</Text>
<Text className='title'> 店铺分类</Text>

View File

@ -1,6 +1,6 @@
import Taro, { Component } from '@tarojs/taro'
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 CopyrightComponent from '../../component/copyrightComponent/copyrightComponent'
@ -25,17 +25,17 @@ class MySupplyDemand extends Component {
startDateSel: '',
endDateSel: '',
allDemandSupply: [],
totalDemandSupply: '',
isConfirmWindow: false, // 是否显示确认弹窗
demandSupplyItemName: '',// 确认框提示时 使用的供求名
demandSupplyId: '',// 删除我的供求时的供求id
totalDemandSupply:'',//所有供求
currentPage:1 //当前页数
}
}
//获取我的供求API
getMySupplyDemand({ curr_page = 1, page_count = 20 }) {
getMySupplyDemand({ curr_page = 1, page_count = 10 }) {
Taro.request({
url: URL.MySupplyDemand,
method: 'POST',
@ -95,10 +95,11 @@ class MySupplyDemand extends Component {
})
}
onSearchButtonHandler(){
Taro.showLoading({title:'加载中'}) .then(() => {
onSearchButtonHandler() {
Taro.showLoading({ title: '加载中' }).then(() => {
setTimeout(() => {
this.searchDemandSupply({})
this.setState({currentPage:1})
}, 1000);
})
@ -211,32 +212,35 @@ class MySupplyDemand extends Component {
// 编辑我的供求
// 跳转到我的供求编辑页面
goToMyDSEditPage() {
goToMyDSEditPage(sdId) {
Taro.navigateTo({
url: '/pages/myDemandSupplyEdit/myDemandSupplyEdit'
url: '/pages/myDemandSupplyEdit/myDemandSupplyEdit?sdId=' + sdId
})
}
// 转到供求查看页面
goToSupplyDemandPage(){
goToSupplyDemandPage(sdId) {
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) {
console.log(this.props, nextProps)
}
componentDidMount() {
Taro.showLoading({title:'加载中'}) .then(() => {
Taro.showLoading({ title: '加载中' }).then(() => {
this.getMySupplyDemand({})
})
}
componentWillUnmount() { }
@ -257,7 +261,12 @@ class MySupplyDemand extends Component {
<AtModalAction> <Button onClick={this.handleWindowModCancel.bind(this)}>取消</Button> <Button className='orange' onClick={this.handleWindowConfirm.bind(this)}></Button> </AtModalAction>
</AtModal>
const demandSupplyElementArray = this.state.allDemandSupply.length ? this.state.allDemandSupply.map((item, index) => {
const SDState=this.state.demandSupplyState.filter(stateItem=>{
return stateItem.id==item.state
})[0].name
return <View key={index} className='info-container'>
<View className='type'>
<Text className='title'>需求类型</Text>
@ -277,17 +286,17 @@ class MySupplyDemand extends Component {
</View>
<View className='demand-status'>
<Text className='title'>需求状态</Text>
<Text className='info'>{item.state}</Text>
<Text className='info'>{SDState}</Text>
</View>
<View className='update-time'>
<Text className='title'>更新时间</Text>
<Text className='info'>{item.update_date}</Text>
</View>
<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>
</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>
</View>
<View className='button' onClick={this.handleOnDelete.bind(this, item.sd_id, item.sd_title)}>
@ -385,6 +394,16 @@ class MySupplyDemand extends Component {
<View className='info-box'>
{demandSupplyElementArray}
</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

@ -133,3 +133,6 @@ $themeColor:#FF7142;
font-size: 35px;
}
.pagination-box{
margin: 50px 0;
}

View File

@ -19,10 +19,10 @@ class SupplyDemand extends Component {
constructor() {
super(...arguments)
this.state = {
demandingSupplyCate: [{name:'需求',id:1}, {name:'供应',id:2}, {name:'人才',id:3}], //供求类型选择
demandingSupplyCateSelected: {name:'需求',id:1},// 当前供求类型
demandingSupplyState: [{name:'上架',id:1}, {name:'下架',id:0}], // 状态选择
demandingSupplyStateSelected: {name:'上架',id:1},// 当前状态
demandingSupplyCate: [{ name: '需求', id: '1' }, { name: '供应', id: '2' }, { name: '人才', id: '3' }], //供求类型选择
demandingSupplyCateSelected: { name: '需求', id: '1' },// 当前供求类型
demandingSupplyState: [{ name: '上架', id: '1' }, { name: '下架', id: '0' }], // 状态选择
demandingSupplyStateSelected: { name: '上架', id: '1' },// 当前状态
title: '',
contactName: '',
contactNumber: '',
@ -30,11 +30,8 @@ class SupplyDemand extends Component {
content: '',
pickerImageUrl: [], // 上传的图片
ImagesInfo: [],// 后台传回来的图片信息
isUploadImageSuccess: false,
uploadImageTextTip: '',
isFormCompleted: false,
isUploadDemSupSuccess: false,
uploadDemSupTextTip: '',
}
}
@ -42,35 +39,35 @@ class SupplyDemand extends Component {
// 上传供求api
uploadSupplyDemand() {
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) {
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})
if (this.state.demandingSupplyCateSelected && this.state.title && this.state.contactName && this.state.contactNumber && this.state.content && this.state.demandingSupplyStateSelected) {
this.uploadDemSup({})
} else {
this.setState({ uploadDemSupTextTip: '请填写完表格', isUploadDemSupSuccess: true }, () => {
setTimeout(() => {
this.setState({ isUploadDemSupSuccess: false })
}, 2000)
Taro.showToast({
title:'请填写完表格',
icon:'none',
duration:1500
})
}
}
// 这个需要写一个uploadDemSup 上传供求 的api
uploadDemSup({sd_type="2",sd_title="第4方",user_name="郑燕彬",user_phone="13509302402",user_address="",sd_desc="但是发射点",state="1"}){
const file_path=[];
this.state.ImagesInfo.forEach((item)=>{
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
thumb_path: item.thumb_path
})
})
Taro.request({
@ -87,7 +84,8 @@ class SupplyDemand extends Component {
user_address: user_address,
sd_desc: sd_desc,
state: state,
file_path:file_path})
file_path: file_path
})
},
header: {
'content-type': 'application/x-www-form-urlencoded',
@ -97,18 +95,24 @@ class SupplyDemand extends Component {
})
.then(res => {
console.log('上传供求', res)
if(res.data.err_msg==='success'){
console.log(11111)
this.setState({ uploadDemSupTextTip: '上传成功', isUploadDemSupSuccess: true }, () => {
if (res.data.err_msg === 'success') {
Taro.showToast({
title: '上传成功',
icon: 'success',
duration: 1500
}).then(() => {
setTimeout(() => {
this.setState({ isUploadDemSupSuccess: false })
Taro.navigateTo({
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,
filePath: files[files.length - 1].url,
name: 'file',
header: {
'content-type': 'multipart/form-data; boundary=----WebKitFormBoundaryAWxeadaAVmRVQCiz',
'Cookie': 'PFWSSS=' + Taro.getStorageSync('session_id'),
@ -136,21 +139,28 @@ class SupplyDemand extends Component {
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 })
}, 2000)
that.setState({ pickerImageUrl: newPickerImageUrl, ImagesInfo: newImageInfo })
Taro.showToast({
title: '上传成功',
icon: 'success',
duration: 1500
})
}
})
}
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 })
}, 2000)
this.state.ImagesInfo.splice(index, 1) // 删除显示的图片
this.state.pickerImageUrl.splice(index, 1)// 删除图片param
that.setState({
pockerImageUrl:this.state.pickerImageUrl,
ImagesInfo:this.state.ImagesInfo,
})
Taro.showToast({
title: '删除成功',
icon: 'success',
duration: 1500
})
}
}
@ -182,7 +192,7 @@ class SupplyDemand extends Component {
contentChange(event) {
this.setState({ content: event.target.value })
}
goToMyDemSupPage(){
goToMyDemSupPage() {
Taro.navigateTo({
url: '/pages/mySupplyDemand/mySupplyDemand'
})
@ -203,23 +213,11 @@ class SupplyDemand extends Component {
componentDidHide() { }
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 (
<View className='supply-demand'>
{/* 图片上传模态框 */}
{imageUploadSuccessElement}
{/* 商品发布模态框 */}
{demandSupplyUploadSuccessElement}
<View className='page-section'>
<View>
@ -264,7 +262,7 @@ class SupplyDemand extends Component {
</View>
<View className='demanding-box'>
<View className='title-box'>
<Text className='title'><Text className='require'>*</Text>:</Text>
<Text className='title'>联系地址:</Text>
</View>
<AtTextarea
@ -294,7 +292,7 @@ class SupplyDemand extends Component {
<View className='img-container'>
<AtImagePicker
multiple
showAddBtn={this.state.pickerImageUrl.length<4}
showAddBtn={this.state.pickerImageUrl.length < 4}
files={this.state.pickerImageUrl}
onChange={this.onChangeImg.bind(this)}
onFail={this.onFail.bind(this)}

View File

@ -1,7 +1,10 @@
//supplyDemandItemView
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'
@ -10,27 +13,168 @@ import './supplyDemandView.scss'
class SupplyDemandView extends Component {
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: [],
}
}
//获取商品信息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',// 供求发布页面
// })
}
componentWillReceiveProps (nextProps) {
goToMySDPage() {
Taro.navigateTo({
url: '/pages/mySupplyDemand/mySupplyDemand',//我的供求页面
})
}
deleteSD() {
console.log('删除供求')
}
componentDidMount() {
Taro.showLoading({title:'加载中'})
this.getSupplyDemandInfo()
}
componentWillReceiveProps(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 (
<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 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
SearchDemandSupply: LOCALURL + 'Supply-myList',// 搜索我的供求接口
DeleteDemandSupply: LOCALURL + 'Supply-delete',// 删除我的供求接口
GetSupplyDemandInfo: LOCALURL + 'Supply-wxEditDeploy',// 获取单个供求信息
// 商品编辑页面 Goods-wxEditPhoneDeploy
GetProductInfo: LOCALURL + 'Goods-wxEditPhoneDeploy',// 获取商品信息
GetProductInfo: LOCALURL + 'Goods-wxEditPhoneDeploy',// 获取单个商品信息

View File

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