import Taro, { Component } from '@tarojs/taro'
import { View, Text, Image } from '@tarojs/components'
import { AtInput, AtButton, Picker, AtIcon, AtLoadMore } from 'taro-ui'
import copyrightComponent from '../../component/copyrightComponent/copyrightComponent'
import URL from '../../serviceAPI.config'
import './allDemanding.scss'
import eyeIcon from '../../icons/eye.png'
let currentPage=1
class AllDemanding extends Component {
config = {
navigationBarTitleText: '全部业主需求'
}
constructor() {
super(...arguments)
this.state = {
supplys:[], // 需求列表
isMore:'more', // 上拉加载状态
demandingState: [ '需求', '供应', '人才'], // 供求状态选择
demandingStateSelected:'全部', // 当前供求状态
industryCate: ['制定家具', '成品家具', '办公家具','设计'], // 行业分类状态选择
industryCateSelected: '全部', // 当前行业分类状态
startDateSel: '2018-04-22',
endDateSel: '2018-04-22',
}
}
GetAllDemanding({ curr_page=1, page_count=20}) {
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 => {
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'})
}
})
}
// 向上拉升延迟一秒加载数据
handleLoadMore(){
this.setState({isMore:'loading'})
setTimeout(() => {
currentPage += 1
this.GetAllDemanding({ curr_page: currentPage })
}, 1000);
}
// 改变需求选项
changeDemandingState = e => {
this.setState({
demandingStateSelected: this.state.demandingState[e.detail.value]
})
}
// 改变行业类别选项
changeIndustryCate = e => {
this.setState({
industryCateSelected: this.state.industryCate[e.detail.value]
})
}
//改变开始日期
onStartDateChange = e => {
this.setState({
startDateSel: e.detail.value
})
}
// 改变结束日期
onEndDateChange = e => {
this.setState({
endDateSel: e.detail.value
})
}
componentWillReceiveProps(nextProps) {
console.log(this.props, nextProps)
}
componentDidMount(){
// 得到第一页需求数据
this.GetAllDemanding({})
}
componentWillUnmount() { }
componentDidShow() { }
componentDidHide() { }
render() {
const allDemandingElementArray=this.state.supplys?this.state.supplys.map((item,index)=>{
return
业主:{item.user_name}
{item.class_name+' '}
|
{item.browse_times}
{item.sd_title}
{item.sd_desc}
抢单
没有数据
更新日期:{item.update_date}
}):null
return (
{/* 供求状态选择 */}
*供求状态: {this.state.demandingStateSelected}
*
{/* 开始和结束日期选择 */}
*开始日期: {this.state.startDateSel}
*结束日期: {this.state.endDateSel}
{/* 行业分类选择 */}
*行业分类: {this.state.industryCateSelected}
搜索
{/* 供求页面的数据加载 */}
{allDemandingElementArray}
)
}
}
export default AllDemanding