add login page

master
tonkia 6 years ago
parent 9e540efe77
commit e265336aa6
  1. 23
      app.js
  2. BIN
      static/img/webbg.jpg
  3. 25
      static/js/createScheme.js
  4. 25
      views/createScheme.html
  5. 23
      views/home.html
  6. 66
      views/login.html

@ -11,11 +11,28 @@ app.use(express.static('static'));
//临时存储数据
var data = { name: '默认方案', components: [] };
var acc = 'tonkia';
var pwd = '123';
//主页加载
//主页加载:登录页面
app.get('/', function (req, res) {
res.sendFile(__dirname + "/views/createScheme.html");
res.sendFile(__dirname + "/views/login.html");
});
//登录
app.post('/', function (req, res) {
var account = req.body.account;
var password = req.body.password;
//用户验证
if (account == acc && password == pwd) {
res.send('登录成功');
} else {
res.send('登录失败');
}
});
app.get('/home', function (req, res) {
res.sendFile(__dirname + "/views/home.html");
});
//接受文件上传,并且返回文件名

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

@ -81,10 +81,10 @@ function freshModelList() {
for (var index in data.components[componentIndex].models) {
if (index == data.components[componentIndex].modelIndex) {
data.components[componentIndex].models[index].modelObj.visible = true;
$('#modelList').append("<a class='list-group-item active' onclick='selectModel(" + index + ")'><span>" + data.components[componentIndex].models[index].name + "</span><button type='button' class='close' onclick='delModelItem(" + index + ")'><span aria-hidden='true'>×</span><span class='sr-only'>Close</span></button></a>");
$('#modelList').append("<a class='list-group-item active' ondblclick='changeModelName(" + index + ")' onclick='selectModel(" + index + ")'><span>" + data.components[componentIndex].models[index].name + "</span><button type='button' class='close' onclick='delModelItem(" + index + ")'><span aria-hidden='true'>×</span><span class='sr-only'>Close</span></button></a>");
} else {
data.components[componentIndex].models[index].modelObj.visible = false;
$('#modelList').append("<a class='list-group-item' onclick='selectModel(" + index + ")'><span>" + data.components[componentIndex].models[index].name + "</span><button type='button' class='close' onclick='delModelItem(" + index + ")'><span aria-hidden='true'>×</span><span class='sr-only'>Close</span></button></a>");
$('#modelList').append("<a class='list-group-item' ondblclick='changeModelName(" + index + ")' onclick='selectModel(" + index + ")'><span>" + data.components[componentIndex].models[index].name + "</span><button type='button' class='close' onclick='delModelItem(" + index + ")'><span aria-hidden='true'>×</span><span class='sr-only'>Close</span></button></a>");
}
}
}
@ -106,6 +106,20 @@ function delModelItem(index) {
event.stopPropagation();
}
//点击事件:修改模型名称
function changeModelName(index) {
$('#modelName').val(data.components[componentIndex].models[index].name);
$('#changeModelNameModal').modal('show');
$('#changeModelName').unbind('click');
$('#changeModelName').click(function () {
if ($('#modelName').val().trim().length > 0) {
data.components[componentIndex].models[index].name = $('#modelName').val();
$('#changeModelNameModal').modal('hide');
freshModelList();
}
});
}
//刷新贴图列表
function freshTextureList() {
$('#textureList').empty();
@ -113,7 +127,6 @@ function freshTextureList() {
var fileName = data.components[componentIndex].textures[index].name;
var fileId = data.components[componentIndex].textures[index].fileId;
$('#textureList').append("<img src='/files/thumbnail/" + fileId + "' width='40px' height='40px' class='img-thumbnail' alt = '" + fileName + "' onclick='delTexture(" + index + ")'> ");
}
}
@ -329,9 +342,6 @@ function initEvent() {
type: 'post',
url: "/upload",
data: formData,
cache: false,
processData: false,
contentType: false,
success: function (fileData) {
//上传成功后加载模型
//加载是异步的
@ -360,9 +370,6 @@ function initEvent() {
type: 'post',
url: "/upload",
data: formData,
cache: false,
processData: false,
contentType: false,
success: function (fileData) {
//上传成功后加载模型
//加载是异步的

@ -146,6 +146,31 @@
</div>
</div>
</div>
<!-- 模态框:修改模型名字 -->
<div class="modal fade" id="changeModelNameModal">
<div class="modal-dialog modal-sm">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span
class="sr-only">关闭</span></button>
<h4 class="modal-title">修改</h4>
</div>
<div class="modal-body">
<div id="textureList">
<input type="text" class="form-control" id="modelName" placeholder="模型名称">
</div>
</div>
<div class="modal-footer">
<form id="uploadTextureForm" enctype="multipart/form-data">
<input type="file" name="file" id="textureFile" style="display: none" />
</form>
<button class="btn btn-primary" id="changeModelName">确定修改</button>
<button type="button" class="btn btn-default" data-dismiss="modal" style="margin-left: 10px">取消</button>
</div>
</div>
</div>
</div>
<script src="/js/createScheme.js"></script>
</body>

@ -0,0 +1,23 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>UserName</title>
</head>
<body>
<a class="card" href="###">
<img src="" alt="">
<div class="card-heading"><strong>良辰美景</strong></div>
<div class="card-content text-muted">良辰美景奈何天,赏心乐事谁家院。</div>
<div class="card-actions">
<button type="button" class="btn btn-danger"><i class="icon-heart"></i> 喜欢</button>
<div class="pull-right text-danger"><i class="icon-heart-empty"></i> 520 人喜欢</div>
</div>
</a>
</body>
</html>

@ -0,0 +1,66 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<!-- jquery -->
<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.js"></script>
<!-- ZUI -->
<link rel="stylesheet" href="//cdn.bootcss.com/zui/1.8.1/css/zui.min.css">
<script src="//cdn.bootcss.com/zui/1.8.1/js/zui.min.js"></script>
<title>3D MODELS SYSTEM</title>
<style>
.input-block{
margin-top: 20px;
}
</style>
</head>
<body background='/img/webbg.jpg'>
<div class="container-fixed-xs">
<div style="height:100px"></div>
<h1>3D MODELS SYSTEM</h1>
<span class="label label-info">v1.0</span>
<hr />
<div class="panel">
<div class="panel-heading">
<h2>用户登录</h2>
</div>
<div class="panel-body">
<div class="input-group input-block">
<span class="input-group-addon">用户名</span>
<input type="text" id="account" class="form-control" placeholder="请输入用户名">
</div>
<div class="input-group input-block">
<span class="input-group-addon"> </span>
<input type="password" id="password" class="form-control" placeholder="请输入密码">
</div>
<button class="btn btn-primary btn-block input-block" id="loginBtn">  </button>
</div>
<div class="panel-footer">
<small>DESIGNED BY TONKIA</small>
</div>
</div>
</div>
<script>
$('#loginBtn').click(function () {
$.ajax({
type: 'post',
url: "/",
contentType: "application/json; charset=utf-8",
data: JSON.stringify({ account: $('#account').val(), password: $('#password').val() }),
success: function (data) {
alert(data);
},
error: function () {
alert("失败");
}
});
});
</script>
</body>
</html>
Loading…
Cancel
Save