2018-12-07 17:17:46 +08:00
|
|
|
import Taro, { Component } from '@tarojs/taro'
|
|
|
|
import { View, Text, Image } from '@tarojs/components'
|
2018-12-24 17:35:51 +08:00
|
|
|
import { AtInput, AtButton, Picker, AtIcon, AtLoadMore, AtModal, AtToast } from 'taro-ui'
|
2018-12-07 17:17:46 +08:00
|
|
|
import copyrightComponent from '../../component/copyrightComponent/copyrightComponent'
|
|
|
|
|
|
|
|
import URL from '../../serviceAPI.config'
|
|
|
|
import './allDemanding.scss'
|
|
|
|
|
|
|
|
import eyeIcon from '../../icons/eye.png'
|
|
|
|
|
|
|
|
|
2018-12-14 17:10:23 +08:00
|
|
|
let currentPage = 1
|
2018-12-07 17:17:46 +08:00
|
|
|
class AllDemanding extends Component {
|
|
|
|
config = {
|
|
|
|
navigationBarTitleText: '全部业主需求'
|
|
|
|
}
|
|
|
|
constructor() {
|
|
|
|
super(...arguments)
|
|
|
|
this.state = {
|
2018-12-14 17:10:23 +08:00
|
|
|
supplys: [], // 需求列表
|
|
|
|
isMore: 'more', // 上拉加载状态
|
|
|
|
demandingState: ['全部', '在用', '已抢单', '已抢光'], // 供求状态选择
|
|
|
|
demandingStateSelected: '全部', // 当前供求状态
|
|
|
|
industryCate: ['全部', '制定家具', '成品家具', '办公家具', '设计'], // 行业分类状态选择
|
2018-12-11 17:34:06 +08:00
|
|
|
industryCateSelected: '全部', // 当前行业分类状态
|
|
|
|
startDateSel: '2018-04-22',
|
|
|
|
endDateSel: '2018-04-22',
|
2018-12-24 17:35:51 +08:00
|
|
|
startValidDate:'',
|
2018-12-21 11:59:24 +08:00
|
|
|
isOpenedGrabModal: false,
|
|
|
|
grabOrderId: '',//抢到订单的id
|
|
|
|
isGrabOrderSuccess: false,// 是否显示轻提示
|
|
|
|
grabOrderSuccess: '无法显示绑定后的字段',// 抢单成功返回字段
|
|
|
|
|
2018-12-07 17:17:46 +08:00
|
|
|
}
|
|
|
|
}
|
2018-12-14 17:10:23 +08:00
|
|
|
GetAllDemanding({ curr_page = 1, page_count = 20 }) {
|
2018-12-07 17:17:46 +08:00
|
|
|
Taro.request({
|
|
|
|
url: URL.GetAllDemanding,
|
|
|
|
method: 'POST',
|
|
|
|
dataType: 'json',
|
|
|
|
data: {
|
|
|
|
param: JSON.stringify({
|
|
|
|
curr_page: curr_page,
|
|
|
|
page_count: page_count
|
|
|
|
}),
|
|
|
|
},
|
|
|
|
header: {
|
|
|
|
'content-type': 'application/x-www-form-urlencoded',
|
|
|
|
'X-Requested-With': 'XMLHttpRequest'
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.then(res => {
|
2018-12-14 17:10:23 +08:00
|
|
|
if (res.data.supplys.length) {
|
|
|
|
const newSupplys = this.state.supplys.concat(res.data.supplys)
|
|
|
|
this.setState({ supplys: newSupplys, isMore: 'more' })
|
|
|
|
} else {
|
|
|
|
this.setState({ isMore: 'noMore' })
|
|
|
|
}
|
2018-12-07 17:17:46 +08:00
|
|
|
})
|
|
|
|
}
|
2018-12-11 17:34:06 +08:00
|
|
|
|
|
|
|
// 向上拉升延迟一秒加载数据
|
2018-12-14 17:10:23 +08:00
|
|
|
handleLoadMore() {
|
|
|
|
this.setState({ isMore: 'loading' })
|
2018-12-07 17:17:46 +08:00
|
|
|
setTimeout(() => {
|
|
|
|
currentPage += 1
|
|
|
|
this.GetAllDemanding({ curr_page: currentPage })
|
2018-12-14 17:10:23 +08:00
|
|
|
|
2018-12-07 17:17:46 +08:00
|
|
|
}, 1000);
|
|
|
|
}
|
2018-12-11 17:34:06 +08:00
|
|
|
// 改变需求选项
|
|
|
|
changeDemandingState = e => {
|
|
|
|
this.setState({
|
|
|
|
demandingStateSelected: this.state.demandingState[e.detail.value]
|
|
|
|
})
|
|
|
|
}
|
|
|
|
// 改变行业类别选项
|
|
|
|
changeIndustryCate = e => {
|
2018-12-07 17:17:46 +08:00
|
|
|
this.setState({
|
2018-12-11 17:34:06 +08:00
|
|
|
industryCateSelected: this.state.industryCate[e.detail.value]
|
2018-12-07 17:17:46 +08:00
|
|
|
})
|
|
|
|
}
|
2018-12-14 17:10:23 +08:00
|
|
|
//改变开始日期
|
2018-12-11 17:34:06 +08:00
|
|
|
onStartDateChange = e => {
|
2018-12-07 17:17:46 +08:00
|
|
|
this.setState({
|
2018-12-24 17:35:51 +08:00
|
|
|
startDateSel: e.detail.value,
|
|
|
|
|
2018-12-11 17:34:06 +08:00
|
|
|
})
|
|
|
|
}
|
2018-12-14 17:10:23 +08:00
|
|
|
// 改变结束日期
|
2018-12-11 17:34:06 +08:00
|
|
|
onEndDateChange = e => {
|
|
|
|
this.setState({
|
|
|
|
endDateSel: e.detail.value
|
2018-12-07 17:17:46 +08:00
|
|
|
})
|
|
|
|
}
|
2018-12-21 11:59:24 +08:00
|
|
|
// 抢单接口
|
|
|
|
GrabDemand({ demandId = 218 }) {
|
|
|
|
Taro.request({
|
|
|
|
url: URL.GrabDemand,
|
|
|
|
method: 'POST',
|
|
|
|
dataType: 'json',
|
|
|
|
data: {
|
|
|
|
demandId: demandId
|
|
|
|
},
|
|
|
|
header: {
|
|
|
|
'content-type': 'application/x-www-form-urlencoded',
|
|
|
|
'Cookie': 'PFWSSS=' + Taro.getStorageSync('session_id'),
|
|
|
|
'X-Requested-With': 'XMLHttpRequest'
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.then(res => {
|
|
|
|
let textTip = res.data.err_msg
|
|
|
|
this.setState({ grabOrderSuccess: textTip, isGrabOrderSuccess: true }, () => {
|
|
|
|
setTimeout(() => {
|
|
|
|
|
|
|
|
this.setState({ isGrabOrderSuccess: false })
|
|
|
|
|
2018-12-24 17:35:51 +08:00
|
|
|
}, 2000)
|
2018-12-21 11:59:24 +08:00
|
|
|
})
|
|
|
|
console.log('抢单请求:', res)
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
grabOrder(Id) {
|
|
|
|
this.setState({ isOpenedGrabModal: true, grabOrderId: Id })
|
|
|
|
}
|
|
|
|
handleGrabModalClose() {
|
|
|
|
this.setState({ isOpenedGrabModal: false })
|
|
|
|
}
|
|
|
|
handleGrabModalCancel() {
|
|
|
|
this.setState({ isOpenedGrabModal: false })
|
|
|
|
}
|
|
|
|
handleGrabConfirm() {
|
|
|
|
this.setState({ isOpenedGrabModal: false })
|
2018-12-07 17:17:46 +08:00
|
|
|
|
2018-12-21 11:59:24 +08:00
|
|
|
this.GrabDemand({ demandId: this.state.grabOrderId })
|
|
|
|
}
|
2018-12-07 17:17:46 +08:00
|
|
|
|
|
|
|
componentWillReceiveProps(nextProps) {
|
|
|
|
console.log(this.props, nextProps)
|
|
|
|
}
|
2018-12-14 17:10:23 +08:00
|
|
|
componentDidMount() {
|
2018-12-11 17:34:06 +08:00
|
|
|
// 得到第一页需求数据
|
2018-12-07 17:17:46 +08:00
|
|
|
this.GetAllDemanding({})
|
2018-12-14 17:10:23 +08:00
|
|
|
|
2018-12-07 17:17:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
componentWillUnmount() { }
|
|
|
|
|
|
|
|
componentDidShow() { }
|
|
|
|
|
|
|
|
componentDidHide() { }
|
|
|
|
|
|
|
|
render() {
|
2018-12-21 11:59:24 +08:00
|
|
|
// 提示模态弹窗element
|
2018-12-24 17:35:51 +08:00
|
|
|
const modalMessageGrabElement = <AtModal className='modal'
|
2018-12-21 11:59:24 +08:00
|
|
|
isOpened={this.state.isOpenedGrabModal}
|
|
|
|
title='提示'
|
|
|
|
cancelText='取消'
|
|
|
|
confirmText='确认'
|
|
|
|
onClose={this.handleGrabModalClose}
|
|
|
|
onCancel={this.handleGrabModalCancel}
|
|
|
|
onConfirm={this.handleGrabConfirm.bind(this)}
|
|
|
|
content='确认抢单?\n'
|
|
|
|
/>
|
|
|
|
// 抢单返回轻提示
|
2018-12-24 17:35:51 +08:00
|
|
|
const grabOrderSuccessElement = <AtToast
|
2018-12-21 11:59:24 +08:00
|
|
|
isOpened={this.state.isGrabOrderSuccess}
|
2018-12-24 17:35:51 +08:00
|
|
|
text={this.state.grabOrderSuccess}
|
|
|
|
duration={2000}
|
2018-12-21 11:59:24 +08:00
|
|
|
></AtToast>
|
2018-12-14 17:10:23 +08:00
|
|
|
const allDemandingElementArray = this.state.supplys ? this.state.supplys.map((item, index) => {
|
2018-12-07 17:17:46 +08:00
|
|
|
return <View className='demanding-info' key={index}>
|
2018-12-14 17:10:23 +08:00
|
|
|
<View className='header'>
|
2018-12-11 17:34:06 +08:00
|
|
|
<AtIcon value='user' size='12' color='#2196F3'></AtIcon>
|
|
|
|
<View className='name'> 业主:{item.user_name}</View>
|
2018-12-07 17:17:46 +08:00
|
|
|
<View className='others'>
|
2018-12-14 17:10:23 +08:00
|
|
|
<Text className='cate'>{item.class_name + ' '} </Text>
|
|
|
|
|
|
2018-12-07 17:17:46 +08:00
|
|
|
<Image src={eyeIcon} style='width:12px; height:12px; vertical-align:middle;' />
|
|
|
|
<Text className='watch'>{item.browse_times}</Text>
|
|
|
|
</View>
|
2018-12-14 17:10:23 +08:00
|
|
|
</View>
|
|
|
|
<View className='body'>
|
|
|
|
<View className='image-container'>
|
2018-12-07 17:17:46 +08:00
|
|
|
<Image style='width:90px;height:60px' src={URL.Base + item.file_path[0].thumb_path} />
|
2018-12-14 17:10:23 +08:00
|
|
|
</View>
|
|
|
|
<View className='detail'>
|
2018-12-07 17:17:46 +08:00
|
|
|
<View className='title'>{item.sd_title}</View>
|
|
|
|
<View className='para'>{item.sd_desc}</View>
|
2018-12-21 11:59:24 +08:00
|
|
|
<View className='button' onClick={this.grabOrder.bind(this, item.sd_id)}>
|
|
|
|
<AtButton type='primary' size='small'> {item.state_name === '在用' ? '抢单' : '已抢单'}</AtButton>
|
2018-12-07 17:17:46 +08:00
|
|
|
</View>
|
|
|
|
</View>
|
2018-12-14 17:10:23 +08:00
|
|
|
</View>
|
|
|
|
<View className='footer'>
|
|
|
|
<View className='location'><AtIcon value='map-pin' size='12' color='black'></AtIcon>没有数据</View>
|
2018-12-07 17:17:46 +08:00
|
|
|
<View className='time'>更新日期:{item.update_date}</View>
|
|
|
|
</View>
|
2018-12-14 17:10:23 +08:00
|
|
|
|
|
|
|
</View>
|
|
|
|
}) : null
|
2018-12-07 17:17:46 +08:00
|
|
|
return (
|
|
|
|
<View className='allDemanding'>
|
2018-12-21 11:59:24 +08:00
|
|
|
{/* 模态框 */}
|
2018-12-24 17:35:51 +08:00
|
|
|
{modalMessageGrabElement}
|
2018-12-21 11:59:24 +08:00
|
|
|
{/* 轻提示 */}
|
2018-12-24 17:35:51 +08:00
|
|
|
{grabOrderSuccessElement}
|
2018-12-07 17:17:46 +08:00
|
|
|
<View className='page-section'>
|
2018-12-11 17:34:06 +08:00
|
|
|
{/* 供求状态选择 */}
|
2018-12-07 17:17:46 +08:00
|
|
|
<View>
|
2018-12-11 17:34:06 +08:00
|
|
|
<Picker mode='selector' range={this.state.demandingState} onChange={this.changeDemandingState}>
|
2018-12-07 17:17:46 +08:00
|
|
|
<View className='picker'>
|
|
|
|
<View className='title-box'>
|
2018-12-11 17:34:06 +08:00
|
|
|
<Text className='title'> <Text className='require'>*</Text>供求状态:</Text> <Text className='selected'>{this.state.demandingStateSelected}</Text>
|
2018-12-07 17:17:46 +08:00
|
|
|
</View>
|
|
|
|
|
|
|
|
</View>
|
|
|
|
</Picker>
|
|
|
|
</View>
|
|
|
|
</View>
|
2018-12-24 17:35:51 +08:00
|
|
|
|
2018-12-07 17:17:46 +08:00
|
|
|
<View className='input-box'>
|
|
|
|
<Text className='require'>*</Text>
|
|
|
|
<AtInput
|
2018-12-21 11:59:24 +08:00
|
|
|
name='value'
|
|
|
|
title='需求标题:'
|
|
|
|
type='text'
|
|
|
|
placeholder='需求标题'
|
|
|
|
value={this.state.value}
|
|
|
|
onChange={this.handleChange.bind(this)}
|
2018-12-07 17:17:46 +08:00
|
|
|
/>
|
|
|
|
</View>
|
2018-12-11 17:34:06 +08:00
|
|
|
{/* 开始和结束日期选择 */}
|
2018-12-07 17:17:46 +08:00
|
|
|
<View className='page-section'>
|
|
|
|
<View className='picker-box'>
|
2018-12-11 17:34:06 +08:00
|
|
|
<Picker mode='date' className='picker-container' onChange={this.onStartDateChange}>
|
2018-12-07 17:17:46 +08:00
|
|
|
<View className='picker'>
|
|
|
|
<View className='title-box'>
|
2018-12-11 17:34:06 +08:00
|
|
|
<Text className='title'><Text className='require'>*</Text>开始日期:</Text> <Text className='selected'>{this.state.startDateSel}</Text>
|
2018-12-07 17:17:46 +08:00
|
|
|
</View>
|
|
|
|
</View>
|
|
|
|
</Picker>
|
2018-12-24 17:35:51 +08:00
|
|
|
<Picker className='picker-container' mode='date' start={this.state.startDateSel} onChange={this.onEndDateChange}>
|
2018-12-07 17:17:46 +08:00
|
|
|
<View className='picker'>
|
|
|
|
<View className='title-box'>
|
2018-12-11 17:34:06 +08:00
|
|
|
<Text className='title'><Text className='require'>*</Text>结束日期:</Text> <Text className='selected'>{this.state.endDateSel}</Text>
|
2018-12-07 17:17:46 +08:00
|
|
|
</View>
|
|
|
|
</View>
|
|
|
|
</Picker>
|
|
|
|
</View>
|
|
|
|
</View>
|
2018-12-11 17:34:06 +08:00
|
|
|
{/* 行业分类选择 */}
|
2018-12-07 17:17:46 +08:00
|
|
|
<View className='page-section'>
|
|
|
|
<View>
|
2018-12-11 17:34:06 +08:00
|
|
|
<Picker mode='selector' range={this.state.industryCate} onChange={this.changeIndustryCate}>
|
2018-12-07 17:17:46 +08:00
|
|
|
<View className='picker'>
|
|
|
|
<View className='title-box'>
|
2018-12-11 17:34:06 +08:00
|
|
|
<Text className='title'> <Text className='require'>*</Text>行业分类:</Text> <Text className='selected'>{this.state.industryCateSelected}</Text>
|
2018-12-07 17:17:46 +08:00
|
|
|
</View>
|
|
|
|
</View>
|
|
|
|
</Picker>
|
|
|
|
</View>
|
|
|
|
</View>
|
|
|
|
<View className='button-box'>
|
|
|
|
<View className='button'>
|
|
|
|
<AtButton type='primary' size='small'>
|
|
|
|
<AtIcon value='search' size='12' color='white'></AtIcon>
|
|
|
|
搜索</AtButton>
|
|
|
|
</View>
|
|
|
|
</View>
|
2018-12-14 17:10:23 +08:00
|
|
|
{/* 供求页面的数据加载 */}
|
2018-12-11 17:34:06 +08:00
|
|
|
<View className='demanding-box'>
|
2018-12-07 17:17:46 +08:00
|
|
|
{allDemandingElementArray}
|
|
|
|
</View>
|
|
|
|
<AtLoadMore
|
2018-12-21 11:59:24 +08:00
|
|
|
onClick={this.handleLoadMore.bind(this)}
|
|
|
|
status={this.state.isMore}
|
|
|
|
loadingText='加载中'
|
|
|
|
noMoreText='没有更多了'
|
2018-12-07 17:17:46 +08:00
|
|
|
/>
|
|
|
|
<copyrightComponent></copyrightComponent>
|
|
|
|
</View>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default AllDemanding
|