mirror of
https://gitee.com/apiadmin/ApiAdmin.git
synced 2025-04-06 03:58:00 +08:00
新增加Ajax数据提交函数
This commit is contained in:
parent
8fadb2bc27
commit
acf70354ec
@ -65,4 +65,8 @@ class User extends Base {
|
|||||||
return $this->fetch();
|
return $this->fetch();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function add(){
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
@ -21,7 +21,7 @@
|
|||||||
<div class="login-box-body">
|
<div class="login-box-body">
|
||||||
<p class="login-box-msg">请填写您的账号名和密码</p>
|
<p class="login-box-msg">请填写您的账号名和密码</p>
|
||||||
|
|
||||||
<form action="{:url('User/login')}" method="post">
|
<form action="{:url('User/login')}" id="form-login">
|
||||||
<div class="form-group has-feedback">
|
<div class="form-group has-feedback">
|
||||||
<input type="text" class="form-control" name="username" placeholder="Username">
|
<input type="text" class="form-control" name="username" placeholder="Username">
|
||||||
<span class="glyphicon glyphicon-user form-control-feedback"></span>
|
<span class="glyphicon glyphicon-user form-control-feedback"></span>
|
||||||
@ -32,7 +32,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-xs-12">
|
<div class="col-xs-12">
|
||||||
<button type="submit" class="btn btn-primary btn-block btn-flat">登 录</button>
|
<span type="submit" target-form="form-login" class="btn btn-primary ajax-post btn-block btn-flat">登 录</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
@ -43,6 +43,10 @@
|
|||||||
<script src="__STATIC__/jQuery/2.2.4/jquery.min.js"></script>
|
<script src="__STATIC__/jQuery/2.2.4/jquery.min.js"></script>
|
||||||
<!-- Bootstrap 3.3.6 -->
|
<!-- Bootstrap 3.3.6 -->
|
||||||
<script src="__STATIC__/bootstrap/js/bootstrap.min.js"></script>
|
<script src="__STATIC__/bootstrap/js/bootstrap.min.js"></script>
|
||||||
|
<!-- BootBox -->
|
||||||
|
<script src="__ADMIN__/plugins/bootBox/bootbox.min.js"></script>
|
||||||
|
|
||||||
|
<script src="__ADMIN__/dist/js/template.js"></script>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
68
public/static/admin/dist/js/template.js
vendored
68
public/static/admin/dist/js/template.js
vendored
@ -4,13 +4,16 @@
|
|||||||
* You should not use this file in production.
|
* You should not use this file in production.
|
||||||
* This file is for demo purposes only.
|
* This file is for demo purposes only.
|
||||||
*/
|
*/
|
||||||
$.AdminTemplate = {};
|
|
||||||
/**
|
(function ($) {
|
||||||
|
"use strict";
|
||||||
|
$(function() {
|
||||||
|
/**
|
||||||
* 格式化时间戳(为了和PHP的date函数统一,这里的时间戳都是10位,不包含毫秒)
|
* 格式化时间戳(为了和PHP的date函数统一,这里的时间戳都是10位,不包含毫秒)
|
||||||
* @param timestamp
|
* @param timestamp
|
||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
var formatDate = function ( timestamp ) {
|
$.formatDate = function ( timestamp ) {
|
||||||
timestamp *= 1000;
|
timestamp *= 1000;
|
||||||
var date = new Date(timestamp);
|
var date = new Date(timestamp);
|
||||||
var Y = date.getFullYear() + '-';
|
var Y = date.getFullYear() + '-';
|
||||||
@ -20,13 +23,19 @@ var formatDate = function ( timestamp ) {
|
|||||||
var m = date.getMinutes() + ':';
|
var m = date.getMinutes() + ':';
|
||||||
var s = date.getSeconds();
|
var s = date.getSeconds();
|
||||||
return Y+M+D+h+m+s;
|
return Y+M+D+h+m+s;
|
||||||
};
|
};
|
||||||
|
|
||||||
(function ($, AdminTemplate) {
|
$.alertMsg = function( msg ){
|
||||||
|
var dialog = bootbox.dialog({
|
||||||
|
message: '<p class="text-center">'+msg+'</p>',
|
||||||
|
closeButton: false
|
||||||
|
});
|
||||||
|
setTimeout(function(){
|
||||||
|
dialog.modal('hide');
|
||||||
|
}, 2000);
|
||||||
|
};
|
||||||
|
|
||||||
"use strict";
|
$.buildDom = function ( jsonStr ) {
|
||||||
|
|
||||||
AdminTemplate.buildDom = function ( jsonStr ) {
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -69,18 +78,37 @@ var formatDate = function ( timestamp ) {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
AdminTemplate.a = function () {
|
//ajax post submit请求
|
||||||
|
$('body').on('click', '.ajax-post', function() {
|
||||||
|
var message,query,form,target;
|
||||||
|
var target_form = $(this).attr('target-form');
|
||||||
|
|
||||||
};
|
if ( $(this).attr('type') == 'submit' ) {
|
||||||
|
form = $('#' + target_form);
|
||||||
AdminTemplate.alertMsg = function( msg ){
|
query = form.serialize();
|
||||||
var dialog = bootbox.dialog({
|
target = form.attr('action');
|
||||||
message: '<p class="text-center">'+msg+'</p>',
|
$.post(target, query).success(function(data) {
|
||||||
closeButton: false
|
if (data.status == 1) {
|
||||||
});
|
if (data.url) {
|
||||||
setTimeout(function(){
|
message = data.msg + ' 页面即将自动跳转~';
|
||||||
dialog.modal('hide');
|
} else {
|
||||||
}, 3000);
|
message = data.msg;
|
||||||
}
|
}
|
||||||
|
$.alertMsg(message);
|
||||||
|
setTimeout(function() {
|
||||||
|
if (data.url) {
|
||||||
|
location.href = data.url;
|
||||||
|
} else {
|
||||||
|
location.reload();
|
||||||
|
}
|
||||||
|
}, 2000);
|
||||||
|
} else {
|
||||||
|
$.alertMsg(data.msg);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
})(jQuery, $.AdminTemplate);
|
})(jQuery);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user