因为用的是uni-app所以配置文件有些要写在根目录下的manifest.json里
"mp-weixin" : { /* 小程序特有相关 */ "usingComponents" : true, "appid" : "wx97058253a5cde687", "setting" : { "urlCheck" : true }, "permission": { "scope.userLocation": { "desc": "你的位置信息将用于签到等需要记录位置的功能" } } },
弹出框提示 授权
通过getLocation方法去获取经度纬度,然后workOrder调后端接口
getLocation(){ uni.getLocation({ type: 'wgs84', success: (res:any)=>{ this.workOrder(res.latitude,res.longitude);//纬度、经度 }, fail:(res)=>{ uni.showToast({ title: '获取定位失败', icon: 'none' }); } }); }