Sfoglia il codice sorgente

Merge branch 'master' of http://192.168.1.220:10080/raolu/PC-prescription

# Conflicts:
#	js/api-service.js
raolu 7 anni fa
parent
commit
6a83ab9e9a
1 ha cambiato i file con 44 aggiunte e 12 eliminazioni
  1. 44 12
      js/api-service.js

+ 44 - 12
js/api-service.js

@ -1,11 +1,33 @@
(function($){
	$.support.cors = true
	var publish_version = false;
	var agentName = "wlyyAgent";
	var server, userAgent, loginUrl;
	
 
	$.support.cors = true;
	if(publish_version) { // 生产环境配置
		
	} else { // 测试环境配置
		server = "http://172.19.103.88:9092/wlyy/"
		loginUrl = "http://172.19.103.88:9092/wlyy/auth/login.html"
	}
	
    // var server = "http://172.19.103.88:9092/wlyy/";
    var server = "http://192.168.131.127:8060/";//逸祥
    var userAgent = {"id":4800,"uid":"zbqD201703150222","imei":"864394010176834","token":"71738e0adf3fa6dfe72eb71dc9c07ce2","platform":2,"hospital":"3502050100"};
//    var userAgent = {"id":4821,"uid":"zbqD201703150228","imei":"864394010176834","token":"ee3fcb6091b46aa0a119c1504b8306d8","platform":2,"hospital":"3502050100"};
    userAgent = JSON.stringify(userAgent);
	
	userAgent = localStorage.getItem(agentName)
	
	if(userAgent) {
		try{
			userAgent = JSON.parse(userAgent)
		}catch(e){
			location.replace(loginUrl+'?redirect_url='+encodeURIComponent(location.href))
		}
	} else {
		location.replace(loginUrl+'?redirect_url='+encodeURIComponent(location.href))
	}
	
//  var server = "http://172.19.103.88:9092/wlyy/",
//      userAgent = {"id":4800,"uid":"zbqD201703150222","imei":"864394010176834","token":"fcf8310ee6d911c3f25cdecd28b9bcdd","platform":2,"hospital":"3502050100","appVersion":"1.3.6"};
//  userAgent = JSON.stringify(userAgent);
	
	function httpGet(url,options) {
		//发送ajax请求
@ -21,12 +43,7 @@
					reject(res)
				},
				success: function(res) {
					if(res.code && res.code == -200) {
            			toastr && toastr.warning("登录失效,请重新登录!")
            			setTimeout(function() {
            				window.location.replace('login_v2.html')
            			},2000)
            		}
					failCodeHandle(res)
					resolve(res)
				}
			},options));
@ -47,12 +64,27 @@
					reject(res)
				},
				success: function(res) {
					failCodeHandle(res)
					resolve(res)
				}
			},options));
		})
	}
	
	function failCodeHandle(res) {
		var tip = "";
		if(res.status == 999) {
			tip = "此账号已在别处登录,请重新登录";
		} else if(res.status == 998) {
			tip = "登录超时,请重新登录";
		} else if(res.status == 997) {
			tip = "此账号未登录,请先登录"
		}
		if(tip) {
			toastr && toastr.warning(tip)
			location.replace(loginUrl+'?redirect_url='+encodeURIComponent(location.href))
		}
	}
	
	APIService = {
        server: server,