const calculateDistance = (options) => { return new Promise((resolve, reject) => { uni.getLocation({ type: 'gcj02', geocode: true, success: res => { if (res.latitude) { resolve(res) // that.detailData.hyCarrierInfo.longitudeLatitude = res.longitude + ',' + res // .latitude // that.detailData.hyCarrierInfo.loadingAreaLongitude = res.longitude; // that.detailData.hyCarrierInfo.loadingAreaLatitude = res.latitude; // that.detailData.hyCarrierInfo.sendCity = that.$helper.filterUrban(res.address.city) // that.localtion.city = that.$helper.filterUrban(res.address.city) // that.$set(that.detailData, 'loadingArea', that.$helper.filterUrban(res.address // .district)) // that.$set(that.detailData, 'loadingCity', that.$helper.filterUrban(res.address // .city)) // that.localtion.sendArea = that.$helper.filterUrban(res.address.district) // // .loadingCity = that.$helper.filterUrban(res.address.city) // that.detailData.loadingLongitude = res.longitude; // that.detailData.loadingLatitude = res.latitude; // that.$forceUpdate() // uni.hideLoading() } else { reject(err) // if (uni.getSystemInfoSync().platform == 'android') { // var context = plus.android.importClass("android.content.Context"); // var locationManager = plus.android.importClass( // "android.location.LocationManager"); // var main = plus.android.runtimeMainActivity(); // var mainSvr = main.getSystemService(context.LOCATION_SERVICE); // that.bool = mainSvr.isProviderEnabled(locationManager.GPS_PROVIDER) // } // if (that.bool === false) { // uni.showModal({ // title: '提示', // content: '请打开定位服务', // success: ({ // confirm, // cancel // }) => { // if (confirm) { // if (uni.getSystemInfoSync().platform == 'android') { // var Intent = plus.android.importClass( // 'android.content.Intent'); // var Settings = plus.android.importClass( // 'android.provider.Settings'); // var intent = new Intent(Settings // .ACTION_LOCATION_SOURCE_SETTINGS); // var main = plus.android.runtimeMainActivity(); // main.startActivity(intent); // 打开系统设置GPS服务页面 // } // } // } // }); // uni.hideLoading() // } } }, fail: res => { reject(err) } }); }) } export default { calculateDistance }