(uni-app)APISpace物流查询工具类

官网地址 APISpace - API数据接口

获取快递公司信息

const mailDiscern = (mailNo) => {
	return new Promise((resolve, reject) => {
		uni.request({
			url: 'https://eolink.o.apispace.com/wlgj1/paidtobuy_api/mail_discern',
			method: 'POST',
			header: {"X-APISpace-Token": '你的token', "Content-Type": 'application/json'},
			dataType: 'json',
			data: {mailNo: mailNo}
		}).then(response => {
			let [error, res] = response
			if (error) {
				toast('后端接口连接异常')
				reject('后端接口连接异常')
				return
			}
			
			const code = res.statusCode
			if (code !== 200) {
				uni.hideLoading()
				toast('获取快递公司失败, 请手动输入!')
				reject('获取快递公司失败, 请手动输入!')
				return
			}
			
			resolve(res.data)
		}).catch(error => {
			let {
				message
			} = error
			if (message === 'Network Error') {
				message = '后端接口连接异常'
			} else if (message.includes('timeout')) {
				message = '系统接口请求超时'
			} else if (message.includes('Request failed with status code')) {
				message = '系统接口' + message.substr(message.length - 3) + '异常'
			}
			toast(message)
			reject(error)
		})
	})
}

获取物流信息

const traceSearch = (logistics) => {
	return new Promise((resolve, reject) => {
		uni.request({
			url: 'https://eolink.o.apispace.com/wlgj1/paidtobuy_api/trace_search',
			method: 'POST',
			header: {"X-APISpace-Token": '你的token', "Content-Type": 'application/json'},
			dataType: 'json',
			data: {...logistics, orderType: 'desc'}
		}).then(response => {
			let [error, res] = response
			if (error) {
				toast('后端接口连接异常')
				reject('后端接口连接异常')
				return
			}
			
			const code = res.statusCode
			if (code !== 200) {
				uni.hideLoading()
				toast('获取快递公司失败, 请手动输入!')
				reject('获取快递公司失败, 请手动输入!')
				return
			}
			
			resolve(res.data)
		}).catch(error => {
			let {
				message
			} = error
			if (message === 'Network Error') {
				message = '后端接口连接异常'
			} else if (message.includes('timeout')) {
				message = '系统接口请求超时'
			} else if (message.includes('Request failed with status code')) {
				message = '系统接口' + message.substr(message.length - 3) + '异常'
			}
			toast(message)
			reject(error)
		})
	})
}

物流状态字典

logisticsStatus: {
		WAIT_ACCEPT: {
			text: '待揽收',
			subStatus: {
				RECEIVE: '接单中',
				WAIT_ACCEPT: '待揽收'
			}
		},
		ACCEPT: {
			text: '已揽收',
			subStatus: {
				ACCEPT: '已揽收'
			}
		},
		TRANSPORT: {
			text: '运输中',
			subStatus: {
				TRANSPORT: '运输中',
				SEND_ON: '转单或修改地址转寄',
				ARRIVE_CITY: '到达目的城市'
			}
		},
		DELIVERING: {
			text: '派件中',
			subStatus: {
				DELIVERING: '派件中',
				STA_INBOUND: '已放入快递柜或驿站'
			}
		},
		AGENT_SIGN: {
			text: '已代签收',
			subStatus: {
				AGENT_SIGN: '已代签收'
			}
		},
		SIGN: {
			text: '已签收',
			subStatus: {
				SIGN: '已签收',
				STA_SIGN: '从快递柜或者驿站取出',
				RETURN_SIGN: '退回签收'
			}
		},
		FAILED: {
			text: '包裹异常',
			subStatus: {
				FAILED: '包裹异常',
				REFUSE_SIGN: '拒收',
				DELIVER_ABNORMAL: '派件异常',
				RETENTION: '滞留件',
				ISSUE: '问题件',
				RETURN: '退回件',
				DAMAGE: '破损',
				CANCEL_ORDER: '揽件取消'
			}
		}
	}
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值