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

江苏连云港网站建设公司营销案例最新

江苏连云港网站建设公司,营销案例最新,腾讯疫情实时查询,北京网站设计外包公司价格需求 有个表单需要一键获取对应位置 并显示出来效果如下&#xff1a; 点击一键获取获取对应位置 显示在 picker 默认选中 前端 代码如下: <view class"box_7 {{ showChange1? change-style: }}"><view class"box_11"><view class"…

需求 有个表单需要一键获取对应位置 并显示出来效果如下:

点击一键获取获取对应位置 显示在  picker 默认选中

前端  代码如下:

     <view class="box_7  {{ showChange==1? 'change-style':'' }}"><view class="box_11"><view class="text-wrapper_6 {{ showChange==1? 'change-style-postiona':'' }}"><text lines="1" class="text_29">考试地址</text><text lines="1" class="text_30" /><text lines="1" class="text_31">*</text></view><picker class="region-select" mode="region" bindchange="bindRegionChange" value="{{region}}" custom-item="{{customItem}}"><view class="picker">{{region[0]}}   {{region[1]}}     {{region[2]}}</view></picker><button  bindtap="getUserLocation" class="get-position {{ showChange==1? 'change-style-postion':''}}">一键获取</button></view></view>

一定注意:小程序中要配置,不然获取位置不生效。

  "permission": {"scope.userLocation": {"desc": "你的位置信息将用于小程序位置接口的效果展示"}},"requiredPrivateInfos" : [ "getLocation" ],

小程序js如下:注意 获取到 经纬度之后 请求腾讯 api key 要进行申请 ,申请很快

申请地址 腾讯位置服务 - 立足生态,连接未来

getUserLocation: function () {let that = this;wx.getSetting({success: (res) => {if (res.authSetting['scope.userLocation'] != undefined && res.authSetting['scope.userLocation'] != true) {//如果没有授权就提示需要授权wx.showModal({title: '请求授权当前位置',content: '需要获取您的地理位置,请确认授权',success: function (res) {if (res.cancel) {wx.showToast({title: '拒绝授权',icon: 'none',duration: 1000})} else if (res.confirm) {wx.openSetting({success: function (dataAu) {if (dataAu.authSetting["scope.userLocation"] == true) {wx.showToast({title: '授权成功',icon: 'success',duration: 1000})//再次授权,调用wx.getLocation的APIthat.getLocations();} else {wx.showToast({title: '授权失败',icon: 'none',duration: 1000})}}})}}})} else if (res.authSetting['scope.userLocation'] == undefined) {that.getLocations();}else {that.getLocations();}}})
},
//获取经纬度getLocations()
{let that = this;wx.getLocation({type: 'wgs84',success (res) {const latitude = res.latitudeconst longitude = res.longitudewx.request({url: 'https://apis.map.qq.com/ws/geocoder/v1/',data: {location: `${latitude},${longitude}`,key: that.data.key,get_poi: 0},success(res) {if(res.statusCode==200){const addressComponent = res.data.result.address_component;const province = addressComponent.province;const city = addressComponent.city;const district = addressComponent.district;var showChange =0;if((province+city+district).length>=12){showChange =1;}var result = [province, city, district];that.setData({region: result,showChange: showChange,addressSelect:1,})}else{wx.showToast({title: '定位获取失败,请手动选择~',icon: 'none'})}}})}})
},

http://www.dtcms.com/wzjs/12131.html

相关文章:

  • 专业做俄语网站建设网站建设制作模板
  • 宝安网站建设公司企业网站推广建议
  • 卖网站赚钱企业网站运营推广
  • 泊头在哪做网站比较好网红推广
  • 设置html编辑器seo课程排行榜
  • 萌导航seo的基本步骤包括哪些
  • wordpress升级教程宁波seo外包方案
  • wordpress 证书seo服务深圳
  • 建设网站的主要任务微信公众号推广
  • 在线商城网站制作惠州seo网络推广
  • 荣成市住房和城乡建设局网站做任务赚佣金一单10块
  • 中国域名根服务器深圳优化公司找高粱seo服务
  • 济南网站自然优化b站推广引流最佳方法
  • 国外优秀设计网站连云港seo优化公司
  • 3维网站制作技术网络兼职平台
  • 建大仁科公司网站产品推广计划怎么写
  • 中国家装家居网seo点石论坛
  • wordpress gravatar关键词seo价格
  • 建设工程合同索赔的原因有哪些seo免费诊断
  • 国内男女直接做的视频网站百度seo关键词优化
  • 手机如何免费做网站app拉新一手渠道商
  • 做网站需要留什么条件百度首页 百度一下
  • 深圳网站关键字优化小红书怎么推广引流
  • wordpress百度收录查阅南宁百度seo排名优化软件
  • 优惠网站怎么做百度站长平台官网
  • vs2013网站开发教程seo整站优化服务
  • 自建英文网站正规网络公司关键词排名优化
  • 宿州市网站建设产品网络推广怎样做
  • 用来做区位分析的地图网站魔方优化大师官网
  • 网站建设基本模板介绍外贸平台排行榜前十名