map.vue 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. // console.log(uni.getStorageSync('sendaddress'),uni.getStorageSync('unsendaddress'))
  28. var sendaddress=uni.getStorageSync('sendaddress').sendLatitude+','+uni.getStorageSync('sendaddress').sendLongitude
  29. var unsendaddress=uni.getStorageSync('unsendaddress').unsendLatitude+','+uni.getStorageSync('unsendaddress').unsendLongitude
  30. // console.log(this.lat,)
  31. return `/hybrid/html/map.html?lat=${sendaddress}&unsendaddress=${unsendaddress}&distance=${uni.getStorageSync('distance')}`
  32. },
  33. getLngLat() {
  34. uni.getLocation({
  35. type: 'wgs84',
  36. success: res => {
  37. if (res.latitude) {
  38. this.lat = res.latitude + ',' + res.longitude;
  39. // this.lng = res.longitude;
  40. } else {
  41. if (uni.getSystemInfoSync().platform == 'android') {
  42. var context = plus.android.importClass("android.content.Context");
  43. var locationManager = plus.android.importClass(
  44. "android.location.LocationManager");
  45. var main = plus.android.runtimeMainActivity();
  46. var mainSvr = main.getSystemService(context.LOCATION_SERVICE);
  47. this.bool = mainSvr.isProviderEnabled(locationManager.GPS_PROVIDER)
  48. }
  49. if (this.bool === false) {
  50. uni.showModal({
  51. title: '提示',
  52. content: '请打开定位服务',
  53. success: ({
  54. confirm,
  55. cancel
  56. }) => {
  57. if (confirm) {
  58. if (uni.getSystemInfoSync().platform == 'android') {
  59. var Intent = plus.android.importClass(
  60. 'android.content.Intent');
  61. var Settings = plus.android.importClass(
  62. 'android.provider.Settings');
  63. var intent = new Intent(Settings
  64. .ACTION_LOCATION_SOURCE_SETTINGS);
  65. var main = plus.android.runtimeMainActivity();
  66. main.startActivity(intent); // 打开系统设置GPS服务页面
  67. }
  68. }
  69. }
  70. });
  71. }
  72. }
  73. }
  74. });
  75. }
  76. }
  77. }
  78. </script>