登陆login布局
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
<title>title</title>
<link rel="stylesheet" type="text/css" href="../css/api.css"/>
<style>
body{
}
header{
width: 100%;
height:50px;
background-color: rgb(218, 1, 107);
position:relative;
}
header .left{
position: absolute;
width:22px;
height:100%;
left:8px;
top:0;
background: url('../image/back.png');
background-position: center;
background-repeat: no-repeat;
background-size: 11px 20px;
}
header .center{
width:100%;
height:100%;
line-height: 50px;
text-align: center;
color:#fff;
font-size: 18px;
}
header .right{
position: absolute;
top:0;
right: 18px;
height: 100px;
line-height: 50px;
color: #fff;
font-size: 20px;
}
.row{
width:auto;
box-sizing: border-box;
height:70px;
margin:0 32px;
padding-top: 40px;
padding-left: 8px;
border-bottom: 1.5px solid #888;
}
.input{
width: 100%;
border: none;
outline: none;
font-size: 16px;
}
.btn{
width:auto;
height: 50px;
background: rgb(218, 1, 107);
margin: 32px 32px;
color:#fff;
font-size: 25px;
text-align: center;
line-height: 50px;
/*边间弧度*/
border-radius: 10px;
}
.highlight{
/*高量实现透明度*/
opacity: 0.7;
}
.wxbtn{
width:auto;
height:45px;
box-sizing: border-box;
background: url('../image/share_friend.png');
background-position:18px center;
background-repeat: no-repeat;
background-size: 25px 18px;
margin:0px 90px;
line-height: 50px;
color:#888;
font-size: 20px;
border-top: 1px solid #aaa;
border-bottom: 1px solid #aaa;
border-left: 1px solid rgb(255, 225, 225);
border-right: 1px solid rgb(255, 225, 225);
border-radius: 8px;
padding-left: 45px;
}
</style>
</head>
<body>
<header id="header">
<div class="left" tapmode οnclick="api.closeWin()"></div>
<div class="center">会员登录</div>
<div class="right" tapmode οnclick="toRegister()">注册</div>
</header>
<!-- 注册界面 -->
<div class="row">
<input type="text" class="input" id="username" placeholder="用户名(不多于6位)" maxlength="6">
</div>
<div class="row">
<input type="password" class="input" id="password" placeholder="密码" maxlength="16">
</div>
<div class="btn" tapmode="highlight" οnclick="toLogin()">登录</div>
<div class="wxbtn" tapmode="highlight" >使用微信登录</div>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript">
apiready = function(){
api.addEventListener({
name: 'account'
}, function(ret, err){
if( ret ){
updateAccount(ret.value.username)
// alert( JSON.stringify( ret ) );
}else{
alert( JSON.stringify( err ) );
}
});
};
function updateAccount(un){
/*获取输入框*/
var usrInput = $api.byId('username');
// alert(usrInput);
/*更改*/
usrInput.value = un;
}
/*登录实现*/
var usrValue,passValue;
function toLogin(){
usrValue = $api.byId('username').value;
passValue = $api.byId('password').value;
if(!usrValue||!passValue){
alert("请输入账号和密码!");
}else{
api.ajax({
url: 'https://d.apicloud.com/mcm/api/user/login',
method: 'post',
"headers": {
"X-APICloud-AppId": "A6944685896647",
"X-APICloud-AppKey": "2854C996-B52C-9991-ED1D-0A8B8F4F7BA5"
},
data: {
values: {
"username": usrValue,
"password":passValue
}
}
},function(ret, err){
if (ret) {
alert(" 登录成功");
//alert( JSON.stringify( ret ) );
/*设置登陆的标记*/
$api.setStorage('logSuccess', usrValue);
/*返回主界面*/
api.closeWin();
} else {
alert( JSON.stringify( err ) );
}
});
}
}
/*注册界面*/
function toRegister() {
api.openWin({
name: 'register',
url: './register.html',
pageParam: {
name: 'test'
}
});
}
</script>
</html>