700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > 微信小程序实现登陆页面代码

微信小程序实现登陆页面代码

时间:2021-12-17 01:51:13

相关推荐

微信小程序实现登陆页面代码

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);

},

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。