Преглед на файлове

图片路径获取方法修改

raolu преди 7 години
родител
ревизия
ff026084ad
променени са 6 файла, в които са добавени 198 реда и са изтрити 192 реда
  1. 2 2
      jianchajianyan.html
  2. 181 177
      js/api-service.js
  3. 3 4
      js/buz/order-list.js
  4. 4 1
      js/buz/prescription-consulting.js
  5. 1 1
      order-list.html
  6. 7 7
      prescription-consulting.html

+ 2 - 2
jianchajianyan.html

@ -78,7 +78,7 @@
    <script src="js/util.js"></script>
    <script src="js/template.js"></script>
    <script src="js/api-service.js"></script>
    <script src="js/jw-prescription-api.js"></script>
    <script src="js/buz/jw-prescription-list.js"></script>
    <script src="js/jianchajianyan-api.js"></script>
    <script src="js/buz/jianchajianyan.js"></script>
</body>
</html>

+ 181 - 177
js/api-service.js

@ -1,191 +1,195 @@
(function($){
	var publish_version = false;
	var agentName = "wlyyAgentForDoc";
	var server, userAgent, loginUrl, imserver, socketUrl;
	
 	var IMEI = localStorage.getItem('WLYY_IMEI') || uuid(16, 16)
	localStorage.setItem('WLYY_IMEI', IMEI)
	$.support.cors = true;
	if(publish_version) { // 生产环境配置
		
	} else { // 测试环境配置
(function($) {
    var publish_version = false;
    var agentName = "wlyyAgentForDoc";
    var server, userAgent, loginUrl, imserver, socketUrl, imgServer;
    var IMEI = localStorage.getItem('WLYY_IMEI') || uuid(16, 16)
    localStorage.setItem('WLYY_IMEI', IMEI)
    $.support.cors = true;
    if(publish_version) { // 生产环境配置
        server = "http://172.19.103.88:9092/wlyy/"
        imserver = "http://172.19.103.88:3000/api/v2";
        socketUrl = "http://172.19.103.88:3000";
        loginUrl = "login.html";
        imgServer = "";
    } else { // 测试环境配置
        server = "http://172.19.103.88:9092/wlyy/"
        // server = "http://192.168.131.127:8060/"; //逸祥
	    // server = "http://192.168.131.24:8080/"; //仕杰
        // server = "http://192.168.131.24:8080/"; //仕杰
        imserver = "http://172.19.103.88:3000/api/v2";
        socketUrl = "http://172.19.103.88:3000";
		loginUrl = "login.html"
	}
	
	
        loginUrl = "login.html";
        imgServer = "http://172.19.103.54/";
    }
    userAgent = localStorage.getItem(agentName)
	
    //hard code userAgent for test start
    //全科
    // userAgent = {"id":4800,"uid":"zbqD201703150222","imei":"864394010176834","token":"9b23e4ec0bcd3b9fa72a52f91544a4e9","platform":4,"hospital":"3502050100"}
	//健管
    //健管
    // userAgent = {"id":4821,"uid":"zbqD201703150228","imei":"864394010176834","token":"73f5ace5c7d4cdb811f743902fd705d9","platform":4,"hospital":"3502050100"}; 
    // userAgent = JSON.stringify(userAgent);
    //hard code userAgent for test end
    
    if(userAgent) {
        try{
        try {
            userAgent = JSON.parse(userAgent)
        }catch(e){
        	toastr && toastr.warning("登录失效,请重新登录")
        	toLoginPage() 
        } catch(e) {
            toastr && toastr.warning("登录失效,请重新登录")
            toLoginPage()
        }
    } else {
    	toLoginPage()
        toLoginPage()
    }
    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 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 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 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 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 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 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 toLoginPage() {
		if(location.href.indexOf('login.html')>-1) {
    		return ;
    	}
    	setTimeout(function() {
    		location.replace(loginUrl+'?redirect_url='+encodeURIComponent(location.href))
    	}, 2000)  
	}
	
	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)
			toLoginPage()
		}
    function toLoginPage() {
        if(location.href.indexOf('login.html') > -1) {
            return;
        }
        setTimeout(function() {
            location.replace(loginUrl + '?redirect_url=' + encodeURIComponent(location.href))
        }, 2000)
    }
    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)
            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('');  
	}  
			
	
	APIService = {
		agentName: agentName,
    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('');
    }
    APIService = {
        agentName: agentName,
        server: server,
        imserver: imserver,
        socketUrl: socketUrl,
@ -194,13 +198,13 @@
        httpPost: httpPost,
        imHttpGet: imHttpGet,
        imHttpPost: imHttpPost,
        getDoctorInfo: function(){
        getDoctorInfo: function() {
            return httpGet('doctor/baseinfo');
        },
        getTeamInfo: function(doctor){
            return httpGet('/doctor/admin-teams/team/'+doctor+'/teams');
        getTeamInfo: function(doctor) {
            return httpGet('/doctor/admin-teams/team/' + doctor + '/teams');
        }
	}
	
	window.APIService = APIService;
})(jQuery)
    }
    window.APIService = APIService;
})(jQuery)

