我的供求,供求编辑,供求查看,供求发布--完成

This commit is contained in:
郑茂强 2019-01-09 16:46:57 +08:00
parent 79f3634eb5
commit aa3eaccf8e
10 changed files with 293 additions and 118 deletions

View File

@ -3,10 +3,9 @@
import Taro, { Component } from '@tarojs/taro' import Taro, { Component } from '@tarojs/taro'
import { View, Text } from '@tarojs/components' import { View, Text } from '@tarojs/components'
import { AtTabBar, Picker, AtButton } from 'taro-ui' import { Picker } from 'taro-ui'
import './goodsTypeInteractionComp.scss' import './goodsTypeInteractionComp.scss'
import { throws } from 'assert';
class GoodsTypeInteractionComp extends Component { class GoodsTypeInteractionComp extends Component {

View File

@ -1,8 +1,10 @@
import Taro, { Component } from '@tarojs/taro' import Taro, { Component } from '@tarojs/taro'
import { View, Text, Image, Button } from '@tarojs/components' import { View, Text, Image, Button } from '@tarojs/components'
import { AtInput, AtButton, Picker, AtIcon, AtLoadMore, AtModal, AtToast, AtModalHeader, AtModalContent, AtModalAction } from 'taro-ui' import { AtInput, AtButton, Picker, AtIcon, AtLoadMore, AtModal, AtToast, AtModalHeader, AtModalContent, AtModalAction, AtPagination } from 'taro-ui'
import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent' import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent'
import InteractionComponent from '../../component/interactionComponent/interactionComponent'
import URL from '../../serviceAPI.config' import URL from '../../serviceAPI.config'
import './allDemanding.scss' import './allDemanding.scss'
@ -21,8 +23,8 @@ class AllDemanding extends Component {
isMore: 'more', // 加载状态 isMore: 'more', // 加载状态
demandingState: [{ name: '全部', id: '' }, { name: '在用', id: '1' }, { name: '已抢单', id: '2' }, { name: '已抢光', id: '3' },], // 供求状态选择 demandingState: [{ name: '全部', id: '' }, { name: '在用', id: '1' }, { name: '已抢单', id: '2' }, { name: '已抢光', id: '3' },], // 供求状态选择
demandingStateSelected: { name: '全部', id: '' }, // 当前供求状态 demandingStateSelected: { name: '全部', id: '' }, // 当前供求状态
industryCate: ['全部', '制定家具', '成品家具', '办公家具', '设计'], // 行业分类状态选择 industryTypeSelected: { name: '全部', id: '' },// 当前行业分类
industryCateSelected: '全部', // 当前行业分类状态 title: '',
startDateSel: '', startDateSel: '',
endDateSel: '', endDateSel: '',
classId: '', classId: '',
@ -30,6 +32,9 @@ class AllDemanding extends Component {
grabOrderId: '',//抢到订单的id grabOrderId: '',//抢到订单的id
isGrabOrderSuccess: false,// 是否显示轻提示 isGrabOrderSuccess: false,// 是否显示轻提示
grabOrderSuccess: '无法显示绑定后的字段',// 抢单成功返回字段 grabOrderSuccess: '无法显示绑定后的字段',// 抢单成功返回字段
totalDemandings:0,
currentPage:1
} }
} }
@ -39,7 +44,7 @@ class AllDemanding extends Component {
state = this.state.demandingStateSelected.id, state = this.state.demandingStateSelected.id,
update_dateL = this.state.startDateSel, update_dateL = this.state.startDateSel,
update_dateU = this.state.endDateSel, update_dateU = this.state.endDateSel,
class_id = this.state.classId class_id = this.state.industryTypeSelected.id
} }
) { ) {
Taro.request({ Taro.request({
@ -71,11 +76,12 @@ class AllDemanding extends Component {
}) })
} }
// 搜索业主需求函数 // 搜索业主需求函数
searchDemanding({ curr_page = 1, page_count = 20, searchDemanding({ curr_page = 1, page_count = 10,
sd_title = this.state.title,
state = this.state.demandingStateSelected.id, state = this.state.demandingStateSelected.id,
update_dateL = this.state.startDateSel, update_dateL = this.state.startDateSel,
update_dateU = this.state.endDateSel, update_dateU = this.state.endDateSel,
class_id = this.state.classId class_id = this.state.industryTypeSelected.id
}) { }) {
Taro.request({ Taro.request({
url: URL.GetAllDemanding, url: URL.GetAllDemanding,
@ -85,6 +91,7 @@ class AllDemanding extends Component {
param: JSON.stringify({ param: JSON.stringify({
curr_page: curr_page, curr_page: curr_page,
page_count: page_count, page_count: page_count,
sd_title: sd_title,
state: state, state: state,
update_dateL: update_dateL, update_dateL: update_dateL,
update_dateU: update_dateU, update_dateU: update_dateU,
@ -100,7 +107,18 @@ class AllDemanding extends Component {
.then(res => { .then(res => {
Taro.hideLoading() Taro.hideLoading()
this.setState({ supplys: res.data.supplys }) if(res.data.err_msg==='success'){
const total=Number(res.data.count)
this.setState({ supplys: res.data.supplys ,totalDemandings:total})
}else{
Taro.showToast({
title:res.data.err_msg,
icon:'none',
duration:1500
})
}
}) })
} }
@ -118,12 +136,10 @@ class AllDemanding extends Component {
demandingStateSelected: this.state.demandingState[e.detail.value] demandingStateSelected: this.state.demandingState[e.detail.value]
}) })
} }
// 改变行业类别选项 titleChange(event) {
changeIndustryCate = e => { this.setState({ title: event })
this.setState({
industryCateSelected: this.state.industryCate[e.detail.value]
})
} }
//改变开始日期 //改变开始日期
onStartDateChange = e => { onStartDateChange = e => {
this.setState({ this.setState({
@ -180,15 +196,45 @@ class AllDemanding extends Component {
this.GrabDemand({ demandId: this.state.grabOrderId }) this.GrabDemand({ demandId: this.state.grabOrderId })
} }
searchHanlder() { searchHanlder() {
Taro.showLoading({ title: '加载中' })
Taro.showLoading({ title: '加载中' }).then(() => { this.searchDemanding({})
setTimeout(() => {
this.searchDemanding({})
}, 1000);
})
} }
//清空筛选项
emptyFilter() {
this.setState({
title: '',
endDateSel: '',
startDateSel: '',
demandingStateSelected: { name: '全部', id: '' },
industryTypeSelected: { name: '全部', id: '' },
})
Taro.showToast({
title: '已清空',
icon: 'success',
duration: 1000
})
}
getDataFromChild(value) {
console.log('从子组件传回来的值', value)
this.setState({ industryTypeSelected: value })
}
// 翻页导航
paginationNav(type) {
Taro.showLoading({
title:'加载中'
})
this.setState({ currentPage: type.current, }, () => {
this.searchDemanding({ curr_page :this.state.currentPage, page_count : 10,
sd_title : this.state.title,
state : this.state.demandingStateSelected.id,
update_dateL : this.state.startDateSel,
update_dateU : this.state.endDateSel,
class_id : this.state.industryTypeSelected.id
})
})
}
componentWillReceiveProps(nextProps) { componentWillReceiveProps(nextProps) {
console.log(this.props, nextProps) console.log(this.props, nextProps)
@ -268,7 +314,7 @@ class AllDemanding extends Component {
<Picker mode='selector' rangeKey='name' range={this.state.demandingState} onChange={this.changeDemandingState}> <Picker mode='selector' rangeKey='name' range={this.state.demandingState} onChange={this.changeDemandingState}>
<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.demandingStateSelected.name}</Text> <Text className='title'> 供求状态:</Text> <Text className='selected'>{this.state.demandingStateSelected.name}</Text>
</View> </View>
</View> </View>
@ -277,14 +323,14 @@ class AllDemanding extends Component {
</View> </View>
<View className='input-box'> <View className='input-box'>
<Text className='require'>*</Text>
<AtInput <AtInput
name='value' name='value'
title='需求标题:' title='需求标题:'
type='text' type='text'
placeholder='需求标题' placeholder='需求标题'
value={this.state.value} value={this.state.title}
onChange={this.handleChange.bind(this)} onChange={this.titleChange.bind(this)}
/> />
</View> </View>
{/* 开始和结束日期选择 */} {/* 开始和结束日期选择 */}
@ -293,48 +339,50 @@ class AllDemanding extends Component {
<Picker mode='date' className='picker-container' onChange={this.onStartDateChange}> <Picker mode='date' className='picker-container' onChange={this.onStartDateChange}>
<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.startDateSel}</Text> <Text className='title'>开始日期:</Text> <Text className='date'>{this.state.startDateSel}</Text>
</View> </View>
</View> </View>
</Picker> </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='picker'>
<View className='title-box'> <View className='title-box'>
<Text className='title'><Text className='require'>*</Text>:</Text> <Text className='selected'>{this.state.endDateSel}</Text> <Text className='title'>结束日期:</Text> <Text className='date'>{this.state.endDateSel}</Text>
</View> </View>
</View> </View>
</Picker> </Picker>
</View> </View>
</View> </View>
{/* 行业分类选择 */} {/* 行业分类选择 */}
<View className='page-section'> <InteractionComponent url={URL.GetIndustryTypeList} onPassDataToChild={this.getDataFromChild.bind(this)} selectedValue={this.state.industryTypeSelected}></InteractionComponent>
<View>
<Picker mode='selector' range={this.state.industryCate} onChange={this.changeIndustryCate}>
<View className='picker'> <View className='button-box'>
<View className='title-box'> <View className='button' onClick={this.searchHanlder.bind(this)}>
<Text className='title'> <Text className='require'>*</Text>:</Text> <Text className='selected'>{this.state.industryCateSelected}</Text>
</View>
</View>
</Picker>
</View>
</View>
<View className='button-box' onClick={this.searchHanlder.bind(this)}>
<View className='button'>
<AtButton type='primary' size='small'> <AtButton type='primary' size='small'>
<AtIcon value='search' size='12' color='white'></AtIcon> <AtIcon value='search' size='12' color='white'></AtIcon>
搜索</AtButton> 搜索</AtButton>
</View> </View>
<View className='button' onClick={this.emptyFilter.bind(this)}>
<AtButton type='primary' className='button-b' size='small'>
<AtIcon value='trash' size='12' color='white'></AtIcon>
清空</AtButton>
</View>
</View> </View>
{/* 供求页面的数据加载 */} {/* 供求页面的数据加载 */}
<View className='demanding-box'> <View className='demanding-box'>
{allDemandingElementArray} {allDemandingElementArray}
</View> </View>
<AtLoadMore <View className='pagination-box'>
onClick={this.handleLoadMore.bind(this)} <AtPagination
status={this.state.isMore} total={this.state.totalDemandings}
loadingText='加载中' pageSize={10}
noMoreText='没有更多了' current={this.state.currentPage}
/> onPageChange={this.state.paginationNav.bind(this)}
>
</AtPagination>
</View>
<CopyrightComponent></CopyrightComponent> <CopyrightComponent></CopyrightComponent>
</View> </View>
) )

View File

@ -22,6 +22,11 @@ $themeColor: #FF7142;
.selected{ .selected{
display: inline-block; display: inline-block;
margin-left: 20%; margin-left: 20%;
font-size: 32rpx
}
.date{
display: inline-block;
font-size: 32rpx font-size: 32rpx
} }
.title-box{ .title-box{
@ -30,7 +35,7 @@ $themeColor: #FF7142;
margin-right:16rpx; margin-right:16rpx;
width:172rpx; width:172rpx;
font-size:32rpx; font-size:32rpx;
line-height:1.5; line-height:100px;
// vertical-align:middle; // vertical-align:middle;
text-align:left; text-align:left;
font-weight: bold; font-weight: bold;
@ -53,17 +58,28 @@ $themeColor: #FF7142;
} }
} }
.button-box{ .button-box{
display: flex;
flex-wrap: nowrap;
flex-direction: row;
margin: 40px 0;
padding: 0 120px;
.button{ .button{
margin-top: 50px; flex:1;
margin-bottom: 50px; text-align: center;
text-align: center;
.at-button--primary{ .at-button--primary{
background-color:$themeColor; background-color:$themeColor;
border:1PX solid $themeColor; border:1PX solid $themeColor;
} }
}
.button-b{
background-color:#d9534f;
border:1PX solid #d9534f;
}
}
} }
.demanding-box{ .demanding-box{
.demanding-info{ .demanding-info{
@ -153,3 +169,6 @@ $themeColor: #FF7142;
} }
} }
.pagination-box{
margin: 50px 0;
}

View File

@ -36,7 +36,9 @@ class Index extends Component {
// url:'/pages/myGoodList/myGoodList' // url:'/pages/myGoodList/myGoodList'
// url:'/pages/myNeeds/myNeeds', // url:'/pages/myNeeds/myNeeds',
//url:'/pages/myNeedsPublish/myNeedsPublish' //url:'/pages/myNeedsPublish/myNeedsPublish'
url:'/pages/goodsPublish/goodsPublish' // url:'/pages/mySupplyDemand/mySupplyDemand'
// url:'/pages/home/home'
url:'/pages/allDemanding/allDemanding'
}) })

View File

@ -22,7 +22,6 @@ class MyNeeds extends Component {
title: '', title: '',
startDateSel: '', startDateSel: '',
endDateSel: '', endDateSel: '',
industryType: '',
industryTypeSelected: { name: '全部', id: '' }, industryTypeSelected: { name: '全部', id: '' },
needsType: [{ name: '业主需求', id: '4' }, { name: '效果图', id: '5' }], needsType: [{ name: '业主需求', id: '4' }, { name: '效果图', id: '5' }],
needsTypeSelected: { name: '业主需求', id: '4' }, needsTypeSelected: { name: '业主需求', id: '4' },
@ -242,7 +241,7 @@ class MyNeeds extends Component {
sd_title: this.state.title, sd_title: this.state.title,
update_dateL: this.state.startDateSel, update_dateL: this.state.startDateSel,
update_dateU: this.state.endDateSel, update_dateU: this.state.endDateSel,
class_id: this.state.industryType, class_id: this.state.industryTypeSelected.id,
state: this.state.needsStateSelected.id state: this.state.needsStateSelected.id
}) })
}) })

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,AtPagination } 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'
@ -28,8 +28,8 @@ class MySupplyDemand extends Component {
isConfirmWindow: false, // 是否显示确认弹窗 isConfirmWindow: false, // 是否显示确认弹窗
demandSupplyItemName: '',// 确认框提示时 使用的供求名 demandSupplyItemName: '',// 确认框提示时 使用的供求名
demandSupplyId: '',// 删除我的供求时的供求id demandSupplyId: '',// 删除我的供求时的供求id
totalDemandSupply:0,//所有供求 totalDemandSupply: 0,//所有供求
currentPage:1 //当前页数 currentPage: 1 //当前页数
} }
@ -56,8 +56,8 @@ class MySupplyDemand extends Component {
if (res.data.err_msg === "success") { if (res.data.err_msg === "success") {
// 判断是否有res.data.supplys 如果没有就是空数组[] // 判断是否有res.data.supplys 如果没有就是空数组[]
Taro.hideLoading() Taro.hideLoading()
const totalCount = Number(res.data.count)
this.setState({ allDemandSupply: res.data.supplys || [], totalDemandSupply:Number(res.data.count) }) this.setState({ allDemandSupply: res.data.supplys || [], totalDemandSupply: totalCount })
} }
}) })
@ -97,12 +97,10 @@ class MySupplyDemand extends Component {
} }
onSearchButtonHandler() { onSearchButtonHandler() {
Taro.showLoading({ title: '加载中' }).then(() => { Taro.showLoading({ title: '加载中' })
setTimeout(() => {
this.searchDemandSupply({})
this.setState({currentPage:1})
}, 1000);
this.setState({ currentPage: 1 }, () => {
this.searchDemandSupply({})
}) })
} }
@ -160,6 +158,22 @@ class MySupplyDemand extends Component {
url: '/pages/supplyDemandPublish/supplyDemandPublish' url: '/pages/supplyDemandPublish/supplyDemandPublish'
}) })
} }
//清空筛选项
emptyFilter() {
this.setState({
title: '',
endDateSel: '',
startDateSel: '',
demandSupplyCateSelected: { name: '全部', id: '' },
demandSupplyStatesSelected: { name: '全部', id: '' },
})
Taro.showToast({
title: '已清空',
icon: 'success',
duration: 1000
})
}
//修改供求类型 //修改供求类型
@ -205,11 +219,10 @@ class MySupplyDemand extends Component {
// 删除我的供求 // 删除我的供求
handleOnDelete(id, itemName) { handleOnDelete(id, itemName) {
this.setState({ isConfirmWindow: true, demandSupplyItemName: itemName, demandSupplyId: id }) this.setState({ isConfirmWindow: true, demandSupplyItemName: itemName, demandSupplyId: id })
} }
// 编辑我的供求 // 编辑我的供求
// 跳转到我的供求编辑页面 // 跳转到我的供求编辑页面
@ -220,19 +233,19 @@ class MySupplyDemand extends Component {
} }
// 转到供求查看页面 // 转到供求查看页面
goToSupplyDemandPage(sdId) { goSupplyDemandView(sdId) {
Taro.navigateTo({ Taro.navigateTo({
url: '/pages/supplyDemandView/supplyDemandView?sdId=' + sdId url: '/pages/supplyDemandView/supplyDemandView?sdId=' + sdId
// url: '/pages/goods/goods?sdId='+goodId// 虚拟地址
}) })
} }
// 翻页导航 // 翻页导航
paginationNav(type) { paginationNav(type) {
this.setState({ currentPage: type.current, }, () => { Taro.showLoading({ title: '加载中' })
this. getMySupplyDemand({ curr_page :this.state.currentPage}) this.setState({ currentPage: type.current, }, () => {
}) this.getMySupplyDemand({ curr_page: this.state.currentPage })
})
} }
componentWillReceiveProps(nextProps) { componentWillReceiveProps(nextProps) {
@ -264,18 +277,18 @@ class MySupplyDemand extends Component {
const demandSupplyElementArray = this.state.allDemandSupply.length ? this.state.allDemandSupply.map((item, index) => { const demandSupplyElementArray = this.state.allDemandSupply.length ? this.state.allDemandSupply.map((item, index) => {
const SDState=this.state.demandSupplyState.filter(stateItem=>{ const SDState = this.state.demandSupplyState.filter(stateItem => {
return stateItem.id==item.state return stateItem.id == item.state
})[0].name })[0].name
return <View key={index} className='info-container'> 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>
</View> </View>
<View className='demand-title'> <View className='demand-title'>
<Text className='title'>需求标题</Text> <Text className='title'>需求标题</Text>
<Text className='info'>{item.sd_title}</Text> <Text className='info' onClick={this.goSupplyDemandView.bind(this, item.sd_id)}>{item.sd_title}</Text>
</View> </View>
<View className='contact-name'> <View className='contact-name'>
<Text className='title'>联系人</Text> <Text className='title'>联系人</Text>
@ -294,7 +307,7 @@ class MySupplyDemand extends Component {
<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, item.sd_id)}> <View className='button' onClick={this.goSupplyDemandView.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, item.sd_id)} > <View className='button' onClick={this.goToMyDSEditPage.bind(this, item.sd_id)} >
@ -360,7 +373,7 @@ class MySupplyDemand extends Component {
<Picker mode='date' className='picker-container' onChange={this.onStartDateChange}> <Picker mode='date' className='picker-container' onChange={this.onStartDateChange}>
<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.startDateSel}</Text> <Text className='title'><Text className='require'>*</Text>:</Text> <Text className='date'>{this.state.startDateSel}</Text>
</View> </View>
</View> </View>
@ -368,7 +381,7 @@ class MySupplyDemand extends Component {
<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='picker'>
<View className='title-box'> <View className='title-box'>
<Text className='title'><Text className='require'>*</Text>:</Text> <Text className='selected'>{this.state.endDateSel}</Text> <Text className='title'><Text className='require'>*</Text>:</Text> <Text className='date'>{this.state.endDateSel}</Text>
</View> </View>
</View> </View>
</Picker> </Picker>
@ -387,6 +400,11 @@ class MySupplyDemand extends Component {
<AtIcon value='add' size='12' color='white'></AtIcon> <AtIcon value='add' size='12' color='white'></AtIcon>
新增</AtButton> 新增</AtButton>
</View> </View>
<View className='button' onClick={this.emptyFilter.bind(this)}>
<AtButton type='primary' className='button-b' size='small'>
<AtIcon value='trash' size='12' color='white'></AtIcon>
清空</AtButton>
</View>
</View> </View>
<View className='total-count'>一共<Text className='number'>{this.state.totalDemandSupply}</Text> </View> <View className='total-count'>一共<Text className='number'>{this.state.totalDemandSupply}</Text> </View>
{/* 我的供求信息 */} {/* 我的供求信息 */}
@ -394,15 +412,15 @@ class MySupplyDemand extends Component {
{demandSupplyElementArray} {demandSupplyElementArray}
</View> </View>
<View className='pagination-box'> <View className='pagination-box'>
<AtPagination <AtPagination
total={this.state.totalDemandSupply} total={this.state.totalDemandSupply}
pageSize={10} pageSize={10}
current={this.state.currentPage} current={this.state.currentPage}
onPageChange={this.state.paginationNav.bind(this)} onPageChange={this.state.paginationNav.bind(this)}
> >
</AtPagination> </AtPagination>
</View> </View>

View File

@ -32,9 +32,14 @@ $themeColor:#FF7142;
// padding: 24rpx 0; // padding: 24rpx 0;
.selected{ .selected{
display: inline-block; display: inline-block;
margin-left: 20%; margin-left: 20%;
font-size: 32rpx font-size: 32rpx
} }
.date{
display: inline-block;
font-size: 32rpx
}
.title-box{ .title-box{
.title{ .title{
//color: #333; //color: #333;
@ -42,7 +47,6 @@ $themeColor:#FF7142;
width:172rpx; width:172rpx;
font-size:32rpx; font-size:32rpx;
line-height:1.5; line-height:1.5;
vertical-align:middle;
text-align:left; text-align:left;
font-weight: bold; font-weight: bold;
} }
@ -86,6 +90,11 @@ $themeColor:#FF7142;
background-color:#5cb85c; background-color:#5cb85c;
border:1PX solid #5cb85c; border:1PX solid #5cb85c;
} }
.button-b{
background-color:#d9534f;
border:1PX solid #d9534f;
}
} }
} }
@ -98,8 +107,9 @@ $themeColor:#FF7142;
box-shadow: 0 8px 8px #ddd; box-shadow: 0 8px 8px #ddd;
padding: 10px; padding: 10px;
View{ View{
margin:10px margin-top: 5px;
} }
.demand-title{ .demand-title{
.info{color:#337ab7; } .info{color:#337ab7; }
} }
@ -132,7 +142,7 @@ $themeColor:#FF7142;
.title{ .title{
text-align: center; text-align: center;
font-size: 35px; font-size: 30px;
} }
.pagination-box{ .pagination-box{

View File

@ -24,14 +24,13 @@ class SupplyDemand extends Component {
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: Taro.getStorageSync('user_identity').username,
contactNumber: '', contactNumber: Taro.getStorageSync('user_identity').userphone,
contactAddress: '', contactAddress: '',
content: '', content: '',
pickerImageUrl: [], // 上传的图片 pickerImageUrl: [], // 上传的图片
ImagesInfo: [],// 后台传回来的图片信息 ImagesInfo: [],// 后台传回来的图片信息
isFormCompleted: false,
} }
} }
@ -200,7 +199,7 @@ class SupplyDemand extends Component {
componentDidMount() { componentDidMount() {
// this.uploadSupplyDemand()
} }
componentWillReceiveProps(nextProps) { componentWillReceiveProps(nextProps) {
console.log(this.props, nextProps) console.log(this.props, nextProps)

View File

@ -1,7 +1,7 @@
import Taro, { Component } from '@tarojs/taro' import Taro, { Component } from '@tarojs/taro'
import { View, Text, Image } from '@tarojs/components' import { View, Text, Image } from '@tarojs/components'
import { AtButton, AtIcon } from 'taro-ui' import { AtButton, AtIcon,AtModal, AtModalHeader, AtModalContent, AtModalAction } 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'
@ -28,6 +28,7 @@ class SupplyDemandView extends Component {
address: '', address: '',
content: '', content: '',
images: [], images: [],
isDeleteModal:false
} }
} }
//获取商品信息api GetProductInfo //获取商品信息api GetProductInfo
@ -59,6 +60,7 @@ class SupplyDemandView extends Component {
address: res.data.sdInfo.user_address, address: res.data.sdInfo.user_address,
content: res.data.sdInfo.sd_desc, content: res.data.sdInfo.sd_desc,
images: res.data.sdInfo.file_path, images: res.data.sdInfo.file_path,
itemId:res.data.sdInfo.sd_id
}) })
Taro.hideLoading() Taro.hideLoading()
} }
@ -67,28 +69,89 @@ class SupplyDemandView extends Component {
console.log('供求详情获取失败', error) console.log('供求详情获取失败', error)
}) })
} }
// 删除我的供求api
onDelete({ sdID = 0 }) {
Taro.request({
url: URL.DeleteDemandSupply,
method: 'POST',
dataType: 'json',
data: {
sdID: sdID
},
header: {
'content-type': 'application/x-www-form-urlencoded',
'Cookie': 'PFWSSS=' + Taro.getStorageSync('session_id'),
'X-Requested-With': 'XMLHttpRequest'
}
})
.then(res => {
if (res.data.err_msg == 'success') {
console.log('删除成功')
Taro.showToast({
title: '删除成功',
icon:'success',
duration:1500
}).then(() => {
setTimeout(() => {
this.goToMySDPage()
}, 1500);
})
} else {
Taro.showToast({
title: res.data.err_msg,
icon: 'none'
})
}
}
)
.catch(error => {
Taro.showToast({
title: '删除失败',
icon: 'none'
})
})
}
goToSDPublishPage() { goToSDPublishPage() {
Taro.navigateTo({ Taro.navigateTo({
url: '/pages/supplyDemandPublish/supplyDemandPublish',// 供求发布页面 url: '/pages/supplyDemandPublish/supplyDemandPublish',// 供求发布页面
}) })
} }
goToSDEditPage() { // 跳转到我的供求编辑页面
console.log('edit page') goToMyDSEditPage() {
// Taro.navigateTo({ Taro.navigateTo({
// url: 'pages/supplyDemandPublish/supplyDemandPublish',// 供求发布页面 url: '/pages/myDemandSupplyEdit/myDemandSupplyEdit?sdId=' + this.state.itemId
// }) })
} }
goToMySDPage() { goToMySDPage() {
Taro.navigateTo({ Taro.navigateTo({
url: '/pages/mySupplyDemand/mySupplyDemand',//我的供求页面 url: '/pages/mySupplyDemand/mySupplyDemand',//我的供求页面
}) })
} }
deleteSD() { makeAPhoneCall(){
console.log('删除供求') Taro.makePhoneCall({
phoneNumber: this.state.contactNumber
})
} }
deleteButton() {
this.setState({ isDeleteModal: true })
}
handleWindowModCancel() {
this.setState({ isDeleteModal: false })
}
handleWindowConfirm() {
this.setState({ isDeleteModal: false })
this.onDelete({ sdID: this.state.itemId })
}
componentDidMount() { componentDidMount() {
Taro.showLoading({title:'加载中'}) Taro.showLoading({title:'加载中'})
this.getSupplyDemandInfo() this.getSupplyDemandInfo()
@ -106,13 +169,21 @@ class SupplyDemandView extends Component {
render() { render() {
const imageElementArray = this.state.images.map((item, index) => { const imageElementArray = this.state.images.map((item, index) => {
return <View key={index} className='image-box'> return <View key={index} className='image-box'>
<Image mode='aspectFit' style='width: 100%;' <Image mode='widthFix' style='width: 100%;'
src={URL.Base + item.file_path} src={URL.Base + item.file_path}
/> />
</View> </View>
}) })
const deleteModalWindowElement = <AtModal isOpened={this.state.isDeleteModal}>
<AtModalHeader>提示</AtModalHeader>
<AtModalContent>
确认删除{this.state.needsItem.sd_title}
</AtModalContent>
<AtModalAction> <Button onClick={this.handleWindowModCancel.bind(this)}>取消</Button> <Button className='orange' onClick={this.handleWindowConfirm.bind(this)}></Button> </AtModalAction>
</AtModal>
return ( return (
<View className='SupplyDemandItemView'> <View className='SupplyDemandItemView'>
{deleteModalWindowElement}
<View className='type box'> <View className='type box'>
<Text className='title'>供求类型</Text> <Text className='title'>供求类型</Text>
<Text className='content'>{this.state.type}</Text> <Text className='content'>{this.state.type}</Text>
@ -131,7 +202,7 @@ class SupplyDemandView extends Component {
</View> </View>
<View className='phone-number box'> <View className='phone-number box'>
<Text className='title'>联系电话</Text> <Text className='title'>联系电话</Text>
<Text className='content'>{this.state.contactNumber}</Text> <Text className='content highlight' onClick={this.state.makeAPhoneCall.bind(this)}>{this.state.contactNumber}</Text>
</View> </View>
<View className='address box'> <View className='address box'>
<Text className='title'>联系地址</Text> <Text className='title'>联系地址</Text>
@ -150,11 +221,11 @@ class SupplyDemandView extends Component {
<View className='button-box'> <View className='button-box'>
<View className='button' onClick={this.goToSDPublishPage.bind(this)}> <View className='button' onClick={this.goToSDPublishPage.bind(this)}>
<AtButton type='primary' size='small'> <AtButton type='primary' className='button-g' size='small'>
<AtIcon value='add' size='12' color='white'></AtIcon> <AtIcon value='add' size='12' color='white'></AtIcon>
新增</AtButton> 新增</AtButton>
</View> </View>
<View className='button' onClick={this.goToSDEditPage.bind(this)}> <View className='button' onClick={this.goToMyDSEditPage.bind(this)}>
<AtButton type='primary' className='button' size='small'> <AtButton type='primary' className='button' size='small'>
<AtIcon value='settings' size='12' color='white'></AtIcon> <AtIcon value='settings' size='12' color='white'></AtIcon>
修改</AtButton> 修改</AtButton>
@ -164,7 +235,7 @@ class SupplyDemandView extends Component {
<AtIcon value='' size='12' color='white'></AtIcon> <AtIcon value='' size='12' color='white'></AtIcon>
我的供求</AtButton> 我的供求</AtButton>
</View> </View>
<View className='button' onClick={this.deleteSD.bind(this)}> <View className='button' onClick={this.deleteButton.bind(this)}>
<AtButton type='primary' className='button-a' size='small'> <AtButton type='primary' className='button-a' size='small'>
<AtIcon value='close' size='12' color='white'></AtIcon> <AtIcon value='close' size='12' color='white'></AtIcon>
删除</AtButton> 删除</AtButton>

View File

@ -9,6 +9,9 @@ $themeColor:#FF7142;
.title{ .title{
font-weight: bold font-weight: bold
} }
.highlight{
color:#337ab7
}
} }
.button-box{ .button-box{
@ -28,9 +31,16 @@ $themeColor:#FF7142;
background-color:$themeColor; background-color:$themeColor;
border:1PX solid $themeColor; border:1PX solid $themeColor;
} }
.button-g{
background-color:#5cb85c;
border:1PX solid #5cb85c;
}
.button-a{ .button-a{
background-color:#d9534f; background-color:#d9534f;
border:1PX solid #d9534f; border:1PX solid #d9534f;
} }
} }
} }
.image-container{
padding: 20px
}