OfficeApp/pages/logistics/deliveryDetil.vue

407 lines
9.6 KiB
Vue
Raw Normal View History

2023-08-09 09:11:05 +08:00
<template>
2023-08-14 18:21:45 +08:00
<view>
2023-08-10 17:32:12 +08:00
<view v-if='showLoading'>
<u-loading-page :loading="showLoading"></u-loading-page>
2023-08-09 09:11:05 +08:00
</view>
2023-08-10 17:32:12 +08:00
<view v-else>
2023-08-14 18:21:45 +08:00
<view class="content">
<u-toast ref="uToast"></u-toast>
<view class="map">
2023-08-18 09:00:40 +08:00
<map :class="mapClass" id="map" @markertap='mapFun' :enable-zoom="true" :polyline="polyline"
:markers='markers' :scale="scale" style="width:100%;height: 70%;"
:latitude="markers[0].latitude" :enable-scroll="true" :longitude="markers[0].longitude">
2023-08-14 18:21:45 +08:00
<cover-image class="map_btn" @tap="test" src="../../static/img/logistics/DH.png">
</cover-image>
</map>
<view class="map_address">
<view>
<text class="cir" style="background-color: #40BC5E;"></text> 起点:&nbsp;&nbsp;{{nowAddress}}
</view>
<view>
<text class="cir" style="background-color: #FF7C32;"></text>
终点:&nbsp;&nbsp;{{goodsDetil.logistics.shop_address}}
</view>
2023-08-11 16:00:08 +08:00
2023-08-14 18:21:45 +08:00
</view>
2023-08-09 09:11:05 +08:00
</view>
2023-08-14 18:21:45 +08:00
<view class="order_info">
<view class="top">
<view>
订单号信息:
</view>
<view>订单编号:&nbsp;&nbsp;{{goodsDetil.logistics.order_sn}}</view>
<view>
商户名称:&nbsp;&nbsp; {{goodsDetil.logistics.shop_name}}
</view>
<view @click.stop="callFn(goodsDetil.logistics.shop_phone)">
联系电话:&nbsp;&nbsp; <u-icon style="display: inline-block;margin-left: 5rpx;" name="phone"
color="#fff" size="22"></u-icon>{{goodsDetil.logistics.shop_phone}}
</view>
<view>
店铺地址:&nbsp;&nbsp;{{goodsDetil.logistics.shop_address}}
</view>
2023-08-10 17:32:12 +08:00
</view>
2023-08-14 18:21:45 +08:00
<view class="mark">
请详细核对订单信息
2023-08-09 09:11:05 +08:00
</view>
2023-08-14 18:21:45 +08:00
2023-08-09 09:11:05 +08:00
</view>
2023-08-14 18:21:45 +08:00
<view class="order_info" style="background-color: #47BE62;">
<view class="top">
<view>
物流信息:
</view>
2023-08-16 09:27:10 +08:00
<view>用户名称:&nbsp;&nbsp;{{fuzzyName( goodsDetil.logistics.receiver_name)}}</view>
2023-08-14 18:21:45 +08:00
<view>
通知时间:&nbsp;&nbsp;{{goodsDetil.logistics.create_time}}
</view>
<view class="pro_list">
<text>
商品信息
</text>
<view class="goods">
<view class="goods_tit" v-for="(item,index) in goodsDetil.product">
<text style="flex: 8;">{{item.goods_name}}</text>
<text style="flex: 2;">X{{item.product_num}}{{item.goods_unit}}</text>
</view>
</view>
2023-08-10 17:32:12 +08:00
</view>
2023-08-09 09:11:05 +08:00
2023-08-10 17:32:12 +08:00
</view>
2023-08-14 18:21:45 +08:00
<view class="mark" style="display: flex; justify-content: space-between;">
<text>请详细核对订单信息</text>
<text style="color: #0122C7;">共计{{goodsDetil.product_count}}件商品</text>
</view>
2023-08-10 17:32:12 +08:00
</view>
2023-08-09 09:11:05 +08:00
2023-08-18 09:00:40 +08:00
<view style="margin-top: 200rpx;height: 1px;">
<!-- 565 -->
</view>
2023-08-14 18:21:45 +08:00
<view class="btn">
2023-08-18 09:00:40 +08:00
<u-button @click="qrqodeFn" type="primary" style="background-color: #0122C7;border: 0;">
<u-icon name="scan" color="white" size="30" style="margin-right: 10rpx;"></u-icon>
2023-08-14 18:21:45 +08:00
扫码取货</u-button>
2023-08-10 17:32:12 +08:00
</view>
2023-08-09 09:11:05 +08:00
</view>
</view>
2023-08-10 17:32:12 +08:00
2023-08-14 18:21:45 +08:00
2023-08-09 09:11:05 +08:00
</view>
</template>
<script>
import {
getDetil
} from "@/api/logistics.js"
import {
takeGoods
} from "@/api/logistics.js"
export default {
data() {
return {
2023-08-18 09:00:40 +08:00
mapClass: 'custom-map',
2023-08-10 17:32:12 +08:00
showLoading: true,
2023-08-09 09:11:05 +08:00
showPop: false,
goodsDetil: undefined,
2023-08-16 16:51:41 +08:00
scale: 17,
2023-08-14 18:21:45 +08:00
nowAddress: "无",
markers: [
// 商家
{
id: 1,
latitude: undefined,
longitude: undefined,
iconPath: '../../static/img/logistics/SJ.png', //显示的图标
},
// 骑手
{
id: 2,
latitude: undefined,
longitude: undefined,
iconPath: '../../static/img/logistics/QS.png', //显示的图标
}
],
polyline: []
2023-08-09 09:11:05 +08:00
}
},
methods: {
2023-08-14 18:21:45 +08:00
fuzzyName(name) {
let length = name.length;
let fuzzyChars = "*".repeat(length - 1);
return name[0] + fuzzyChars;
},
callFn(num) {
uni.makePhoneCall({
phoneNumber: num
});
},
// 获取位置
// 位置
locationFn() {
let that = this
2023-08-16 09:27:10 +08:00
//#ifdef APP
2023-08-14 18:21:45 +08:00
uni.getLocation({
type: 'gcj02',
geocode: true,
isHighAccuracy: true,
success: function async (res) {
that.nowAddress = res.address.city + res.address.district + res.address.street + res
.address.streetNum + res.address.poiName
2023-08-18 09:00:40 +08:00
2023-08-14 18:21:45 +08:00
that.markers[1].latitude = res.latitude
that.markers[1].longitude = res.longitude
that.getDriverLine()
}
});
2023-08-16 09:27:10 +08:00
//#endif
2023-08-14 18:21:45 +08:00
},
2023-08-11 16:00:08 +08:00
// 唤起高德
test() {
var packageName = 'com.autonavi.minimap';
var main = plus.android.runtimeMainActivity();
var packageManager = main.getPackageManager();
var PackageManager = plus.android.importClass(packageManager)
var packageInfo = packageManager.getPackageInfo(packageName, PackageManager.GET_ACTIVITIES);
if (packageInfo) {
var Uri = plus.android.importClass("android.net.Uri");
var url =
`amapuri://route/plan?sourceApplication=maxuslife+
&sid=A&slat=36.702558&slon=116.876678&sname=我的位置&did=B&dlat=${this.markers[0].latitude}&dlon=${this.markers[0].longitude}&dname=${this.goodsDetil.logistics.shop_name}&dev=0&t=0`;
var Intent = plus.android.importClass('android.content.Intent');
var intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.addCategory(Intent.CATEGORY_DEFAULT);
var uri = Uri.parse(url);
//将功能Scheme以URI的方式传入data
intent.setData(uri);
intent.setPackage("com.autonavi.minimap");
var main = plus.android.runtimeMainActivity();
main.startActivity(intent);
} else {
// alert('未安装' + packageName + '')
uni.showToast({
title: `只支持高德地图`,
icon: 'none'
})
}
console.log("唤醒高德线路规划")
},
2023-08-09 17:26:01 +08:00
showToast() {
this.$refs.uToast.show({
type: 'success',
title: '成功主题(带图标)',
message: "操作成功",
iconUrl: 'https://cdn.uviewui.com/uview/demo/toast/success.png'
})
2023-08-09 09:11:05 +08:00
},
2023-08-10 17:32:12 +08:00
mapFun() {
uni.openLocation({
latitude: Number(this.goodsDetil.logistics.shop_lat),
longitude: Number(this.goodsDetil.logistics.shop_long),
address: this.goodsDetil.logistics.shop_address,
name: this.goodsDetil.logistics.shop_name,
scale: 15,
2023-08-09 09:11:05 +08:00
});
},
2023-08-10 17:32:12 +08:00
showToast() {
this.$refs.uToast.show({
type: 'success',
title: '成功主题(带图标)',
message: "操作成功",
iconUrl: 'https://cdn.uviewui.com/uview/demo/toast/success.png'
})
2023-08-09 09:11:05 +08:00
},
2023-08-14 18:21:45 +08:00
getDriverLine() {
const that = this;
const key = "997c9a3d88154fa78f4d28bebc1dd84f";
const origin = `${this.markers[1].longitude},${this.markers[1].latitude}`;
const destination = `${this.markers[0].longitude},${this.markers[0].latitude}`;
uni.request({
// url: `https://restapi.amap.com/v3/direction/walking?key=${key}&origin=105.43639400000002,28.908854&destination=105.439304,28.908447`,
url: `https:restapi.amap.com/v4/direction/bicycling?key=${key}&origin=${origin}&destination=${destination}`,
success: (res) => {
const data = res.data.data;
var points = [];
if (data.paths && data.paths[0] && data.paths[0].steps) {
var steps = data.paths[0].steps;
for (var i = 0; i < steps.length; i++) {
//将每一步的数据放到points数组中
var poLen = steps[i].polyline.split(";");
for (var j = 0; j < poLen.length; j++) {
points.push({
longitude: parseFloat(poLen[j].split(",")[0]),
latitude: parseFloat(poLen[j].split(",")[1]),
});
}
}
that.runningRoute = data.paths[0].steps[0].instruction;
}
that.polyline = [{
points: points,
color: "#0091ff",
dottedLine: true,
2023-08-18 09:00:40 +08:00
width: 30,
2023-08-14 18:21:45 +08:00
}, ];
},
fail: function(res) {
console.log("获取路线失败", res);
},
});
},
2023-08-10 17:32:12 +08:00
qrqodeFn() {
let that = this
uni.scanCode({
onlyFromCamera: true,
success: function(res) {
that.takeGood(res.result)
}
});
2023-08-09 09:11:05 +08:00
},
2023-08-10 17:32:12 +08:00
// 取货{}
takeGood(sn) {
takeGoods({
logistics_id: this.goodsDetil.logistics.id,
order_id: this.goodsDetil.logistics.order_id,
order_sn: sn
}).then(res => {
this.showToast()
setTimeout(() => {
uni.navigateBack()
}, 1000)
})
2023-08-09 09:11:05 +08:00
2023-08-10 17:32:12 +08:00
},
2023-08-09 09:11:05 +08:00
},
onLoad(options) {
getDetil({
logistics_id: options.id
}).then(res => {
this.goodsDetil = res.data
2023-08-10 17:32:12 +08:00
this.markers[0].latitude = res.data.logistics.shop_lat
this.markers[0].longitude = res.data.logistics.shop_long
2023-08-14 18:21:45 +08:00
this.locationFn()
2023-08-10 17:32:12 +08:00
setTimeout(() => {
this.showLoading = false
}, 500)
2023-08-09 09:11:05 +08:00
})
},
}
</script>
<style lang='scss' scoped>
2023-08-18 09:00:40 +08:00
.custom-map /deep/ .polyline {
stroke-width: 20px;
}
2023-08-14 18:21:45 +08:00
.content {
padding: 2vh 3vw;
background-color: #F6F7FC;
height: 100vh;
box-sizing: border-box;
}
2023-08-09 09:11:05 +08:00
.map {
2023-08-16 16:51:41 +08:00
height: 40vh;
2023-08-14 18:21:45 +08:00
border-radius: 2vw;
overflow: hidden;
2023-08-11 16:00:08 +08:00
2023-08-14 18:21:45 +08:00
}
2023-08-09 09:11:05 +08:00
2023-08-14 18:21:45 +08:00
.map_address {
background-color: white;
padding: 20rpx 10rpx;
.cir {
display: inline-block;
width: 2vw;
height: 4vw;
border-radius: 2vw;
margin: 0 20rpx;
}
2023-08-09 09:11:05 +08:00
}
2023-08-11 16:00:08 +08:00
.map_btn {
width: 50px;
height: 50px;
position: absolute;
bottom: 0px;
right: 0;
z-index: 9999999;
}
2023-08-10 17:32:12 +08:00
2023-08-09 09:11:05 +08:00
.order_info {
2023-08-14 18:21:45 +08:00
border: none;
background-color: #FF7C32;
border-radius: 2vw;
overflow: hidden;
margin-top: 50rpx;
margin-bottom: 30rpx;
color: white;
2023-08-09 09:11:05 +08:00
2023-08-14 18:21:45 +08:00
.top {
padding: 1vw 3vw;
2023-08-09 09:11:05 +08:00
2023-08-14 18:21:45 +08:00
view {
margin: 10rpx 0;
}
2023-08-09 09:11:05 +08:00
}
2023-08-14 18:21:45 +08:00
.mark {
background-color: white;
color: #A8A8A8;
padding: 10rpx 20rpx;
2023-08-09 09:11:05 +08:00
}
2023-08-14 18:21:45 +08:00
.pro_list {
2023-08-09 09:11:05 +08:00
display: flex;
2023-08-14 18:21:45 +08:00
text {
2023-08-09 09:11:05 +08:00
2023-08-14 18:21:45 +08:00
flex: 2
}
2023-08-09 09:11:05 +08:00
2023-08-14 18:21:45 +08:00
.goods {
flex: 8;
margin: 0;
2023-08-09 09:11:05 +08:00
2023-08-14 18:21:45 +08:00
.goods_tit {
margin: 0;
display: flex;
2023-08-09 09:11:05 +08:00
2023-08-14 18:21:45 +08:00
}
2023-08-09 09:11:05 +08:00
2023-08-14 18:21:45 +08:00
}
2023-08-09 09:11:05 +08:00
}
2023-08-14 18:21:45 +08:00
}
.btn {
2023-08-18 09:00:40 +08:00
position: fixed;
bottom: 20rpx;
width: 90vw;
left: 50%;
transform: translateX(-50%);
2023-08-09 09:11:05 +08:00
}
</style>