| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479 | 
							- var isModify = false,
 
- 	isJGmodify = false,
 
- 	isQkmodify = false,
 
- 	isPhonenumber = false,
 
- 	expenses, expenseName,
 
- 	patiCode,
 
- 	patiPhoto,
 
- 	signStatus,
 
- 	isSigned,
 
- 	isRenewable,
 
- 	qyRelation;
 
- var $doctorJGInput;
 
- var $doctorQkInput;
 
- var docInfo;
 
- var oldMobile;
 
- mui.init({
 
- 	beforeback: function() {
 
- 		if(isModify || isJGmodify || isQkmodify || isPhonenumber) {
 
- 			mui.confirm("您有未保存的变动,是否保存?", "提示", ["保存", "不了"], function(e) {
 
- 				if(e.index == 0) {
 
- 					submit();
 
- 				} else {
 
- 					plus.webview.currentWebview().close();
 
- 				}
 
- 			})
 
- 			return false;
 
- 		}
 
- 	}
 
- });
 
- var self;
 
- mui.plusReady(function() {
 
- 	self = plus.webview.currentWebview();
 
- 	patiCode = self.patiCode;
 
- 	patiPhoto = self.patiPhoto;
 
- 	isRenewable = self.renewable;
 
- 	qyRelation = self.qyRelation;
 
- 	docInfo = JSON.parse(plus.storage.getItem("docInfo"));
 
- 	getPatientInfo();
 
- 	bindEvents();
 
- });
 
- /**
 
-  * 获取患者信息
 
-  */
 
- function getPatientInfo() {
 
- 	var curDoc = docInfo.code;
 
- 	sendPost("doctor/patient_label_info/patient", {
 
- 		patient: patiCode
 
- 	}, null, function(res) {
 
- 		if(res.status == 200) {
 
- 			var data = res.data;
 
- 			if(self.teamCode) {
 
- 				data.isShowJt = data.jtAdminTeam == self.teamCode ? true : false;
 
- 			} else if(data.jtDoctor == curDoc || data.jtDoctorHealth == curDoc) {
 
- 				data.isShowJt = true;
 
- 			}
 
- 			if(self.teamCode) {
 
- 				data.isShowSs = data.ssAdminTeam == self.teamCode ? true : false;
 
- 			} else if(data.ssDoctor == curDoc || data.ssDoctorHealth == curDoc) {
 
- 				data.isShowSs = true;
 
- 			}
 
- 			//判断是否显示提醒按钮
 
- 			if(isRenewable && isRenewable == 1) {
 
- 				$("#remindXQ").parent().show();
 
- 				if(data.isRemindRenew == "1") {
 
- 					$("#remindXQ").text("已提醒续签");
 
- 					$("#remindXQ").addClass("ytx");
 
- 				} else {
 
- 					//判断用户是否有微信号和手机号
 
- 					if(!data.openid && !data.mobile) {
 
- 						$("#remindXQ").addClass("remind-not");
 
- 					}
 
- 					$("#remindXQ").text("提醒续签");
 
- 					$("#remindXQ").removeClass("ytx");
 
- 				}
 
- 			} else {
 
- 				$("#remindXQ").parent().hide();
 
- 			}
 
- 			data.photo = patiPhoto;
 
- 			data.idcard = plusXing(data.idcard,9,2);
 
- 			data.ssc = plusXing(data.ssc,3,2);
 
- 			$("#pati_info").html(template("info_tmpl", data));
 
- //			//取家庭签约团队
 
- //			sendGet("/doctor/admin-teams/team/members/" + patiCode, {}, null, function(res1) {
 
- //				if(res1.status == 200 && res1.data.teamId) {
 
- //					//					res1.data.isLeader = true; //测试用
 
- //					data.teamName = res1.data.teamName;
 
- //					data.Modifqk = data.ssDoctor || !res1.data.isLeader ? false : true;
 
- //					data.ModifyJgs = res1.data.isLeader;
 
- //					oldQy = res1.data;
 
- //
 
- //					$("#pati_info").html(template("info_tmpl", data));
 
- //					$doctorJGInput = $('#healthManagement input');
 
- //					$doctorQkInput = $('#dortor_qke input');
 
- //					setExpenses(); //初始化政府补贴下拉框
 
- //					if(res1.data.isLeader && $doctorJGInput.length > 0)
 
- //						getTeamMember(oldQy.teamId); // 初始化健管师下拉框
 
- //					if(data.ssDoctor) {
 
- //						$(".no").show();
 
- //					}
 
- //
 
- //				} else
 
- //					mui.toast("获取居民签约团队失败!");
 
- //			})
 
- 		} else {
 
- 			mui.toast(res.msg);
 
- 		}
 
- 	});
 
- }
 
