wxml
<viewclass="usermotto">
<view>
账号:<inputdata-id="u_name"bindinput="setVals"/>
</view>
<view>
密码:<inputdata-id=u_password"bindinput="setVals"type="password"/>
</view>
<view>
<buttonclass="btn_login"bindtap="btn"data-indo="{{3}}">登录</button>
</view>
</view>
</view>
wxss
.userinfo{
display:flex;
flex-direction:column;
align-items:center;
color:#aaa;
}
.userinfo-avatar{
overflow:hidden;
width:128rpx;
height:128rpx;
margin:20rpx;
border-radius:50%;
}
.usermotto{
margin-top:50px;
}
.usermotto>view{
display:flex;
margin-top:12px;
}
.usermotto>view>input{
border-bottom:1pxrgb(15,15,15)solid;
border-color:rgb(15,15,15);
}
.btn_login{
margin-top:30px;
background-color:rgb(75,111,209);
}
js
data:{
u_name:'',
u_password:''
},
btn(e){
letname=this.data.u_name;
letpassword=this.data.u_password;
//if(name==null||name==""||name==undefined||name=="undefined"){
if(this.isNull(name)){
wx.showToast({
title:'请输入账号!',
icon:'error'
});
}elseif(this.isNull(password)){
wx.showToast({
title:'请输入密码!',
icon:'error'
});
}else{
wx.request({
url:'http://114.116.32.26:8080/func/OPERATOR/LOGIN',
method:'GET',
data:{
loginname:name,
pass:password
},
success:function(res){
if(res.data.errorcode==0){
app.globalData.userInfo=res.data.employee;
console.log(app.globalData.userInfo);
wx.navigateTo({
url:"../home/home"
})
}else{
wx.showToast({
title:res.data.message,
icon:'error'
});
}
}
})
}
},
isNull(val){
console.log(val);
if(val==null||val==""||val==undefined||val=="undefined"){
returntrue
}else{
returnfalse
}
},setVals(e){
this.setData({
[e.currentTarget.dataset.id]:e.detail.value
})
console.log(this.data);
},