添加 我的商品列表页面, 我的供求页面

This commit is contained in:
郑茂强 2018-12-26 17:32:35 +08:00
parent 48894c62fe
commit 104c844b14
12 changed files with 834 additions and 98 deletions

View File

@ -18,14 +18,16 @@ class App extends Component {
config = {
pages: [
'pages/index/index',
'pages/home/home',
'pages/shop/shop',
'pages/goods/goods',
'pages/goodsPublish/goodsPublish',
'pages/supplyDemandPublish/supplyDemandPublish',
'pages/mySupplyDemand/mySupplyDemand',
'pages/allDemanding/allDemanding',
'pages/index/index', // index页面
'pages/home/home',//首页
'pages/shop/shop',//店铺页面
'pages/goods/goods',// 商品页面
'pages/goodsPublish/goodsPublish',// 商品发布页面
'pages/supplyDemandPublish/supplyDemandPublish',// 供求发布页面
'pages/mySupplyDemand/mySupplyDemand',// 我的供求页面
'pages/allDemanding/allDemanding',// 所有供求页面
'pages/myGoodList/myGoodList',// 我的商品列表页面
'pages/myDemandSupplyEdit/myDemandSupplyEdit',// 我的供求编辑页面
// 'pages/shopDescription/shopDescription',
],
window: {

View File

@ -231,7 +231,7 @@ class GoodsPublish extends Component {
const that = this
if (operationType === 'add') {
Taro.uploadFile({
url: URL.UploadPorductImage,
url: URL.UploadGoodsPorductImage,
filePath: files[files.length - 1].url,
name: 'file',
formData: {
@ -297,6 +297,13 @@ class GoodsPublish extends Component {
console.log(this.state.shopCategoryCheckedPicker)
})
}
goToMyGoodListPage(){
Taro.navigateTo({
url: '/pages/myGoodList/myGoodList'
})
}
componentDidMount() {
@ -563,7 +570,7 @@ class GoodsPublish extends Component {
{/* <View className='button'>
<AtButton type='primary' className='button-a' size='small' >发布并新增</AtButton>
</View> */}
<View className='button'>
<View className='button' onClick={this.goToMyGoodListPage.bind(this)}>
<AtButton type='primary' className='button-a' size='small'>商品列表</AtButton>
</View>

View File

@ -20,6 +20,7 @@ import './index.scss'
dispatch(asyncAdd())
}
}))
class Index extends Component {
config = {
navigationBarTitleText: '首页'
@ -29,6 +30,8 @@ class Index extends Component {
componentDidMount(){
Taro.navigateTo({
// url: '/pages/goodsPublish/goodsPublish'
// url: '/pages/myGoodList/myGoodList'
// url: '/pages/myDemandSupplyEdit/myDemandSupplyEdit'
url: '/pages/home/home'
// url:'/pages/supplyDemandPublish/supplyDemandPublish'
})

View File

@ -0,0 +1,293 @@
import Taro, { Component } from '@tarojs/taro'
import { View, Text } from '@tarojs/components'
import { AtInput, AtImagePicker, AtTextarea, AtButton, Picker, AtToast } from 'taro-ui'
import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent'
import URL from '../../serviceAPI.config'
import './myDemandSupplyEdit.scss'
class MyDemandSupplyEdit extends Component {
config = {
navigationBarTitleText: '我的供求编辑'
}
constructor() {
super(...arguments)
this.state = {
demandingSupplyCate: ['需求', '供应', '人才'], //供求类型选择
demandingSupplyCateSelected: '需求',// 当前供求类型
demandingSupplyState: ['上架', '下架'], // 状态选择
demandingSupplyStateSelected: '上架',// 当前状态
title: '',
contactName: '',
contactNumber: '',
contactAddress: '',
content: '',
pickerImageUrl: [], // 上传的图片
ImagesInfo: [],// 后台传回来的图片信息
isUploadImageSuccess: false,
uploadImageTextTip: '',
isFormCompleted: false,
isUploadDemSupSuccess: false,
uploadDemSupTextTip: '',
}
}
// 上传供求api
uploadSupplyDemand() {
if (this.state.demandingSupplyCateSelected && this.state.title && this.state.contactName && this.state.contactNumber && this.state.contactAddress && this.state.content && this.state.demandingSupplyStateSelected) {
this.uploadDemSup({})
} else {
this.setState({ uploadDemSupTextTip: '请填写完表格', isUploadDemSupSuccess: true }, () => {
setTimeout(() => {
this.setState({ isUploadDemSupSuccess: false })
}, 2000)
})
}
// Taro.request({
// url: URL.UploadSupplyDemand,
// method: 'POST',
// dataType: 'json',
// data: {
// action: 1,
// sdInfo: JSON.stringify({ "sd_type": "2", "sd_title": "534523", "user_name": "杨夕兵", "user_phone": "18950295811", "user_address": "2342", "sd_desc": "42342", "state": "1", "file_path": [{ "file_name": "bg3.jpg", "file_size": "212678", "file_path": "Uploads/supply/user_27/201812/38bf91f30d215bbefb2686f2401217a6.jpg", "thumb_path": "Uploads/supply/user_27/201812/thumb/38bf91f30d215bbefb2686f2401217a6_200X200.jpg" }] })
// },
// header: {
// 'content-type': 'application/x-www-form-urlencoded',
// }
// })
// .then(res => {
// console.log('上传供求', res)
// }
// )
}
// 这个需要写一个uploadDemSup 上传供求 的api
// 上传图片
onChangeImg(files, operationType, index) {
const that = this
if (operationType === 'add') {
Taro.uploadFile({
url: URL.UploadDSPorductImage,
filePath: files[files.length - 1].url,
name: 'file',
header: {
'content-type': 'multipart/form-data',
'Cookie': 'PFWSSS=' + Taro.getStorageSync('session_id'),
'X-Requested-With': 'XMLHttpRequest'
},
success(response) {
const data = JSON.parse(response.data)
const imagePath = URL.Base + data.file_path
const newPickerImageUrl = that.state.pickerImageUrl.concat({ url: imagePath })
const newImageInfo = that.state.ImagesInfo.concat(data)
that.setState({ pickerImageUrl: newPickerImageUrl, isUploadImageSuccess: true, uploadImageTextTip: '图片上传成功', ImagesInfo: newImageInfo }, () => {
setTimeout(() => {
that.setState({ isUploadImageSuccess: false })
}, 2000)
})
}
})
}
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)
})
}
}
// 修改供求类型
demandingSupplyCate = e => {
this.setState({
demandingSupplyCateSelected: this.state.demandingSupplyCate[e.detail.value]
})
}
// 修改供求状态
demSupplyStateChange = e => {
this.setState({
demandingSupplyStateSelected: this.state.demandingSupplyState[e.detail.value]
})
}
//改标题
titleChange(event) {
this.setState({ title: event })
}
contactNameChange(event) {
this.setState({ contactName: event })
}
contactNumberChange(event) {
this.setState({ contactNumber: event })
}
contactAddressChange(event) {
this.setState({ contactAddress: event.target.value })
}
contentChange(event) {
this.setState({ content: event.target.value })
}
goToMyDemSupPage(){
Taro.navigateTo({
url: '/pages/mySupplyDemand/mySupplyDemand'
})
}
componentDidMount() {
// this.uploadSupplyDemand()
}
componentWillReceiveProps(nextProps) {
console.log(this.props, nextProps)
}
componentWillUnmount() { }
componentDidShow() { }
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>
<Picker mode='selector' 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>
</View>
</View>
</Picker>
</View>
</View>
<View className='border-box'>
<Text className='require'>*</Text><AtInput
name='value'
title='需求标题:'
type='text'
value={this.state.title}
onChange={this.titleChange.bind(this)}
/>
</View>
<View className='input-box'>
<Text className='require'>*</Text>
<AtInput
name='value'
title='联系人:'
type='text'
value={this.state.contactName}
onChange={this.contactNameChange.bind(this)}
/>
</View>
<View className='input-box'>
<Text className='require'>*</Text>
<AtInput
name='value'
title='联系电话:'
type='number'
value={this.state.contactNumber}
onChange={this.contactNumberChange.bind(this)}
/>
</View>
<View className='demanding-box'>
<View className='title-box'>
<Text className='title'><Text className='require'>*</Text>:</Text>
</View>
<AtTextarea
value={this.state.contactAddress}
onChange={this.contactAddressChange.bind(this)}
maxlength='200'
placeholder='联系地址'
/>
</View>
<View className='demanding-box'>
<View className='title-box'>
<Text className='title'><Text className='require'>*</Text>:</Text>
</View>
<AtTextarea
value={this.state.content}
onChange={this.contentChange.bind(this)}
maxlength='200'
placeholder=''
/>
</View>
<View className='img-box'>
<View className='title-box'>
<Text className='title'>需求图片:</Text>
<View className='warn'>(最多4张)</View>
</View>
<View className='img-container'>
<AtImagePicker
multiple
showAddBtn={this.state.pickerImageUrl.length<4}
files={this.state.pickerImageUrl}
onChange={this.onChangeImg.bind(this)}
onFail={this.onFail.bind(this)}
onImageClick={this.onImageClick.bind(this)}
/>
</View>
</View>
<View className='page-section'>
<View>
<Picker mode='selector' 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>
</View>
</View>
</Picker>
</View>
</View>
<View className='button-box'>
<View className='button' onClick={this.uploadSupplyDemand.bind(this)}>
<AtButton type='primary' size='small'>保存</AtButton>
</View>
{/* <View className='button'>
<AtButton type='primary' className='button-a' size='small'>保存并新增</AtButton>
</View> */}
<View className='button' onClick={this.goToMyDemSupPage.bind(this)}>
<AtButton type='primary' className='button-a' size='small'>我的供求</AtButton>
</View>
</View>
<CopyrightComponent></CopyrightComponent>
</View>
)
}
}
export default MyDemandSupplyEdit

View File

@ -0,0 +1,80 @@
$themeColor:#FF7142;
.supply-demand{
padding: 10px 20px;
.border-box{
border-bottom: 1Px solid #d6e4ef;
display: flex
}
.at-input__container{
color:black;
font-weight: bold;
.at-input__input{
font-weight: normal
}
}
.img-box{
margin-top:10Px;
.img-container{
border: 1Px solid #d6e4ef;
border-radius:8rpx;
}
}
.button-box{
display: flex;
flex-wrap: nowrap;
flex-direction: row;
margin: 40px 0;
padding: 0 120px;
.button{
flex:1;
text-align: center;
.at-button--primary{
background-color:$themeColor,;
border:1PX solid $themeColor,;
}
.button-a{
background-color:#5cb85c;
border:1PX solid #5cb85c;
}
}
}
}
.title-box{
.title{
//color: #333;
margin-right:16rpx;
width:172rpx;
font-size:32rpx;
line-height:1.5;
vertical-align:middle;
text-align:left;
font-weight: bold;
}
}
.warn{
font-size: 25px;
color:red;
}
.page-section{
border-bottom: 1Px solid #d6e4ef;
}
.selected{
display: inline-block;
margin-left: 20%;
font-size: 32rpx
}
.input-box{
border-bottom: 1Px solid #d6e4ef;
display: flex;
}
.require{
color:red;
line-height:100rpx;
}

View File

@ -0,0 +1,176 @@
import Taro, { Component } from '@tarojs/taro'
import { View } from '@tarojs/components'
import { AtInput, Text, AtButton, AtIcon, Picker, Image } from 'taro-ui'
import copyrightComponent from '../../component/copyrightComponent/copyrightComponent'
import './myGoodList.scss'
class MyGoodList extends Component {
config = {
navigationBarTitleText: '我的商品列表'
}
constructor() {
super(...arguments)
this.state = {
productName: '',
lowestPrice: '',
heightestPrice: '',
minimumSold: '',
maximumSold: '',
productId: '',
productCate: ['全部类目', '衣柜', '人工服务', '开料机', '书柜', '橱柜', '更衣室'],
productCateSelected: '全部类目'
}
}
productNameChange(event) {
this.setState({ productName: event })
}
productIdChange(event) {
this.setState({ productId: event })
}
lowestPriceChange(event) {
this.setState({ lowestPrice: event })
}
heightestPriceChange(event) {
this.setState({ heightestPrice: event })
}
minimumSoldChange(event) {
this.setState({ minimumSold: event })
}
maximumSoldChange(event) {
this.setState({ maximumSold: event })
}
productCateChange = e => {
this.setState({
productCateSelected: this.state.productCate[e.detail.value]
})
}
componentDidMount() {
}
componentWillReceiveProps(nextProps) {
console.log(this.props, nextProps)
}
componentWillUnmount() { }
componentDidShow() { }
componentDidHide() { }
render() {
//等待接口数据
const goodListElementArray = <View className='good-container'>
<View className='img-box'>
<Image mode='aspectFit' className='img' style='height:50px;width:50px' src='http://192.168.1.230/Uploads/zone/user_1295/201812/thumb/2badb6ea3c1e4eb058873ab2086110ef_400X400.jpg' />
</View>
<View className='name-box'>名称</View>
<View className='price-box'>12.00</View>
<View className='quantity-box'>3243</View>
<View className='button-box1'>
<AtButton type='primary' className='button-a' size='small'>
编辑商品</AtButton>
</View>
</View>
return (
<View className='MyGoodList'>
<View className='border-box'>
<AtInput
name='value'
title='宝贝名称:'
type='text'
value={this.state.productName}
onChange={this.productNameChange.bind(this)}
/>
</View>
<View className='input-box'>
<AtInput
name='value'
title='最低价:'
className='input'
type='number'
value={this.state.lowestPrice}
onChange={this.lowestPriceChange.bind(this)}
/>
<AtInput
name='value'
title='最高价:'
className='input'
type='number'
value={this.state.heightestPrice}
onChange={this.heightestPriceChange.bind(this)}
/>
</View>
<View className='border-box'>
<AtInput
name='value'
title='最低销量:'
className='input'
type='number'
value={this.state.minimumSold}
onChange={this.minimumSoldChange.bind(this)}
/>
<AtInput
name='value'
title='最高销量:'
className='input'
type='number'
value={this.state.maximumSold}
onChange={this.maximumSoldChange.bind(this)}
/>
</View>
<View className='border-box'>
<AtInput
border={false}
name='value'
title='商品编码:'
type='text'
value={this.state.productId}
onChange={this.productIdChange.bind(this)}
/>
</View>
<View className='page-section'>
<Picker mode='selector' range={this.state.productCate} onChange={this.productCateChange.bind(this)}>
<View className='picker'>
<View className='title-box'>
<Text className='title'>宝贝类目:</Text>
<Text className='selected'>{this.state.productCateSelected}</Text>
</View>
</View>
</Picker>
</View>
<View className='button-box'>
<View className='button' onClick={this.searchDemandSupply.bind(this)}>
<AtButton type='primary' size='small'>
<AtIcon value='search' size='12' color='white'></AtIcon>
搜索</AtButton>
</View>
<View className='button' onClick={this.addDemandSupply.bind(this)}>
<AtButton type='primary' className='button-a' size='small'>
清空条件</AtButton>
</View>
</View>
<View className='mygoodlist-container'>
{goodListElementArray}
{goodListElementArray}
{goodListElementArray}
{goodListElementArray}
</View>
<copyrightComponent></copyrightComponent>
</View>
)
}
}
export default MyGoodList

View File

@ -0,0 +1,112 @@
$themeColor:#FF7142;
.MyGoodList{
padding: 10px 20px;
.at-input__container{
color:black;
font-weight: bold;
.at-input__input{
font-weight: normal
}
}
.border-box {
border-bottom: 1Px solid #d6e4ef;
display: flex;
}
.input-box{
display: flex;
}
.page-section{
border-bottom: 1Px solid #d6e4ef;
height: 100rpx;
.title-box{
line-height: 100rpx;
.title{
//color: #333;
margin-right:16rpx;
width:172rpx;
font-size:32rpx;
line-height:1.5;
vertical-align:middle;
font-weight: bold;
}
.selected{
display:inline-block;
margin-left:30%;
font-size:32rpx;
}
}
}
.button-box{
display: flex;
flex-wrap: nowrap;
flex-direction: row;
margin: 40px 0;
padding: 0 120px;
.button{
flex:1;
text-align: center;
.at-button--primary{
background-color:$themeColor;
border:1PX solid $themeColor;
}
.button-a{
background-color:#5cb85c;
border:1PX solid #5cb85c;
}
}
}
.mygoodlist-container{
border-top:1px solid #ddd;
.good-container{
border: 1px solid #ddd;
border-top: 0px;
display: flex;
flex-wrap: nowrap;
flex-direction: row;
font-size: 30px;
height: 200px;
line-height: 200px;
text-align: center;
color:#717592;
.img-box{
flex:1;
.img{
margin-top: 25%;
}
}
.name-box{
flex:1;
color: #0579c6
}
.price-box{
flex:1;
}
.quantity-box{
flex:1;
}
.button-box1{
flex:1;
padding-top: 3%;
padding-right: 2%;
.button-a{
background-color:$themeColor;
border:1PX solid $themeColor;
}
}
}
}
}

View File

@ -1,6 +1,6 @@
import Taro, { Component } from '@tarojs/taro'
import { View, Text } from '@tarojs/components'
import { AtInput, AtButton, Picker, AtIcon, AtModal, AtToast } from 'taro-ui'
import { View, Text, Button } from '@tarojs/components'
import { AtInput, AtButton, Picker, AtIcon, AtModal, AtToast, AtModalHeader, AtModalContent, AtModalAction } from 'taro-ui'
import URL from '../../serviceAPI.config'
import copyrightComponent from '../../component/copyrightComponent/copyrightComponent'
@ -9,7 +9,6 @@ import copyrightComponent from '../../component/copyrightComponent/copyrightComp
import './mySupplyDemand.scss'
console.log('hi')
class MySupplyDemand extends Component {
config = {
@ -23,8 +22,8 @@ class MySupplyDemand extends Component {
demandSupplyState: ['全部', '上架', '下架'],
demandSupplyStatesSelected: '全部',
title: '',
startDateSel: '2018-04-22',
endDateSel: '2018-04-22',
startDateSel: '',
endDateSel: '',
allDemandSupply: [],
totalDemandSupply: '',
isToast: false,// 是否显示轻提示
@ -56,14 +55,14 @@ class MySupplyDemand extends Component {
}
}).then(res => {
if (res.data.err_msg === "success") {
// 判断是否有res.data.supplys 如果没有就是空数组[]
this.setState({ allDemandSupply: res.data.supplys?res.data.supplys:[], totalDemandSupply: res.data.count })
// 判断是否有res.data.supplys 如果没有就是空数组[]
this.setState({ allDemandSupply: res.data.supplys ? res.data.supplys : [], totalDemandSupply: res.data.count })
}
})
}
//搜索我的供求api
searchDemandSupply({ curr_page = 1, page_count = 20, sd_type = "2", state = "1", sd_title = "1", update_dateL = "2018-12-18", update_dateU = "2018-12-20" }) {
searchDemandSupply({ curr_page = 1, page_count = 20, sd_type = "2", state = "1", sd_title = this.state.title, update_dateL = this.state.startDateSel, update_dateU = this.state.endDateSel }) {
Taro.request({
url: URL.SearchDemandSupply,
method: 'POST',
@ -119,11 +118,11 @@ class MySupplyDemand extends Component {
this.getMySupplyDemand({})
}, 2000)
})
}else{
} else {
this.setState({ toastContent: res.data.err_msg, isToast: true }, () => {
setTimeout(() => {
this.setState({ isToast: false })
}, 2000)
})
}
@ -198,6 +197,15 @@ class MySupplyDemand extends Component {
// 编辑我的供求
// 跳转到我的供求编辑页面
goToMyDSEditPage(){
Taro.navigateTo({
url: '/pages/myDemandSupplyEdit/myDemandSupplyEdit'
})
}
//查看我的供求
componentWillReceiveProps(nextProps) {
@ -214,22 +222,21 @@ class MySupplyDemand extends Component {
componentDidHide() { }
render() {
// 提示模态弹窗element
const modalMessageConfirmElement = <AtModal className='modal'
isOpened={this.state.isConfirmWindow}
title='提示'
cancelText='取消'
confirmText='确认'
onClose={this.handleWindowModClose}
onCancel={this.handleWindowModCancel}
onConfirm={this.handleWindowConfirm.bind(this)}
content={'确认删除' + this.state.demandSupplyItemName + ''}
/>
const modalMessageConfirmElement = <AtModal isOpened={this.state.isConfirmWindow}>
<AtModalHeader>提示</AtModalHeader>
<AtModalContent>
确认删除{this.state.demandSupplyItemName}
</AtModalContent>
<AtModalAction> <Button onClick={this.handleWindowModCancel.bind(this)}>取消</Button> <Button className='orange' onClick={this.handleWindowConfirm.bind(this)}></Button> </AtModalAction>
</AtModal>
// 轻提示
const toastElement = <AtToast
isOpened={this.state.isToast}
text={this.state.toastContent}
duration={2000}
isOpened={this.state.isToast}
text={this.state.toastContent}
duration={2000}
></AtToast>
const demandSupplyElementArray = this.state.allDemandSupply.length ? this.state.allDemandSupply.map((item, index) => {
return <View key={index} className='info-container'>
@ -261,7 +268,7 @@ class MySupplyDemand extends Component {
<View className='button'>
<AtButton type='primary' size='small'>查看</AtButton>
</View>
<View className='button'>
<View className='button'onClick={this.goToMyDSEditPage.bind(this)} >
<AtButton type='primary' size='small'>编辑</AtButton>
</View>
<View className='button' onClick={this.handleOnDelete.bind(this, item.sd_id, item.sd_title)}>
@ -280,9 +287,9 @@ class MySupplyDemand extends Component {
{modalMessageConfirmElement}
{/* 轻提示 */}
{toastElement}
{/* 供求类型 */}
<View className='page-section'>
<View>
@ -313,12 +320,12 @@ class MySupplyDemand extends Component {
<View className='input-box'>
<Text className='require'>*</Text>
<AtInput
name='value'
title='供求标题:'
placeholder='供求标题·'
type='text'
value={this.state.title}
onChange={this.titleChange.bind(this)}
name='value'
title='供求标题:'
placeholder='供求标题·'
type='text'
value={this.state.title}
onChange={this.titleChange.bind(this)}
/>
</View>
{/* 开始和结束日期 */}
@ -332,7 +339,7 @@ class MySupplyDemand extends Component {
</View>
</Picker>
<Picker className='picker-container' mode='date' start={this.state.startDateSel} onChange={this.onEndDateChange}>
<Picker className='picker-container' mode='date' start={this.state.startDateSel} onChange={this.onEndDateChange}>
<View className='picker'>
<View className='title-box'>
<Text className='title'><Text className='require'>*</Text>:</Text> <Text className='selected'>{this.state.endDateSel}</Text>

View File

@ -1,6 +1,6 @@
import Taro, { Component } from '@tarojs/taro'
import { View, Button, Text, Image } from '@tarojs/components'
import { AtTag, AtIcon, AtPagination, AtActionSheet, AtActionSheetItem } from 'taro-ui'
import { AtTag, AtIcon, AtPagination } from 'taro-ui'
import URL from '../../serviceAPI.config'

View File

@ -41,8 +41,16 @@ 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({})
this.uploadDemSup({
sd_type:"2",
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:"1"})
} else {
this.setState({ uploadDemSupTextTip: '请填写完表格', isUploadDemSupSuccess: true }, () => {
setTimeout(() => {
@ -51,25 +59,62 @@ class SupplyDemand extends Component {
})
}
// Taro.request({
// url: URL.UploadSupplyDemand,
// method: 'POST',
// dataType: 'json',
// data: {
// action: 1,
// sdInfo: JSON.stringify({ "sd_type": "2", "sd_title": "534523", "user_name": "杨夕兵", "user_phone": "18950295811", "user_address": "2342", "sd_desc": "42342", "state": "1", "file_path": [{ "file_name": "bg3.jpg", "file_size": "212678", "file_path": "Uploads/supply/user_27/201812/38bf91f30d215bbefb2686f2401217a6.jpg", "thumb_path": "Uploads/supply/user_27/201812/thumb/38bf91f30d215bbefb2686f2401217a6_200X200.jpg" }] })
// },
// header: {
// 'content-type': 'application/x-www-form-urlencoded',
// }
// })
// .then(res => {
// console.log('上传供求', res)
// }
// )
}
// 这个需要写一个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)=>{
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: 1,
sdInfo: JSON.stringify({
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'){
console.log(11111)
this.setState({ uploadDemSupTextTip: '上传成功', isUploadDemSupSuccess: true }, () => {
setTimeout(() => {
this.setState({ isUploadDemSupSuccess: false })
Taro.navigateTo({
url: '/pages/mySupplyDemand/mySupplyDemand'
})
}, 2000)
})
}else{
console.log('上传供求失败')
}
}
)
}
// 上传图片
@ -77,14 +122,12 @@ class SupplyDemand extends Component {
const that = this
if (operationType === 'add') {
Taro.uploadFile({
url: URL.UploadPorductImage,
url: URL.UploadDSPorductImage,
filePath: files[files.length - 1].url,
name: 'file',
formData: {
user: 'test'
},
header: {
'content-type': 'multipart/form-data',
'content-type': 'multipart/form-data; boundary=----WebKitFormBoundaryAWxeadaAVmRVQCiz',
'Cookie': 'PFWSSS=' + Taro.getStorageSync('session_id'),
'X-Requested-With': 'XMLHttpRequest'
},
@ -170,6 +213,7 @@ class SupplyDemand extends Component {
text={this.state.uploadDemSupTextTip}
duration={2000}
></AtToast>
return (
<View className='supply-demand'>
{/* 图片上传模态框 */}
@ -277,16 +321,13 @@ class SupplyDemand extends Component {
<View className='button' onClick={this.uploadSupplyDemand.bind(this)}>
<AtButton type='primary' size='small'>发布</AtButton>
</View>
<View className='button'>
{/* <View className='button'>
<AtButton type='primary' className='button-a' size='small'>发布并新增</AtButton>
</View>
</View> */}
<View className='button' onClick={this.goToMyDemSupPage.bind(this)}>
<AtButton type='primary' className='button-a' size='small'>我的供求</AtButton>
</View>
</View>
<copyrightComponent></copyrightComponent>

View File

@ -1,34 +1,40 @@
const LOCALURL = "http://192.168.1.230/"
const URL = {
Base:LOCALURL,
Login: LOCALURL + 'Applet-login', //登入接口
ShopWxStore: LOCALURL + 'Shop-wxStore', //商城首页信息
ShopSupplyShops: LOCALURL + 'Shop-supplyShops',// 商城店铺信息
// 店铺信息
GoodsSearch: LOCALURL + 'GoodsSearch-search',// 店铺页面的信息
GetSearchParam: LOCALURL + 'GoodsSearch-getSearchParam',// sidebar筛选的字段
GetShopCategoryList: LOCALURL + 'Shop-ajaxShopCartgory',// 店铺内分类目录
GetProductCategoryList: LOCALURL + 'applet-getGoodsClass',// 商品分类目录
SearchResult: LOCALURL + 'GoodsSearch-search',// 得到搜索结果
SearchBarKeyWords: LOCALURL + 'Search-getKeywords',// 搜索栏接口
GetAllDemanding: LOCALURL + 'supply-allDemandList',// 获取所有业主需求
MySupplyDemand: LOCALURL + 'Supply-myList',// 获取所有业主需求
ShopDescription: LOCALURL + 'shop-wxShopInfo',// 获取店铺详情
GrabDemand: LOCALURL + 'Supply-grabDemand',// 抢单接口
GetVoucherInfo: LOCALURL + 'Shop-couponsTips',// 优惠卷信息
GetConsultInfo: LOCALURL + 'Shop-consultTips',// 咨询信息
BuyConsult: LOCALURL + 'Shop-consult',// 购买咨询
GetShopItemDetail: LOCALURL + 'GoodsQuery-wxGoodsDetail',// 商品详情
// 商品发布api接口
Base: LOCALURL,
Login: LOCALURL + 'Applet-login', //登入接口
ShopWxStore: LOCALURL + 'Shop-wxStore', //商城首页信息
ShopSupplyShops: LOCALURL + 'Shop-supplyShops',// 商城店铺信息
GrabDemand: LOCALURL + 'Supply-grabDemand',// 抢单接口
GetVoucherInfo: LOCALURL + 'Shop-couponsTips',// 优惠卷信息
GetConsultInfo: LOCALURL + 'Shop-consultTips',// 咨询信息
BuyConsult: LOCALURL + 'Shop-consult',// 购买咨询
GetShopItemDetail: LOCALURL + 'GoodsQuery-wxGoodsDetail',// 商品详情
UploadDSPorductImage: LOCALURL + 'Supply-fileUpload',// 上传图片API
UploadPorductImage: LOCALURL + 'Goods-fileUpload',// 上传商品图片
UploadProduct: LOCALURL + 'Goods-phonePost',// 上传商品
UploadSupplyDemand: LOCALURL + 'Supply-post',// 上传供求
//所有业主供求
GetAllDemanding: LOCALURL + 'supply-allDemandList',// 获取所有业主需求
MySupplyDemand: LOCALURL + 'Supply-myList',// 我的供求
// 店铺信息
GoodsSearch: LOCALURL + 'GoodsSearch-search',// 店铺页面的信息
ShopDescription: LOCALURL + 'shop-wxShopInfo',// 获取店铺详情
GetSearchParam: LOCALURL + 'GoodsSearch-getSearchParam',// sidebar筛选的字段
GetShopCategoryList: LOCALURL + 'Shop-ajaxShopCartgory',// 店铺内分类目录
GetProductCategoryList: LOCALURL + 'applet-getGoodsClass',// 商品分类目录
SearchResult: LOCALURL + 'GoodsSearch-search',// 得到搜索结果
SearchBarKeyWords: LOCALURL + 'Search-getKeywords',// 搜索栏接口
// 商品发布api接口
UploadGoodsPorductImage: LOCALURL + 'Goods-fileUpload',// 上传商品
UploadProduct: LOCALURL + 'Goods-phonePost',// 上传商品
UploadSupplyDemand: LOCALURL + 'Supply-post',// 上传供求
// 我的供求页面接口Supply-myList
SearchDemandSupply: LOCALURL + 'Supply-myList',// 搜索我的供求接口
DeleteDemandSupply: LOCALURL + 'Supply-delete',// 删除我的供求接口
SearchDemandSupply: LOCALURL + 'Supply-myList',// 搜索我的供求接口
DeleteDemandSupply: LOCALURL + 'Supply-delete',// 删除我的供求接口
}
module.exports = URL

View File

@ -21,4 +21,13 @@ todo list
我的供求页面:
搜索接口--等待后台
我的供求 -查看和编辑页面
我的供求查看页面
我的供求编辑页面--等待后台接口
我的商品列表页面
我的商品列表数据
我的商品--筛选项目
商品编辑页面??