cf-wx-app/src/pages/supplyDemandView/supplyDemandView.js

183 lines
5.6 KiB
JavaScript
Raw Normal View History

2018-12-29 17:15:59 +08:00
import Taro, { Component } from '@tarojs/taro'
2019-01-02 17:31:07 +08:00
import { View, Text, Image } from '@tarojs/components'
import { AtButton, AtIcon } from 'taro-ui'
import URL from '../../serviceAPI.config'
import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent'
2018-12-29 17:15:59 +08:00
import './supplyDemandView.scss'
class SupplyDemandView extends Component {
2019-01-02 17:31:07 +08:00
config = {
navigationBarTitleText: '供求查看'
}
constructor() {
super(...arguments)
this.state = {
demandingSupplyCate: [{name:'需求',id:'1'}, {name:'供求',id:'2'}, {name:'人才',id:'3'}], //供求类型选择
type: '',
title: '',
browsing: '',
contactName: '',
contactNumber: '',
address: '',
content: '',
images: [],
}
}
//获取商品信息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',
'Cookie': 'PFWSSS=' + Taro.getStorageSync('session_id'),
'X-Requested-With': 'XMLHttpRequest'
}
})
.then(res => {
console.log('供求详情获取成功', res)
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,
})
Taro.hideLoading()
}
)
.catch(error => {
console.log('供求详情获取失败', error)
})
}
goToSDPublishPage() {
Taro.navigateTo({
url: '/pages/supplyDemandPublish/supplyDemandPublish',// 供求发布页面
})
}
goToSDEditPage() {
console.log('edit page')
// Taro.navigateTo({
// url: 'pages/supplyDemandPublish/supplyDemandPublish',// 供求发布页面
// })
2018-12-29 17:15:59 +08:00
}
2019-01-02 17:31:07 +08:00
goToMySDPage() {
Taro.navigateTo({
url: '/pages/mySupplyDemand/mySupplyDemand',//我的供求页面
})
2018-12-29 17:15:59 +08:00
}
2019-01-02 17:31:07 +08:00
deleteSD() {
console.log('删除供求')
}
componentDidMount() {
Taro.showLoading({title:'加载中'})
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'>
<Image mode='aspectFit' style='width: 100%;'
src={URL.Base + item.file_path}
/>
</View>
})
2018-12-29 17:15:59 +08:00
return (
<View className='SupplyDemandItemView'>
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>
<Text className='content'>{this.state.contactNumber}</Text>
</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)}>
<AtButton type='primary' size='small'>
<AtIcon value='add' size='12' color='white'></AtIcon>
新增</AtButton>
</View>
<View className='button' onClick={this.goToSDEditPage.bind(this)}>
<AtButton type='primary' className='button' size='small'>
<AtIcon value='settings' size='12' color='white'></AtIcon>
修改</AtButton>
</View>
<View className='button' onClick={this.goToMySDPage.bind(this)}>
<AtButton type='primary' className='button' size='small'>
<AtIcon value='' size='12' color='white'></AtIcon>
我的供求</AtButton>
</View>
<View className='button' onClick={this.deleteSD.bind(this)}>
<AtButton type='primary' className='button-a' size='small'>
<AtIcon value='close' size='12' color='white'></AtIcon>
删除</AtButton>
</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