+ 3 - 4
js/buz/order-list.js

@ -154,9 +154,9 @@ function getHealthDoctorList(isRefresh){
            title: '',
            width: '50',
            formatter: function(val, row, index){
                var url = "img/d-male.png";
                if(val.indexOf("http")>-1 || val.indexOf("https")>-1){
                    url = val;
                var url = APIService.getImgUrl(val);
                if((url.indexOf("http")== -1) && (url.indexOf("https")== -1)){
                    url = "img/d-male.png";
                }
                return '<img src="'+url+'" class="img-circle" width="40">';
            }
@ -184,7 +184,6 @@ function getHealthDoctorList(isRefresh){
}
function queryParams2(params) {
    console.log(params);
    //当表格数据变化的时候,则取消全选按钮,然后之前的选中的信息将取消选中
    return {
        page: params.offset/params.limit + 1,

+ 4 - 1
js/buz/prescription-consulting.js

@ -116,7 +116,7 @@ function formatMsg(reply){
                break;
            }
        }
        var img = member.avatar;
        var img = APIService.getImgUrl(reply.avatar);
        if((img.indexOf('http') == -1) && (img.indexOf("https") == -1)){
            img = member.is_patient ? 'img/p-default.png' : 'img/d-male.png';
        }
@ -355,3 +355,6 @@ function bindEvents(){
}
template.helper('getSourceUrl', function(str){
    return APIService.getImgUrl(str);
})

+ 1 - 1
order-list.html

@ -157,7 +157,7 @@
        {{each list as it}}
        <option value="{{it.hospitalCode}}">{{it.hospitalName}}</option>
        {{/each}}
        <!-- <option value="">其他</option> -->
         <option value="other">其他</option> 
    </script>
    <script type="text/html" id="list_tmpl">

+ 7 - 7
prescription-consulting.html

@ -68,8 +68,8 @@
            {{/if}}
            {{if type == 2}}
            <dd class="word-bread wb-img">
                <a class="fancybox" href="{{content}}" title="图片">
                    <img width="100" src="{{content}}" />
                <a class="fancybox" href="{{content | getSourceUrl}}" title="图片">
                    <img width="100" src="{{content | getSourceUrl}}" />
                </a>
            </dd>
            {{/if}}
@ -78,9 +78,9 @@
                <div class="player" style="width:292px;">
                    <audio controls>
                        <!-- Audio files -->
                        <source src="{{content.path}}" type="audio/mp3">
                        <source src="{{content.path | getSourceUrl}}" type="audio/mp3">
                        <!-- Fallback for browsers that don't support the <audio> element -->
                        您的浏览器不支持在线播放,请<a href="{{content.path}}">下载</a>
                        您的浏览器不支持在线播放,请<a href="{{content.path | getSourceUrl}}">下载</a>
                    </audio>
                </div>
            </dd>
@ -97,15 +97,15 @@
            {{if type == 12}}
            <dd class="word-bread">
                <div class="player" style="width:292px;">
                    <video poster="{{content.img}}" controls crossorigin>
                    <video poster="{{content.img | getSourceUrl}}" controls crossorigin>
                        <!-- Video files -->
                        <source src="{{content.path}}" type="video/mp4">
                        <source src="{{content.path | getSourceUrl}}" type="video/mp4">
                        <!-- Text track file -->
                        <!-- <track kind="captions" label="English" srclang="en" src="https://cdn.selz.com/plyr/1.0/example_captions_en.vtt" default> -->
                        <!-- Fallback for browsers that don't support the <video> element -->
                        <a href="{{content.path}}">Download</a>
                        <a href="{{content.path | getSourceUrl}}">Download</a>
                    </video>
                </div>
            </dd>