map.vue 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <template>
  2. <view class="shareImage">
  3. <view style="">
  4. <web-view id="mapContainer" :src="srcHandler()"></web-view>
  5. </view>
  6. </view>
  7. </template>
  8. <script>
  9. export default {
  10. data() {
  11. return {
  12. bgColor: '#317AFE',
  13. bool: false,
  14. lat: '',
  15. lng: ''
  16. }
  17. },
  18. created() {
  19. this.getLngLat();
  20. },
  21. methods: {
  22. back(){
  23. uni.navigateBack({
  24. })
  25. },
  26. srcHandler() {
  27. var unsendaddress=uni.getStorageSync('unsendaddress').unsendLatitude+','+uni.getStorageSync('unsendaddress').unsendLongitude
  28. console.log(this.lat,)
  29. return `/hybrid/html/map.html?lat=${this.lat}&unsendaddress=${unsendaddress}&distance=${uni.getStorageSync('distance')}`
  30. },
  31. getLngLat() {
  32. uni.getLocation({
  33. type: 'wgs84',
  34. success: res => {
  35. if (res.latitude) {
  36. this.lat = res.latitude + ',' + res.longitude;
  37. // this.lng = res.longitude;
  38. } else {
  39. if (uni.getSystemInfoSync().platform == 'android') {
  40. var context = plus.android.importClass("android.content.Context");
  41. var locationManager = plus.android.importClass(
  42. "android.location.LocationManager");
  43. var main = plus.android.runtimeMainActivity();
  44. var mainSvr = main.getSystemService(context.LOCATION_SERVICE);
  45. this.bool = mainSvr.isProviderEnabled(locationManager.GPS_PROVIDER)
  46. }
  47. if (this.bool === false) {
  48. uni.showModal({
  49. title: '提示',
  50. content: '请打开定位服务',
  51. success: ({
  52. confirm,
  53. cancel
  54. }) => {
  55. if (confirm) {
  56. if (uni.getSystemInfoSync().platform == 'android') {
  57. var Intent = plus.android.importClass(
  58. 'android.content.Intent');
  59. var Settings = plus.android.importClass(
  60. 'android.provider.Settings');
  61. var intent = new Intent(Settings
  62. .ACTION_LOCATION_SOURCE_SETTINGS);
  63. var main = plus.android.runtimeMainActivity();
  64. main.startActivity(intent); // 打开系统设置GPS服务页面
  65. }
  66. }
  67. }
  68. });
  69. }
  70. }
  71. }
  72. });
  73. }
  74. }
  75. }
  76. </script>