var app = getApp(); var request = require("../utils/request") // 获取定位 function getAddress(that) { var userinfo = wx.getStorageSync('userinfo') // userinfo.citycode 是否有值来判断是否获取到了地址 if(userinfo.citycode == null || !userinfo.citycode) { wx.getLocation({ type: 'wgs84', success (res) { const latitude = res.latitude const longitude = res.longitude const speed = res.speed const accuracy = res.accuracy console.log(latitude, '地址') request.getData('loc/queryUserNearArea?lat=' + latitude + '&lng=' + longitude, res => { console.log(res, '我传地址了') that.setData({ addressArr: res.data }) } ) } }) } } module.exports = getAddress;