|
经过这么多天终于把注册登录界面源码搞出来了,话不多说,分享出来。有需要的老哥复制粘贴就可以了,记得修改APPID 和appkey 还要下载 sha1.js文件应用到这两个页面中
//登录页面
<!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" />
<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
<title>注册Frame</title>
<link rel="stylesheet" type="text/css" href="../../css/api.css" />
<style>
.row {
box-sizing: border-box;
width: auto;
height: 70px;
margin-left: 32px;
margin-right: 32px;
padding-top: 40px;
border-bottom: 1px solid #888;
}
.input {
width: 100%;
height: 20px;
line-height: 20px;
border: none;
outline: none;
font-size: 16px;
}
.btn {
width: auto;
height: 50px;
margin-left: 32px;
margin-right: 32px;
margin-top: 32px;
background-color: #32CD32;
color: #fff;
font-size: 24px;
line-height: 50px;
text-align: center;
border-radius: 8px;
}
.highlight {
opacity: 0.7;
}
</style>
</head>
<body>
<div class="row">
<input id="username" class="input" type="number" placeholder="用户名">
</div>
<div class="row">
<input id="password" class="input" type="password" placeholder="密码">
</div>
<div class="btn" tapmode="highlight">登录</div>
</body>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/SHA1.js"></script>
<script type="text/javascript">
apiready = function() {
};
// 注册
function fnRegister() {
var username = $api.byId("username");
var password = $api.byId("password");
var vusername = $api.val(username);
var vpassword = $api.val(password);
var now = Date.now();
var appKey = SHA1("A6020051321024" + "UZ" + "02E35D63-EFE5-5CA7-3D04-1F5DB433A0F2" + "UZ" + now) + "." + now
api.ajax({
url: 'https://d.apicloud.com/mcm/api/user/login',
method: 'post',
headers: {
"X-APICloud-AppId": "A6020051321024",
"X-APICloud-AppKey": appKey,
},
data: {
values: {
username: vusername,
password: vpassword
}
}
},
function(ret, err) {
if (ret && ret.id) {
alert("登录成功!");
api.openWin({
name: 'login',
url: '../../html/main/login.html',
pageParam: {
name: 'test'
}
});
} else {
alert("登录失败,用户名或密码错误");
}
}
);
}
</script>
</html>
//注册界面
<!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" />
<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
<title>注册Frame</title>
<link rel="stylesheet" type="text/css" href="../../css/api.css" />
<style>
.row {
box-sizing: border-box;
width: auto;
height: 70px;
margin-left: 32px;
margin-right: 32px;
padding-top: 40px;
border-bottom: 1px solid #888;
}
.input {
width: 100%;
height: 20px;
line-height: 20px;
border: none;
outline: none;
font-size: 16px;
}
.btn {
width: auto;
height: 50px;
margin-left: 32px;
margin-right: 32px;
margin-top: 32px;
background-color: #32CD32;
color: #fff;
font-size: 24px;
line-height: 50px;
text-align: center;
border-radius: 8px;
}
.highlight {
opacity: 0.7;
}
</style>
</head>
<body>
<div class="row">
<input id="username" class="input" type="number" placeholder="用户名">
</div>
<div class="row">
<input id="password" class="input" type="password" placeholder="密码">
</div>
<div class="btn" tapmode="highlight">注册</div>
</body>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/SHA1.js"></script>
<script type="text/javascript">
apiready = function() {
};
// 注册
function fnRegister() {
var username = $api.byId("username");
var password = $api.byId("password");
var vusername = $api.val(username);
var vpassword = $api.val(password);
var now = Date.now();
var appKey = SHA1("A6020051321024" + "UZ" + "02E35D63-EFE5-5CA7-3D04-1F5DB433A0F2" + "UZ" + now) + "." + now
api.ajax({
url: 'https://d.apicloud.com/mcm/api/user',
method: 'post',
headers: {
"X-APICloud-AppId": "A6020051321024",
"X-APICloud-AppKey": appKey,
},
data: {
values: {
username: vusername,
password: vpassword
}
}
},
function(ret, err) {
if (ret && ret.id) {
alert("注册成功!");
api.openWin({
name: 'login',
url: '../../html/main/login.html',
pageParam: {
name: 'test'
}
});
} else {
alert("注册失败用户名已经存在!");
}
}
);
}
</script>
</html>
|
|