import Taro, { Component } from '@tarojs/taro'
import { View, Text, Image } from '@tarojs/components'
import { AtButton, AtIcon } from 'taro-ui'
import URL from '../../serviceAPI.config'
import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent'
import './supplyDemandView.scss'
class SupplyDemandView extends Component {
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',// 供求发布页面
// })
}
goToMySDPage() {
Taro.navigateTo({
url: '/pages/mySupplyDemand/mySupplyDemand',//我的供求页面
})
}
deleteSD() {
console.log('删除供求')
}
componentDidMount() {
Taro.showLoading({title:'加载中'})
this.getSupplyDemandInfo()
}
componentWillReceiveProps(nextProps) {
console.log(this.props, nextProps)
}
componentWillUnmount() { }
componentDidShow() { }
componentDidHide() { }
render() {
const imageElementArray = this.state.images.map((item, index) => {
return
})
return (
供求类型:
{this.state.type}
需求标题:
{this.state.title}
浏览量:
{this.state.browsing}
联系人:
{this.state.contactName}
联系电话:
{this.state.contactNumber}
联系地址:
{this.state.address}
需求内容:
{this.state.content}
需求图片:
{imageElementArray}
新增
修改
我的供求
删除
)
}
}
export default SupplyDemandView