| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- function doajax(method, dataurl, data, sucessCallBack, errorCallBack) {
- var user_key = undefined;
- var user = $.zui.store.get("user")
- if (typeof(user) == "undefined" || user == null) {
- } else {
- user_key = "XinTong " + (user.token);
- }
- if (typeof(user_key) == "undefined" || user_key == null) {
- $.ajax({
- type: method,
- url: dataurl,
- contentType: "application/json",
- dataType: "json",
- async: true,
- data: JSON.stringify(data),
- success: sucessCallBack,
- error: function(error) {
- if (HandleError(error)) return;
- errorCallBack(error);
- }
- })
- } else {
- $.ajax({
- type: method,
- url: dataurl,
- contentType: "application/json",
- dataType: "json",
- beforeSend: function(xhr) {
- xhr.setRequestHeader("token", user_key);
- },
- headers: {
- 'token': user_key
- },
- async: true,
- data: JSON.stringify(data),
- success: sucessCallBack,
- error: function(error) {
- if (HandleError(error)) return;
- errorCallBack(error);
- }
- })
- }
- }
- function ajaxGet(dataurl, data, sucessCallBack, errorCallBack) {
- doajax("GET", dataurl, data, sucessCallBack, errorCallBack)
- }
- function ajaxPost(dataurl, data, sucessCallBack, errorCallBack) {
- doajax("POST", dataurl, data, sucessCallBack, errorCallBack)
- }
- function ajaxPut(dataurl, data, sucessCallBack, errorCallBack) {
- doajax("PUT", dataurl, data, sucessCallBack, errorCallBack)
- }
- function ajaxDelete(dataurl, data, sucessCallBack, errorCallBack) {
- doajax("DELETE", dataurl, data, sucessCallBack, errorCallBack)
- }
- function HandleError(error) {
- if (typeof(error) != "undefined" && error != null) {
- if (typeof(error.status) != "undefined" && error.status != null) {
- if (error.status == 403) {
- //未登录退出
- swal({
- title: "提示",
- text: "登陆已经过期,将重新登陆!",
- timer: 3000,
- showConfirmButton: false
- }, function() {
- self.location = base_ui_url + UI_USER_LOGIN
- });
- return true;
- }
- }
- }
- return false;
- }
- // var ViewMap = new HashMap()
- // ViewMap.set("/view/mytask/unchecked.html", __inline('/view/mytask/unchecked.html'));
- // ViewMap.set("/view/mytask/unexamined.html", __inline('/view/mytask/unexamined.html'));
- // ViewMap.set("/view/mytask/undispatched.html", __inline('/view/mytask/undispatched.html'));
- // ViewMap.set("/view/mytask/dispatched.html", __inline('/view/mytask/dispatched.html'));
- // ViewMap.set("/view/constant/constant.html", __inline('/view/constant/constant.html'));
|