//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 == null) return;
//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
})
}
})
},
网友回复
看看后端收到请求没,为啥没响应