success: function(res) {
if (res.code) {
var APPID='***************'
var SECRET='***********************'
wx.request({
url: 'https://api.weixin.qq.com/sns/jscode2session?appid='+APPID+'&secret='+SECRET+'&js_code='+res.code+'&grant_type=authorization_code',
data: {},
method: 'POST',
success : function(ret){
that.globalData.openid = ret.data.openid; //获取openid (这个地方已经获取到了,也可以后台去获取,这里就不多说了)
wx.getLocation({
type: 'wgs84',
success: function(res) {
that.globalData.lat = res.latitude //获取维度
that.globalData.long = res.longitude //获取经度
wx.getUserInfo({ //用户微信信息
success: function (rey) {
that.globalData.userInfo = rey.userInfo
that.yang() //调用接口
},
//拒绝共享信息
fail : function(){ wx.hideLoading() }
})
},
//拒绝定位
fail : function(e){ wx.hideLoading() }
})
},
fail : function(errMsg){ console.log(errMsg) }
})
} else {
wx.showModal({ title: '提示', content: '获取用户登录态失败!' + res.errMsg })
}
}
});
that.yang() //页面数据请求完成执行自定义函数
},