//基于mui的scroll之上 function appendFamilyMember(obj,fun,cssfun,opts){ var data = {}, $obj = obj; var userAgent = JSON.parse(window.localStorage.getItem(agentName)); if(userAgent){ //删除represented字段 if(userAgent.represented){ delete userAgent.represented } window.localStorage.setItem(agentName,JSON.stringify(userAgent)) } sendPost("patient/family/authorize_members", data, "json", "get", queryListFailed, queryAppoListSuccesss); function queryAppoListSuccesss(res){ if (res.status == 200) { if (res.data.length > 0) { showMember(res); if(res.data.length == 1){ $obj.hide(); }else{ cssfun && cssfun.call(this); } }else{ dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'加载家庭成员失败'}).show(); } }else{ //非200则为失败 // queryListFailed(res); } } function queryListFailed(res) { // 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 showMember(res){ var html='', data=res.data; for(var i=0;i\ \
'+data[i].name+'('+data[i].familyRelationName+')
' } if(opts && opts.btns) { for(var i=0;i\ \
'+opts.btns[i].text+'
' } } html = '
\
'+html+'
'; $obj.append(html); setTimeout(function(){ addEvent(); },100) } function addEvent(){ mui('.family-member').scroll({ scrollY: false, //是否竖向滚动 scrollX: true, //是否横向滚动 }); function active(one){ one.find('img').css({width: '55px',height: '55px'}); one.find('.name').css({'font-size': '14px','line-height':'23px'}); } //关联被代理人 var $ul = $obj.find('.mui-control-item'); if(userAgent.represented){ for(var i=0;i<$ul.length;i++){ if($ul.eq(i).data('code') == userAgent.represented){ active($ul.eq(i)); window.localStorage.setItem('nowPatientName',$ul.eq(i).data('name')) } } }else{ active($ul.eq(0)); window.localStorage.setItem('nowPatientName',$ul.eq(0).data('name')) } $obj.on('tap','.mui-control-item',function(){ var $this = $(this), $code = $this.data('code'); window.localStorage.setItem('nowPatientName',$this.data('name')) //添加represented字段 var userobj = userAgent; userobj.represented = $code; var str = JSON.stringify(userobj); window.localStorage.setItem(agentName,str) $('.mui-control-item').find('img').css({width: '40px',height: '40px'}); $('.mui-control-item').find('.name').css({'font-size': '12px','line-height':'20px'}); active($this); fun && fun.call(this,$code); }) } } //获取家庭所有成员 function familyAllMembers(){ var data = {}; return new Promise(function(resolve, reject) { sendPost("patient/family/authorize_members", data, "json", "get", queryFailed, function(res){ if (res.status == 200) { if (res.data.length > 0){ resolve(res.data); } else { } }else{ //非200则为失败 queryFailed(res); } }); }) function queryFailed(res) { 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(); } } }