var d = dialog({contentType:'load', skin:'bk-popup'}); var dd = dialog({contentType:'load', skin:'bk-popup', content:'提交中...'}); var scroller1 = new IScrollPullUpDown('wrapper',{ probeType:2, bounceTime: 250, bounceEasing: 'quadratic', mouseWheel:false, scrollbars:true, click:true, fadeScrollbars:true, interactiveScrollbars:false }, null, null); var info; $(function(){ // 判断是否登录 checkUserAgent(); // 获取缓存 info = JSON.parse(window.localStorage.getItem("familyMemberInfo")); $("#name").html(info.name); $("#pic").attr("src", getImgUrl(info.photo)); $("#idcard").html(info.idcard); $("#mobile").html(info.mobile); $("#address").html(info.address); $("#sign").html(info.signText); $("#select").find("p").html(info.relation); // 选择家庭关系 $('#select').mobiscroll({ theme: 'ios', lang: 'zh', formatValue: function(d) { return d; }, customWheels: true, wheels: [ [{ keys: ['1', '2', '3', '4', '5', '6', '0'], values: ['父亲', '母亲', '老公', '老婆', '儿子', '女儿', '其他'] }] ], onSelect: function(valueText, inst) { var values = eval("[" + valueText + "]"), keys = values[0].keys; var s = info.idcard[info.idcard.length-2], isMan = s%2 == 1; //判断所选的值是否与性别相冲突 if(isMan && (keys==2 || keys==4 || keys==6)){ dialog({ contentType:'tipsbox', skin:'bk-popup', content: "您的家人性别与家庭关系不匹配,请核对后再确认" }).show(); return false; } if(!isMan && (keys==1 || keys==3 || keys==5)){ dialog({ contentType:'tipsbox', skin:'bk-popup', content: "您的家人性别与家庭关系不匹配,请核对后再确认" }).show(); return false; } $('#select').find("p").html(values[0].values); selectKey = values[0].keys; dd.show(); var data = {}; data.member = info.code; data.relation = selectKey; sendPost("patient/family/relation_update", data, "json", "post", changeFailed, changeSuccess); } }); // 删除家人 $("#delete").bind("tap", function () { dialog({ content:'删除家人后,无法查看家人信息,并为家人进行相关操作,是否继续删除', button: [ { value: '继续删除', callback: function(){ this.close(); dd.show(); var data = {}; data.member = info.code; sendPost("patient/family/member_delete", data, "json", "post", deleteFailed, deleteSuccess); } }, { value: '不了,谢谢', callback: function(){} } ] }).showModal(); }); }); // 禁止拖动 document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false); // 修改失败 function changeFailed (res) { dd.close(); if (res && res.msg) { dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:res.msg}).show(); } else { dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'加载失败'}).show(); } } // 修改成功 function changeSuccess (res) { if (res.status == 200) { dd.close(); dialog({contentType:'tipsbox', skin:'bk-popup' , content:"家庭关系修改成功"}).show(); } else { //非200则为失败 changeFailed(res); } } // 删除失败 function deleteFailed (res) { dd.close(); if (res && res.msg) { dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:res.msg}).show(); } else { dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'加载失败'}).show(); } } // 删除成功 function deleteSuccess (res) { if (res.status == 200) { dd.close(); dialog({contentType:'tipsbox', skin:'bk-popup' , content:res.msg}).show(); setTimeout(function(){ window.location.href = "family.html"; }, 1000); } else { //非200则为失败 deleteFailed(res); } }