import Taro, { Component } from '@tarojs/taro' import { View, Text, Image,Button } from '@tarojs/components' import { AtIcon,AtModal, AtModalHeader, AtModalContent, AtModalAction } 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: [], isDeleteModal:false } } //获取商品信息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, itemId:res.data.sdInfo.sd_id }) Taro.hideLoading() } ) .catch(error => { console.log('供求详情获取失败', error) }) } // 删除我的供求api onDelete({ sdID = 0 }) { Taro.request({ url: URL.DeleteDemandSupply, method: 'POST', dataType: 'json', data: { sdID: sdID }, header: { 'content-type': 'application/x-www-form-urlencoded', 'Cookie': 'PFWSSS=' + Taro.getStorageSync('session_id'), 'X-Requested-With': 'XMLHttpRequest' } }) .then(res => { if (res.data.err_msg == 'success') { console.log('删除成功') Taro.showToast({ title: '删除成功', icon:'success', duration:1500 }).then(() => { setTimeout(() => { this.goToMySDPage() }, 1500); }) } else { Taro.showToast({ title: res.data.err_msg, icon: 'none' }) } } ) .catch(error => { Taro.showToast({ title: '删除失败', icon: 'none' }) }) } goToSDPublishPage() { Taro.reLaunch({ url: '/pages/supplyDemandPublish/supplyDemandPublish',// 供求发布页面 }) } // 跳转到我的供求编辑页面 goToMyDSEditPage() { Taro.navigateTo({ url: '/pages/myDemandSupplyEdit/myDemandSupplyEdit?sdId=' + this.state.itemId }) } goToMySDPage() { Taro.reLaunch({ url: '/pages/mySupplyDemand/mySupplyDemand',//我的供求页面 }) } makeAPhoneCall(){ Taro.makePhoneCall({ phoneNumber: this.state.contactNumber }) } deleteButton() { this.setState({ isDeleteModal: true }) } handleWindowModCancel() { this.setState({ isDeleteModal: false }) } handleWindowConfirm() { this.setState({ isDeleteModal: false }) this.onDelete({ sdID: this.state.itemId }) } 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 }) const deleteModalWindowElement = 提示 确认删除{this.state.needsItem.sd_title}? return ( {deleteModalWindowElement} 供求类型: {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