/** * Created by Administrator on 2019/3/1 0001. */commonModule.factory('jqFetch',['$translate','$q','apiInterceptor',function($translate,$q,apiInterceptor){'use strict';functionget(url,params,resType){returnquery(url,"GET",params,resType);}functionpost(url,params,resType){returnquery(url,"POST",params,resType);}functionquery(url,method,params,resType){$('#busy-indicator-container').show();vardefer=$q.defer();window.$.ajax({type:method,url:url,data:method==="POST"?JSON.stringify(params):params,dataType:resType?resType:"json",beforeSend:function(request){request.setRequestHeader("Authorization",apiInterceptor.tokenType+' '+apiInterceptor.apiToken());request.setRequestHeader("Content-Type",'application/json;charset=UTF-8');},success:function(result){$('#busy-indicator-container').hide();defer.resolve(result);},error:function(result){$('#busy-indicator-container').hide();defer.reject(result);}});returndefer.promise;}return{get:get,post:post}}]);