业主全部需求完成

This commit is contained in:
郑茂强 2019-01-09 17:35:32 +08:00
parent aa3eaccf8e
commit 9e1f708f73
6 changed files with 47 additions and 83 deletions

View File

@ -3,6 +3,11 @@ $themeColor: #FF7142;
.orange{ .orange{
color:#FF7142, color:#FF7142,
} }
.blur{
color:#FF7142;
opacity: .65;
}
.orange-bg{ .orange-bg{
background-color:#FF7142, background-color:#FF7142,
} }

View File

@ -1,6 +1,6 @@
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, AtPagination } from 'taro-ui' import { AtInput, AtButton, Picker, AtIcon, 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 InteractionComponent from '../../component/interactionComponent/interactionComponent'
@ -20,61 +20,23 @@ class AllDemanding extends Component {
super(...arguments) super(...arguments)
this.state = { this.state = {
supplys: [], // 需求列表 supplys: [], // 需求列表
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: '' }, // 当前供求状态
industryTypeSelected: { name: '全部', id: '' },// 当前行业分类 industryTypeSelected: { name: '全部', id: '' },// 当前行业分类
title: '', title: '',
startDateSel: '', startDateSel: '',
endDateSel: '', endDateSel: '',
classId: '',
isOpenedGrabModal: false, isOpenedGrabModal: false,
grabOrderId: '',//抢到订单的id grabOrderId: '',//抢到订单的id
isGrabOrderSuccess: false,// 是否显示轻提示 isGrabOrderSuccess: false,// 是否显示轻提示
grabOrderSuccess: '无法显示绑定后的字段',// 抢单成功返回字段 grabOrderSuccess: '无法显示绑定后的字段',// 抢单成功返回字段
totalDemandings:0, totalDemandings: 0,
currentPage:1 currentPage: 1
} }
} }
//加载更多业主需求函数
loadMoreDemanding(
{ curr_page = 1, page_count = 20,
state = this.state.demandingStateSelected.id,
update_dateL = this.state.startDateSel,
update_dateU = this.state.endDateSel,
class_id = this.state.industryTypeSelected.id
}
) {
Taro.request({
url: URL.GetAllDemanding,
method: 'POST',
dataType: 'json',
data: {
param: JSON.stringify({
curr_page: curr_page,
page_count: page_count,
state: state,
update_dateL: update_dateL,
update_dateU: update_dateU,
class_id: class_id
}),
},
header: {
'content-type': 'application/x-www-form-urlencoded',
'X-Requested-With': 'XMLHttpRequest'
}
})
.then(res => {
if (res.data.supplys.length) {
Taro.hideLoading()
this.setState({ supplys: this.state.supplys.concat(res.data.supplys), isMore: 'more' })
} else {
this.setState({ isMore: 'noMore' })
}
})
}
// 搜索业主需求函数 // 搜索业主需求函数
searchDemanding({ curr_page = 1, page_count = 10, searchDemanding({ curr_page = 1, page_count = 10,
sd_title = this.state.title, sd_title = this.state.title,
@ -105,31 +67,24 @@ class AllDemanding extends Component {
} }
}) })
.then(res => { .then(res => {
Taro.hideLoading()
if(res.data.err_msg==='success'){
const total=Number(res.data.count)
this.setState({ supplys: res.data.supplys ,totalDemandings:total})
}else{ Taro.hideLoading()
if (res.data.err_msg === 'success') {
const total = Number(res.data.count)
this.setState({ supplys: res.data.supplys, totalDemandings: total })
} else {
Taro.showToast({ Taro.showToast({
title:res.data.err_msg, title: res.data.err_msg,
icon:'none', icon: 'none',
duration:1500 duration: 1500
}) })
} }
}) })
} }
// 向上拉升延迟一秒加载数据
handleLoadMore() {
this.setState({ isMore: 'loading' })
setTimeout(() => {
currentPage += 1
this.loadMoreDemanding({ curr_page: currentPage })
}, 1000);
}
// 改变需求选项 // 改变需求选项
changeDemandingState = e => { changeDemandingState = e => {
this.setState({ this.setState({
@ -221,20 +176,21 @@ class AllDemanding extends Component {
} }
// 翻页导航 // 翻页导航
paginationNav(type) { paginationNav(type) {
Taro.showLoading({ Taro.showLoading({
title:'加载中' title: '加载中'
}) })
this.setState({ currentPage: type.current, }, () => { this.setState({ currentPage: type.current, }, () => {
this.searchDemanding({ curr_page :this.state.currentPage, page_count : 10, this.searchDemanding({
sd_title : this.state.title, curr_page: this.state.currentPage, page_count: 10,
state : this.state.demandingStateSelected.id, sd_title: this.state.title,
update_dateL : this.state.startDateSel, state: this.state.demandingStateSelected.id,
update_dateU : this.state.endDateSel, update_dateL: this.state.startDateSel,
class_id : this.state.industryTypeSelected.id 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)
@ -290,13 +246,16 @@ class AllDemanding extends Component {
<View className='detail'> <View className='detail'>
<View className='title'>{item.sd_title}</View> <View className='title'>{item.sd_title}</View>
<View className='para'>{item.sd_desc}</View> <View className='para'>{item.sd_desc}</View>
<View className='button' onClick={this.grabOrder.bind(this, item.sd_id)}> {item.state_name === '在用' ? <View className='button' onClick={this.grabOrder.bind(this, item.sd_id)}>
<AtButton type='primary' size='small' className='orange'> {item.state_name === '在用' ? '抢单' : '已抢单'}</AtButton> <AtButton type='primary' size='small' className='orange'>抢单</AtButton>
</View> </View> : <View className='button' >
<AtButton type='primary' size='small' className='blur'> 已抢单</AtButton>
</View>
}
</View> </View>
</View> </View>
<View className='footer'> <View className='footer'>
<View className='location'><AtIcon value='map-pin' size='12' color='black'></AtIcon></View> <View className='location'><AtIcon value='map-pin' size='12' color='black'></AtIcon>{item.user_address}</View>
<View className='time'>更新日期:{item.update_date}</View> <View className='time'>更新日期:{item.update_date}</View>
</View> </View>

View File

@ -75,7 +75,7 @@ $themeColor: #FF7142;
} }
.button-b{ .button-b{
background-color:#d9534f; background-color:#d9534f;
border:1PX solid #d9534f; border:1PX solid #d9534f;
} }

View File

@ -37,8 +37,8 @@ class Index extends Component {
// url:'/pages/myNeeds/myNeeds', // url:'/pages/myNeeds/myNeeds',
//url:'/pages/myNeedsPublish/myNeedsPublish' //url:'/pages/myNeedsPublish/myNeedsPublish'
// url:'/pages/mySupplyDemand/mySupplyDemand' // url:'/pages/mySupplyDemand/mySupplyDemand'
// url:'/pages/home/home' url:'/pages/home/home'
url:'/pages/allDemanding/allDemanding' // url:'/pages/allDemanding/allDemanding'
}) })

View File

@ -142,6 +142,7 @@ class Shop extends Component {
} }
//侧边筛选商品类型 //侧边筛选商品类型
if (data.goods_type) { if (data.goods_type) {
// console.log('数据',data.goods_type)
let goodTypeArray = [] let goodTypeArray = []
Object.keys(data.goods_type).forEach(key => { Object.keys(data.goods_type).forEach(key => {
goodTypeArray.push({ id: data.goods_type[key].goods_type_id, name: data.goods_type[key].goods_type_ch_name, checked: false }) goodTypeArray.push({ id: data.goods_type[key].goods_type_id, name: data.goods_type[key].goods_type_ch_name, checked: false })

View File

@ -34,4 +34,3 @@ bug 商品编辑 增加图片后 图片顺序乱了
等待后台--- 单个我的商品页面的图片顺序,单个我的需求页面的接口, 当个我哦的需求编辑页面的接口 等待后台--- 单个我的商品页面的图片顺序,单个我的需求页面的接口, 当个我哦的需求编辑页面的接口
// switch ---- shopTypeInteractionComp