rukou.js 3.32 KB
Newer Older
hanpeng committed
1 2 3
define(['zepto','medtap'],function($,medtap){
	var main = {
		wechatId:medtap.getRequest('wechatId'),
4
		doctorId:medtap.getRequest('doctorId'),
hanpeng committed
5
		operationType:medtap.getRequest('operationType'),
hanpeng committed
6
		healthType:'',
hanpeng committed
7 8 9 10 11 12 13
		init:function(){
			main.getToken();
		},
		getToken:function(){
			localStorage.wxLungToken = '';
			medtap.loading(1);
			medtap.submitAjax({
hanpeng committed
14
				url: 'https://testdevgw.medtap.cn/user/auth/token',
hanpeng committed
15 16 17 18 19 20 21 22 23 24 25
				type: 'POST',
				async: false,
				contentType: 'application/json',
				data: {
					wechatId: main.wechatId
				},
				success: function(res) {
					medtap.loading(0);
					if (res.success == true) {
						var token = res.content.token;
						localStorage.setItem('wxLungToken', token);
26
						main.checkUser();
hanpeng committed
27 28 29 30 31 32 33 34 35
					} else {
			
					}
				},
				error: function(res) {
					console.log(res.resultDesc);
				}
			})
		},
36 37 38 39
		//
		checkUser:function(){
			medtap.loading(1);
			medtap.submitAjax({
hanpeng committed
40
				url:'https://testdevgw.medtap.cn/wechat/user/getWechatUser',
41 42 43 44 45 46 47 48 49 50 51 52 53 54
				type:'GET',
				async: false,
				data:{
					wechatId:main.wechatId
				},
				success:function(res){
					medtap.loading(0);
					var info = res.content.wechatUser;
					if(info.hasOwnProperty('userId')){
						//已绑定手机号
						main.getUserDetail();
						//main.getUserPatientInfo();
					}else{
						//未绑定手机号
hanpeng committed
55
						window.location.replace('pages/login.html?wechatId=' + main.wechatId + '&doctorId=' + main.doctorId + '&operationType=' + main.operationType);
56 57 58 59
					}
				}
			})
		},
hanpeng committed
60
		getUserDetail:function(){
61 62
			medtap.loading(1);
			medtap.submitAjax({
hanpeng committed
63
				url:'https://testdevgw.medtap.cn/user/getUserDetail',
64 65 66 67 68 69 70 71 72
				type:'GET',
				async:false,
				data:{
					
				},
				success:function(res){
					medtap.loading(0);
					if(res.success == true){
						var info = res.content.userInfo;
hanpeng committed
73
						if(!info.hasOwnProperty('healthType') ||!info['username'] || !info['sex'] || !info['telephone']){
hanpeng committed
74
							window.location.replace('pages/basicUserInfo.html?wechatId=' + main.wechatId + '&doctorId=' + main.doctorId + '&operationType=' + main.operationType)
hanpeng committed
75
						}else{
hanpeng committed
76 77 78
							if(info.hasOwnProperty('healthType')){
								main.healthType = info.healthType.child;
							}
hanpeng committed
79
							main.getUserPatientInfo();
80 81 82 83 84
						}
					}
				}
				
			})
hanpeng committed
85
		},
86 87 88
		getUserPatientInfo:function(){
			medtap.loading(1);
			medtap.submitAjax({
hanpeng committed
89
				url:'https://testdevgw.medtap.cn/user/patientEMR/listPatientEMR',
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
				type:'POST',
				async:false,
				contentType: 'application/json',
				data:{
					pageNum:1,
					pageSize:10,
					condition:{
						
					}
				},
				success:function(res){
					medtap.loading(0);
					if(res.success == true){
						var patientInfo = res.content.list;
						if(patientInfo.length == 0){
							//未完善患者信息
hanpeng committed
106 107 108 109 110
							if(main.healthType == 'HE1'){
								window.location.replace('pages/doctorHomePage.html?wechatId=' + main.wechatId + '&doctorId=' + main.doctorId + '&operationType=' + main.operationType);
							}else{
								window.location.replace('pages/createPatientInfo.html?wechatId=' + main.wechatId + '&doctorId=' + main.doctorId + '&operationType=' + main.operationType + '&canSkip=false');
							}
111 112
						}else{
							//跳转至医生主页
hanpeng committed
113
							window.location.replace('pages/doctorHomePage.html?wechatId=' + main.wechatId + '&doctorId=' + main.doctorId + '&operationType=' + main.operationType);
114 115 116 117
						}
					}
				}
			})
hanpeng committed
118
		}
119

hanpeng committed
120 121 122 123
	}
	main.init()
	
})