**

源代码-微信小程序获取附近商家

**

const app = getApp();
var timer = false;
var QQMapWX = require('../../utils/qqmap-wx-jssdk.js');
var qqmapsdk;
Page({data: {statusBarHeight: app.globalData.statusBarHeight,page: 1,pois: [],result: [],latitude: '',longitude: ''},onLoad: function () {qqmapsdk = new QQMapWX({key: '秘钥'})},onShow: function () {let vm = this;vm.getUserLocation();},// 授权位置信息getUserLocation: function () {let vm = 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的APIvm.getLocation();} else {wx.showToast({title: '授权失败',icon: 'none',duration: 1000})}}})}}})} else if (res.authSetting['scope.userLocation'] == undefined) {//调用wx.getLocation的APIvm.getLocation();}else {//调用wx.getLocation的APIvm.getLocation();}}})},// 微信获得经纬度getLocation: function () {let vm = this;wx.getLocation({type: 'wgs84',success: function (res) {console.log('获得经纬度:',JSON.stringify(res))var latitude = res.latitudevar longitude = res.longitudevm.setData({latitude: latitude,longitude: longitude})vm.getLocal(latitude, longitude)},fail: function (res) {}})},// 获取当前地理位置getLocal: function (latitude, longitude) {let that = this;wx.showLoading({title: '加载中',duration: 3000})qqmapsdk.reverseGeocoder({location: {latitude: latitude,longitude: longitude,},success:function (params) {console.log('params',params)that.setData({result:params.result})}}),qqmapsdk.search({location: {latitude: latitude,longitude: longitude,},keyword:'小吃',page_size:10,page_index:that.data.page,header: {'content-type': 'application/json' // 默认值},success: function (res) {console.log('地理位置:',res);wx.hideLoading()let pois = res.datathat.setData({pois: that.data.pois.concat(pois),})},fail: function (res) {console.log(res);},complete: function (res) {// console.log(res);}});},// 点击进入地图turn_map:function (e) {console.log('e',e)wx.openLocation({latitude: e.currentTarget.dataset.index.lat,longitude: e.currentTarget.dataset.index.lng,scale: 18,name:e.currentTarget.dataset.name,address:e.currentTarget.dataset.address,})console.log('e',e)},// 下拉获取数据页数onReachBottom:function(){let vm = this;vm.setData({page:vm.data.page+1})vm.getLocal(vm.data.latitude, vm.data.longitude)}

微信小程序获取附近商家相关推荐

  1. 微信小程序获取openid和session_key并且把openid存入数据库

    微信小程序开发交流qq群   581478349 微信小程序获取openid和session_key并且把openid存入数据库.已经调用openid的demo 前后端代码都有,后端php实现 在其它 ...

  2. android获取小程序音频时长,最新微信小程序获取音频时长与实时获取播放进度...

    #微信小程序获取音频时长与实时获取播放进度 在小程序官方文档中 audio 注意:1.6.0 版本开始,该组件不再维护.建议使用能力更强的 wx.createInnerAudioContext 接口 ...

  3. 微信小程序获取用户手机号--官方示例

    微信小程序获取用户手机号–官方示例 https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/getPhoneNu ...

  4. 微信小程序 获取用户信息并保存登录状态

    微信小程序 获取用户信息并保存登录状态:http://www.360doc.com/content/18/0124/11/9200790_724662071.shtml 转载于:https://www ...

  5. .Net之微信小程序获取用户UnionID

    前言: 在实际项目开发中我们经常会遇到账号统一的问题,如何在不同端或者是不同的登录方式下保证同一个会员或者用户账号唯一(便于用户信息的管理).这段时间就有一个这样的需求,之前有个客户做了一个微信小程序 ...

  6. uni-app微信小程序获取手机号;微信小程序获取手机号,获取到后需要进行解密;微信小程序获取手机号失败 Error:该appId没有权限

    方法1.uni-app登录加获取手机号解密-直接看此篇即可解决 微信小程序获取手机号注意点: 1.需要先登录,微信小程序登录看这篇 2.手机号获取到时加密的,需要后端解密或者前端自己解密(解密时候就会 ...

  7. 微信小程序获取unionid为空

    微信小程序获取unionid为空 原因:未绑定微信开放平台 绑定步骤 原因:未绑定微信开放平台 最新在调试一个新的微信小程序,因为要对web授权登录.app授权登录.小程序授权登录:几种登录场景根据u ...

  8. 微信小程序获取二维码中URL中带的参数

    解析微信小程序获取二维码中的url参数 onLoad: function (options) { console.log(options) let qrUrl = decodeURIComponent ...

  9. 微信小程序 获取input输入的值

    微信小程序 获取input输入的值 view <view><text>姓名:</text><input type='text' name="user ...

最新文章

  1. 软件测试培训分享:软件测试初期怎么面试工作?
  2. 刻意练习:LeetCode实战 -- Task11. 删除链表的倒数第N个节点
  3. Win7碎片整理在哪?
  4. 实用小命令-windows下查看端口占用情况
  5. IOS开发之——颜色设置
  6. [summary] 单调队列
  7. 开源项目【zheng】搭建流程
  8. 简单循迹小车实验心得_红外自动循迹小车实验报告
  9. android中返回刷新,Android intent 传递对象以及返回刷新
  10. or计算机二级,计算机二级VF历年上机试题or答案
  11. tabpanel中autoload方法传递参数
  12. KEIL MDK access violation at 0x40021000 : no ‘read‘ permission的一种解决方法
  13. testlink匹配mysql8_TestLink与RedMine连接部署说明
  14. java key value 数据类型_JAVA面试锦囊(一)
  15. 【5步解决】打开Word 2016时出现MathType has detected an error in AutoExecCls.Main 以及 文件未找到:MathPage.WILL.亲测完美方案
  16. 数据库持久层框架iBatis、myBatis、Hibernate对比
  17. Python-移位密码、仿射变换解密
  18. 智慧城管拓展业务系统建设方案
  19. C语言str函数系列
  20. 魏鹏机器人_智能刷脸、机器人、无人机...山东多地校园开学充满“科技感”

热门文章

  1. 蜗牛星际风扇噪音的简单解决方案
  2. 哪个软件可以制作GIF表情包
  3. 数据结构与算法之2-3-4树
  4. 见证历史 -- 2013 NBA 热火夺冠之路有感
  5. 2021高考语文作文成绩查询,2021高考语文作文已出炉,撒贝宁押题太准了,你有想写的冲动吗...
  6. 简报悦读:教育部取消5类高考加分项目,猿辅导纪录片讲述十年坚守
  7. 天地图矢量数据下载_全球谷歌卫星地图影像数据下载
  8. jq实现一个简易的选项卡
  9. dubbo官方文档_Dubbo(一)
  10. 算法 64式 7、搜索算法整理_第2部分_16到30题