rukou.js 4.29 KB
Newer Older
hanpeng committed
1 2 3 4
define(['zepto', 'medtap'], function($, medtap) {
	var rukou = {
		wechatId: medtap.getRequest('wechatId'),
		linkType:medtap.getRequest('linkType'),
hanpeng committed
5
		healthType:"",
hanpeng committed
6
		init: function() {
hanpeng committed
7
			rukou.getToken();
hanpeng committed
8 9 10 11 12 13 14 15 16 17 18 19 20 21
		},
		checkUser: function() {
			medtap.loading(1);
			medtap.submitAjax({
				url: 'https://testdevgw.medtap.cn/wechat/user/getWechatUser',
				type: 'GET',
				async: false,
				data: {
					wechatId: rukou.wechatId
				},
				success: function(res) {
					medtap.loading(0);
					var info = res.content.wechatUser;
					if (info.hasOwnProperty('userId')) {
hanpeng committed
22
						
hanpeng committed
23
						rukou.getUserDetail();
hanpeng committed
24 25 26
					} else {
						window.location.replace(
							'https://review-formal.iplusmed.com/wechatForLungCancer/dev/wechat_lung_login/login.html?wechatId=' +
hanpeng committed
27
							rukou.wechatId + '&operationType=12&toLink=' + rukou.linkType);
hanpeng committed
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
					}
				}
			})
		},
		getToken: function() {
			localStorage.wxLungToken = '';
			medtap.loading(1);
			medtap.submitAjax({
				url: 'https://testdevgw.medtap.cn/user/auth/token',
				type: 'POST',
				async: false,
				contentType: 'application/json',
				data: {
					wechatId: rukou.wechatId
				},
				success: function(res) {
					medtap.loading(0);
					if (res.success == true) {
						var token = res.content.token;
						localStorage.setItem('wxLungToken', token);
						rukou.checkUser();
					} else {

					}
				},
				error: function(res) {
					console.log(res.resultDesc);
				}
			})
hanpeng committed
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
		},
		getUserDetail:function(){
			medtap.loading(1);
			medtap.submitAjax({
				url:'https://testdevgw.medtap.cn/user/getUserDetail',
				type:'GET',
				async:false,
				data:{
					
				},
				success:function(res){
					medtap.loading(0);
					if(res.success == true){
						var info = res.content.userInfo;
						if(!info.hasOwnProperty('healthType') ||!info['username'] || !info['sex'] || !info['telephone']){
							window.location.replace('https://review-formal.iplusmed.com/wechatForLungCancer/dev/wechat_lung_login/pages/basicUserInfo.html?wechatId=' + rukou.wechatId + '&toLink='+ rukou.linkType);
						}else{
hanpeng committed
74 75 76
							if(info.hasOwnProperty('healthType')){
								rukou.headlthType = info.healthType.child;
							}
hanpeng committed
77
							rukou.getUserPatientInfo();
hanpeng committed
78
							//console.log(rukou.headlthType)
hanpeng committed
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
						}
					}
				}
				
			})
		},
		getUserPatientInfo:function(){
			medtap.loading(1);
			medtap.submitAjax({
				url:'https://testdevgw.medtap.cn/user/patientEMR/listPatientEMR',
				type:'POST',
				async:false,
				contentType: 'application/json',
				data:{
					pageNum:1,
					pageSize:10,
					condition:{
						
					}
				},
				success:function(res){
					medtap.loading(0);
					if(res.success == true){
hanpeng committed
102
						var ts = new Date().getTime();
hanpeng committed
103 104 105
						var patientInfo = res.content.list;
						if(patientInfo.length == 0){
							//未完善患者信息
hanpeng committed
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
							if(rukou.headlthType == 'HE1'){
								switch (rukou.linkType){
									case 'MYDOCTOR':
										window.location.replace('pages/myDoctor.html?wechatId=' + rukou.wechatId + '&ts=' + ts)
										break;
									case 'MYEMR':
										window.location.replace('pages/myEMR.html?wechatId=' + rukou.wechatId + '&ts=' + ts);
										break;
									case 'MYREMIND':
										window.location.replace('pages/myRemind.html?wechatId=' + rukou.wechatId + '&ts=' + ts);
										break;
									case 'MYCONSULT':
										window.location.replace('pages/myConsult.html?wechatId=' + rukou.wechatId + '&ts=' + ts);
									default:
										break;
								}
							}else{
								window.location.replace('https://review-formal.iplusmed.com/wechatForLungCancer/dev/wechat_lung_login/pages/createPatientInfo.html?wechatId=' + rukou.wechatId + '&toLink=' + rukou.linkType + '&ts=' + ts);
							}
hanpeng committed
125 126 127 128
						}else{
							//跳转至
							switch (rukou.linkType){
								case 'MYDOCTOR':
hanpeng committed
129
									window.location.replace('pages/myDoctor.html?wechatId=' + rukou.wechatId + '&ts=' + ts)
hanpeng committed
130 131
									break;
								case 'MYEMR':
hanpeng committed
132
									window.location.replace('pages/myEMR.html?wechatId=' + rukou.wechatId + '&ts=' + ts);
hanpeng committed
133 134
									break;
								case 'MYREMIND':
hanpeng committed
135
									window.location.replace('pages/myRemind.html?wechatId=' + rukou.wechatId + '&ts=' + ts);
hanpeng committed
136 137
									break;
								case 'MYCONSULT':
hanpeng committed
138
									window.location.replace('pages/myConsult.html?wechatId=' + rukou.wechatId + '&ts=' + ts);
hanpeng committed
139 140 141 142 143 144 145
								default:
									break;
							}
						}
					}
				}
			})
hanpeng committed
146 147 148 149
		}
	}
	rukou.init();
})