- //参数的含义:str:字符串,frontLen:前面保留位数,endLen:后面保留位数。
 
- function plusXing (str,frontLen,endLen) { 
 
-  var len = str.length-frontLen-endLen;
 
-  var xing = '';
 
-  for (var i=0;i<len;i++) {
 
-  xing+='*';
 
-  }
 
-  return str.substring(0,frontLen)+xing+str.substring(str.length-endLen);
 
- }
 
- function changeInfo() {
 
- }
 
- /**
 
-  * 获取政府补贴数据
 
-  */
 
- function setExpenses() {
 
- 	var $expenses = $('#li_expenses');
 
- 	if($expenses.length > 0) {
 
- 		expenses = $expenses.attr('data-code');
 
- 		if(signStatus != 'yjy') {
 
- 			$('.header-link').show();
 
- 		}
 
- 		var expensesCode = [];
 
- 		var expensesName = [];
 
- 		sendGet("/common/getDictByDictName?name=SIGN_EXPENSES", null, null, function(res) {
 
- 			if(res.status == 200) {
 
- 				var expensesList = res.list;
 
- 				for(var i = 0; i < expensesList.length; i++) {
 
- 					if(expenses == expensesList[i].code) {
 
- 						expenseName = expensesList[i].value;
 
- 						$expenses.val(expensesList[i].value);
 
- 					}
 
- 					expensesCode.push(expensesList[i].code);
 
- 					expensesName.push(expensesList[i].value);
 
- 				}
 
- 				checkQy(expensesCode, expensesName);
 
- 			};
 
- 		});
 
- 	}
 
- }
 
- function checkQy(expensesCode, expensesName) {
 
- 	sendPost("/doctor/family_contract/medical_insurance_num", {
 
- 		patient: patiCode
 
- 	}, null, function(res) {
 
- 		isSigned = res.data.status;
 
- 		if(signStatus != 'yjy')
 
- 			activExpensesM(expensesCode, expensesName);
 
- 	});
 
- }
 
- function setExpensesSelect(code, name) {
 
- 	var $li_expenses = $('#li_expenses');
 
- 	var mobiscroll = $li_expenses.mobiscroll('getInst');
 
- 	var valueText = "{keys:'" + code + "',values:'" + name + "'}";
 
- 	mobiscroll.setVal([valueText]);
 
- 	$li_expenses.val(name);
 
- 	$li_expenses.attr("data-code", code);
 
- }
 
- /**
 
-  * 设置政府补贴下拉框
 
-  */
 
- function activExpensesM(expensesCode, expensesName) {
 
- 	if(isSigned == 0) {
 
- 		$('#li_expenses').mobiscroll({
 
- 			theme: 'ios',
 
- 			lang: 'zh',
 
- 			customWheels: true,
 
- 			wheels: [
 
- 				[{
 
- 					keys: expensesCode,
 
- 					values: expensesName
 
- 				}]
 
- 			],
 
- 			onSelect: function(valueText, inst) {
 
- 				var dd = eval("[" + valueText + "]");
 
- 				$(this).val(dd[0].values).attr("data-code", dd[0].keys);
 
- 				isModify = expenses != dd[0].keys;
 
- 				toggleModify();
 
- 			},
 
- 			onShow: function() {
 
- 				if($(this).attr('data-init') == "1") {
 
- 					$(this).attr('data-init', "0");
 
- 					$('#li_expenses').mobiscroll("selectWheel", [$(this).attr('data-code')]);
 
- 				}
 
- 			}
 
- 		});
 
- 	} else {
 
- 		$('#li_expenses').on('tap', function() {
 
- 			mui.toast("已成功签约,无法变更");
 
- 		})
 
- 	}
 
- };
 
- /**
 
-  * 手机号码修改
 
-  */
 
- function Mobilephone() {
 
- 	var Inputbox = $("#Inputbox").val();
 
- 	oldMobile = $('#Inputbox').attr('data-id')
 
- 	if(!isPhonenumber) {
 
- 		if(oldMobile==null||oldMobile=='') {
 
- 			sendPost("/doctor/patient/updateMobile", 
 
- 			{patient: patiCode,newMobile: Inputbox},null,function(res) {
 
- 				if(res.status == 200) {
 
- 					mui.toast(res.msg)
 
- 				} else {
 
- 					mui.toast(res.msg);
 
- 				}
 
- 			}, 'post');
 
- 		}else {
 
- 			sendPost("/doctor/patient/updateMobile", 
 
- 			{patient: patiCode,newMobile: Inputbox,oldMobile: oldMobile},null,function(res) {
 
- 				if(res.status == 200) {
 
- 					mui.toast(res.msg)
 
- 				} else {
 
- 					mui.toast(res.msg);
 
- 				}
 
- 			}, 'post');
 
- 		}
 
- 	}
 
- }
 
