dw.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. const calculateDistance = (options) => {
  2. return new Promise((resolve, reject) => {
  3. uni.getLocation({
  4. type: 'gcj02',
  5. geocode: true,
  6. success: res => {
  7. if (res.latitude) {
  8. resolve(res)
  9. // that.detailData.hyCarrierInfo.longitudeLatitude = res.longitude + ',' + res
  10. // .latitude
  11. // that.detailData.hyCarrierInfo.loadingAreaLongitude = res.longitude;
  12. // that.detailData.hyCarrierInfo.loadingAreaLatitude = res.latitude;
  13. // that.detailData.hyCarrierInfo.sendCity = that.$helper.filterUrban(res.address.city)
  14. // that.localtion.city = that.$helper.filterUrban(res.address.city)
  15. // that.$set(that.detailData, 'loadingArea', that.$helper.filterUrban(res.address
  16. // .district))
  17. // that.$set(that.detailData, 'loadingCity', that.$helper.filterUrban(res.address
  18. // .city))
  19. // that.localtion.sendArea = that.$helper.filterUrban(res.address.district)
  20. // // .loadingCity = that.$helper.filterUrban(res.address.city)
  21. // that.detailData.loadingLongitude = res.longitude;
  22. // that.detailData.loadingLatitude = res.latitude;
  23. // that.$forceUpdate()
  24. // uni.hideLoading()
  25. } else {
  26. reject(err)
  27. // if (uni.getSystemInfoSync().platform == 'android') {
  28. // var context = plus.android.importClass("android.content.Context");
  29. // var locationManager = plus.android.importClass(
  30. // "android.location.LocationManager");
  31. // var main = plus.android.runtimeMainActivity();
  32. // var mainSvr = main.getSystemService(context.LOCATION_SERVICE);
  33. // that.bool = mainSvr.isProviderEnabled(locationManager.GPS_PROVIDER)
  34. // }
  35. // if (that.bool === false) {
  36. // uni.showModal({
  37. // title: '提示',
  38. // content: '请打开定位服务',
  39. // success: ({
  40. // confirm,
  41. // cancel
  42. // }) => {
  43. // if (confirm) {
  44. // if (uni.getSystemInfoSync().platform == 'android') {
  45. // var Intent = plus.android.importClass(
  46. // 'android.content.Intent');
  47. // var Settings = plus.android.importClass(
  48. // 'android.provider.Settings');
  49. // var intent = new Intent(Settings
  50. // .ACTION_LOCATION_SOURCE_SETTINGS);
  51. // var main = plus.android.runtimeMainActivity();
  52. // main.startActivity(intent); // 打开系统设置GPS服务页面
  53. // }
  54. // }
  55. // }
  56. // });
  57. // uni.hideLoading()
  58. // }
  59. }
  60. },
  61. fail: res => {
  62. reject(err)
  63. }
  64. });
  65. })
  66. }
  67. export default {
  68. calculateDistance
  69. }