This commit is contained in:
weipengfei 2023-08-25 10:57:01 +08:00
commit 89811e4067

View File

@ -1,14 +1,24 @@
<template> <template>
<view> <view>
<view v-if="false"> <!-- 有车辆 -->
<view v-if="1">
<view class="content"> <view class="content">
<view class="map" style="position: relative;"> <view :class="allMap?'map1':'map2'" style="position: relative;">
<map :class="mapClass" id="map" @markertap='mapFun' :enable-zoom="true" :polyline="polyline" <map :class="mapClass" id="map" :enable-zoom="true" :polyline="polyline" :markers='markers'
:markers='markers' :scale="scale" style="width:100%;height: 100%;" :scale="scale" style="width:100%;height: 100%;" :latitude="markers[0].latitude"
:latitude="markers[0].latitude" :enable-scroll="true" :longitude="markers[0].longitude"> :enable-scroll="true" :longitude="markers[0].longitude" @tap="allMap=!allMap">
</map> </map>
</view> </view>
<view v-if="!allMap">
<view class="query">
<!-- <u--input placeholder="请选择日期" suffixIcon="clock" class="ipt" border="surround"
v-model="queryData" @focus='fousFn'></u--input> -->
<view class="ipt" @click="showDate=true">
<text>{{queryData}}</text>
<u-icon name="clock" size="24"></u-icon>
</view>
<u-button type="primary" class='poline_btn' @click="showPloyline" text="显示轨迹"></u-button>
</view>
<view class="personnel_list" @click="toDetail('/subpkg/property/vehicle')"> <view class="personnel_list" @click="toDetail('/subpkg/property/vehicle')">
<view class="cards"> <view class="cards">
<view class="cards_head"> <view class="cards_head">
@ -45,23 +55,19 @@
<text> 所属片区 </text> <text> 所属片区 </text>
</view> </view>
</view> </view>
</view> </view>
<view class="fooot">
<!-- <mybtn></mybtn> -->
<u-button text="续约" color="#0122C7"></u-button>
</view>
</view> </view>
</view> </view>
</view> </view>
</view> </view>
<u-calendar @close='showDate=false' :show="showDate" @confirm="dataFn"></u-calendar>
</view>
<!-- 没有车辆 -->
<view class="" v-else> <view class="" v-else>
<view class="" v-if="!isMycar"> <view class="" v-if="!isMycar">
<view class="empty_car"> <view class="empty_car">
@ -79,10 +85,7 @@
</view> </view>
</u-modal> </u-modal>
</view> </view>
</view> </view>
<view style="text-align: center;margin-top: 100rpx;" v-if="isMycar"> <view style="text-align: center;margin-top: 100rpx;" v-if="isMycar">
您上传自有车两,系统正在审核中,请耐心等待 您上传自有车两,系统正在审核中,请耐心等待
</view> </view>
@ -91,9 +94,6 @@
</view> </view>
</template> </template>
<script> <script>
@ -111,16 +111,14 @@
}, },
data() { data() {
return { return {
allMap: false,
showDate: false,
isMycar: false, isMycar: false,
myCarnum: "",
modelShow: false,
status: 1,
mapClass: 'custom-map',
showLoading: true,
showPop: false, showPop: false,
goodsDetil: undefined, queryData: "请选择时间",
myCarnum: "",
mapClass: 'custom-map',
scale: 17, scale: 17,
nowAddress: "无",
markers: [ markers: [
// //
{ {
@ -132,29 +130,30 @@
// //
{ {
id: 2, id: 2,
latitude: undefined, latitude: 28.8733,
longitude: undefined, longitude: 105.444828,
iconPath: '../../static/img/logistics/QS.png', // iconPath: '../../static/img/logistics/QS.png', //
} }
], ],
polyline: [], polyline: [],
task_id: -1,
address: {
terminus: {
status: 1
},
transfer: {
status: 1
}
}
} }
}, },
onLoad(options) { onLoad(options) {
this.task_id = options.task_id;
this.initPosition();
this.locationFn();
}, },
methods: { methods: {
fousFn() {
uni.hideKeyboard()
this.showDate = true
},
dataFn(e) {
console.log(e)
this.queryData = e[0]
this.showDate = false
},
confirm() { confirm() {
if (this.myCarnum) { if (this.myCarnum) {
console.log(this.myCarnum) console.log(this.myCarnum)
@ -162,197 +161,159 @@
this.isMycar = true this.isMycar = true
} }
}, },
// showPloyline() {
async initPosition() { // points: points,
let res = await taskTricycleDetail({ // color: "#0091ff",
id: this.task_id // dottedLine: true,
}); // width: 30,
this.address = res.data.extend; let points = [{
if (res.data.extend?.update?.terminus?.lnglat[0]) { //, latitude: 28.916022,
this.markers[0].latitude = +res.data.extend.transfer.lnglat[1]; longitude: 105.442732,
this.markers[0].longitude = +res.data.extend.transfer.lnglat[0];
this.status = 2;
this.address.terminus['status'] = 2;
} else { // ,
this.markers[0].latitude = +res.data.extend.terminus.lnglat[1];
this.markers[0].longitude = +res.data.extend.terminus.lnglat[0];
this.address.terminus['status'] = 1;
}
if (res.data.extend?.update?.transfer?.lnglat[0] || res.data.status == 3) {
this.address.transfer['status'] = 2;
this.status = 3;
} else this.address.transfer['status'] = 1;
if (res.data.status == 5) {
this.status = 5;
}
}, },
// {
locationFn() { latitude: 28.916848,
let that = this longitude: 105.443175,
//#ifdef APP
uni.getLocation({
type: 'gcj02',
geocode: true,
isHighAccuracy: true,
success: function async (res) {
that.markers[1].latitude = res.latitude
that.markers[1].longitude = res.longitude
that.getDriverLine()
}
});
//#endif
}, },
{
// latitude: 28.916918,
test() { longitude: 105.443269,
if (this.is_captain) return
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);
//SchemeURIdata
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("唤醒高德线路规划")
}, },
showToast() { {
this.$refs.uToast.show({ latitude: 28.917041,
type: 'success', longitude: 105.443466,
title: '成功主题(带图标)',
message: "操作成功",
iconUrl: 'https://cdn.uviewui.com/uview/demo/toast/success.png'
})
}, },
mapFun() { {
uni.openLocation({ latitude: 28.917073,
latitude: Number(this.goodsDetil.logistics.shop_lat), longitude: 105.443522,
longitude: Number(this.goodsDetil.logistics.shop_long),
address: this.goodsDetil.logistics.shop_address,
name: this.goodsDetil.logistics.shop_name,
scale: 15,
});
}, },
showToast() { {
this.$refs.uToast.show({ latitude: 28.91705,
type: 'success', longitude: 105.443607,
title: '成功主题(带图标)',
message: "操作成功",
iconUrl: 'https://cdn.uviewui.com/uview/demo/toast/success.png'
})
}, },
// {
getDistance(point1, point2) { latitude: 28.917057,
const rad = Math.PI / 180.0; longitude: 105.443643,
const lat1 = point1.latitude; },
const lng1 = point1.longitude; {
const lat2 = point2.latitude; latitude: 28.916925,
const lng2 = point2.longitude; longitude: 105.443546,
const dlat = lat2 - lat1; },
const dlng = lng2 - lng1; {
const a = latitude: 28.916796,
Math.sin(dlat / 2 * rad) * Math.sin(dlat / 2 * rad) + longitude: 105.443466,
Math.cos(lat1 * rad) * Math.cos(lat2 * rad) * },
Math.sin(dlng / 2 * rad) * Math.sin(dlng / 2 * rad); {
const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)); latitude: 28.916615,
const distance = 6378137 * c; longitude: 105.443344,
return distance; },
{
latitude: 28.916437,
longitude: 105.443274,
},
{
latitude: 28.916356,
longitude: 105.443222,
},
{
latitude: 28.916515,
longitude: 105.442643,
},
{
latitude: 28.916591,
longitude: 105.442448,
},
{
latitude: 28.916944,
longitude: 105.442338,
},
{
latitude: 28.91706,
longitude: 105.442376,
},
{
latitude: 28.917169,
longitude: 105.442489,
},
{
latitude: 28.917345,
longitude: 105.442601,
},
{
latitude: 28.917433,
longitude: 105.442663,
},
{
latitude: 28.917461,
longitude: 105.442683,
},
{
latitude: 28.917461,
longitude: 105.442683,
},
{
latitude: 28.917518,
longitude: 105.442874,
},
{
latitude: 28.917537,
longitude: 105.443032,
},
{
latitude: 28.917537,
longitude: 105.443032,
},
{
latitude: 28.917497,
longitude: 105.443198,
},
{
latitude: 28.917409,
longitude: 105.443256,
},
{
latitude: 28.91732,
longitude: 105.443318,
},
{
latitude: 28.917234,
longitude: 105.443442,
},
{
latitude: 28.917072,
longitude: 105.443497,
},
{
latitude: 28.916977,
longitude: 105.443539,
},
{
latitude: 28.916867,
longitude: 105.443529,
},
{
latitude: 28.916867,
longitude: 105.443529,
},
{
latitude: 28.916761,
longitude: 105.443404,
},
{
latitude: 28.916722,
longitude: 105.443274,
},
{
latitude: 28.916762,
longitude: 105.443132,
}, },
//
getFn() {
uni.showLoading({
title: '上传中',
mask: true
})
this.locationFn()
// console.log(this.getDistance(this.markers[0], this.markers[1]))
if ((this.getDistance(this.markers[0], this.markers[1]) >> 0) > 10000) {
return Toast('距离目标位置过远');
} else {
let data;
if (this.status == 1) data = {
id: this.task_id,
terminus: {
lnglat: [
this.markers[1].longitude,
this.markers[1].latitude
] ]
} this.polyline = [{
};
else data = {
id: this.task_id,
transfer: {
lnglat: [
this.markers[1].longitude,
this.markers[1].latitude
]
}
};
taskAddTricycleCoordinate(data).then(() => {
uni.hideLoading()
Toast('上传成功!')
this.initPosition();
this.locationFn();
})
}
},
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, points: points,
color: "#0091ff", color: "#0091ff",
dottedLine: true, dottedLine: true,
width: 30, width: 30,
}, ]; }]
}, },
fail: function(res) {
console.log("获取路线失败", res);
},
});
},
}, },
onPullDownRefresh() { onPullDownRefresh() {
// this.getOrderList(); // this.getOrderList();
@ -364,19 +325,8 @@
</script> </script>
<style lang='scss' scoped> <style lang='scss' scoped>
.serch {
margin: 28rpx 28rpx 0 28rpx;
}
.add {
position: fixed;
bottom: 100rpx;
right: 0;
}
.empty_car { .empty_car {
padding: 200rpx 50rpx; padding: 200rpx 50rpx;
/* text-align: center; */
.btn_cls { .btn_cls {
background-color: #0122C7; background-color: #0122C7;
@ -386,12 +336,38 @@
} }
} }
.query {
display: flex;
background-color: #F5F5F5;
margin: 20rpx 0 0 0;
.ipt {
background-color: white;
width: 60vw;
border-radius: 10rpx;
padding: 10rpx;
display: flex;
justify-content: space-between;
line-height: 60rpx;
padding-left: 30rpx;
/* margin: 0 auto; */
/* line-height: auto; */
}
.poline_btn {
width: 20vw;
margin-left: 20rpx;
background-color: $theme-oa-color;
border: none;
}
}
.personnel_list { .personnel_list {
padding: 28rpx 0; padding: 28rpx 0;
margin-bottom: 130rpx; margin-bottom: 130rpx;
.empty { .empty {
padding-top: 200rpx; padding-top: 200rpx;
text-align: center; text-align: center;
@ -479,70 +455,6 @@
} }
} }
.cover {
position: absolute;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
background-color: rgba(#000, 0.3);
.cover_model {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 650rpx;
/* height: 300rpx; */
background-color: #fff;
border-radius: 6px;
display: flex;
flex-direction: column;
justify-content: space-between;
.model_title {
height: 92rpx;
line-height: 92rpx;
text-align: center;
font-size: 16px;
font-weight: bold;
}
.model_content {
margin: 12px 25px 25px 25px;
font-size: 15px;
}
.model_btn {
display: flex;
height: 96rpx;
font-size: 16px;
.item {
flex: 1;
text-align: center;
line-height: 96rpx;
}
.model_confirm {
color: #0122c7;
}
}
}
}
.red {
color: #ff0000;
}
.green {
color: #40bc5e;
}
.yellow {
color: #ff7c32;
}
.custom-map /deep/ .polyline { .custom-map /deep/ .polyline {
stroke-width: 20px; stroke-width: 20px;
} }
@ -554,47 +466,16 @@
box-sizing: border-box; box-sizing: border-box;
} }
.map { .map1 {
height: 40vh; height: 100vh;
width: 100vw;
border-radius: 2vw; border-radius: 2vw;
overflow: hidden; overflow: hidden;
} }
.map_address { .map2 {
background-color: white; height: 30vh;
padding: 20rpx 10rpx;
border-radius: 0 0 14rpx 14rpx;
.li {
margin: 20rpx 0;
line-height: 40rpx;
}
.cir {
display: inline-block;
width: 2vw;
height: 2vw;
border-radius: 2vw; border-radius: 2vw;
margin: 0 20rpx; overflow: hidden;
}
}
.map_btn {
width: 50px;
height: 50px;
position: absolute;
bottom: 0px;
right: 0;
z-index: 9999999;
}
.btn {
position: fixed;
bottom: 20rpx;
width: 90vw;
left: 50%;
transform: translateX(-50%);
} }
</style> </style>