let Detectionlocations = class Detectionlocation{ SystemInfo = ''; /** * @获取设备GPS是否开启 */ GetSystemInfoGps(){ this['SystemInfo'] = uni.getSystemInfoSync(); console.log(this['SystemInfo'],this['SystemInfo']['locationEnabled'],'检查设备是否开启GPS'); let self = this; if (!this['SystemInfo']['locationEnabled']){ console.log('未开启GPS') uni.showModal({ title: "温馨提示", content: "亲,我们未获得您的位置信息授权,请确认手机GPS是否开启", confirmText: '我已开启', showCancel: false, success(res) { if (res.confirm == true) { // 点击已开启之后检测系统定位是否真正开启 self.GetSystemInfoGps(); } } }) }else{ console.log('已未开启GPS') this.WXlocationAuthorized(); } } /** * @微信是否开启定位权限 */ WXlocationAuthorized(){ console.log('检查微信应用是否开启定位权限'); if(!this['SystemInfo']['locationAuthorized']){ console.log('微信应用未开启定位权限'); uni.showModal({ title: "温馨提示", content: "您的微信应用未开启定位权限,请开启后再试", confirmText: '好的', showCancel: false, success(res) { if (res.confirm == true) { console.log(self,'未开启') // 点击已开启之后检测系统定位是否真正开启 self.WXlocationAuthorized(); } } }) }else{ console.log('微信应用已开启定位权限'); } } } export default Detectionlocations;