// dist product //VUE_BASE_PATH var basePath = "/ses-enrol-v1"; // var basePath = "../"; // var basePath = "../../";//本地 var ajaxRequest = function(type,url,param,callback){ // var loading = showLoading(); $.ajax({ type : 'POST', url : basePath + url, data : param, dataType : 'json', success : function(response) { // setTimeout(function(){hideLoading(loading);},500) if (response.success) { if (callback) { var obj = response; if (type === 'Entity') { obj = response.entity; } else if (type === 'Array') { obj = response.array; } else if (type === 'Page') { obj = response.page; } else if (type === 'Map') { obj = response.map; } callback.call(undefined, obj); } } else { if (response.login === false) { // 登录超时 this.alert('登录超时,请重新登录','提示') window.location.href = '../enrol/login/index.html'; return; } //TODO // alert_danger(response.errorMsg); callback.call(undefined, response); } } }) }; var initAlert = function(){ $('#danger').html(""); $('#danger').hide(); $('#success').html(""); $('#success').hide(""); } var alert_danger = function(msg){ initAlert() $('#danger').html(msg); $('#danger').show(); } var alert_success = function(msg){ initAlert() $('#success').html(msg); $('#success').show(); } var loadcss = function(href){ $("") .attr({ rel: "stylesheet", type: "text/css", href: href }).appendTo("head"); } var showLoading = function(text){ return window['Vue'].$loading({ lock: true, text: '加载中...', spinner: 'el-icon-loading', background: 'rgba(0, 0, 0, 0.7)' }); ; } var hideLoading = function(loading){ loading.close(); }