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

徐州cms建站wordpress 搜索 自定义字段

徐州cms建站,wordpress 搜索 自定义字段,小程序开发框架,成都住房和城乡建设厅网站首页需求 有个表单需要一键获取对应位置 并显示出来效果如下&#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.yayakq.cn/news/250923/

相关文章:

  • 泉州做网站优化的公司.net 开源 企业网站
  • 惠州市建设规划局网站ens域名注册
  • 设计招聘网站百度助手免费下载
  • 视频解析网站建设介绍重庆网页设计
  • 建设银行 网站西宁做网站seo
  • 上海南京东路网站建设如何做网站seo
  • 网站优化的方式有哪些iis不能新建网站
  • 青岛企业建设网站企业wordpress能做大么
  • 网站建设初步课程介绍西安网络公司做网站
  • 网站的建设与应用西安网站开发建
  • php mysql网站开发教程整站优化系统厂家
  • 电商网站建设好么产品开发的流程包括哪几个阶段
  • 制作网站培训网站怎么做最吸引人
  • 江门网站如何制作公司注册资金要求
  • 县总工会网站建设情况超市网站设计
  • 建设工程质量检测网站邯郸如何做企业网站
  • 网站二维码怎么制作建设银行的网站怎么打开
  • 如何加强省市级政门户网站建设门户网站官网有哪些
  • 网站 html 作用项目管理软件project
  • 东营网站的优化怎么样在网站上做跳转
  • 沈阳建设局网站一般网站建设用什么样的代码
  • 官方网站建站镇江搜索优化技巧
  • 织梦做的网站能做seo吗wordpress为什么用循环
  • 广州家居网站设计可以自己做头像的网站
  • 达建网站防止爬虫的办法敦煌网站外引流怎么做
  • 成都建设局网站阿里云网站搭建
  • 有什么网站可以自己做书百度推广区域代理
  • 中江门户网站做搜狗pc网站
  • 南京房地产网站模板设计模式
  • 网站特色怎么写c 做网站实例