查看位置页面路基调整

test
zhangdi 1 year ago
parent c2c0f195c9
commit 4b72ed472b
  1. 18
      App.vue
  2. 3
      manifest.json
  3. 1
      pages/login/login.vue
  4. 196
      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 { export default {
onReady() { 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 () { onShow: function () {
console.log("App Show"); console.log("App Show");
@ -35,7 +18,6 @@ export default {
if (userInfo) { if (userInfo) {
// //
this.$store.dispatch("changeTabbar", userInfo.role_id); 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.RECORD_AUDIO\"/>",
"<uses-permission android:name=\"android.permission.VIBRATE\"/>", "<uses-permission android:name=\"android.permission.VIBRATE\"/>",
"<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>", "<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, "minSdkVersion" : 19,
"targetSdkVersion" : 28 "targetSdkVersion" : 28

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

@ -1,97 +1,131 @@
<template> <template>
<view style="width: 100%;height: 100vh;"> <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" show-compass 是否显示指南针
:latitude="latitude" :longitude="longitude" :markers="markers" > 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> </map>
</view> </view>
</template> </template>
<script> <script>
export default { /*
data() { markers 获取维修人员的位置信息
return { latitude和longitude 显示目的地的位置
scale: 12,// 5-18 */
latitude: 30.64525,//--- export default {
longitude: 114.17240, // data() {
markers: [{ return {
id: 1, scale: 16,// 5-18
latitude: 30.51242,// latitude: 36.146504,//---
longitude: 114.18055,// longitude: 120.486065, //
height: 80,// markers: [{
width: 80, id: 1,
callout: { latitude: 36.146504,//
color: '#007AFF', // longitude: 120.486065,//
bgColor: '#fff', // height: 160,//
display: "ALWAYS", // 'BYCLICK':; 'ALWAYS': width: 160,
fontSize: 15, callout: {
textAlign: 'left', // : left, right, center color: '#007AFF', //
padding: 10, // bgColor: '#fff', //
borderRadius: 5, display: "ALWAYS", // 'BYCLICK':; 'ALWAYS':
content: '距离5km', fontSize: 15,
}, textAlign: 'left', // : left, right, center
padding: 10, //
borderRadius: 5,
content: '距离5km',
},
iconPath: 'https://zpkoss.oss-cn-shenzhen.aliyuncs.com/newsys/dms_app/logo/house.jpg'// iconPath: '/static/images/position/destination.png'//
}, ]
};
},
methods: {
//
rad(d) {
return d * Math.PI / 180.0;
}, },
// {
getDistances(lat1, lng1, lat2, lng2) { id:2,
var radLat1 = this.rad(lat1); latitude: 35.146504,//
var radLat2 = this.rad(lat2); longitude: 116.486065,//
var a = radLat1 - radLat2; height: 160,//
var b = this.rad(lng1) - this.rad(lng2); width: 160,
var s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) + callout: {
Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2))); color: '#007AFF', //
s = s * 6378.137; bgColor: '#fff', //
s = Math.round(s * 10000) / 10000; display: "ALWAYS", // 'BYCLICK':; 'ALWAYS':
fontSize: 15,
textAlign: 'left', // : left, right, center
padding: 10, //
borderRadius: 5,
content: '距离5km',
},
iconPath: '/static/images/position/weixiu.png'//
}]
};
},
methods: {
//
rad(d) {
return d * Math.PI / 180.0;
},
//
getDistances(lat1, lng1, lat2, lng2) {
console.log('计算距离',lat1, lng1, lat2, lng2)
var distance = s; var radLat1 = this.rad(lat1);
var distance_str = ""; var radLat2 = this.rad(lat2);
var a = radLat1 - radLat2;
var b = this.rad(lng1) - this.rad(lng2);
var s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) +
Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2)));
s = s * 6378.137;
s = Math.round(s * 10000) / 10000;
if (parseInt(distance) >= 1) { var distance = s;
distance_str = distance.toFixed(2) + "km"; var distance_str = "";
} else {
distance_str = (distance * 1000).toFixed(2) + "m"; if (parseInt(distance) >= 1) {
} distance_str = distance.toFixed(2) + "km";
let objData = { } else {
distance: distance, distance_str = (distance * 1000).toFixed(2) + "m";
distance_str: distance_str }
} let objData = {
this.markers[0].callout.content = '距离您' + objData.distance_str distance: distance,
distance_str: distance_str
} }
this.markers[0].callout.content = '距离您' + objData.distance_str
}, },
mounted() { //
let that = this getLocation() {
// // uni.getLocation({
uni.getLocation({ // type: 'wgs84',
type: 'wgs84', // success: (res) => {
geocode: true, //true // this.latitude = res.latitude//
success: function(res) { // this.longitude = res.longitude
console.log(res) this.markers[1].latitude = this.latitude+20//
that.latitude = res.latitude// this.markers[1].longitude = this.longitude+20
that.longitude = res.longitude // console.log(':', res,this.markers);
that.markers[0].latitude = 30.51242// this.getDistances(this.markers[1].latitude, this.markers[1].longitude,this.markers[0].latitude, this.markers[0].longitude)
that.markers[0].longitude = 114.18055 // },
}, // fail: (err) => {
fail: function() { // this.error = err;
uni.showToast({ // console.error(':', err);
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({ uni.reLaunch({
url: "/pages/order/tasking", url: "/pages/order/tasking",
}); });
// 如果是维修人员登录 则实时更新当前维修人员的位置
} }
}, },

Loading…
Cancel
Save