- /**
 
-  * 提交
 
-  */
 
- function submit(t) {
 
- 	if(!isModify && !isJGmodify && !isQkmodify && !isPhonenumber)
 
- 		return;
 
- 	plus.nativeUI.showWaiting();
 
- 	var p = {
 
- 		patient: patiCode
 
- 	}
 
- 	if(isModify) {
 
- 		p.expensesType = $('#li_expenses').attr('data-code');
 
- 	}
 
- 	if(isJGmodify) {
 
- 		p.healthDoctor = $doctorJGInput.attr("data-code");
 
- 	}
 
- 	if(isQkmodify) {
 
- 		p.doctor = $doctorQkInput.attr("data-code");
 
- 	}
 
- 	if(isPhonenumber) {
 
- 		p.newMobile = $("#Inputbox").val();
 
- 	}
 
- 	sendPost("/doctor/family_contract/sign_info_update", p, null,
 
- 		function(res) {
 
- 			if(res.status == 200) {
 
- 				expenses = $('#li_expenses').attr('data-code');
 
- 				oldQy.healthDoctorCode = $doctorJGInput.attr('data-code');
 
- 				oldQy.healthDoctorName = $doctorJGInput.val();
 
- 				oldQy.doctor = $doctorQkInput.attr('data-code');
 
- 				oldQy.doctorName = $doctorQkInput.val();
 
- 				isModify = false;
 
- 				isJGmodify = false;
 
- 				isQkmodify = false;
 
- 				toggleModify();
 
- 				mui.toast("保存成功!");
 
- 				plus.nativeUI.closeWaiting();
 
- 				if(!t)
 
- 					plus.webview.currentWebview().close();
 
- 			} else {
 
- 				if(isModify) {
 
- 					setExpensesSelect(expenses, expenseName);
 
- 					isModify = false;
 
- 				}
 
- 				if(isJGmodify) {
 
- 					setJGSelect(oldQy.healthDoctorCode, oldQy.healthDoctorName);
 
- 					isJGmodify = false;
 
- 				}
 
- 				if(isQkmodify) {
 
- 					setQkSelect(oldQy.doctor, oldQy.doctorName);
 
- 					isQkmodify = false;
 
- 				}
 
- 				if(isPhonenumber) {
 
- 					$("#Inputbox").val()
 
- 					isPhonenumber = false;
 
- 				}
 
- 				toggleModify();
 
- 				plus.nativeUI.closeWaiting();
 
- 				mui.toast(res.msg);
 
- 			}
 
- 		})
 
- }
 
- //获取团队成员
 
- function getTeamMember(teamCode) {
 
- 	plus.nativeUI.showWaiting();
 
- 	sendGet("/doctor/admin-teams/" + teamCode + "/members", {}, null, function(res) {
 
- 		if(res.status == 200) {
 
- 			var jgs = [],
 
- 				qk = [],
 
- 				jgCodes = [],
 
- 				jgNames = [],
 
- 				qkCodes = [],
 
- 				qkNames = [];
 
- 			$.each(res.data, function(i, v) {
 
- 				if(v.level == 3 || v.level == 2) {
 
- 					jgs.push(v);
 
- 				}
 
- 				if(v.level == 2) {
 
- 					qk.push(v);
 
- 				}
 
- 			});
 
- 			qkCodes = _.pluck(qk, 'code')
 
- 			qkNames = _.pluck(qk, 'name');
 
- 			// 萃取数组对象中code、name,返回一个数组
 
- 			jgCodes = _.pluck(jgs, 'code');
 
- 			jgNames = _.pluck(jgs, 'name');
 
- 			activHealthM(jgCodes, jgNames);
 
- 			activDoctorM(qkCodes, qkNames)
 
- 		} else
 
- 			mui.toast("获取团队成员失败!");
 
- 		plus.nativeUI.closeWaiting();
 
- 	})
 
- }
 
