//grabOrderPage
import Taro, { Component } from '@tarojs/taro'
import { View, Text, Button, Image } from '@tarojs/components'
import { AtModal, AtModalHeader, AtModalContent, AtModalAction, AtIcon } from 'taro-ui'
import URL from '../../serviceAPI.config'
import CopyrightComponent from '../../component/copyrightComponent/copyrightComponent'
import './grabOrderPage.scss'
import { SymbolDef } from '_terser@3.14.1@terser';
class GrabOrderPage extends Component {
config = {
navigationBarTitleText: '抢单页面'
}
constructor() {
super(...arguments);
this.state = {
type: '',
title: '',
browsing: '',
contactName: '',
contactNumber: '',
address: '',
content: '',
images: [],
isOpen: false, // 抢单消息提示
grabOrderId: this.$router.params.orderId,
stateId: '',
stateName: '',
userId: ''
}
}
//获取抢单信息api supplyDemandDetails
getGrabOrderInfo() {
Taro.request({
url: URL.supplyDemandDetails,
method: 'GET',
dataType: 'json',
data: {
demandId: this.$router.params.orderId,
},
header: {
'content-type': 'application/x-www-form-urlencoded',
'Cookie': 'PFWSSS=' + Taro.getStorageSync('session_id'),
'X-Requested-With': 'XMLHttpRequest'
}
})
.then(res => {
console.log('抢单详情获取成功', res)
this.setState({
type: res.data.sdInfo.class_name,
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,
stateId: res.data.sdInfo.state,
stateName: res.data.sdInfo.state_name,
userId: res.data.sdInfo.user_id
})
}
)
.catch(error => {
console.log('抢单详情获取失败', error)
})
}
//抢单请求
GrabDemand({ demandId = 218 }) {
Taro.request({
url: URL.GrabDemand,
method: 'POST',
dataType: 'json',
data: {
demandId: demandId
},
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') {
Taro.showToast({
title: '抢单成功',
icon: 'success',
duration: 1500
})
setTimeout(() => {
Taro.navigateTo({
url: '/pages/home/home'
})
}, 1500);
} else {
Taro.showToast({
title: res.data.err_msg,
icon: 'none',
duration: 1500
})
}
console.log('抢单请求:', res)
})
}
callPhoneNumber() {
Taro.makePhoneCall({
phoneNumber: this.state.contactNumber
})
}
grabButtonHandler() {
this.setState({ isOpen: true })
}
handleGrabModalClose() {
this.setState({ isOpen: false })
}
handleGrabModalCancel() {
this.setState({ isOpen: false })
}
handleGrabConfirm() {
this.setState({ isOpen: false })
// 确认抢单之后
this.GrabDemand({ demandId: this.state.grabOrderId })
}
componentDidMount() {
this.getGrabOrderInfo()
}
componentWillReceiveProps(nextProps) {
console.log(this.props, nextProps)
}
componentWillUnmount() { }
componentDidShow() { }
componentDidHide() { }
render() {
const localStoageUserId = Taro.getStorageSync('userInfo').user_id
let ButtonElement
if (localStoageUserId === this.state.userId && this.state.stateId === '1') {
ButtonElement =
} else if (localStoageUserId === this.state.userId && this.state.stateId != '1') {
ButtonElement =
} else if (this.state.stateId === '1') {
ButtonElement =
} else if (this.state.stateId === '2') {
ButtonElement =
} else if (this.state.stateId === '3') {
ButtonElement =
}
// 提示模态弹窗element
const modalMessageGrabElement =
提示
确认抢单?
const imageElementArray = this.state.images.map((item, index) => {
return
})
return (
{modalMessageGrabElement}
行业分类:
{this.state.type}
业主需求标题:
{this.state.title}
浏览量:
{this.state.browsing}
联系人:
{this.state.contactName}
联系电话:
{this.state.contactNumber}
联系地址:
{this.state.address}
业主需求内容:
{this.state.content}
{this.state.images.length ? 业主需求图片: : null}
{imageElementArray}
{ButtonElement}
)
}
}
export default GrabOrderPage