我想获取手机号,在app.js页登录时,通过向服务器发送code来获取openid和session_key,,,写代码时用模拟器测试一切正常,但是真机调试和上传到微信小程序的体验版时wx.request请求服务器一直没有相应,服务器端没有收到任何消息,求大神帮忙看看,下面是代码:
var that = this;
// 登录
wx.login({
success(res) {
var code = res.code
console.log(code)
wx.request({
url: “http://192.168.1.1:8080/wx/getSessionByCode”,
method: “post”,
data: {
jsCode:code
},
success: function (res) {
// that.setData(res.data.data)
that.globalData.openid = res.data.data.openid;
that.globalData.session_key = res.data.data.session_key;
console.log(that.globalData)
},
fail: function () {
wx.hideLoading();
wx.showModal({
title: ‘提示’,
showCancel: false,
content: ‘请求超时,请退出重新扫码!’,
})
}
})
}