map.vue 1.9 KB

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