gocron/public/resource/javascript/main.js

38 lines
1.0 KiB
JavaScript
Raw Normal View History

2017-04-07 09:26:46 +00:00
/**
* Created by ouqiang on 2017/4/1.
*/
function Util() {
var util = {};
util.post = function(url, params, callback) {
// 用户认证失败
var AUTH_ERROR = -1;
var FAILURE = 1;
var SUCCESS = 0;
var FAILURE_MESSAGE = '操作失败';
$.post(
url,
params,
function(response) {
if (!response) {
}
if (response.code === undefined) {
swal(FAILURE_MESSAGE, '服务端返回值无法解析', 'error');
}
if (response.code == AUTH_ERROR) {
swal(FAILURE_MESSAGE, '请登录后操作', 'error');
return;
}
if (response.code == FAILURE) {
swal(FAILURE_MESSAGE, response.message ,'error');
return;
}
callback(response.code, response.message, response.data);
},
'json'
)
};
return util;
}