第一次打开小程序request请求不成功 , 第二次打开小程可以访问成功
模拟器上不会出现问题, 真机上会有,不管是android还是ios,
第一次错误提示 : request : fail url not in domain list
代码 :
wx.login({
success : function(code){
wx.getUserInfo({
success : function(user){
var userCod = code.code;
var nickName = user.userInfo.nickName
wx.showModal({
title: ‘title’,
content: 'code = ’ + code.code +"user = " +user.userInfo.nickName,
showCancel : false,
success : function(res){
if(res.confirm){
wx.request({
url: ‘http://***.com/hepcws/v2/restws/****’,
data: {
“appid”: “********e5be52”,
“secret”: “******cb393a9de”,
“js_code”: userCod,
“nickName”: nickName
},
method: “POST”,
header: {
‘content-type’: ‘application/json’
},
success: function (res) {
wx.showToast({
title: 'success : ’ + res,
})
that.setData({
userInfo: user.userInfo
})
},
fail: function (res) {
wx.showToast({
title: 'fail = ’ + res.errMsg,
})
},
complete: function (res) {
}
})
}
}
})
}
})
}
})