是环境问题么?complete函数也不触发
wx.request为什么无法起作用?如下代码在开发工具真机测试时,日志只能打印到console.log("app.globalData.wxcode---------------" + app.globalData.wxcode); 后面wx.request没有任何反馈,服务器端也无任何调用记录。 但是在开发工具一开始加载本项目时,是正常可以获取服务端数据的,百思不得其解,请大佬们解惑,困扰一天了。 Page({ data: { canIUse: wx.canIUse('button.open-type.getUserInfo'), }, onLoad: function (e) { //加载入口 console.log('首页开始加载。。。') //custId -----: ' + custId) var that = this console.log(app.globalData) console.log('全局变量'); // if (!app.globalData.userInfo) { if (1) { console.log('进入') var that = this; wx.getSetting({ success (res){ if (res.authSetting['scope.userInfo']) { wx.getUserInfo({ success: function(res) { console.log(res.userInfo) that.setData({ userInfo: res.userInfo }) app.globalData.userInfo=res.userInfo; console.log("新测试0" + app.globalData.wxcode); console.log("新测试1" + res.userInfo.avatarUrl); console.log("新测试2" + app.globalData.userInfo.avatarUrl); let obj = {}; console.log(app.globalData.userInfo); //头像 obj.avatarUrl = app.globalData.userInfo.avatarUrl; //性别 obj.gender = app.globalData.userInfo.gender; //昵称 obj.nickName = app.globalData.userInfo.nickName; //国家 obj.country = app.globalData.userInfo.country; //省份 obj.province = app.globalData.userInfo.province; //城市 obj.city = app.globalData.userInfo.city; console.log(obj); console.log("app.globalData.wxcode---------------" + app.globalData.wxcode); wx.request({ url: properties.getURL() + '/test/getOpenId.do', data: { wxcode: app.globalData.wxcode, nickName: app.globalData.userInfo.nickName, city: app.globalData.userInfo.city, avatarUrl: app.globalData.userInfo.avatarUrl, gender: app.globalData.userInfo.gender, fatherCustId:e.custId, fatherName:e.custNickname }, header: { 'content-type': 'application/json' // 默认值 }, success(res) { //success: function (res) { console.log("res.responseCode : " + res.data.responseCode) if (res.data.responseCode == 0) { console.log("data ffffffff : " + JSON.stringify(res.data.data)) app.globalData.custid = res.data.data.user.custid console.log(" app.globalData.custid ffffffff : " + JSON.stringify(app.globalData.custid)) } } }) } }) } } }) //}) }
10-22