html52.com
我爱小程序-开发者交流社区

request:fail timeout超时?同一个接口PC端访问没事,小程序就超时,之前一直没问题





//1、后台登录方法  post

  onlyLogin:function(username,password,rememberMe,saveData) {

    console.log("login页中login接口调用");

   var that=this;

    wx.request({

      url:app.globalData.httpUrl+'login',

      method: 'POST',

      dataType: 'json',

      header: {

        'Content-Type': 'application/x-www-form-urlencoded'

      },

      data: { username: username, password: password, rememberMe: rememberMe },

      success: function (res) {

        //console.log(res);

        // console.log(res.header['Set-Cookie']);

        var header_cookie=res.header['Set-Cookie'];

        wx.setStorageSync('cookie', header_cookie);

        wx.setStorageSync('cookieDate', new Date());


        if (res.data.code == "0"{

          wx.showToast({

            title: '登录成功',  //提示文字

            icon: 'success', //图标,支持"success"、"loading"  

            mask: 'true',   //是否显示透明蒙层,防止触摸穿透,默认:false

            duration: 2000    //显示时长

          };

          //对用户信息进行处理

          that.saveWxUser(saveData,header_cookie);

          //跳转到业务页面

          wx.switchTab({

            url: '../home/index',

            success: function (e) {

              var page = getCurrentPages().pop();

              if (page == undefined || page == nullreturn;

              //console.log("首次的跳转");

              //page.onLoad();

              //page.onShow();

            }

          })


        } else {

          wx.showToast({

            title: '登录失败!'+res.data.msg,

            icon: 'none',

            mask: 'true',

            duration: 2000

          })

        }


      },

      fail: function (res) {

        console.log(res)

        wx.showToast({

          title: '系统错误!',

          icon: 'none',

          mask: 'true',

          duration: 2000

        })

      }

    })

  },


网友回复

浪迹天涯:服务器没收到请求,本地调用接口没问题
A.G.A.I.N:

看看后端收到请求没,为啥没响应

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

真正的个人免签约支付接口

云免签H5支付