- 需求的场景描述(希望解决的问题)
小程序做了一个登录页面,开发版本中进行登录操作,希望登录成功
代码:
formSubmit: function (e) {
// 获取表单数据
var objData = e.detail.value;
// console.log(“formSubmit >>>>>>>>>>>>>>>>”);
// console.log(objData);
if (objData.username && objData.password) {
var url = app.globalData.http + “/clientApi/wxapi/login”;
var openid = wx.getStorageSync(‘openId’);
// console.log(openid);
wx.request({
url: url,
method: “POST”,
data: {
openId: openid,
loginName: objData.username,
password: objData.password
},
header: {
‘content-type’: ‘application/x-www-form-urlencoded’
},
success: function (res) {
console.log(res.data);
var myInfo = res.data.manager
if (res.data.code == 200) {
wx.showToast({
title: “登录成功”,
icon: ‘success’,
duration: 3000
})
wx.setStorageSync(‘mchtId’, res.data.mchtUserInfo[0].mchtId);
wx.setStorageSync(‘mchtName’, res.data.mchtUserInfo[0].mchtName);
wx.setStorageSync(‘mchtTypeName’, res.data.mchtUserInfo[0].mchtTypeName);
// 成功后跳转
wx.reLaunch({
url: ‘…/index/index’,
})
} else {
wx.showModal({
title: ‘提示’,
showCancel: false,
content: res.data.msg,
})
}
},
fail: function (res) {
wx.showToast({
title: ‘登录超时’,
icon: ‘loading’,
duration: 3000
})
}
})
} else {
wx.showToast({
title: ‘登录失败’,
icon: ‘loading’,
duration: 1000
})
}
}
开发版本,不打开调试,小程序一直进fail。打开调试,程序正常运行。请问这是什么原因???