微信小程序api

//获取地理位置
wx.getLocation({
type: 'wgs84',
success: function (res) {
console.log(res)
var latitude = res.latitude
var longitude = res.longitude
_this.globalData.lat = latitude;
_this.globalData.log = longitude;
}
})


// 获取用户信息
wx.getSetting({
success: function (res) {
if (res.authSetting['scope.userInfo']) {
// 已经授权,可以直接调用 getUserInfo 获取头像昵称
wx.getUserInfo({
success: function (res) {

_this.globalData.userInfo = res.userInfo
wx.setStorage({
key: "userInfo",
data: res.userInfo
});
}
})
}
}
})
posted @ 2018-07-30 16:47  Y-HJ  阅读(210)  评论(0编辑  收藏  举报