Commit ef304d65 by shz

后台登录

parent 04a1cdad
<<<<<<< HEAD
<?php <?php
class introduction class introduction
...@@ -48,57 +47,3 @@ class introduction ...@@ -48,57 +47,3 @@ class introduction
return $current_user->ID; return $current_user->ID;
} }
} }
\ No newline at end of file
=======
<?php
class introduction
{
public static function ajax_submit_introduction()
{
$introduction = $_POST['introduction'];
$user_id = $_POST['user_id'];
wp_send_json(introduction::submit_introduction($introduction, $user_id));
}
public static function submit_introduction($introduction, $user_id)
{
global $wpdb;
$result = $wpdb->update(
Config::TOSPUR_CONSULTANT,
array(
'introduction' => $introduction
),
array('id' => $user_id)
);
return $result;
}
public static function search_introduction()
{
global $wpdb;
$user_id = introduction::get_user_id();
$sql = "select introduction from " . Config::TOSPUR_CONSULTANT . " where id = " . $user_id;
$result = $wpdb->get_var($sql);
return $result;
}
public static function introduction_html()
{
$context = array();
$context['url'] = home_url();
$context['introduction'] = introduction::search_introduction();
$user_id = introduction::get_user_id();
$context['user_id'] = $user_id;
Timber::render('introduction.html', $context);
}
public static function get_user_id()
{
$current_user = wp_get_current_user();
return $current_user->ID;
}
}
>>>>>>> felix
?>
\ No newline at end of file
<h2>添加特色</h2>
<label for="feature">特色:</label>
<input id="feature" type="text">
<input type="submit" id="submit" class="button">
<script>
(function ($) {
$(document).ready(function () {
$('#submit').click(function () {
var name = $('#feature').val();
if (name.trim() != '') {
$.ajax({
type: 'POST',
url: '{{ url }}/wp-admin/admin-ajax.php/',
data: 'action=add_feature&name=' + name,
success: function (data) {
if (data) {
alert('添加成功');
} else {
alert('添加失败');
}
}
});
} else {
alert('请输入特色');
}
});
});
})(jQuery);
</script>
\ No newline at end of file
<<<<<<< HEAD
<h2>诚信宣言</h2> <h2>诚信宣言</h2>
<label for="introduction"> <label for="introduction">
<textarea id="introduction" placeholder="请输入诚信宣言" rows="10" cols="50" style="resize: none;">{{ introduction }}</textarea> <textarea id="introduction" placeholder="请输入诚信宣言" rows="10" cols="50" style="resize: none;">{{ introduction }}</textarea>
...@@ -31,38 +30,4 @@ ...@@ -31,38 +30,4 @@
}); });
}); });
})(jQuery); })(jQuery);
=======
<h2>诚信宣言</h2>
<label for="introduction">
<textarea id="introduction" placeholder="请输入诚信宣言" rows="10" cols="50" style="resize: none;">{{ introduction }}</textarea>
</label>
<p>
<input type="hidden" id="user_id" value="{{ user_id }}">
<input type="submit" id="submit" class="button">
</p>
<script>
(function ($) {
var oldIntroduction = '{{ introduction }}';
$(document).ready(function () {
$('#submit').click(function () {
var introduction = $('#introduction').val();
var user_id = $('#user_id').val();
if (introduction.trim() != '' && oldIntroduction != introduction) {
$.ajax({
type: 'POST',
url: '{{ url }}/wp-admin/admin-ajax.php/',
data: 'action=submit_introduction&introduction=' + introduction + '&user_id=' + user_id,
success: function (data) {
if (data) {
alert('提交成功');
}
}
});
}else{
alert('请修改诚信宣言');
}
});
});
})(jQuery);
>>>>>>> felix
</script> </script>
\ No newline at end of file
.tab {
width: 100%;
height: 40px;
margin-bottom: 0;
border-bottom: 1px solid #008cd7;
}
.tab li .btn {
color: #000000;
font-size: 18px;
font-weight: bold;
position: static;
}
.tab li .btn:after {
content: "";
width: 88%;
height: 4px;
position: absolute;
bottom: 0;
left: 0;
right: 0;
margin: 0 auto;
}
.tab li .btn:active {
box-shadow: none;
-webkit-box-shadow: none;
}
.tab li.active .btn:after {
background-color: #008cd7;
}
.row {
width: 100%;
height: 121px;
margin: 0;
padding: 15px 0;
border-bottom: 1px solid #b7b7b7;
}
.row p {
width: 140px;
height: 100%;
float: left;
padding: 0 10px;
margin-bottom: 0;
overflow: hidden;
}
.row p img {
height: 100%;
border-top-left-radius: 6px;
border-top-right-radius: 6px;
border-bottom-left-radius: 6px;
border-bottom-right-radius: 6px;
-webkit-border-top-left-radius: 6px;
-webkit-border-top-right-radius: 6px;
-webkit-border-bottom-left-radius: 6px;
-webkit-border-bottom-right-radius: 6px;
}
.row ul {
height: 100%;
padding-right: 10px;
margin-bottom: 0;
overflow: hidden;
zoom: 1;
position: relative;
color: #5a5a5a;
font-size: 15px;
}
.row ul li {
height: 18px;
line-height: 18px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.row ul li span {
margin-right: 15px;
}
.row ul li span:last-child {
margin-right: 0;
}
.row ul li.address {
height: 22px;
line-height: 22px;
margin-top: 2px;
}
.row ul li.address span:nth-child(1) {
color: #000000;
font-size: 19px;
font-weight: bold;
}
.row ul li:last-child {
position: absolute;
left: 0;
right: 10px;
bottom: 0;
font-size: 0;
}
.row ul li:last-child .label {
color: #ff0000;
padding: 1px 4px;
font-size: 9px;
border: 1px solid #acacac;
margin: 0 5px 0 0;
vertical-align: middle;
border-top-left-radius: 3px;
border-top-right-radius: 3px;
border-bottom-left-radius: 3px;
border-bottom-right-radius: 3px;
-webkit-border-top-left-radius: 3px;
-webkit-border-top-right-radius: 3px;
-webkit-border-bottom-left-radius: 3px;
-webkit-border-bottom-right-radius: 3px;
}
.row ul li:last-child span {
color: #000000;
font-size: 15px;
}
.row ul li:last-child span em {
font-style: normal;
}
.row ul li:last-child span em:nth-child(1) {
color: #ff0000;
font-size: 19px;
font-weight: bold;
}
.row ul li:last-child span em:nth-child(2) {
font-size: 7px;
vertical-align: top;
}
.row ul li.multiLine_omit {
color: #000000;
font-weight: bold;
height: 36px;
margin-top: 0;
-webkit-line-clamp: 2;
display: -webkit-box;
-webkit-box-orient: vertical;
white-space: normal;
}
.row:active {
background-color: #e9e9e9;
}
.modal .modal-dialog {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
width: 280px;
height: 130px;
}
.modal .modal-dialog .modal-content {
color: #000000;
font-size: 16px;
border: 0;
border-top-left-radius: 8px;
border-top-right-radius: 8px;
border-bottom-left-radius: 8px;
border-bottom-right-radius: 8px;
-webkit-border-top-left-radius: 8px;
-webkit-border-top-right-radius: 8px;
-webkit-border-bottom-left-radius: 8px;
-webkit-border-bottom-right-radius: 8px;
box-shadow: none;
-webkit-box-shadow: none;
}
.modal .modal-dialog .modal-content h4 {
font-size: 19px;
font-weight: bold;
margin: 0 20px;
padding-top: 15px;
}
.modal .modal-dialog .modal-content p {
margin: 12px 20px 14px;
}
.modal .modal-dialog .modal-content p:nth-of-type(2) {
margin: 0;
font-size: 0;
}
.modal .modal-dialog .modal-content p:nth-of-type(2) .btn {
width: 50%;
}
.modal .modal-dialog .modal-content p:nth-of-type(2) .btn:nth-child(2) {
border-left-color: #cfd0d0;
}
.modal .modal-dialog .modal-content .btn {
border-top-color: #cfd0d0;
background-color: transparent;
font-weight: bold;
border-top-left-radius: 0;
border-top-right-radius: 0;
border-bottom-left-radius: 0;
border-bottom-right-radius: 0;
-webkit-border-top-left-radius: 0;
-webkit-border-top-right-radius: 0;
-webkit-border-bottom-left-radius: 0;
-webkit-border-bottom-right-radius: 0;
}
.modal .modal-dialog .modal-content .btn:active {
background-color: #e9e9e9;
border-bottom-left-radius: 8px;
border-bottom-right-radius: 8px;
-webkit-border-bottom-left-radius: 8px;
-webkit-border-bottom-right-radius: 8px;
box-shadow: none;
-webkit-box-shadow: none;
}
.modal .modal-dialog .modal-content .btn:focus {
outline: 0;
}
.loading {
position: fixed;
top: 0;
bottom: 0;
left: 0;
right: 0;
z-index: 1040;
background-color: rgba(0, 0, 0, 0.5);
}
.loading ul {
position: fixed;
top: 0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
width: 40px;
height: 40px;
}
.loading ul li {
position: absolute;
width: 100%;
height: 100%;
}
.loading ul li:nth-child(1) p:nth-child(2) {
animation-delay: -0.9s;
-webkit-animation-delay: -0.9s;
}
.loading ul li:nth-child(1) p:nth-child(3) {
animation-delay: -0.6s;
-webkit-animation-delay: -0.6s;
}
.loading ul li:nth-child(1) p:nth-child(4) {
animation-delay: -0.3s;
-webkit-animation-delay: -0.3s;
}
.loading ul li:nth-child(2) {
transform: rotateZ(45deg);
-webkit-transform: rotateZ(45deg);
}
.loading ul li:nth-child(2) p:nth-child(1) {
animation-delay: -1.1s;
-webkit-animation-delay: -1.1s;
}
.loading ul li:nth-child(2) p:nth-child(2) {
animation-delay: -0.8s;
-webkit-animation-delay: -0.8s;
}
.loading ul li:nth-child(2) p:nth-child(3) {
animation-delay: -0.5s;
-webkit-animation-delay: -0.5s;
}
.loading ul li:nth-child(2) p:nth-child(4) {
animation-delay: -0.2s;
-webkit-animation-delay: -0.2s;
}
.loading ul li:nth-child(3) {
transform: rotateZ(90deg);
-webkit-transform: rotateZ(90deg);
}
.loading ul li:nth-child(3) p:nth-child(1) {
animation-delay: -1s;
-webkit-animation-delay: -1s;
}
.loading ul li:nth-child(3) p:nth-child(2) {
animation-delay: -0.7s;
-webkit-animation-delay: -0.7s;
}
.loading ul li:nth-child(3) p:nth-child(3) {
animation-delay: -0.4s;
-webkit-animation-delay: -0.4s;
}
.loading ul li:nth-child(3) p:nth-child(4) {
animation-delay: -0.1s;
-webkit-animation-delay: -0.1s;
}
.loading ul li p {
width: 10px;
height: 10px;
margin-bottom: 0;
border-top-left-radius: 50%;
border-top-right-radius: 50%;
border-bottom-left-radius: 50%;
border-bottom-right-radius: 50%;
-webkit-border-top-left-radius: 50%;
-webkit-border-top-right-radius: 50%;
-webkit-border-bottom-left-radius: 50%;
-webkit-border-bottom-right-radius: 50%;
position: absolute;
background-color: #ffffff;
animation: bouncedelay 1.2s infinite ease-in-out both;
-webkit-animation: bouncedelay 1.2s infinite ease-in-out both;
}
.loading ul li p:nth-child(1) {
top: 0;
left: 0;
}
.loading ul li p:nth-child(2) {
top: 0;
right: 0;
}
.loading ul li p:nth-child(3) {
bottom: 0;
right: 0;
}
.loading ul li p:nth-child(4) {
bottom: 0;
left: 0;
}
@keyframes bouncedelay {
0%,
80%,
100% {
transform: scale(0);
-webkit-transform: scale(0);
}
40% {
transform: scale(1);
-webkit-transform: scale(1);
}
}
@-webkit-keyframes bouncedelay {
0%,
80%,
100% {
transform: scale(0);
-webkit-transform: scale(0);
}
40% {
transform: scale(1);
-webkit-transform: scale(1);
}
}
html,
body {
width: 100%;
height: 100%;
}
body {
user-select: none;
-webkit-user-select: none;
tap-highlight-color: rgba(0, 0, 0, 0);
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
color: #707070;
background-color: #f9f9f9;
}
a:hover {
text-decoration: none;
}
.container-fluid {
width: 100%;
height: 100%;
background: url("../img/formBg.jpg") no-repeat;
background-size: 100% 100%;
-webkit-background-size: 100% 100%;
background-attachment: fixed;
overflow: auto;
padding: 0 25px;
}
.container-fluid form {
width: 400px;
margin: 0 auto;
}
.container-fluid form h2 {
margin: 100px 0;
color: #ffffff;
font-weight: bold;
width: 100%;
height: 34px;
background: url("../img/logo.png") no-repeat;
background-size: 150px 34px;
-webkit-background-size: 150px 34px;
background-position: center;
}
.container-fluid form .has-feedback {
margin-bottom: 0;
background-color: #ffffff;
border: 1px solid #cfd0d0;
}
.container-fluid form .has-feedback .form-control {
height: 60px;
color: #7d7d7d;
border: 0;
box-shadow: none;
-webkit-box-shadow: none;
border-top-left-radius: 0;
border-top-right-radius: 0;
border-bottom-left-radius: 0;
border-bottom-right-radius: 0;
-webkit-border-top-left-radius: 0;
-webkit-border-top-right-radius: 0;
-webkit-border-bottom-left-radius: 0;
-webkit-border-bottom-right-radius: 0;
-webkit-appearance: none;
}
.container-fluid form .has-feedback .form-control::-webkit-input-placeholder {
color: #7d7d7d;
}
.container-fluid form .has-feedback:first-of-type {
margin-bottom: -1px;
border-top-left-radius: 4px;
border-top-right-radius: 4px;
-webkit-border-top-left-radius: 4px;
-webkit-border-top-right-radius: 4px;
}
.container-fluid form .has-feedback:first-of-type .form-control {
border-top-left-radius: 3px;
border-top-right-radius: 3px;
-webkit-border-top-left-radius: 3px;
-webkit-border-top-right-radius: 3px;
}
.container-fluid form .has-feedback:last-of-type {
margin-top: -1px;
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
-webkit-border-bottom-left-radius: 4px;
-webkit-border-bottom-right-radius: 4px;
}
.container-fluid form .has-feedback:last-of-type .form-control {
border-bottom-left-radius: 3px;
border-bottom-right-radius: 3px;
-webkit-border-bottom-left-radius: 3px;
-webkit-border-bottom-right-radius: 3px;
}
.container-fluid form .has-feedback.username .form-control-feedback {
width: 30px;
height: 30px;
background: url("../img/gray_username_icon.png") no-repeat;
background-size: cover;
-webkit-background-size: cover;
top: 15px;
right: 15px;
}
.container-fluid form .has-feedback.password .form-control-feedback {
width: 30px;
height: 30px;
background: url("../img/gray_password_icon.png") no-repeat;
background-size: cover;
-webkit-background-size: cover;
top: 15px;
right: 15px;
}
.container-fluid form .has-feedback.code .form-control {
width: 60%;
}
.container-fluid form .has-feedback.code .form-control-feedback {
top: 6px;
right: 4px;
width: 35%;
height: 46px;
line-height: 46px;
color: #ffffff;
font-size: 16px;
background-color: #0bacd3;
box-shadow: 0 2px 0 0 #088aa9;
-webkit-box-shadow: 0 2px 0 0 #088aa9;
border-top-left-radius: 4px;
border-top-right-radius: 4px;
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
-webkit-border-top-left-radius: 4px;
-webkit-border-top-right-radius: 4px;
-webkit-border-bottom-left-radius: 4px;
-webkit-border-bottom-right-radius: 4px;
pointer-events: auto;
}
.container-fluid form .has-feedback.code .form-control-feedback:active {
background-color: #088aa9;
}
.container-fluid form .btn {
color: #ffffff;
font-weight: bold;
margin: 100px 0 0;
padding: 8px;
background-color: #008cd7;
border-top-left-radius: 4px;
border-top-right-radius: 4px;
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
-webkit-border-top-left-radius: 4px;
-webkit-border-top-right-radius: 4px;
-webkit-border-bottom-left-radius: 4px;
-webkit-border-bottom-right-radius: 4px;
box-shadow: 0 2px 0 0 #117bb9;
-webkit-box-shadow: 0 2px 0 0 #117bb9;
}
.container-fluid form .btn:active {
background-color: #117bb9;
}
.container-fluid form .btn:focus {
outline: 0;
}
.container-fluid form .btn.btn-register {
margin-top: 20%;
}
.container-fluid form a {
display: block;
color: #ffffff;
font-size: 16px;
}
.container-fluid form a span {
width: 30px;
height: 1px;
display: inline-block;
vertical-align: middle;
margin: 0 5px;
background-color: rgba(255, 255, 255, 0.4);
}
.container-fluid form a:active {
color: #636363;
}
.container-fluid form a:active span {
background-color: #636363;
}
.container-fluid form a.link-register {
margin-top: 30%;
padding-bottom: 25px;
}
...@@ -53,6 +53,9 @@ function page_template($template) ...@@ -53,6 +53,9 @@ function page_template($template)
case 'loan_calculator': case 'loan_calculator':
$page = $theme . '/loan_calculator.php'; $page = $theme . '/loan_calculator.php';
break; break;
case 'manager':
$page = $theme . '/manager.php';
break;
} }
return $page; return $page;
} else { } else {
...@@ -224,7 +227,7 @@ function add_collect($house_id) ...@@ -224,7 +227,7 @@ function add_collect($house_id)
add_filter('login_redirect', 'new_login_redirect', 10, 3); add_filter('login_redirect', 'new_login_redirect', 10, 3);
function new_login_redirect($redirect_to, $request, $user) function new_login_redirect($redirect_to, $request, $user)
{ {
if ($user - ID > 0) { if ($user->ID > 0) {
$role = $user->roles[0]; $role = $user->roles[0];
if ($role == 'administrator' || $role == 'editor') { if ($role == 'administrator' || $role == 'editor') {
return admin_url('admin.php?page=newHouseList'); return admin_url('admin.php?page=newHouseList');
...@@ -236,4 +239,31 @@ function new_login_redirect($redirect_to, $request, $user) ...@@ -236,4 +239,31 @@ function new_login_redirect($redirect_to, $request, $user)
} }
} }
add_action('wp_logout', 'auto_redirect_after_logout');
function auto_redirect_after_logout()
{
header('Location: ' . home_url('/?page=manager'));
exit;
}
add_filter('login_url', 'my_login_page', 10, 2);
function my_login_page($login_url, $redirect)
{
return home_url('/?page=manager&redirect_to=' . $redirect);
}
function user_redirect($user)
{
$url = null;
if ($user->ID > 0) {
$role = $user->roles[0];
if ($role == 'administrator' || $role == 'editor') {
$url = admin_url('admin.php?page=newHouseList');
} else {
$url = site_url();
}
header('Location:' . $url);
}
}
?> ?>
\ No newline at end of file
<?php
$context = array();
$context['theme'] = get_template_directory_uri();
if (is_user_logged_in()) {
$user = wp_get_current_user();
user_redirect($user);
} else {
if ($_POST) {
$phone = $_POST['phone'];
$password = $_POST['password'];
if (!$phone) {
$context['error'] = '请输入用户名';
} else if (!$password) {
$context['error'] = '请输入密码';
} else {
if (strlen($phone) != 11 && $phone != 'admin') {
$response = wp_remote_post('http://218.1.67.130:8988/api/NanTongWechat/LoginWechat' .
'?userName=' . $phone . '&password=' . $password
);
$body = json_decode($response['body']);
$data = $body->data;
if ($data) {
$password = $data->WorkNoAndId;
}
}
$creds['user_login'] = $phone;
$creds['user_password'] = $password;
$creds['remember'] = true;
$user = wp_signon($creds, false);
if (!is_wp_error($user)) {
user_redirect($user);
} else if ($user->get_error_code() == 'invalid_username') {
$context['error'] = '此帐号尚未注册';
} else if ($user->get_error_code() == 'incorrect_password') {
$context['error'] = '您输入的密码有误';
}
}
}
Timber::render('manager.html', $context);
}
?>
\ No newline at end of file
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<meta name="viewport" content="width=360, user-scalable=0"/>
<meta name="apple-mobile-web-app-capable" content="yes"/>
<meta name="apple-mobile-web-app-status-bar-style" content="black"/>
<title>登录</title>
<link rel="stylesheet" type="text/css" href="{{ theme }}/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="{{ theme }}/css/manager.css">
<script src="{{ theme }}/js/jquery.min.js"></script>
<script src="{{ theme }}/js/jquery.validate.js"></script>
<script src="{{ theme }}/js/bootstrap.min.js"></script>
<script>
$(document).ready(function () {
var notice = $('#notice');
var myModal = $('#myModal');
$('#loginForm').validate({
onkeyup: false,
onfocusout: false,
rules: {
phone: 'required',
password: 'required'
},
messages: {
phone: '请输入用户名',
password: '请输入密码'
},
errorLabelContainer: "#notice",
errorElement: 'span',
invalidHandler: function () {
myModal.modal('show');
},
submitHandler: function (form) {
form.submit();
}
});
notice.bind('DOMNodeInserted',function(){
$(this).children(':not(:first)').remove();
});
myModal.on('hide.bs.modal',function(){
notice.children().remove();
});
{% if(error) %}
notice.html('<span>{{ error }}</span>');
myModal.modal('show');
{% endif %}
});
</script>
</head>
<body>
<div class="container-fluid text-center">
<form id="loginForm" method="post">
<h2></h2>
<p class="has-feedback username">
<label for="phone" class="sr-only">用户名</label>
<input type="tel" name="phone" id="phone" class="form-control input-lg" placeholder="账号">
<span class="form-control-feedback"></span>
</p>
<p class="has-feedback password">
<label for="password" class="sr-only">密码</label>
<input type="password" name="password" id="password" class="form-control input-lg" placeholder="密码">
<span class="form-control-feedback"></span>
</p>
<input type="submit" id="login_submit" value="登录" class="btn btn-lg btn-block">
</form>
</div>
<div class="modal fade" id="myModal">
<div class="modal-dialog">
<div class="modal-content text-center">
<h4>提示</h4>
<p id="notice"></p>
<button type="button" class="btn btn-lg btn-block" data-dismiss="modal">确认</button>
</div>
</div>
</div>
</body>
</html>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment