|  | @ -1,343 +1,387 @@
 | 
												
													
														
															|  | (function($) {
 |  | 
 | 
												
													
														
															|  |     var publish_version = false;
 |  | 
 | 
												
													
														
															|  |     var isInner = true; //发布线上后有内外网的配置
 |  | 
 | 
												
													
														
															|  |     var docInfo = "app_storage";
 |  | 
 | 
												
													
														
															|  |     var agentName = "wlyyAgentForDoc";
 |  | 
 | 
												
													
														
															|  |     var docAgentName = "wlyyAgent";
 |  | 
 | 
												
													
														
															|  |     var server, userAgent, loginUrl, imserver, socketUrl, imgServer,teamworkService;
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |     var IMEI = localStorage.getItem('WLYY_IMEI') || uuid(16, 16)
 |  | 
 | 
												
													
														
															|  |     localStorage.setItem('WLYY_IMEI', IMEI)
 |  | 
 | 
												
													
														
															|  |     $.support.cors = true;
 |  | 
 | 
												
													
														
															|  |     if(publish_version) { // 生产环境配置
 |  | 
 | 
												
													
														
															|  |         server = "//www.xmtyw.cn/wlyy/"
 |  | 
 | 
												
													
														
															|  |         imserver = "//www.xmtyw.cn/api/v2";
 |  | 
 | 
												
													
														
															|  |         socketUrl = "//www.xmtyw.cn";
 |  | 
 | 
												
													
														
															|  |         articleServer = "//www.xmtyw.cn/wlyy/"
 |  | 
 | 
												
													
														
															|  |         loginUrl = "../../login/login.html";
 |  | 
 | 
												
													
														
															|  |         imgServer = "//www.xmtyw.cn/";
 |  | 
 | 
												
													
														
															|  |         teamworkService="//hlwyy.xmzsh.com/hlwyy/ims-web";
 |  | 
 | 
												
													
														
															|  |         videoChatIntranetFlag = false;
 |  | 
 | 
												
													
														
															|  |         if(isInner){
 |  | 
 | 
												
													
														
															|  |             server = "http://10.95.22.10:8011/wlyy/"
 |  | 
 | 
												
													
														
															|  |             imserver = "http://10.95.22.138:3000/api/v2";
 |  | 
 | 
												
													
														
															|  |             socketUrl = "http://10.95.22.138:3000";
 |  | 
 | 
												
													
														
															|  |             articleServer = "http://10.95.22.10:8011/wlyy/"
 |  | 
 | 
												
													
														
															|  |             loginUrl = "../../login/login.html";
 |  | 
 | 
												
													
														
															|  |             imgServer = "http://10.95.22.10:8011/";
 |  | 
 | 
												
													
														
															|  |         }
 |  | 
 | 
												
													
														
															|  |     } else { // 测试环境配置
 |  | 
 | 
												
													
														
															|  |         server = "http://172.26.0.118:9092/wlyy/"  //测试环境
 |  | 
 | 
												
													
														
															|  |         // server = "http://192.168.131.190:8080/"  //桃红
 |  | 
 | 
												
													
														
															|  | //      server = "http://192.168.131.144:8080/" //冬梅
 |  | 
 | 
												
													
														
															|  |         imserver = "http://172.26.0.118:3000/api/v2";
 |  | 
 | 
												
													
														
															|  |         socketUrl = "http://172.26.0.118:3000";
 |  | 
 | 
												
													
														
															|  |     //  server = "http://192.168.131.154:8080/"
 |  | 
 | 
												
													
														
															|  |         // articleServer="http://172.26.0.118:9092/wlyy/"
 |  | 
 | 
												
													
														
															|  | //   server = "http://192.168.131.130:8080/";
 |  | 
 | 
												
													
														
															|  | 		// server = "http://192.168.131.118:8080/"; // 明芬
 |  | 
 | 
												
													
														
															|  | //      server = "http://192.168.131.127:8060/"; //逸祥
 |  | 
 | 
												
													
														
															|  | //      server = "http://192.168.131.24:8080/"; //仕杰
 |  | 
 | 
												
													
														
															|  | //      server = "http://192.168.131.112:8080/"; // 志南
 |  | 
 | 
												
													
														
															|  | //      server = "http://192.168.131.24:8082/"; // 文彬
 |  | 
 | 
												
													
														
															|  | //      imserver = "http://192.168.131.24:3000/api/v2"
 |  | 
 | 
												
													
														
															|  | //      socketUrl = "http://192.168.131.24:3000";
 |  | 
 | 
												
													
														
															|  | //		server = "http://192.168.131.144:8080/";//冬梅
 |  | 
 | 
												
													
														
															|  |         loginUrl = "../../login/login.html";
 |  | 
 | 
												
													
														
															|  | //      loginUrl = "/PC-prescription/login.html"; //自己本地测试时的路径
 |  | 
 | 
												
													
														
															|  |         imgServer = "http://172.26.0.110:8888/";
 |  | 
 | 
												
													
														
															|  |         teamworkService="//ehr.yihu.com/hlwyy/ims-web";
 |  | 
 | 
												
													
														
															|  |         videoChatIntranetFlag = false;
 |  | 
 | 
												
													
														
															|  |     }
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |     var baseInfo = window.localStorage.getItem(docInfo);
 |  | 
 | 
												
													
														
															|  |     
 |  | 
 | 
												
													
														
															|  |     userAgent = window.localStorage.getItem(agentName)
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |     if(userAgent || baseInfo) {
 |  | 
 | 
												
													
														
															|  |         try {
 |  | 
 | 
												
													
														
															|  |             if(baseInfo){
 |  | 
 | 
												
													
														
															|  |                 baseInfo = JSON.parse(baseInfo);
 |  | 
 | 
												
													
														
															|  |                 window.localStorage.setItem(docAgentName, JSON.stringify(baseInfo.api_login_doctor));
 |  | 
 | 
												
													
														
															|  |                 userAgent = {
 |  | 
 | 
												
													
														
															|  |                     'id': baseInfo.api_login_doctor.id,
 |  | 
 | 
												
													
														
															|  |                     'uid': baseInfo.api_login_doctor.uid,
 |  | 
 | 
												
													
														
															|  |                     'imei': baseInfo.IMEI,
 |  | 
 | 
												
													
														
															|  |                     'token': baseInfo.api_login_doctor.token,
 |  | 
 | 
												
													
														
															|  |                     'platform': '4'
 |  | 
 | 
												
													
														
															|  |                 };
 |  | 
 | 
												
													
														
															|  |                 window.localStorage.setItem(agentName, JSON.stringify(userAgent));
 |  | 
 | 
												
													
														
															|  |                 localStorage.setItem('WLYY_IMEI', baseInfo.IMEI)
 |  | 
 | 
												
													
														
															|  |             }else{
 |  | 
 | 
												
													
														
															|  |                 userAgent = JSON.parse(userAgent)
 |  | 
 | 
												
													
														
															|  |             }
 |  | 
 | 
												
													
														
															|  |         } catch(e) {
 |  | 
 | 
												
													
														
															|  |             toastr && toastr.warning("登录失效,请关闭当前弹窗前往PC IM重新登录")
 |  | 
 | 
												
													
														
															|  | //          toLoginPage()
 |  | 
 | 
												
													
														
															|  |         }
 |  | 
 | 
												
													
														
															|  |     } else {
 |  | 
 | 
												
													
														
															|  |         toLoginPage()
 |  | 
 | 
												
													
														
															|  |     }
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |     var isRelogined = sessionStorage.getItem('wlyy_relogin')
 |  | 
 | 
												
													
														
															|  |     if(isRelogined && location.href.indexOf("login.html") < 0){
 |  | 
 | 
												
													
														
															|  |         sessionStorage.removeItem('wlyy_relogin')
 |  | 
 | 
												
													
														
															|  |     }
 |  | 
 | 
												
													
														
															|  | 	
 |  | 
 | 
												
													
														
															|  |     function httpGet(url, options) {
 |  | 
 | 
												
													
														
															|  |         //发送ajax请求
 |  | 
 | 
												
													
														
															|  |         return new Promise(function(resolve, reject) {
 |  | 
 | 
												
													
														
															|  |             $.ajax(server + url,
 |  | 
 | 
												
													
														
															|  |                 $.extend({}, {
 |  | 
 | 
												
													
														
															|  |                     type: 'GET',
 |  | 
 | 
												
													
														
															|  |                     dataType: 'JSON',
 |  | 
 | 
												
													
														
															|  |                     beforeSend: function(request) {
 |  | 
 | 
												
													
														
															|  |                         var agent = userAgent || {
 |  | 
 | 
												
													
														
															|  |                             imei: localStorage.getItem('WLYY_IMEI'),
 |  | 
 | 
												
													
														
															|  |                             platform: 4
 |  | 
 | 
												
													
														
															|  |                         }
 |  | 
 | 
												
													
														
															|  |                         request.setRequestHeader("userAgent", JSON.stringify(agent));
 |  | 
 | 
												
													
														
															|  |                     },
 |  | 
 | 
												
													
														
															|  |                     error: function(res) {
 |  | 
 | 
												
													
														
															|  |                         reject(res)
 |  | 
 | 
												
													
														
															|  |                     },
 |  | 
 | 
												
													
														
															|  |                     success: function(res) {
 |  | 
 | 
												
													
														
															|  |                         failCodeHandle(res)
 |  | 
 | 
												
													
														
															|  |                         resolve(res)
 |  | 
 | 
												
													
														
															|  |                     }
 |  | 
 | 
												
													
														
															|  |                 }, options));
 |  | 
 | 
												
													
														
															|  |         })
 |  | 
 | 
												
													
														
															|  |     }
 |  | 
 | 
												
													
														
															|  | 	function articleGet(url, options) {
 |  | 
 | 
												
													
														
															|  |         //发送ajax请求
 |  | 
 | 
												
													
														
															|  |         return new Promise(function(resolve, reject) {
 |  | 
 | 
												
													
														
															|  |             $.ajax(articleServer + url,
 |  | 
 | 
												
													
														
															|  |                 $.extend({}, {
 |  | 
 | 
												
													
														
															|  |                     type: 'GET',
 |  | 
 | 
												
													
														
															|  |                     dataType: 'JSON',
 |  | 
 | 
												
													
														
															|  |                     beforeSend: function(request) {
 |  | 
 | 
												
													
														
															|  |                         var agent = userAgent || {
 |  | 
 | 
												
													
														
															|  |                             imei: localStorage.getItem('WLYY_IMEI'),
 |  | 
 | 
												
													
														
															|  |                             platform: 4
 |  | 
 | 
												
													
														
															|  |                         }
 |  | 
 | 
												
													
														
															|  |                         request.setRequestHeader("userAgent", JSON.stringify(agent));
 |  | 
 | 
												
													
														
															|  |                     },
 |  | 
 | 
												
													
														
															|  |                     error: function(res) {
 |  | 
 | 
												
													
														
															|  |                         reject(res)
 |  | 
 | 
												
													
														
															|  |                     },
 |  | 
 | 
												
													
														
															|  |                     success: function(res) {
 |  | 
 | 
												
													
														
															|  |                         failCodeHandle(res)
 |  | 
 | 
												
													
														
															|  |                         resolve(res)
 |  | 
 | 
												
													
														
															|  |                     }
 |  | 
 | 
												
													
														
															|  |                 }, options));
 |  | 
 | 
												
													
														
															|  |         })
 |  | 
 | 
												
													
														
															|  |     }
 |  | 
 | 
												
													
														
															|  |     function httpPost(url, options) {
 |  | 
 | 
												
													
														
															|  |         //发送ajax请求
 |  | 
 | 
												
													
														
															|  |         return new Promise(function(resolve, reject) {
 |  | 
 | 
												
													
														
															|  |             $.ajax(server + url,
 |  | 
 | 
												
													
														
															|  |                 $.extend({}, {
 |  | 
 | 
												
													
														
															|  |                     type: 'POST',
 |  | 
 | 
												
													
														
															|  |                     dataType: 'JSON',
 |  | 
 | 
												
													
														
															|  |                     beforeSend: function(request) {
 |  | 
 | 
												
													
														
															|  |                         var agent = userAgent || {
 |  | 
 | 
												
													
														
															|  |                             imei: localStorage.getItem('WLYY_IMEI')
 |  | 
 | 
												
													
														
															|  |                         }
 |  | 
 | 
												
													
														
															|  |                         request.setRequestHeader("userAgent", JSON.stringify(agent));
 |  | 
 | 
												
													
														
															|  |                     },
 |  | 
 | 
												
													
														
															|  |                     error: function(res) {
 |  | 
 | 
												
													
														
															|  |                         reject(res)
 |  | 
 | 
												
													
														
															|  |                     },
 |  | 
 | 
												
													
														
															|  |                     success: function(res) {
 |  | 
 | 
												
													
														
															|  |                         failCodeHandle(res)
 |  | 
 | 
												
													
														
															|  |                         resolve(res)
 |  | 
 | 
												
													
														
															|  |                     }
 |  | 
 | 
												
													
														
															|  |                 }, options));
 |  | 
 | 
												
													
														
															|  |         })
 |  | 
 | 
												
													
														
															|  |     }
 |  | 
 | 
												
													
														
															|  |     function articlePost(url, options) {
 |  | 
 | 
												
													
														
															|  |         //发送ajax请求
 |  | 
 | 
												
													
														
															|  |         return new Promise(function(resolve, reject) {
 |  | 
 | 
												
													
														
															|  |             $.ajax(articleServer + url,
 |  | 
 | 
												
													
														
															|  |                 $.extend({}, {
 |  | 
 | 
												
													
														
															|  |                     type: 'POST',
 |  | 
 | 
												
													
														
															|  |                     dataType: 'JSON',
 |  | 
 | 
												
													
														
															|  |                     beforeSend: function(request) {
 |  | 
 | 
												
													
														
															|  |                         var agent = userAgent || {
 |  | 
 | 
												
													
														
															|  |                             imei: localStorage.getItem('WLYY_IMEI')
 |  | 
 | 
												
													
														
															|  |                         }
 |  | 
 | 
												
													
														
															|  |                         request.setRequestHeader("userAgent", JSON.stringify(agent));
 |  | 
 | 
												
													
														
															|  |                     },
 |  | 
 | 
												
													
														
															|  |                     error: function(res) {
 |  | 
 | 
												
													
														
															|  |                         reject(res)
 |  | 
 | 
												
													
														
															|  |                     },
 |  | 
 | 
												
													
														
															|  |                     success: function(res) {
 |  | 
 | 
												
													
														
															|  |                         failCodeHandle(res)
 |  | 
 | 
												
													
														
															|  |                         resolve(res)
 |  | 
 | 
												
													
														
															|  |                     }
 |  | 
 | 
												
													
														
															|  |                 }, options));
 |  | 
 | 
												
													
														
															|  |         })
 |  | 
 | 
												
													
														
															|  |     }
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |     function imHttpGet(url, options) {
 |  | 
 | 
												
													
														
															|  |         //发送ajax请求
 |  | 
 | 
												
													
														
															|  |         return new Promise(function(resolve, reject) {
 |  | 
 | 
												
													
														
															|  |             $.ajax(imserver + url,
 |  | 
 | 
												
													
														
															|  |                 $.extend({}, {
 |  | 
 | 
												
													
														
															|  |                     type: 'GET',
 |  | 
 | 
												
													
														
															|  |                     dataType: 'JSON',
 |  | 
 | 
												
													
														
															|  |                     beforeSend: function(request) {
 |  | 
 | 
												
													
														
															|  |                         request.setRequestHeader("userAgent", JSON.stringify(userAgent));
 |  | 
 | 
												
													
														
															|  |                     },
 |  | 
 | 
												
													
														
															|  |                     error: function(res) {
 |  | 
 | 
												
													
														
															|  |                         reject(res)
 |  | 
 | 
												
													
														
															|  |                     },
 |  | 
 | 
												
													
														
															|  |                     success: function(res) {
 |  | 
 | 
												
													
														
															|  |                         failCodeHandle(res)
 |  | 
 | 
												
													
														
															|  |                         resolve(res)
 |  | 
 | 
												
													
														
															|  |                     }
 |  | 
 | 
												
													
														
															|  |                 }, options));
 |  | 
 | 
												
													
														
															|  |         })
 |  | 
 | 
												
													
														
															|  |     }
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |     function imHttpPost(url, options) {
 |  | 
 | 
												
													
														
															|  |         //发送ajax请求
 |  | 
 | 
												
													
														
															|  |         return new Promise(function(resolve, reject) {
 |  | 
 | 
												
													
														
															|  |             $.ajax(imserver + url,
 |  | 
 | 
												
													
														
															|  |                 $.extend({}, {
 |  | 
 | 
												
													
														
															|  |                     type: 'POST',
 |  | 
 | 
												
													
														
															|  |                     dataType: 'JSON',
 |  | 
 | 
												
													
														
															|  |                     beforeSend: function(request) {
 |  | 
 | 
												
													
														
															|  |                         request.setRequestHeader("userAgent", JSON.stringify(userAgent));
 |  | 
 | 
												
													
														
															|  |                     },
 |  | 
 | 
												
													
														
															|  |                     error: function(res) {
 |  | 
 | 
												
													
														
															|  |                         reject(res)
 |  | 
 | 
												
													
														
															|  |                     },
 |  | 
 | 
												
													
														
															|  |                     success: function(res) {
 |  | 
 | 
												
													
														
															|  |                         failCodeHandle(res)
 |  | 
 | 
												
													
														
															|  |                         resolve(res)
 |  | 
 | 
												
													
														
															|  |                     }
 |  | 
 | 
												
													
														
															|  |                 }, options));
 |  | 
 | 
												
													
														
															|  |         })
 |  | 
 | 
												
													
														
															|  |     }
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 	function videoChatPost(url, options) {
 |  | 
 | 
												
													
														
															|  | 		if(options && options.data){
 |  | 
 | 
												
													
														
															|  | 			options.data.intranetFlag = videoChatIntranetFlag
 |  | 
 | 
												
													
														
															|  | 		}
 |  | 
 | 
												
													
														
															|  | 		return httpPost(url, options);
 |  | 
 | 
												
													
														
															|  |     }
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |     function toLoginPage() {
 |  | 
 | 
												
													
														
															|  |         if(location.href.indexOf('login.html') > -1) {
 |  | 
 | 
												
													
														
															|  |             return;
 |  | 
 | 
												
													
														
															|  |         }
 |  | 
 | 
												
													
														
															|  |         setTimeout(function() {
 |  | 
 | 
												
													
														
															|  |             sessionStorage.setItem("wlyy_relogin", 1)
 |  | 
 | 
												
													
														
															|  | //          var path = top.location.pathname,
 |  | 
 | 
												
													
														
															|  | //              rootPath = path.split("/")[1];
 |  | 
 | 
												
													
														
															|  |             top.location.replace(loginUrl + '?redirect_url=' + encodeURIComponent(top.location.href))
 |  | 
 | 
												
													
														
															|  |         }, 2000)
 |  | 
 | 
												
													
														
															|  |     }
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |     var count = 0;
 |  | 
 | 
												
													
														
															|  |     function failCodeHandle(res) {
 |  | 
 | 
												
													
														
															|  |         var tip = "";
 |  | 
 | 
												
													
														
															|  |         if(res.status == 999) {
 |  | 
 | 
												
													
														
															|  |             tip = "此账号已在别处登录,请关闭当前弹窗前往PC IM重新登录";
 |  | 
 | 
												
													
														
															|  |         } else if(res.status == 998) {
 |  | 
 | 
												
													
														
															|  |             tip = "登录超时,请关闭当前弹窗前往PC IM重新登录";
 |  | 
 | 
												
													
														
															|  |         } else if(res.status == 997) {
 |  | 
 | 
												
													
														
															|  |             tip = "此账号未登录,请先登录"
 |  | 
 | 
												
													
														
															|  |         }
 |  | 
 | 
												
													
														
															|  |         if(tip) {
 |  | 
 | 
												
													
														
															|  |             count ++;
 |  | 
 | 
												
													
														
															|  |             if(count == 1){
 |  | 
 | 
												
													
														
															|  | //          	console.log(tip)
 |  | 
 | 
												
													
														
															|  | 				toastr && toastr.warning(tip)
 |  | 
 | 
												
													
														
															|  | //          	toLoginPage()
 |  | 
 | 
												
													
														
															|  |             }
 |  | 
 | 
												
													
														
															|  |         }
 |  | 
 | 
												
													
														
															|  |     }
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |     function uuid(len, radix) {
 |  | 
 | 
												
													
														
															|  |         var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split('');
 |  | 
 | 
												
													
														
															|  |         var uuid = [],
 |  | 
 | 
												
													
														
															|  |             i;
 |  | 
 | 
												
													
														
															|  |         radix = radix || chars.length;
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |         if(len) {
 |  | 
 | 
												
													
														
															|  |             // Compact form  
 |  | 
 | 
												
													
														
															|  |             for(i = 0; i < len; i++) uuid[i] = chars[0 | Math.random() * radix];
 |  | 
 | 
												
													
														
															|  |         } else {
 |  | 
 | 
												
													
														
															|  |             // rfc4122, version 4 form  
 |  | 
 | 
												
													
														
															|  |             var r;
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |             // rfc4122 requires these characters  
 |  | 
 | 
												
													
														
															|  |             uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
 |  | 
 | 
												
													
														
															|  |             uuid[14] = '4';
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |             // Fill in random data.  At i==19 set the high bits of clock sequence as  
 |  | 
 | 
												
													
														
															|  |             // per rfc4122, sec. 4.1.5  
 |  | 
 | 
												
													
														
															|  |             for(i = 0; i < 36; i++) {
 |  | 
 | 
												
													
														
															|  |                 if(!uuid[i]) {
 |  | 
 | 
												
													
														
															|  |                     r = 0 | Math.random() * 16;
 |  | 
 | 
												
													
														
															|  |                     uuid[i] = chars[(i == 19) ? (r & 0x3) | 0x8 : r];
 |  | 
 | 
												
													
														
															|  |                 }
 |  | 
 | 
												
													
														
															|  |             }
 |  | 
 | 
												
													
														
															|  |         }
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |         return uuid.join('');
 |  | 
 | 
												
													
														
															|  |     }
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |     /*
 |  | 
 | 
												
													
														
															|  |      * 获取图片路径方法修改
 |  | 
 | 
												
													
														
															|  |      */
 |  | 
 | 
												
													
														
															|  |     function getImgUrl(str) {
 |  | 
 | 
												
													
														
															|  |         if(typeof str != 'string') {
 |  | 
 | 
												
													
														
															|  |             return "";
 |  | 
 | 
												
													
														
															|  |         }
 |  | 
 | 
												
													
														
															|  |         if(str.length == 0) {
 |  | 
 | 
												
													
														
															|  |             return "";
 |  | 
 | 
												
													
														
															|  |         } else {
 |  | 
 | 
												
													
														
															|  |             if(str.indexOf("../") > -1) {
 |  | 
 | 
												
													
														
															|  |                 //访问本地路径
 |  | 
 | 
												
													
														
															|  |                 return str;
 |  | 
 | 
												
													
														
															|  |             } else if((str.indexOf("http://") > -1) || (str.indexOf("https://") > -1)) {
 |  | 
 | 
												
													
														
															|  |                 return str;
 |  | 
 | 
												
													
														
															|  |             } else {
 |  | 
 | 
												
													
														
															|  |                 //服务器上的图片路径
 |  | 
 | 
												
													
														
															|  |                 return imgServer + str;
 |  | 
 | 
												
													
														
															|  |             }
 |  | 
 | 
												
													
														
															|  |         }
 |  | 
 | 
												
													
														
															|  |     }
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |     httpRequest = {
 |  | 
 | 
												
													
														
															|  |         agentName: agentName,
 |  | 
 | 
												
													
														
															|  |         server: server,
 |  | 
 | 
												
													
														
															|  |         imserver: imserver,
 |  | 
 | 
												
													
														
															|  |         socketUrl: socketUrl,
 |  | 
 | 
												
													
														
															|  |         userAgent: userAgent,
 |  | 
 | 
												
													
														
															|  |         get: httpGet,
 |  | 
 | 
												
													
														
															|  |         post: httpPost,
 |  | 
 | 
												
													
														
															|  |         imHttpGet: imHttpGet,
 |  | 
 | 
												
													
														
															|  |         imHttpPost: imHttpPost,
 |  | 
 | 
												
													
														
															|  |         getImgUrl: getImgUrl,
 |  | 
 | 
												
													
														
															|  |         imgServer:imgServer,
 |  | 
 | 
												
													
														
															|  |         teamworkService:teamworkService,
 |  | 
 | 
												
													
														
															|  |         articleGet:articleGet,
 |  | 
 | 
												
													
														
															|  |         articlePost:articlePost,
 |  | 
 | 
												
													
														
															|  |         failCodeHandle: failCodeHandle,
 |  | 
 | 
												
													
														
															|  |         uuid: uuid,
 |  | 
 | 
												
													
														
															|  |         videoChatPost: videoChatPost,
 |  | 
 | 
												
													
														
															|  |         loginIm: function(data){
 |  | 
 | 
												
													
														
															|  |             return imHttpPost('/users/login', data);
 |  | 
 | 
												
													
														
															|  |         },
 |  | 
 | 
												
													
														
															|  |         getDoctorInfo: function() {
 |  | 
 | 
												
													
														
															|  |             return httpGet('doctor/baseinfo');
 |  | 
 | 
												
													
														
															|  |         }
 |  | 
 | 
												
													
														
															|  |     }
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  |     window.httpRequest = httpRequest;
 |  | 
 | 
												
													
														
															|  | 
 |  | (function($) {
 | 
												
													
														
															|  | 
 |  |     var publish_version = true;
 | 
												
													
														
															|  | 
 |  |     var isInner = false; //发布线上后有内外网的配置
 | 
												
													
														
															|  | 
 |  |     var docInfo = "app_storage";
 | 
												
													
														
															|  | 
 |  |     var agentName = "wlyyAgentForDoc";
 | 
												
													
														
															|  | 
 |  |     var docAgentName = "wlyyAgent";
 | 
												
													
														
															|  | 
 |  |     var server, userAgent, loginUrl, imserver, socketUrl, imgServer,teamworkService;
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |     var IMEI = localStorage.getItem('WLYY_IMEI') || uuid(16, 16)
 | 
												
													
														
															|  | 
 |  |     localStorage.setItem('WLYY_IMEI', IMEI)
 | 
												
													
														
															|  | 
 |  |     $.support.cors = true;
 | 
												
													
														
															|  | 
 |  |     if(publish_version) { // 生产环境配置
 | 
												
													
														
															|  | 
 |  |         server = "//www.xmtyw.cn/wlyy/"
 | 
												
													
														
															|  | 
 |  |         imserver = "//www.xmtyw.cn/api/v2";
 | 
												
													
														
															|  | 
 |  |         socketUrl = "//www.xmtyw.cn";
 | 
												
													
														
															|  | 
 |  |         articleServer = "//www.xmtyw.cn/wlyy/"
 | 
												
													
														
															|  | 
 |  |         loginUrl = "../../login/login.html";
 | 
												
													
														
															|  | 
 |  |         imgServer = "//www.xmtyw.cn/";
 | 
												
													
														
															|  | 
 |  |         teamworkService="//hlwyy.xmzsh.com/hlwyy/ims-web";
 | 
												
													
														
															|  | 
 |  |         videoChatIntranetFlag = false;
 | 
												
													
														
															|  | 
 |  |         if(isInner){
 | 
												
													
														
															|  | 
 |  |             server = "http://10.95.22.10:8011/wlyy/"
 | 
												
													
														
															|  | 
 |  |             imserver = "http://10.95.22.138:3000/api/v2";
 | 
												
													
														
															|  | 
 |  |             socketUrl = "http://10.95.22.138:3000";
 | 
												
													
														
															|  | 
 |  |             articleServer = "http://10.95.22.10:8011/wlyy/"
 | 
												
													
														
															|  | 
 |  |             loginUrl = "../../login/login.html";
 | 
												
													
														
															|  | 
 |  |             imgServer = "http://10.95.22.10:8011/";
 | 
												
													
														
															|  | 
 |  |         }
 | 
												
													
														
															|  | 
 |  |     } else { // 测试环境配置
 | 
												
													
														
															|  | 
 |  |         server = "https://ehr.yihu.com/wlyy/"  //测试环境
 | 
												
													
														
															|  | 
 |  |         // server = "http://192.168.131.190:8080/"  //桃红
 | 
												
													
														
															|  | 
 |  | //      server = "http://192.168.131.144:8080/" //冬梅
 | 
												
													
														
															|  | 
 |  |         imserver = "https://172.26.0.118:3000/api/v2";
 | 
												
													
														
															|  | 
 |  |         socketUrl = "https://172.26.0.118:3000";
 | 
												
													
														
															|  | 
 |  |     //  server = "http://192.168.131.154:8080/"
 | 
												
													
														
															|  | 
 |  |         // articleServer="http://172.26.0.118:9092/wlyy/"
 | 
												
													
														
															|  | 
 |  | //   server = "http://192.168.131.130:8080/";
 | 
												
													
														
															|  | 
 |  | 		// server = "http://192.168.131.118:8080/"; // 明芬
 | 
												
													
														
															|  | 
 |  | //      server = "http://192.168.131.127:8060/"; //逸祥
 | 
												
													
														
															|  | 
 |  | //      server = "http://192.168.131.24:8080/"; //仕杰
 | 
												
													
														
															|  | 
 |  | //      server = "http://192.168.131.112:8080/"; // 志南
 | 
												
													
														
															|  | 
 |  | //      server = "http://192.168.131.24:8082/"; // 文彬
 | 
												
													
														
															|  | 
 |  | //      imserver = "http://192.168.131.24:3000/api/v2"
 | 
												
													
														
															|  | 
 |  | //      socketUrl = "http://192.168.131.24:3000";
 | 
												
													
														
															|  | 
 |  | //		server = "http://192.168.131.144:8080/";//冬梅
 | 
												
													
														
															|  | 
 |  |         loginUrl = "../../login/login.html";
 | 
												
													
														
															|  | 
 |  | //      loginUrl = "/PC-prescription/login.html"; //自己本地测试时的路径
 | 
												
													
														
															|  | 
 |  |         imgServer = "http://172.26.0.110:8888/";
 | 
												
													
														
															|  | 
 |  |         teamworkService="//ehr.yihu.com/hlwyy/ims-web";
 | 
												
													
														
															|  | 
 |  |         videoChatIntranetFlag = false;
 | 
												
													
														
															|  | 
 |  |     }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |     var baseInfo = window.localStorage.getItem(docInfo);
 | 
												
													
														
															|  | 
 |  |     
 | 
												
													
														
															|  | 
 |  |     userAgent = window.localStorage.getItem(agentName)
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |     if(userAgent || baseInfo) {
 | 
												
													
														
															|  | 
 |  |         try {
 | 
												
													
														
															|  | 
 |  |             if(baseInfo){
 | 
												
													
														
															|  | 
 |  |                 baseInfo = JSON.parse(baseInfo);
 | 
												
													
														
															|  | 
 |  |                 window.localStorage.setItem(docAgentName, JSON.stringify(baseInfo.api_login_doctor));
 | 
												
													
														
															|  | 
 |  |                 userAgent = {
 | 
												
													
														
															|  | 
 |  |                     'id': baseInfo.api_login_doctor.id,
 | 
												
													
														
															|  | 
 |  |                     'uid': baseInfo.api_login_doctor.uid,
 | 
												
													
														
															|  | 
 |  |                     'imei': baseInfo.IMEI,
 | 
												
													
														
															|  | 
 |  |                     'token': baseInfo.api_login_doctor.token,
 | 
												
													
														
															|  | 
 |  |                     'platform': '4'
 | 
												
													
														
															|  | 
 |  |                 };
 | 
												
													
														
															|  | 
 |  |                 window.localStorage.setItem(agentName, JSON.stringify(userAgent));
 | 
												
													
														
															|  | 
 |  |                 localStorage.setItem('WLYY_IMEI', baseInfo.IMEI)
 | 
												
													
														
															|  | 
 |  |             }else{
 | 
												
													
														
															|  | 
 |  |                 userAgent = JSON.parse(userAgent)
 | 
												
													
														
															|  | 
 |  |             }
 | 
												
													
														
															|  | 
 |  |         } catch(e) {
 | 
												
													
														
															|  | 
 |  |             toastr && toastr.warning("登录失效,请关闭当前弹窗前往PC IM重新登录")
 | 
												
													
														
															|  | 
 |  | //          toLoginPage()
 | 
												
													
														
															|  | 
 |  |         }
 | 
												
													
														
															|  | 
 |  |     } else {
 | 
												
													
														
															|  | 
 |  |         toLoginPage()
 | 
												
													
														
															|  | 
 |  |     }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |     var isRelogined = sessionStorage.getItem('wlyy_relogin')
 | 
												
													
														
															|  | 
 |  |     if(isRelogined && location.href.indexOf("login.html") < 0){
 | 
												
													
														
															|  | 
 |  |         sessionStorage.removeItem('wlyy_relogin')
 | 
												
													
														
															|  | 
 |  |     }
 | 
												
													
														
															|  | 
 |  | 	
 | 
												
													
														
															|  | 
 |  |     function httpGet(url, options) {
 | 
												
													
														
															|  | 
 |  |         //发送ajax请求
 | 
												
													
														
															|  | 
 |  |         return new Promise(function(resolve, reject) {
 | 
												
													
														
															|  | 
 |  |             $.ajax(server + url,
 | 
												
													
														
															|  | 
 |  |                 $.extend({}, {
 | 
												
													
														
															|  | 
 |  |                     type: 'GET',
 | 
												
													
														
															|  | 
 |  |                     dataType: 'JSON',
 | 
												
													
														
															|  | 
 |  |                     beforeSend: function(request) {
 | 
												
													
														
															|  | 
 |  |                         var agent = userAgent || {
 | 
												
													
														
															|  | 
 |  |                             imei: localStorage.getItem('WLYY_IMEI'),
 | 
												
													
														
															|  | 
 |  |                             platform: 4
 | 
												
													
														
															|  | 
 |  |                         }
 | 
												
													
														
															|  | 
 |  |                         request.setRequestHeader("userAgent", JSON.stringify(agent));
 | 
												
													
														
															|  | 
 |  |                     },
 | 
												
													
														
															|  | 
 |  |                     error: function(res) {
 | 
												
													
														
															|  | 
 |  |                         reject(res)
 | 
												
													
														
															|  | 
 |  |                     },
 | 
												
													
														
															|  | 
 |  |                     success: function(res) {
 | 
												
													
														
															|  | 
 |  |                         failCodeHandle(res)
 | 
												
													
														
															|  | 
 |  |                         resolve(res)
 | 
												
													
														
															|  | 
 |  |                     }
 | 
												
													
														
															|  | 
 |  |                 }, options));
 | 
												
													
														
															|  | 
 |  |         })
 | 
												
													
														
															|  | 
 |  |     }
 | 
												
													
														
															|  | 
 |  | 	function articleGet(url, options) {
 | 
												
													
														
															|  | 
 |  |         //发送ajax请求
 | 
												
													
														
															|  | 
 |  |         return new Promise(function(resolve, reject) {
 | 
												
													
														
															|  | 
 |  |             $.ajax(articleServer + url,
 | 
												
													
														
															|  | 
 |  |                 $.extend({}, {
 | 
												
													
														
															|  | 
 |  |                     type: 'GET',
 | 
												
													
														
															|  | 
 |  |                     dataType: 'JSON',
 | 
												
													
														
															|  | 
 |  |                     beforeSend: function(request) {
 | 
												
													
														
															|  | 
 |  |                         var agent = userAgent || {
 | 
												
													
														
															|  | 
 |  |                             imei: localStorage.getItem('WLYY_IMEI'),
 | 
												
													
														
															|  | 
 |  |                             platform: 4
 | 
												
													
														
															|  | 
 |  |                         }
 | 
												
													
														
															|  | 
 |  |                         request.setRequestHeader("userAgent", JSON.stringify(agent));
 | 
												
													
														
															|  | 
 |  |                     },
 | 
												
													
														
															|  | 
 |  |                     error: function(res) {
 | 
												
													
														
															|  | 
 |  |                         reject(res)
 | 
												
													
														
															|  | 
 |  |                     },
 | 
												
													
														
															|  | 
 |  |                     success: function(res) {
 | 
												
													
														
															|  | 
 |  |                         failCodeHandle(res)
 | 
												
													
														
															|  | 
 |  |                         resolve(res)
 | 
												
													
														
															|  | 
 |  |                     }
 | 
												
													
														
															|  | 
 |  |                 }, options));
 | 
												
													
														
															|  | 
 |  |         })
 | 
												
													
														
															|  | 
 |  |     }
 | 
												
													
														
															|  | 
 |  |     function httpPost(url, options) {
 | 
												
													
														
															|  | 
 |  |         //发送ajax请求
 | 
												
													
														
															|  | 
 |  |         return new Promise(function(resolve, reject) {
 | 
												
													
														
															|  | 
 |  |             $.ajax(server + url,
 | 
												
													
														
															|  | 
 |  |                 $.extend({}, {
 | 
												
													
														
															|  | 
 |  |                     type: 'POST',
 | 
												
													
														
															|  | 
 |  |                     dataType: 'JSON',
 | 
												
													
														
															|  | 
 |  |                     beforeSend: function(request) {
 | 
												
													
														
															|  | 
 |  |                         var agent = userAgent || {
 | 
												
													
														
															|  | 
 |  |                             imei: localStorage.getItem('WLYY_IMEI')
 | 
												
													
														
															|  | 
 |  |                         }
 | 
												
													
														
															|  | 
 |  |                         request.setRequestHeader("userAgent", JSON.stringify(agent));
 | 
												
													
														
															|  | 
 |  |                     },
 | 
												
													
														
															|  | 
 |  |                     error: function(res) {
 | 
												
													
														
															|  | 
 |  |                         reject(res)
 | 
												
													
														
															|  | 
 |  |                     },
 | 
												
													
														
															|  | 
 |  |                     success: function(res) {
 | 
												
													
														
															|  | 
 |  |                         failCodeHandle(res)
 | 
												
													
														
															|  | 
 |  |                         resolve(res)
 | 
												
													
														
															|  | 
 |  |                     }
 | 
												
													
														
															|  | 
 |  |                 }, options));
 | 
												
													
														
															|  | 
 |  |         })
 | 
												
													
														
															|  | 
 |  |     }
 | 
												
													
														
															|  | 
 |  |     function articlePost(url, options) {
 | 
												
													
														
															|  | 
 |  |         //发送ajax请求
 | 
												
													
														
															|  | 
 |  |         return new Promise(function(resolve, reject) {
 | 
												
													
														
															|  | 
 |  |             $.ajax(articleServer + url,
 | 
												
													
														
															|  | 
 |  |                 $.extend({}, {
 | 
												
													
														
															|  | 
 |  |                     type: 'POST',
 | 
												
													
														
															|  | 
 |  |                     dataType: 'JSON',
 | 
												
													
														
															|  | 
 |  |                     beforeSend: function(request) {
 | 
												
													
														
															|  | 
 |  |                         var agent = userAgent || {
 | 
												
													
														
															|  | 
 |  |                             imei: localStorage.getItem('WLYY_IMEI')
 | 
												
													
														
															|  | 
 |  |                         }
 | 
												
													
														
															|  | 
 |  |                         request.setRequestHeader("userAgent", JSON.stringify(agent));
 | 
												
													
														
															|  | 
 |  |                     },
 | 
												
													
														
															|  | 
 |  |                     error: function(res) {
 | 
												
													
														
															|  | 
 |  |                         reject(res)
 | 
												
													
														
															|  | 
 |  |                     },
 | 
												
													
														
															|  | 
 |  |                     success: function(res) {
 | 
												
													
														
															|  | 
 |  |                         failCodeHandle(res)
 | 
												
													
														
															|  | 
 |  |                         resolve(res)
 | 
												
													
														
															|  | 
 |  |                     }
 | 
												
													
														
															|  | 
 |  |                 }, options));
 | 
												
													
														
															|  | 
 |  |         })
 | 
												
													
														
															|  | 
 |  |     }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |     function imHttpGet(url, options) {
 | 
												
													
														
															|  | 
 |  |         //发送ajax请求
 | 
												
													
														
															|  | 
 |  |         return new Promise(function(resolve, reject) {
 | 
												
													
														
															|  | 
 |  |             $.ajax(imserver + url,
 | 
												
													
														
															|  | 
 |  |                 $.extend({}, {
 | 
												
													
														
															|  | 
 |  |                     type: 'GET',
 | 
												
													
														
															|  | 
 |  |                     dataType: 'JSON',
 | 
												
													
														
															|  | 
 |  |                     beforeSend: function(request) {
 | 
												
													
														
															|  | 
 |  |                         request.setRequestHeader("userAgent", JSON.stringify(userAgent));
 | 
												
													
														
															|  | 
 |  |                     },
 | 
												
													
														
															|  | 
 |  |                     error: function(res) {
 | 
												
													
														
															|  | 
 |  |                         reject(res)
 | 
												
													
														
															|  | 
 |  |                     },
 | 
												
													
														
															|  | 
 |  |                     success: function(res) {
 | 
												
													
														
															|  | 
 |  |                         failCodeHandle(res)
 | 
												
													
														
															|  | 
 |  |                         resolve(res)
 | 
												
													
														
															|  | 
 |  |                     }
 | 
												
													
														
															|  | 
 |  |                 }, options));
 | 
												
													
														
															|  | 
 |  |         })
 | 
												
													
														
															|  | 
 |  |     }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |     function imHttpPost(url, options) {
 | 
												
													
														
															|  | 
 |  |         //发送ajax请求
 | 
												
													
														
															|  | 
 |  |         return new Promise(function(resolve, reject) {
 | 
												
													
														
															|  | 
 |  |             $.ajax(imserver + url,
 | 
												
													
														
															|  | 
 |  |                 $.extend({}, {
 | 
												
													
														
															|  | 
 |  |                     type: 'POST',
 | 
												
													
														
															|  | 
 |  |                     dataType: 'JSON',
 | 
												
													
														
															|  | 
 |  |                     beforeSend: function(request) {
 | 
												
													
														
															|  | 
 |  |                         request.setRequestHeader("userAgent", JSON.stringify(userAgent));
 | 
												
													
														
															|  | 
 |  |                     },
 | 
												
													
														
															|  | 
 |  |                     error: function(res) {
 | 
												
													
														
															|  | 
 |  |                         reject(res)
 | 
												
													
														
															|  | 
 |  |                     },
 | 
												
													
														
															|  | 
 |  |                     success: function(res) {
 | 
												
													
														
															|  | 
 |  |                         failCodeHandle(res)
 | 
												
													
														
															|  | 
 |  |                         resolve(res)
 | 
												
													
														
															|  | 
 |  |                     }
 | 
												
													
														
															|  | 
 |  |                 }, options));
 | 
												
													
														
															|  | 
 |  |         })
 | 
												
													
														
															|  | 
 |  |     }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  | 	function videoChatPost(url, options) {
 | 
												
													
														
															|  | 
 |  | 		if(options && options.data){
 | 
												
													
														
															|  | 
 |  | 			options.data.intranetFlag = videoChatIntranetFlag
 | 
												
													
														
															|  | 
 |  | 		}
 | 
												
													
														
															|  | 
 |  | 		return httpPost(url, options);
 | 
												
													
														
															|  | 
 |  |     }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |     function toLoginPage() {
 | 
												
													
														
															|  | 
 |  |         if(location.href.indexOf('login.html') > -1) {
 | 
												
													
														
															|  | 
 |  |             return;
 | 
												
													
														
															|  | 
 |  |         }
 | 
												
													
														
															|  | 
 |  |         setTimeout(function() {
 | 
												
													
														
															|  | 
 |  |             sessionStorage.setItem("wlyy_relogin", 1)
 | 
												
													
														
															|  | 
 |  | //          var path = top.location.pathname,
 | 
												
													
														
															|  | 
 |  | //              rootPath = path.split("/")[1];
 | 
												
													
														
															|  | 
 |  |             top.location.replace(loginUrl + '?redirect_url=' + encodeURIComponent(top.location.href))
 | 
												
													
														
															|  | 
 |  |         }, 2000)
 | 
												
													
														
															|  | 
 |  |     }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |     var count = 0;
 | 
												
													
														
															|  | 
 |  |     function failCodeHandle(res) {
 | 
												
													
														
															|  | 
 |  |         var tip = "";
 | 
												
													
														
															|  | 
 |  |         if(res.status == 999) {
 | 
												
													
														
															|  | 
 |  |             tip = "此账号已在别处登录,请关闭当前弹窗前往PC IM重新登录";
 | 
												
													
														
															|  | 
 |  |         } else if(res.status == 998) {
 | 
												
													
														
															|  | 
 |  |             tip = "登录超时,请关闭当前弹窗前往PC IM重新登录";
 | 
												
													
														
															|  | 
 |  |         } else if(res.status == 997) {
 | 
												
													
														
															|  | 
 |  |             tip = "此账号未登录,请先登录"
 | 
												
													
														
															|  | 
 |  |         }
 | 
												
													
														
															|  | 
 |  |         if(tip) {
 | 
												
													
														
															|  | 
 |  |             count ++;
 | 
												
													
														
															|  | 
 |  |             if(count == 1){
 | 
												
													
														
															|  | 
 |  | //          	console.log(tip)
 | 
												
													
														
															|  | 
 |  | 				toastr && toastr.warning(tip)
 | 
												
													
														
															|  | 
 |  | //          	toLoginPage()
 | 
												
													
														
															|  | 
 |  |             }
 | 
												
													
														
															|  | 
 |  |         }
 | 
												
													
														
															|  | 
 |  |     }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |     function uuid(len, radix) {
 | 
												
													
														
															|  | 
 |  |         var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split('');
 | 
												
													
														
															|  | 
 |  |         var uuid = [],
 | 
												
													
														
															|  | 
 |  |             i;
 | 
												
													
														
															|  | 
 |  |         radix = radix || chars.length;
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |         if(len) {
 | 
												
													
														
															|  | 
 |  |             // Compact form  
 | 
												
													
														
															|  | 
 |  |             for(i = 0; i < len; i++) uuid[i] = chars[0 | Math.random() * radix];
 | 
												
													
														
															|  | 
 |  |         } else {
 | 
												
													
														
															|  | 
 |  |             // rfc4122, version 4 form  
 | 
												
													
														
															|  | 
 |  |             var r;
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |             // rfc4122 requires these characters  
 | 
												
													
														
															|  | 
 |  |             uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
 | 
												
													
														
															|  | 
 |  |             uuid[14] = '4';
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |             // Fill in random data.  At i==19 set the high bits of clock sequence as  
 | 
												
													
														
															|  | 
 |  |             // per rfc4122, sec. 4.1.5  
 | 
												
													
														
															|  | 
 |  |             for(i = 0; i < 36; i++) {
 | 
												
													
														
															|  | 
 |  |                 if(!uuid[i]) {
 | 
												
													
														
															|  | 
 |  |                     r = 0 | Math.random() * 16;
 | 
												
													
														
															|  | 
 |  |                     uuid[i] = chars[(i == 19) ? (r & 0x3) | 0x8 : r];
 | 
												
													
														
															|  | 
 |  |                 }
 | 
												
													
														
															|  | 
 |  |             }
 | 
												
													
														
															|  | 
 |  |         }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |         return uuid.join('');
 | 
												
													
														
															|  | 
 |  |     }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |     /*
 | 
												
													
														
															|  | 
 |  |      * 获取图片路径方法修改
 | 
												
													
														
															|  | 
 |  |      */
 | 
												
													
														
															|  | 
 |  |     function getImgUrl(str) {
 | 
												
													
														
															|  | 
 |  |         if(typeof str != 'string') {
 | 
												
													
														
															|  | 
 |  |             return "";
 | 
												
													
														
															|  | 
 |  |         }
 | 
												
													
														
															|  | 
 |  |         if(str.length == 0) {
 | 
												
													
														
															|  | 
 |  |             return "";
 | 
												
													
														
															|  | 
 |  |         } else {
 | 
												
													
														
															|  | 
 |  |             if(str.indexOf("../") > -1) {
 | 
												
													
														
															|  | 
 |  |                 //访问本地路径
 | 
												
													
														
															|  | 
 |  |                 return str;
 | 
												
													
														
															|  | 
 |  |             } else if((str.indexOf("http://") > -1) || (str.indexOf("https://") > -1)) {
 | 
												
													
														
															|  | 
 |  |                 return str;
 | 
												
													
														
															|  | 
 |  |             } else {
 | 
												
													
														
															|  | 
 |  |                 //服务器上的图片路径
 | 
												
													
														
															|  | 
 |  |                 return imgServer + str;
 | 
												
													
														
															|  | 
 |  |             }
 | 
												
													
														
															|  | 
 |  |         }
 | 
												
													
														
															|  | 
 |  |     }
 | 
												
													
														
															|  | 
 |  | 	
 | 
												
													
														
															|  | 
 |  | 	// 导出xls
 | 
												
													
														
															|  | 
 |  | 	function downLoadFileForAjax(url, fileName, data){
 | 
												
													
														
															|  | 
 |  | 		return new Promise(function(resolve, reject){
 | 
												
													
														
															|  | 
 |  | 			const xhr = new XMLHttpRequest();
 | 
												
													
														
															|  | 
 |  | 			if(data){
 | 
												
													
														
															|  | 
 |  | 				var p = []
 | 
												
													
														
															|  | 
 |  | 				for(var k in data){
 | 
												
													
														
															|  | 
 |  | 					p.push(k + "=" + data[k])
 | 
												
													
														
															|  | 
 |  | 				}
 | 
												
													
														
															|  | 
 |  | 				url += (url.indexOf("?")!=-1? "&" : "?") + p.join("&")
 | 
												
													
														
															|  | 
 |  | 			}
 | 
												
													
														
															|  | 
 |  | 			xhr.open('GET', server + url, true);
 | 
												
													
														
															|  | 
 |  | 	      	xhr.responseType = "blob";  
 | 
												
													
														
															|  | 
 |  | 	      	xhr.onload = function() {
 | 
												
													
														
															|  | 
 |  | 				if(xhr.readyState == 4 && xhr.status==200){
 | 
												
													
														
															|  | 
 |  | 			        const blob = xhr.response;
 | 
												
													
														
															|  | 
 |  | 			        const blobUrl = URL.createObjectURL(blob);
 | 
												
													
														
															|  | 
 |  | 			        const a = document.createElement('a');
 | 
												
													
														
															|  | 
 |  | 			        a.style.display = 'none';
 | 
												
													
														
															|  | 
 |  | 			        a.download = fileName
 | 
												
													
														
															|  | 
 |  | 			        a.href = blobUrl;
 | 
												
													
														
															|  | 
 |  | 			        a.target = '_blank';
 | 
												
													
														
															|  | 
 |  | 			        a.click();
 | 
												
													
														
															|  | 
 |  | 					resolve()
 | 
												
													
														
															|  | 
 |  | 				} else {
 | 
												
													
														
															|  | 
 |  | 					reject(xhr)
 | 
												
													
														
															|  | 
 |  | 				}
 | 
												
													
														
															|  | 
 |  | 	      	}   
 | 
												
													
														
															|  | 
 |  | 			xhr.onerror = function(err){
 | 
												
													
														
															|  | 
 |  | 				console.error(err)
 | 
												
													
														
															|  | 
 |  | 				reject(xhr)
 | 
												
													
														
															|  | 
 |  | 			}           
 | 
												
													
														
															|  | 
 |  | 	      
 | 
												
													
														
															|  | 
 |  | 	      	xhr.setRequestHeader("Content-Type","application/json;charset=UTF-8");
 | 
												
													
														
															|  | 
 |  | 			var agent = userAgent || {
 | 
												
													
														
															|  | 
 |  | 				imei: localStorage.getItem('WLYY_IMEI'),
 | 
												
													
														
															|  | 
 |  | 				platform: 4
 | 
												
													
														
															|  | 
 |  | 			}
 | 
												
													
														
															|  | 
 |  | 	      	xhr.setRequestHeader("userAgent", JSON.stringify(agent));  
 | 
												
													
														
															|  | 
 |  | 	      	xhr.send();
 | 
												
													
														
															|  | 
 |  | 		})
 | 
												
													
														
															|  | 
 |  | 	}
 | 
												
													
														
															|  | 
 |  | 	
 | 
												
													
														
															|  | 
 |  |     httpRequest = {
 | 
												
													
														
															|  | 
 |  | 		downLoadFileForAjax: downLoadFileForAjax,
 | 
												
													
														
															|  | 
 |  |         agentName: agentName,
 | 
												
													
														
															|  | 
 |  |         server: server,
 | 
												
													
														
															|  | 
 |  |         imserver: imserver,
 | 
												
													
														
															|  | 
 |  |         socketUrl: socketUrl,
 | 
												
													
														
															|  | 
 |  |         userAgent: userAgent,
 | 
												
													
														
															|  | 
 |  |         get: httpGet,
 | 
												
													
														
															|  | 
 |  |         post: httpPost,
 | 
												
													
														
															|  | 
 |  |         imHttpGet: imHttpGet,
 | 
												
													
														
															|  | 
 |  |         imHttpPost: imHttpPost,
 | 
												
													
														
															|  | 
 |  |         getImgUrl: getImgUrl,
 | 
												
													
														
															|  | 
 |  |         imgServer:imgServer,
 | 
												
													
														
															|  | 
 |  |         teamworkService:teamworkService,
 | 
												
													
														
															|  | 
 |  |         articleGet:articleGet,
 | 
												
													
														
															|  | 
 |  |         articlePost:articlePost,
 | 
												
													
														
															|  | 
 |  |         failCodeHandle: failCodeHandle,
 | 
												
													
														
															|  | 
 |  |         uuid: uuid,
 | 
												
													
														
															|  | 
 |  |         videoChatPost: videoChatPost,
 | 
												
													
														
															|  | 
 |  |         loginIm: function(data){
 | 
												
													
														
															|  | 
 |  |             return imHttpPost('/users/login', data);
 | 
												
													
														
															|  | 
 |  |         },
 | 
												
													
														
															|  | 
 |  |         getDoctorInfo: function() {
 | 
												
													
														
															|  | 
 |  |             return httpGet('doctor/baseinfo');
 | 
												
													
														
															|  | 
 |  |         }
 | 
												
													
														
															|  | 
 |  |     }
 | 
												
													
														
															|  | 
 |  | 
 | 
												
													
														
															|  | 
 |  |     window.httpRequest = httpRequest;
 | 
												
													
														
															|  | })(jQuery)
 |  | })(jQuery)
 |