define(["mui", "app"], function(mui, app) { var clientid; try { clientid = plus.device.uuid; } catch(e) {} function Ajax(ajaxObj, data) { this.ajaxObj = ajaxObj; this.data = data; } Ajax.prototype.then = function(resolve, reject) { mui.ajax(this.ajaxObj.getUrl, { headers: { "X-Requested-Token": app.getTokenStorage(), // token头部 "locale": app.getLanguageLocalStorage() // 语种头部 }, data: this.data, dataType: 'json', type: this.ajaxObj.getType, timeout: 10000, success: function(rest) { resolve(rest); }, error: function(xhr, type, errorThrown) { reject ? reject():function(){ console.log(type + ":" + errorThrown); } } }); } function send(ajaxObj, data) { return new Ajax(ajaxObj, data); } return { send: send } })