|
@@ -14,6 +14,119 @@
|
|
|
import permision from "@/js_sdk/wa-permission/permission.js"
|
|
|
export default {
|
|
|
methods: {
|
|
|
+ getLngLat(){
|
|
|
+ uni.getLocation({
|
|
|
+ type: 'gcj02',
|
|
|
+ geocode: true,
|
|
|
+ success: res => {
|
|
|
+ if (res.latitude) {
|
|
|
+ console.log(res)
|
|
|
+ if(res.address.city){
|
|
|
+ if(res.address.city.indexOf('市')!=-1){
|
|
|
+ res.address.city=res.address.city.substring(0,res.address.city.length-1)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(res.address.province){
|
|
|
+ if(res.address.province.indexOf('省')!=-1){
|
|
|
+ res.address.province=res.address.province.substring(0,res.address.province.length-1)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ uni.setStorageSync('fPlaceObj',{
|
|
|
+ fchoosearea:'全部',
|
|
|
+ fchoosecity:res.address.city,
|
|
|
+ fchooseprovince:res.address.province,
|
|
|
+ selected:res.address.city
|
|
|
+ })
|
|
|
+ uni.setStorageSync('sPlaceObj',{
|
|
|
+ schoosearea:'请选择区',
|
|
|
+ schoosecity:'请选择市',
|
|
|
+ schooseprovince:'全国',
|
|
|
+ selected:'全国'
|
|
|
+ })
|
|
|
+ uni.setStorageSync('longitudeAndLatitude',res.longitude+','+res.latitude)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ checkOpenGPSServiceByAndroidIOS() {
|
|
|
+ console.log()
|
|
|
+ let system = uni.getSystemInfoSync(); // 获取系统信息
|
|
|
+ console.log(system);
|
|
|
+ if (system.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);
|
|
|
+ if (!mainSvr.isProviderEnabled(locationManager.GPS_PROVIDER)) {
|
|
|
+ uni.showModal({
|
|
|
+ title: '提示',
|
|
|
+ content: '请打开定位服务功能',
|
|
|
+ // showCancel: false, // 不显示取消按钮
|
|
|
+ success(res) {
|
|
|
+ if(res.confirm){
|
|
|
+ if (!mainSvr.isProviderEnabled(locationManager.GPS_PROVIDER)) {
|
|
|
+ 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);
|
|
|
+ main.startActivity(intent); // 打开系统设置GPS服务页面
|
|
|
+ this.getLngLat()
|
|
|
+ } else {
|
|
|
+ uni.setStorageSync('fPlaceObj',{
|
|
|
+ fchoosearea:'全部',
|
|
|
+ fchoosecity:'市辖区',
|
|
|
+ fchooseprovince:'北京',
|
|
|
+ selected:res.address.city
|
|
|
+ })
|
|
|
+ uni.setStorageSync('sPlaceObj',{
|
|
|
+ schoosearea:'请选择区',
|
|
|
+ schoosecity:'请选择市',
|
|
|
+ schooseprovince:'全国',
|
|
|
+ selected:'全国'
|
|
|
+ })
|
|
|
+ uni.setStorageSync('longitudeAndLatitude','116.3972,39.9096')
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }else{
|
|
|
+ this.getLngLat()
|
|
|
+ }
|
|
|
+ } else if (system.platform === 'ios') {
|
|
|
+ console.log("苹果");
|
|
|
+ var cllocationManger = plus.ios.import("CLLocationManager");
|
|
|
+ var enable = cllocationManger.locationServicesEnabled();
|
|
|
+ var status = cllocationManger.authorizationStatus();
|
|
|
+ plus.ios.deleteObject(cllocationManger);
|
|
|
+ if (enable && status != 2) {
|
|
|
+ this.getLngLat()
|
|
|
+ console.log("手机系统的定位已经打开");
|
|
|
+ } else {
|
|
|
+ console.log("手机系统的定位没有打开");
|
|
|
+ uni.showModal({
|
|
|
+ title: '提示',
|
|
|
+ content: '请前往设置-隐私-定位服务打开定位服务功能',
|
|
|
+ // showCancel: false, // 不显示取消按钮
|
|
|
+ success(res) {
|
|
|
+ if(res.confirm){
|
|
|
+ var UIApplication = plus.ios.import("UIApplication");
|
|
|
+ var application2 = UIApplication.sharedApplication();
|
|
|
+ var NSURL2 = plus.ios.import("NSURL");
|
|
|
+ // var setting2 = NSURL2.URLWithString("prefs:root=LOCATION_SERVICES");
|
|
|
+ // var setting2 = NSURL2.URLWithString("App-Prefs:root=LOCATION_SERVICES");
|
|
|
+ // var setting2 = NSURL2.URLWithString("app-settings");
|
|
|
+ var setting2 = NSURL2.URLWithString("App-Prefs:root=Privacy&path=LOCATION");
|
|
|
+ // var setting2 = NSURL2.URLWithString("App-Prefs:root=Privacy&path=LOCATION_SERVICES");
|
|
|
+ application2.openURL(setting2);
|
|
|
+ plus.ios.deleteObject(setting2);
|
|
|
+ plus.ios.deleteObject(NSURL2);
|
|
|
+ plus.ios.deleteObject(application2);
|
|
|
+ this.getLngLat()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
...mapMutations(['login']),
|
|
|
// vue的method里编写如下代码
|
|
|
// async requestAndroidPermission(permisionID) {
|
|
@@ -34,7 +147,41 @@
|
|
|
},
|
|
|
|
|
|
onLaunch: function() {
|
|
|
+ var that = this
|
|
|
// #ifdef APP-PLUS
|
|
|
+ this.checkOpenGPSServiceByAndroidIOS()
|
|
|
+ // uni.getNetworkType({
|
|
|
+ // success: function (res) {
|
|
|
+ // if(res.networkType=='none'){
|
|
|
+ // let options = {
|
|
|
+ // title: '提示',
|
|
|
+ // info:'当前没有网络中',
|
|
|
+ // okText: '连接Wifi',
|
|
|
+ // cancelText:'开启流量',
|
|
|
+ // infoAlignment:'center',
|
|
|
+ // radius:10,
|
|
|
+ // // cancelText: '否',
|
|
|
+ // // showCancel:false,
|
|
|
+ // okButtonColor:'#2772FB'
|
|
|
+ // };
|
|
|
+ // const native = uni.requireNativePlugin('AJ-Alert');
|
|
|
+ // native.showAction(options, result => {
|
|
|
+ // // #ifdef APP-PLUS
|
|
|
+ // if (uni.getSystemInfoSync().platform == 'ios') {
|
|
|
+ // plus.ios.import("UIApplication").sharedApplication().performSelector("exit")
|
|
|
+ // } else if (uni.getSystemInfoSync().platform == 'android') {
|
|
|
+ // plus.runtime.quit();
|
|
|
+ // }
|
|
|
+ // // #endif
|
|
|
+ // // 点击是的回调, result暂时没有返回内容
|
|
|
+ // }, cancel => {
|
|
|
+ // // 点击否的回调
|
|
|
+ // });
|
|
|
+
|
|
|
+ // }
|
|
|
+ // console.log(res.networkType);
|
|
|
+ // }
|
|
|
+ // });
|
|
|
console.log(uni.getStorageSync('userInfo'))
|
|
|
if(uni.getStorageSync('userInfo')){
|
|
|
that.$request.baseRequest('get', '/driverInfo/firstAuthentication', {
|
|
@@ -301,7 +448,7 @@
|
|
|
|
|
|
// }, false);
|
|
|
// #endif
|
|
|
- this.$socket.initWebIM(this.$ws, true, true)
|
|
|
+ // this.$socket.initWebIM(this.$ws, true, true)
|
|
|
let userInfo = uni.getStorageSync('userInfo') || '';
|
|
|
if (userInfo.id) {
|
|
|
//更新登陆状态
|