查看位置页面路基调整

test
zhangdi 1 year ago
parent c2c0f195c9
commit 4b72ed472b
  1. 18
      App.vue
  2. 3
      manifest.json
  3. 1
      pages/login/login.vue
  4. 112
      pages/order/location.vue
  5. BIN
      static/images/position/destination.png
  6. BIN
      static/images/position/weixiu.png
  7. 3
      store/index.js

@ -2,23 +2,6 @@
export default {
onReady() {
// this.$common.getStorage("user").then((res) => {
// if (res == null || res == "") {
// uni.redirectTo({
// url: "/pages/login/login"
// });
// }
// });
const _self = this;
// const _handlePush = function(message) {
// uni.navigateTo({
// url: "/pages/task/index"
// });
// };
// plus.push.addEventListener('click', _handlePush);
// plus.push.addEventListener('receive', _handlePush);
},
onShow: function () {
console.log("App Show");
@ -35,7 +18,6 @@ export default {
if (userInfo) {
//
this.$store.dispatch("changeTabbar", userInfo.role_id);
}
},

@ -33,7 +33,8 @@
"<uses-permission android:name=\"android.permission.RECORD_AUDIO\"/>",
"<uses-permission android:name=\"android.permission.VIBRATE\"/>",
"<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>",
"<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>"
"<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>",
"<uses-permission android:name=\"android.permission.LOCATION\"/>"
],
"minSdkVersion" : 19,
"targetSdkVersion" : 28

@ -26,7 +26,6 @@
<script>
import { getTopUrl, bjectToQueryString } from "@/utils/util";
import md5 from "@/uni_modules/md5/md5.min.js";
import tabBar from "@/utils/tabbar.js"; // tabBar.js
export default {
data() {

@ -1,25 +1,39 @@
<template>
<view style="width: 100%;height: 100vh;">
<map :scale="scale" style="width: 100%; height: 100%;" :show-compass="true"
:enable-overlooking="false" :enable-satellite="false" :enable-traffic="true" :show-location="true"
:latitude="latitude" :longitude="longitude" :markers="markers" >
<!--
show-compass 是否显示指南针
enable-overlooking 是否开启俯视
enable-satellite 是否开启卫星图
enable-traffic 是否开启实时路况
show-location 显示带有方向的当前定位点
latitude 经度
longitude 纬度
markers 标记点
-->
<map :scale="scale" style="width: 100%; height: 100%;" :show-compass="true" :enable-overlooking="false"
:enable-satellite="false" :enable-traffic="true" :show-location="true" :latitude="latitude"
:longitude="longitude" :markers="markers">
</map>
</view>
</template>
<script>
export default {
/*
markers 获取维修人员的位置信息
latitude和longitude 显示目的地的位置
*/
export default {
data() {
return {
scale: 12,// 5-18
latitude: 30.64525,//---
longitude: 114.17240, //
scale: 16,// 5-18
latitude: 36.146504,//---
longitude: 120.486065, //
markers: [{
id: 1,
latitude: 30.51242,//
longitude: 114.18055,//
height: 80,//
width: 80,
latitude: 36.146504,//
longitude: 120.486065,//
height: 160,//
width: 160,
callout: {
color: '#007AFF', //
bgColor: '#fff', //
@ -31,8 +45,27 @@
content: '距离5km',
},
iconPath: 'https://zpkoss.oss-cn-shenzhen.aliyuncs.com/newsys/dms_app/logo/house.jpg'//
}, ]
iconPath: '/static/images/position/destination.png'//
},
{
id:2,
latitude: 35.146504,//
longitude: 116.486065,//
height: 160,//
width: 160,
callout: {
color: '#007AFF', //
bgColor: '#fff', //
display: "ALWAYS", // 'BYCLICK':; 'ALWAYS':
fontSize: 15,
textAlign: 'left', // : left, right, center
padding: 10, //
borderRadius: 5,
content: '距离5km',
},
iconPath: '/static/images/position/weixiu.png'//
}]
};
},
methods: {
@ -42,6 +75,8 @@
},
//
getDistances(lat1, lng1, lat2, lng2) {
console.log('计算距离',lat1, lng1, lat2, lng2)
var radLat1 = this.rad(lat1);
var radLat2 = this.rad(lat2);
var a = radLat1 - radLat2;
@ -64,34 +99,33 @@
distance_str: distance_str
}
this.markers[0].callout.content = '距离您' + objData.distance_str
}
},
mounted() {
let that = this
//
uni.getLocation({
type: 'wgs84',
geocode: true, //true
success: function(res) {
console.log(res)
that.latitude = res.latitude//
that.longitude = res.longitude
that.markers[0].latitude = 30.51242//
that.markers[0].longitude = 114.18055
//
getLocation() {
// uni.getLocation({
// type: 'wgs84',
// success: (res) => {
// this.latitude = res.latitude//
// this.longitude = res.longitude
this.markers[1].latitude = this.latitude+20//
this.markers[1].longitude = this.longitude+20
// console.log(':', res,this.markers);
this.getDistances(this.markers[1].latitude, this.markers[1].longitude,this.markers[0].latitude, this.markers[0].longitude)
// },
// fail: (err) => {
// this.error = err;
// console.error(':', err);
// }
// });
},
fail: function() {
uni.showToast({
title: '获取地址失败,将导致部分功能不可用',
icon: 'none'
});
}
});
//
this.getDistances(30.64525, 114.17240, 30.51242, 114.18055)
},
};
</script>
onload() {
<style scoped>
},
mounted() {
this.getLocation()
},
};
</script>
</style>
<style scoped></style>

Binary file not shown.

After

Width:  |  Height:  |  Size: 993 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 661 B

@ -47,6 +47,9 @@ const store = new Vuex.Store({
uni.reLaunch({
url: "/pages/order/tasking",
});
// 如果是维修人员登录 则实时更新当前维修人员的位置
}
},

Loading…
Cancel
Save