2018-12-29 17:15:59 +08:00
|
|
|
|
|
|
|
|
|
import Taro, { Component } from '@tarojs/taro'
|
2019-02-20 16:59:06 +08:00
|
|
|
|
import { View, Text, Image, Button } from '@tarojs/components'
|
|
|
|
|
import { AtIcon, AtModal, AtModalHeader, AtModalContent, AtModalAction } from 'taro-ui'
|
2019-01-02 17:31:07 +08:00
|
|
|
|
|
|
|
|
|
import URL from '../../serviceAPI.config'
|
|
|
|
|
import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent'
|
2018-12-29 17:15:59 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import './supplyDemandView.scss'
|
2019-02-20 16:59:06 +08:00
|
|
|
|
import loginExpired from '../../util/loginExpired';
|
2019-03-08 17:32:42 +08:00
|
|
|
|
import { getGlobalStorage } from '../../util/getSetStoage';
|
2018-12-29 17:15:59 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class SupplyDemandView extends Component {
|
2019-01-02 17:31:07 +08:00
|
|
|
|
config = {
|
|
|
|
|
navigationBarTitleText: '供求查看'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
constructor() {
|
|
|
|
|
super(...arguments)
|
|
|
|
|
this.state = {
|
2019-02-20 16:59:06 +08:00
|
|
|
|
demandingSupplyCate: [{ name: '需求', id: '1' }, { name: '供求', id: '2' }, { name: '人才', id: '3' }], //供求类型选择
|
2019-01-02 17:31:07 +08:00
|
|
|
|
type: '',
|
|
|
|
|
title: '',
|
|
|
|
|
browsing: '',
|
|
|
|
|
contactName: '',
|
|
|
|
|
contactNumber: '',
|
|
|
|
|
address: '',
|
|
|
|
|
content: '',
|
|
|
|
|
images: [],
|
2019-02-20 16:59:06 +08:00
|
|
|
|
isDeleteModal: false
|
2019-01-02 17:31:07 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//获取商品信息api GetProductInfo
|
|
|
|
|
getSupplyDemandInfo() {
|
|
|
|
|
Taro.request({
|
|
|
|
|
url: URL.GetSupplyDemandInfo,
|
|
|
|
|
method: 'GET',
|
|
|
|
|
dataType: 'json',
|
|
|
|
|
data: {
|
|
|
|
|
sdID: this.$router.params.sdId,
|
|
|
|
|
},
|
|
|
|
|
header: {
|
|
|
|
|
'content-type': 'application/x-www-form-urlencoded',
|
2019-03-08 17:32:42 +08:00
|
|
|
|
'Cookie': 'PFWSSS=' + getGlobalStorage('session_id'),
|
2019-01-02 17:31:07 +08:00
|
|
|
|
'X-Requested-With': 'XMLHttpRequest'
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.then(res => {
|
|
|
|
|
console.log('供求详情获取成功', res)
|
2019-03-04 17:42:02 +08:00
|
|
|
|
Taro.hideLoading()
|
2019-02-20 16:59:06 +08:00
|
|
|
|
if (res.data.err_code === 0) {
|
|
|
|
|
const selectedType = this.state.demandingSupplyCate.filter(item => item.id === res.data.sdInfo.sd_type)[0].name
|
|
|
|
|
this.setState({
|
|
|
|
|
type: selectedType,
|
|
|
|
|
title: res.data.sdInfo.sd_title,
|
|
|
|
|
browsing: res.data.sdInfo.browse_times,
|
|
|
|
|
contactName: res.data.sdInfo.user_name,
|
|
|
|
|
contactNumber: res.data.sdInfo.user_phone,
|
|
|
|
|
address: res.data.sdInfo.user_address,
|
|
|
|
|
content: res.data.sdInfo.sd_desc,
|
|
|
|
|
images: res.data.sdInfo.file_path,
|
|
|
|
|
itemId: res.data.sdInfo.sd_id
|
|
|
|
|
})
|
2019-03-04 17:42:02 +08:00
|
|
|
|
|
2019-02-20 16:59:06 +08:00
|
|
|
|
} else if (res.data.err_code === 88888) {
|
|
|
|
|
loginExpired(res)
|
2019-03-04 17:42:02 +08:00
|
|
|
|
}else{
|
|
|
|
|
Taro.showToast({
|
|
|
|
|
title:res.data.err_msg,
|
|
|
|
|
icon:'none'
|
|
|
|
|
})
|
|
|
|
|
}
|
2019-01-02 17:31:07 +08:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
)
|
2019-02-20 16:59:06 +08:00
|
|
|
|
|
2019-01-02 17:31:07 +08:00
|
|
|
|
}
|
2019-02-20 16:59:06 +08:00
|
|
|
|
// 删除我的供求api
|
|
|
|
|
onDelete({ sdID = 0 }) {
|
2019-01-09 16:46:57 +08:00
|
|
|
|
Taro.request({
|
2019-02-20 16:59:06 +08:00
|
|
|
|
url: URL.DeleteDemandSupply,
|
|
|
|
|
method: 'POST',
|
|
|
|
|
dataType: 'json',
|
|
|
|
|
data: {
|
|
|
|
|
sdID: sdID
|
|
|
|
|
},
|
|
|
|
|
header: {
|
|
|
|
|
'content-type': 'application/x-www-form-urlencoded',
|
2019-03-08 17:32:42 +08:00
|
|
|
|
'Cookie': 'PFWSSS=' + getGlobalStorage('session_id'),
|
2019-02-20 16:59:06 +08:00
|
|
|
|
'X-Requested-With': 'XMLHttpRequest'
|
|
|
|
|
}
|
2019-01-09 16:46:57 +08:00
|
|
|
|
})
|
2019-02-20 16:59:06 +08:00
|
|
|
|
.then(res => {
|
2019-03-06 14:16:09 +08:00
|
|
|
|
Taro.hideLoading()
|
2019-02-20 16:59:06 +08:00
|
|
|
|
if (res.data.err_code == 0) {
|
|
|
|
|
console.log('删除成功')
|
|
|
|
|
Taro.showToast({
|
|
|
|
|
title: '删除成功',
|
|
|
|
|
icon: 'success',
|
|
|
|
|
duration: 1500
|
|
|
|
|
}).then(() => {
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
this.goToMySDPage()
|
|
|
|
|
}, 1500);
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
} else if (res.data.err_code === 88888) {
|
|
|
|
|
loginExpired(res)
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
Taro.showToast({
|
|
|
|
|
title: res.data.err_msg,
|
|
|
|
|
icon: 'none'
|
|
|
|
|
})
|
2019-01-09 16:46:57 +08:00
|
|
|
|
|
|
|
|
|
}
|
2019-02-20 16:59:06 +08:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
}
|
2019-01-02 17:31:07 +08:00
|
|
|
|
goToSDPublishPage() {
|
2019-03-05 17:32:53 +08:00
|
|
|
|
Taro.redirectTo({
|
2019-01-02 17:31:07 +08:00
|
|
|
|
url: '/pages/supplyDemandPublish/supplyDemandPublish',// 供求发布页面
|
|
|
|
|
})
|
|
|
|
|
}
|
2019-01-09 16:46:57 +08:00
|
|
|
|
// 跳转到我的供求编辑页面
|
|
|
|
|
goToMyDSEditPage() {
|
2019-03-05 17:32:53 +08:00
|
|
|
|
Taro.redirectTo({
|
2019-02-20 16:59:06 +08:00
|
|
|
|
url: '/pages/myDemandSupplyEdit/myDemandSupplyEdit?sdId=' + this.state.itemId
|
2019-01-09 16:46:57 +08:00
|
|
|
|
})
|
2019-01-02 17:31:07 +08:00
|
|
|
|
|
2019-02-20 16:59:06 +08:00
|
|
|
|
}
|
2019-01-02 17:31:07 +08:00
|
|
|
|
goToMySDPage() {
|
2019-03-05 17:32:53 +08:00
|
|
|
|
Taro.redirectTo({
|
2019-01-02 17:31:07 +08:00
|
|
|
|
url: '/pages/mySupplyDemand/mySupplyDemand',//我的供求页面
|
|
|
|
|
})
|
2018-12-29 17:15:59 +08:00
|
|
|
|
}
|
2019-02-20 16:59:06 +08:00
|
|
|
|
makeAPhoneCall() {
|
2019-01-09 16:46:57 +08:00
|
|
|
|
Taro.makePhoneCall({
|
|
|
|
|
phoneNumber: this.state.contactNumber
|
|
|
|
|
})
|
|
|
|
|
}
|
2019-02-20 16:59:06 +08:00
|
|
|
|
|
2019-01-09 16:46:57 +08:00
|
|
|
|
deleteButton() {
|
|
|
|
|
this.setState({ isDeleteModal: true })
|
2019-01-02 17:31:07 +08:00
|
|
|
|
}
|
2019-01-09 16:46:57 +08:00
|
|
|
|
handleWindowModCancel() {
|
|
|
|
|
this.setState({ isDeleteModal: false })
|
|
|
|
|
}
|
|
|
|
|
handleWindowConfirm() {
|
|
|
|
|
this.setState({ isDeleteModal: false })
|
2019-03-06 14:16:09 +08:00
|
|
|
|
Taro.showLoading({
|
|
|
|
|
title: '加载中'
|
|
|
|
|
})
|
2019-01-09 16:46:57 +08:00
|
|
|
|
this.onDelete({ sdID: this.state.itemId })
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-02 17:31:07 +08:00
|
|
|
|
|
|
|
|
|
componentDidMount() {
|
2019-02-20 16:59:06 +08:00
|
|
|
|
Taro.showLoading({ title: '加载中' })
|
2019-01-02 17:31:07 +08:00
|
|
|
|
this.getSupplyDemandInfo()
|
|
|
|
|
}
|
|
|
|
|
componentWillReceiveProps(nextProps) {
|
2018-12-29 17:15:59 +08:00
|
|
|
|
console.log(this.props, nextProps)
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-02 17:31:07 +08:00
|
|
|
|
componentWillUnmount() { }
|
2018-12-29 17:15:59 +08:00
|
|
|
|
|
2019-01-02 17:31:07 +08:00
|
|
|
|
componentDidShow() { }
|
2018-12-29 17:15:59 +08:00
|
|
|
|
|
2019-01-02 17:31:07 +08:00
|
|
|
|
componentDidHide() { }
|
2018-12-29 17:15:59 +08:00
|
|
|
|
|
2019-01-02 17:31:07 +08:00
|
|
|
|
render() {
|
|
|
|
|
const imageElementArray = this.state.images.map((item, index) => {
|
|
|
|
|
return <View key={index} className='image-box'>
|
2019-01-09 16:46:57 +08:00
|
|
|
|
<Image mode='widthFix' style='width: 100%;'
|
2019-01-02 17:31:07 +08:00
|
|
|
|
src={URL.Base + item.file_path}
|
|
|
|
|
/>
|
|
|
|
|
</View>
|
|
|
|
|
})
|
2019-01-09 16:46:57 +08:00
|
|
|
|
const deleteModalWindowElement = <AtModal isOpened={this.state.isDeleteModal}>
|
2019-02-20 16:59:06 +08:00
|
|
|
|
<AtModalHeader>提示</AtModalHeader>
|
|
|
|
|
<AtModalContent>
|
|
|
|
|
确认删除{this.state.needsItem.sd_title}?
|
2019-01-09 16:46:57 +08:00
|
|
|
|
</AtModalContent>
|
2019-02-20 16:59:06 +08:00
|
|
|
|
<AtModalAction> <Button onClick={this.handleWindowModCancel.bind(this)}>取消</Button> <Button className='orange' onClick={this.handleWindowConfirm.bind(this)}>确定</Button> </AtModalAction>
|
|
|
|
|
</AtModal>
|
2018-12-29 17:15:59 +08:00
|
|
|
|
return (
|
|
|
|
|
<View className='SupplyDemandItemView'>
|
2019-02-20 16:59:06 +08:00
|
|
|
|
{deleteModalWindowElement}
|
2019-01-02 17:31:07 +08:00
|
|
|
|
<View className='type box'>
|
|
|
|
|
<Text className='title'>供求类型:</Text>
|
|
|
|
|
<Text className='content'>{this.state.type}</Text>
|
|
|
|
|
</View>
|
|
|
|
|
<View className='needed-title box'>
|
|
|
|
|
<Text className='title'>需求标题:</Text>
|
|
|
|
|
<Text className='content'>{this.state.title}</Text>
|
|
|
|
|
</View>
|
|
|
|
|
<View className='browsing-amount box'>
|
|
|
|
|
<Text className='title'>浏览量:</Text>
|
|
|
|
|
<Text className='content'>{this.state.browsing}</Text>
|
|
|
|
|
</View>
|
|
|
|
|
<View className='contact-name box'>
|
|
|
|
|
<Text className='title'>联系人:</Text>
|
|
|
|
|
<Text className='content'>{this.state.contactName}</Text>
|
|
|
|
|
</View>
|
|
|
|
|
<View className='phone-number box'>
|
|
|
|
|
<Text className='title'>联系电话:</Text>
|
2019-01-09 16:46:57 +08:00
|
|
|
|
<Text className='content highlight' onClick={this.state.makeAPhoneCall.bind(this)}>{this.state.contactNumber}</Text>
|
2019-01-02 17:31:07 +08:00
|
|
|
|
</View>
|
|
|
|
|
<View className='address box'>
|
|
|
|
|
<Text className='title'>联系地址:</Text>
|
|
|
|
|
<Text className='content'>{this.state.address}</Text>
|
|
|
|
|
</View>
|
|
|
|
|
<View className='needed-content box'>
|
|
|
|
|
<Text className='title'>需求内容:</Text>
|
|
|
|
|
<Text className='content'>{this.state.content}</Text>
|
|
|
|
|
</View>
|
|
|
|
|
<View className='needed-content box'>
|
|
|
|
|
<Text className='title'>需求图片:</Text>
|
|
|
|
|
<View className='image-container'>
|
|
|
|
|
{imageElementArray}
|
|
|
|
|
</View>
|
|
|
|
|
</View>
|
|
|
|
|
|
|
|
|
|
<View className='button-box'>
|
|
|
|
|
<View className='button' onClick={this.goToSDPublishPage.bind(this)}>
|
2019-02-20 16:59:06 +08:00
|
|
|
|
<Button className='button-green' size='mini' >
|
2019-01-02 17:31:07 +08:00
|
|
|
|
<AtIcon value='add' size='12' color='white'></AtIcon>
|
2019-01-10 17:36:45 +08:00
|
|
|
|
新增</Button>
|
2019-01-02 17:31:07 +08:00
|
|
|
|
</View>
|
2019-01-09 16:46:57 +08:00
|
|
|
|
<View className='button' onClick={this.goToMyDSEditPage.bind(this)}>
|
2019-02-20 16:59:06 +08:00
|
|
|
|
<Button className='button-blue' size='mini'>
|
2019-01-02 17:31:07 +08:00
|
|
|
|
<AtIcon value='settings' size='12' color='white'></AtIcon>
|
2019-01-10 17:36:45 +08:00
|
|
|
|
修改</Button>
|
2019-01-02 17:31:07 +08:00
|
|
|
|
</View>
|
|
|
|
|
<View className='button' onClick={this.goToMySDPage.bind(this)}>
|
2019-02-20 16:59:06 +08:00
|
|
|
|
<Button className='button-orange' size='mini'>
|
2019-01-02 17:31:07 +08:00
|
|
|
|
<AtIcon value='' size='12' color='white'></AtIcon>
|
2019-01-10 17:36:45 +08:00
|
|
|
|
我的供求</Button>
|
2019-01-02 17:31:07 +08:00
|
|
|
|
</View>
|
2019-01-09 16:46:57 +08:00
|
|
|
|
<View className='button' onClick={this.deleteButton.bind(this)}>
|
2019-02-20 16:59:06 +08:00
|
|
|
|
<Button className='button-dark-red' size='mini'>
|
2019-01-17 08:52:30 +08:00
|
|
|
|
<AtIcon value='trash' size='12' color='white'></AtIcon>
|
2019-01-10 17:36:45 +08:00
|
|
|
|
删除</Button>
|
2019-01-02 17:31:07 +08:00
|
|
|
|
</View>
|
|
|
|
|
</View>
|
|
|
|
|
<CopyrightComponent></CopyrightComponent>
|
2018-12-29 17:15:59 +08:00
|
|
|
|
</View>
|
2019-01-02 17:31:07 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-12-29 17:15:59 +08:00
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default SupplyDemandView
|