Skip to content

Add: login page logic #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 9, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion public/src/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ table a{color: #30bfa1;}
.dc{color: #30bfa1;}
/* 黑名单 */
.bla-tit{height: 40px; margin-bottom: 30px;}
.bla-tit input{width: 500px; height: 40px;border-radius: 3px; border: 1px solid #ddd;padding-left: 10px; float: left;background: #fff;}
.bla-tit input{width: 400px; height: 40px;border-radius: 3px; border: 1px solid #ddd;padding-left: 10px; float: left;background: #fff;}
.xg{float: right; margin-top: 10px;font-size: 16px;color: #30bfa1;}
.xg span{cursor: pointer;}
.nb-more{display: none;}
Expand Down
1 change: 0 additions & 1 deletion public/src/js/controllers/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
angular.module('insight.system').controller('HeaderController',
function($scope, $rootScope, $modal, getSocket, Global, Block) {
$scope.global = Global;
$rootScope.isLogin=false;

$rootScope.currency = {
factor: 1,
Expand Down
25 changes: 9 additions & 16 deletions public/src/js/controllers/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,19 @@

angular.module('insight.login').controller('loginController',
function($scope, $rootScope, $routeParams, $location,Account) {
$rootScope.isLogin=false;
$scope.isLogin = function () {
console.log('insight.logi loginController isLogin:', $rootScope.isLogin);
return $rootScope.isLogin;
}
//依赖注入的内容 作用域 本地 账户信息 弹出提示 状态值
$scope.login = function () {

if ($scope.user && $scope.user.name && $scope.user.password) { //如果用户和用户名及密码都是正确的
$location.path('/home');
$rootScope.isLogin=true;
/* Account.signIn($scope.user, function (data) { //account.signIn是登录方法 登录后本地获取用户信息
console.log(data);
$localStorage.userId = data.userId;
$localStorage.username = data.name;
$localStorage.telephone = data.phone;
$location.path('/home'); //登录成功跳转页面
},function(data){
if (data.code !== 200) {
// SweetAlert.swal("", "用户名或密码错误", "warning");
console.log(data);
}
})
*/
$rootScope.isLogin = Account.login($scope.user);
console.log('login user info:', $scope.user.name, $scope.user.password);
if ($rootScope.isLogin) {
$location.path('/home');
}
}
else {
//SweetAlert.swal("", "请重新输入用户名或密码", "warning");
Expand Down
53 changes: 31 additions & 22 deletions public/src/js/services/login.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,35 @@
'use strict';

angular.module('insight.login').factory('Account', function () {
var authService = {
userId:1,
name:"admin",
password:123456,
phone:13645784152,
message:"test messafe"
};
angular.module('insight.login')
.factory('Account', function () {
var users = [{
userId: 1,
name: "admin",
password: "123456",
phone: 13645784152,
message: "test messafe"
}];

/* signIn = function (user) {
if(user.name=="admin"&&user.password==123456){
return authService;
}else{
var service = {};

}
return $http
.post('/login', credentials)
.then(function (res) {
Session.create(res.data.id, res.data.user.id,
res.data.user.role);
return res.data.user;
});
};*/
});
service.login = function (user) {
//if this user already in the list, ignore it.
for (i in users) {
// console.log(typeof users[i].name, typeof user.name);
if (users[i].name == user.name && users[i].password == user.password) {
console.log('login user info OKOKOK:', users[i],user);
return true;
}
}

// console.log(typeof users.name, typeof user.name);
// if (users[i].name == user.name && users[i].password == user.password) {
// console.log('login user info OKOKOK:', users[i],user);
// return true;
// }
return false;
};

return service;

});
8 changes: 4 additions & 4 deletions public/views/blacklists.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

<hr>
<form class="form-horizontal">
<label class="col-sm-2 control-label">地址:</label>
<div class="col-sm-10 bla-tit">
<label class="col-sm-1 control-label">地址:</label>
<div class="col-sm-4 bla-tit">
<input type="text" name="addr" ng-model="newblacklist.addr" ng-disabled="!bedit" placeholder="地址">
</div>
<label class="col-sm-2 control-label">备注:</label>
<div class="col-sm-10 bla-tit">
<label class="col-sm-1 control-label">备注:</label>
<div class="col-sm-4 bla-tit">
<input type="text" name="comment" ng-model="newblacklist.comment" placeholder="备注">
</div>

Expand Down
5 changes: 3 additions & 2 deletions public/views/includes/header.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="container">
<div data-ng-controller="HeaderController">
<div data-ng-controller="HeaderController" data-ng-show="isLogin" >
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse" data-ng-click="$root.isCollapsed = !$root.isCollapsed">
<span class="sr-only">Toggle navigation</span>
Expand All @@ -9,7 +9,7 @@
</button>
<a class="insight navbar-brand" href=".">BTCEXPLORER</a>
</div>
<div class="navbar-collapse collapse" data-ng-show="false" collapse="$root.isCollapsed">
<div class="navbar-collapse collapse"collapse="$root.isCollapsed">
<ul class="nav navbar-nav">
<li data-ng-repeat="item in menu" ui-route="{{item.link}}" data-ng-class="{active: $uiRoute}">
<a href="{{item.link}}">{{item.title|translate}}</a>
Expand Down Expand Up @@ -45,4 +45,5 @@
</ul> -->
</div>
</div>
<h1 data-ng-hide="isLogin">比特币数据处理平台</h1>
</div>
5 changes: 1 addition & 4 deletions public/views/login.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
<div class="login-nav">
<!-- <img src="images/login-logo.png" height="62" width="309" alt=""> -->
<b>比特币数据处理平台</b>
</div>

<div class="login-content" data-ng-controller="loginController" >
<div class="lon-con">
<img src="images/login-bg.png" alt="" width="600">
Expand Down