查看位置页面路基调整

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 { 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,25 +1,39 @@
<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 { /*
markers 获取维修人员的位置信息
latitude和longitude 显示目的地的位置
*/
export default {
data() { data() {
return { return {
scale: 12,// 5-18 scale: 16,// 5-18
latitude: 30.64525,//--- latitude: 36.146504,//---
longitude: 114.17240, // longitude: 120.486065, //
markers: [{ markers: [{
id: 1, id: 1,
latitude: 30.51242,// latitude: 36.146504,//
longitude: 114.18055,// longitude: 120.486065,//
height: 80,// height: 160,//
width: 80, width: 160,
callout: { callout: {
color: '#007AFF', // color: '#007AFF', //
bgColor: '#fff', // bgColor: '#fff', //
@ -31,8 +45,27 @@
content: '距离5km', 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: { methods: {
@ -42,6 +75,8 @@
}, },
// //
getDistances(lat1, lng1, lat2, lng2) { getDistances(lat1, lng1, lat2, lng2) {
console.log('计算距离',lat1, lng1, lat2, lng2)
var radLat1 = this.rad(lat1); var radLat1 = this.rad(lat1);
var radLat2 = this.rad(lat2); var radLat2 = this.rad(lat2);
var a = radLat1 - radLat2; var a = radLat1 - radLat2;
@ -64,34 +99,33 @@
distance_str: distance_str distance_str: distance_str
} }
this.markers[0].callout.content = '距离您' + objData.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) => {
// this.error = err;
// console.error(':', err);
// }
// });
}, },
fail: function() {
uni.showToast({
title: '获取地址失败,将导致部分功能不可用',
icon: 'none'
});
}
});
//
this.getDistances(30.64525, 114.17240, 30.51242, 114.18055)
}, },
}; onload() {
</script>
<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