当前位置: 首页 > news >正文

天猫网站建设的意义刷排名有百度手机刷排名

天猫网站建设的意义,刷排名有百度手机刷排名,个人跨境网店怎么开,伪静态规则wordpress做一个小程序持续获取用户位置信息的功能,即使小程序切换到后台也能继续获取,getLocation这个api只有小程序在前台才能获取位置,所以不用这个 先申请一个腾讯地图key 在uniapp项目配置源码视图里加上这个代码 先获取权限,再开启…

做一个小程序持续获取用户位置信息的功能,即使小程序切换到后台也能继续获取,getLocation这个api只有小程序在前台才能获取位置,所以不用这个

先申请一个腾讯地图key
在这里插入图片描述
在uniapp项目配置源码视图里加上这个代码
先获取权限,再开启后台持续获取位置的能力

"mp-weixin" : {"requiredPrivateInfos" : ["chooseLocation","getLocation","onLocationChange","startLocationUpdateBackground"],"requiredBackgroundModes" : [ "location" ],"permission" : {"scope.userLocation" : {"desc" : "方便您使用更完整的功能"},"scope.startLocationUpdateBackground" : {"desc" : "方便获取您的位置"}}
},

下面是使用页面的代码

//获取位置权限
setPosition(){const thle = this;uni.getSetting({success(res) {console.log('权限权限',res.authSetting)if (!res.authSetting['scope.userLocation']) {uni.authorize({scope: 'scope.userLocation',success() {console.log("用户成功授权位置信息")thle.keepPosition()},fail() {console.log("用户拒绝授权位置信息,再次提示用户授权")thle.showRefuseLocationPermission('nonono')}})}else if(!res.authSetting['scope.userLocationBackground']){//后台获取位置变化的权限uni.authorize({scope: 'scope.userLocationBackground',success() {console.log("用户成功授权位置信息")thle.keepPosition()},fail() {console.log("用户拒绝授权位置信息,再次提示用户授权")thle.showRefuseLocationPermission('nonono')}})}else{thle.keepPosition() }}})
},
//持续上传位置
keepPosition(){const thle = this;// uni.startLocationUpdate({//   success: res => console.log('开启前台位置成功'),//   fail: err => console.error('开启前台位置失败:', err),// });//开启前后台位置获取uni.startLocationUpdateBackground({success: res =>{console.log('前后台位置成功')uni.onLocationChange(rr=> {console.log('持续位置:',rr);console.log('纬度:' + rr.latitude);console.log('经度:' + rr.longitude);thle.updataPosition(rr.latitude,rr.longitude)});},fail: err => console.error('前后台位置失败:', err),});
},
//更新位置
updataPosition(latitude,longitude){const thle = this;console.log('更新位置',latitude,longitude)uni.request({url: `https://apis.map.qq.com/ws/geocoder/v1/?key=${'腾讯地图key'}&location=`+ latitude + ',' +longitude,success: res => {console.log('解析成功',res) let address = res.data.result.address;//经纬度解析后的地址}})
},
// 用户拒绝授权的展示
showRefuseLocationPermission(e) {const that = this;uni.showModal({title: "提示",content: "需要获取用户位置以及后台定位权限",confirmText: "前往设置",showCancel: false,success(res) {if (res.confirm) {uni.openSetting({success: (res) => {console.log("打开设置成功", res);if (res.authSetting['scope.userLocation']) {console.log('成功授权userLocation')} else {console.log('用户未授权userLocation')// 递归调用本函数,(函数套函数)that.showRefuseLocationPermission()}},fail: (err) => {console.log("打开设置失败", err)}})}}})
},
http://www.yidumall.com/news/98416.html

相关文章:

  • 机械公司网站源码天津seo结算
  • 网站加地图标记温州最好的seo
  • 做传奇网站怎么弄的软文有哪些推广渠道
  • c .net网站开发入门网络seo是什么意思
  • 做网站这个工作怎么样网站历史权重查询
  • 东莞专业网站建设服务58网络推广
  • 营销型 网站开发小说排行榜2020前十名
  • wordpress文件管理蚌埠seo外包
  • 网站关键词表格下载seo优化快排
  • 网站 演示代码成品网站源码在线看
  • win7 iis网站设置网络营销岗位有哪些
  • 黑龙江做网站长沙百度网站优化
  • 网站搭建与服务器配置百度怎么搜索网址打开网页
  • 苏州市高新区建设局网站搜索引擎优化服务公司哪家好
  • 攻击自己做的网站吗高端企业网站模板
  • 公司做个网站好还是做公众号好爱链网中可以进行链接买卖
  • 建设网站的公司汇总网站排名优化软件有哪些
  • 网站开发类型广州seo公司排名
  • 如何保存自己做的网站做外贸推广
  • 成都科技网站建设电话咨询可口可乐软文营销案例
  • 网站地图提交地址营销号
  • 全国最新的疫情广州seo黑帽培训
  • 代做ppt网站好云计算培训
  • 免费微信小程序官网seo怎么做优化
  • 设计一个网站要多少钱百度指数查询官方下载
  • 定制棺材网站看网站搜索什么关键词
  • 网页设计模板的网站如何开网站呢
  • 山东外贸网站建设是什么百度seo关键词怎么做
  • 带后台的网站开发运营成本青岛快速排名优化
  • wordpress表单提交 阿里云邮箱网络优化器