<template> <wybPopup @touchmove.stop ref="popup" zIndex="999" type="bottom" width="500" height="500" :scrollY="true" radius="0" :showCloseIcon="true"> <view class="pd-main wuliupop backcor9"> <view class="pop-title fontwig6 backcor9"><text>物流信息</text></view> <view class="pd-main backcolorfff border-8r font14" > <view class="dis-flex flex-sp mart10 marb10 paddbotm10 border-b"> <view class="dis-flex"> <!-- <image class="wuliu-img" src="https://pic.616pic.com/ys_bnew_img/00/07/04/1ZtrvD1AMY.jpg" mode="aspectFill"></image> --> <text class="paddleft5">{{tracesData.expressCompanyName}}</text> <text class="paddleft5">{{tracesData.number}}</text> </view> <view class="dis-flex "> <text @click="copyText(tracesData.number)">复制</text> <text class="paddleft5 paddtright5 fcor666">|</text> <text @click="callPhone">打电话</text> </view> </view> <trackNode v-for="(item, index) in tracesData.logisticsTraceDetails" :key="index" :is-first="index===tracesData.length-1" :is-newest="index===0" :is-main-node="item.logisticsStatus!='TRANSPORT'" :node-data="item"></trackNode> </view> </view> </wybPopup> </template> <script> import wybPopup from '@/components/wyb-popup/wyb-popup.vue' import trackNode from '../trackNode/trackNode.vue' import {getLogisticsMsg} from '@/Utils/physicalObject.js' export default { data () { return { tracesData:{}, phoneNumber:[], /* [ { acceptStation: '包裹已被吴亦发同学签收', // 节点描述 createTime: '2019-10-24 15: 27: 16', status: 'COMPLETE', // 节点状态 phone: '', // 电话 statusName: '已签收', // 节点标题 isMainNode: true // 是否主节点,主节点前方展示icon }, { acceptStation: '由派送员蔡小坤同志配送,电话:', createTime: '2019-10-24 15: 26: 41', status: 'DELIVERING', phone: '16677778888', statusName: '运输中', isMainNode: true }, { acceptStation: '已到XXX小区快递点', createTime: '2019-10-24 15: 26: 41', status: 'DELIVERING', phone: '', statusName: '运输中', isMainNode: false }, { acceptStation: '已到海宁集散中心', createTime: '2019-10-24 15: 26: 18', status: 'DELIVERING', phone: '', statusName: '运输中', isMainNode: false }, { acceptStation: '已到杭州集散中心', createTime: '2019-10-24 15: 26: 07', status: 'DELIVERING', phone: '', statusName: '运输中', isMainNode: false }, { acceptStation: '包裹已到达余杭区集散中心', createTime: '2019-10-24 15: 25: 54', status: 'DELIVERING', phone: '', statusName: '运输中', isMainNode: false }, { acceptStation: '快递员已上门取件', createTime: '2019-10-24 15: 25: 17', status: 'DELIVERING', phone: '', statusName: '已揽收', isMainNode: false }, { acceptStation: '等待快递员上门揽件', createTime: '2019-10-24 15: 25: 00', status: 'WATTING_DELIVER', phone: '', statusName: '已发货', isMainNode: true }, { acceptStation: '您的包裹正在打包', createTime: '2019-10-24 15: 24: 00', status: 'WATTING_DELIVER', phone: '', statusName: '待发货', isMainNode: false }, { acceptStation: '订单支付成功,等待商家发货', createTime: '2019-10-24 15: 22: 30', status: 'PAYED', statusName: '已支付', isMainNode: true }, { acceptStation: '订单提交成功', createTime: '2019-10-24 15: 22: 00', status: 'WATTING_PAY', statusName: '已下单', isMainNode: true } ] */ } }, components:{ wybPopup, trackNode }, created(){ }, methods:{ show(logisticsNo){ // console.log(logisticsNo) this.tracesData={}; this.$refs.popup.show(); this.getLogisticsMsg(logisticsNo) }, //查询物流信息 getLogisticsMsg(num){ let params ={ orderId:num } uni.showLoading({ title: '加载中', mask:true, }); getLogisticsMsg(params).then(res=>{ setTimeout(()=>{ uni.hideLoading(); if (res.return_code == '000000') { this.tracesData=res.return_data; this.tracesData.logisticsTraceDetails =JSON.parse(this.tracesData.logisticsTraceDetails) this.tracesData.logisticsTraceDetails=this.tracesData.logisticsTraceDetails.sort((item,item2)=>{ if(item.logisticsStatus == 'TRANSPORT'){ item.isMainNode=false; }else{ item.isMainNode=true; } return item2.time - item.time; }) let mobile = /(1[0-9]{10})|([0-9]{3,4})?[0-9]{7,8}/g; //匹配手机号或固话 let phone = []; this.tracesData.logisticsTraceDetails.map(item=>{ // 提取电话号码 // if(item.logisticsStatus == 'SIGN'||item.logisticsStatus == 'DELIVERING'){ let num = item.desc.replace(/\s|[(]|[)]|[(]|[)]|[-]*/g, ''); //去除字符串中所有空格、小括号和横杠 if(num.match(mobile)){ phone.push((num.match(mobile))) } // } }) this.phoneNumber =phone.flat(Infinity); // console.log(this.phoneNumber, phone) } else { uni.showToast({ title: res.return_msg, icon: 'none', duration: 2000 }) } },100) }) }, // 复制 copyText(text){ // #ifdef H5 this.$copyText(text).then( res => { uni.showToast({ title: '复制成功' }) } ) // #endif // #ifndef H5 uni.setClipboardData({ data: text, success: () => { uni.showToast({ title: '复制成功' }) } }) // #endif }, // 打电话 callPhone(){ if(this.phoneNumber.length==0){ uni.showToast({ title:"暂无可拨打电话号码", icon:'none' }) return } // 数组去重 this.phoneNumber = [...new Set(this.phoneNumber)]; let that = this; uni.showActionSheet({ itemList: that.phoneNumber, success: function (res) { // console.log('选中了第' + (res.tapIndex + 1) + '个按钮'); uni.makePhoneCall({ phoneNumber:String(that.phoneNumber[res.tapIndex]), //电话号码 success: function(e) { console.log(e); }, fail: function(e) { console.log(e); } }) }, fail: function (res) { // console.log("点击了取消"); } }); }, } } </script> <style lang="scss" scoped> .wuliu-img{ width: 30px; height: 30px; border-radius: 50%; } .border-b{ border-bottom: 2px solid #f6f6f6; } .wuliupop{ padding: 50px 10px 10px; } .pop-title{ text-align: center; height: 50px; line-height: 50px; font-size: 18px; position: fixed; top:0; left: 0; right: 0; z-index: 999; background-color: #f6f6f6; } </style>