电脑上一切正常,一次登录就能进,用iPhone7真机调试时必须点两次登录才能进,而且第一次报错,第二次正常,什么情况。。我的密码先是md5加密,和这个有关系吗
js:
Page({
data: {
},
onSubmit:function(event){
var value = event.detail.value;
var phoneNumber = value.phoneNumber;
var password = value.password;
this.setData({
phoneNumber: phoneNumber,
password: password
})
},
login(event) {
var that=this;
var phoneNumber = that.data.phoneNumber;
var password = that.data.password;
var utilMd5 = require('../../utils/md5.js');
var password = utilMd5.hexMD5(password);
wx.showLoading({ title: '登录中...' });
wx.request({
url: 'xxxxxxx',
method: 'POST',
header: {
"Content-Type": "application/x-www-form-urlencoded"
},
data: {
phoneNumber: phoneNumber,
password: password
},
success:function(res) {
wx.setStorageSync('sessionid', res.cookies[0]),
console.log(res);
wx.switchTab({
url: "/pages/download/download"
});
},
fail:function(){
console.log('账号或密码错误')
}
})
}
})
wxml:
<view class="login-container">
<form bindsubmit='onSubmit'>
<view class="section-container">
<image class='image' src='https://s1.ax1x.com/2020/04/01/G1DZWR.png'></image>
<input class="common-input" name="phoneNumber" placeholder="请输入账号/手机号"></input>
</view>
<view class="section-container">
<image class='image' src='https://s1.ax1x.com/2020/04/01/G1B5RI.png'></image>
<input class="common-input" name="password" password placeholder="请输入密码"></input>
</view>
<view class="btn-area">
<button class="btn" form-type='submit' style="background:#3775F6; color:white" bindtap="login">登录</button>
</view>
</form>
</view>
直接给代码片段吧,节约大家时间