- function activDoctorM(codes, names) {
 
- 	$doctorQkInput.mobiscroll({
 
- 		theme: 'ios',
 
- 		lang: 'zh',
 
- 		customWheels: true,
 
- 		wheels: [
 
- 			[{
 
- 				keys: codes,
 
- 				values: names
 
- 			}]
 
- 		],
 
- 		onSelect: function(valueText, inst) {
 
- 			var dd = eval("[" + valueText + "]");
 
- 			var curDocCode = dd[0].keys;
 
- 			$(this).val(dd[0].values);
 
- 			$doctorQkInput.attr("data-code", curDocCode);
 
- 			isQkmodify = oldQy.doctor != curDocCode;
 
- 			toggleQkModify();
 
- 		}
 
- 	});
 
- 	setQkSelect(oldQy.doctor, oldQy.doctorName);
 
- };
 
- function activHealthM(codes, names) {
 
- 	$doctorJGInput.mobiscroll({
 
- 		theme: 'ios',
 
- 		lang: 'zh',
 
- 		customWheels: true,
 
- 		wheels: [
 
- 			[{
 
- 				keys: codes,
 
- 				values: names
 
- 			}]
 
- 		],
 
- 		onSelect: function(valueText, inst) {
 
- 			var dd = eval("[" + valueText + "]");
 
- 			var curDocCode = dd[0].keys;
 
- 			$(this).val(dd[0].values);
 
- 			$doctorJGInput.attr("data-code", curDocCode);
 
- 			isJGmodify = oldQy.healthDoctorCode != curDocCode;
 
- 			toggleModify();
 
- 		}
 
- 	});
 
- 	setJGSelect(oldQy.healthDoctorCode, oldQy.healthDoctorName);
 
- };
 
- function setJGSelect(code, name) {
 
- 	var mobiscroll = $doctorJGInput.mobiscroll('getInst');
 
- 	var valueText = "{keys:'" + code + "',values:'" + name + "'}";
 
- 	mobiscroll.setVal([valueText]);
 
- 	$doctorJGInput.val(name);
 
- 	$doctorJGInput.attr("data-code", code);
 
- }
 
- function setQkSelect(code, name) {
 
- 	var mobiscroll = $doctorJGInput.mobiscroll('getInst');
 
- 	var valueText = "{keys:'" + code + "',values:'" + name + "'}";
 
- 	mobiscroll.setVal([valueText]);
 
- 	$doctorQkInput.val(name);
 
- 	$doctorQkInput.attr("data-code", code);
 
- }
 
- function toggleModify() {
 
- 	console.log(isModify + "," + isJGmodify)
 
- 	$('.link').toggleClass('c-ccc', !(isModify || isJGmodify));
 
- }
 
- function toggleQkModify() {
 
- 	console.log(isModify + "," + isQkmodify)
 
- 	$('.link').toggleClass('c-ccc', !(isModify || isQkmodify));
 
- }
 
- function togglePhonenumberModify() {
 
- 	$('.link').toggleClass('c-ccc', !isPhonenumber);
 
- 	Mobilephone()
 
- }
 
- /*提醒续签*/
 
- function sendRenewRemind() {
 
- 	var url = "/doctor/sign/remindPatientRenew",
 
- 		params = {
 
- 			patient: patiCode
 
- 		};
 
- 	plus.nativeUI.showWaiting();
 
- 	sendPost(url, params, null, function(res) {
 
- 		if(res.status == 200) {
 
- 			if(res.data == 1 || res.data == 2) {
 
- 				$("#remindXQ").text("已提醒续签");
 
- 				$("#remindXQ").addClass("ytx");
 
- 			}
 
- 			mui.toast(res.msg);
 
- 		} else {
 
- 			mui.toast(res.msg)
 
- 		}
 
- 		plus.nativeUI.closeWaiting();
 
- 	}, "post", "", true);
 
- }
 
- function bindEvents() {
 
- 	$("#remindXQ").on("click", function() {
 
- 		var $this = $(this);
 
- 		if($this.hasClass("ytx")) {
 
- 			mui.toast("您今日已提醒过居民续签啦~");
 
- 		} else {
 
- 			if($this.hasClass("remind-not")) {
 
- 				mui.toast("对不起,该居民未绑定手机及微信,无法提醒。");
 
- 				$("#remindXQ").text("已提醒续签");
 
- 				$("#remindXQ").addClass("ytx");
 
- 			} else {
 
- 				sendRenewRemind();
 
- 			}
 
- 		}
 
- 	});
 
- 	$("#pati_info").on('change', '#Inputbox', function() {
 
- 		if($(this).val()) {
 
- 			togglePhonenumberModify()
 
- 		} else {
 
- 		}
 
- 	})
 
- }
 
- template.helper("setPhoto", function(p) {
 
- 	return getImgUrl(p);
 
- });
 
 
  |