//创建全局变量 var obj ,p_aggregate, arr =[],singlepatiCode,docName; //创建节点变量并且赋值 var $n_list = $('.n-list'), $makeSure = $('#makeSure'); //mui 初始化 mui.init(); //文档就绪函数执行函数 mui.plusReady(function(){ //获取基本信息 obj = pageInfo(); //获取页面信息 var self = plus.webview.currentWebview(); //获取病人集合 p_aggregate = self.residentArr; //获取单个病人 singlepatiCode = self.patiCode; healthCode = self.healthAssistant; //初始化页面 initpage(); //事件执行函数 bindEvent(); }) function pageInfo (){ userInfo = JSON.parse(plus.storage.getItem('userAgent')); accountInfo = JSON.parse(plus.storage.getItem('docInfo')); return { dlxx :userInfo, docxx:accountInfo } } function initpage(){ //获取所有健管师 var url = '/doctor/specialist/findHealthAssistantPatientCount'; var params = { doctor :obj.docxx.code } sendGet(url,params,null,function(res){ if (res.status == 200) { for (var i in res.data){ res.data[i].photo = getImgUrl(res.data[i].photo); } $n_list.html(template('health_care_manager',{list :res.data})) //遍历健管师的code 看看是否已经授权 var nodeArr = $('.n-list').find('li'); nodeArr.each(function(){ var jgCode = $(this).attr('data-code'); if(jgCode == healthCode){ $(this).find('input[name=care_manager]').attr('checked','checked'); docName = $(this).attr('data-name') } }) } else{ mui.toast(res.msg) } },'GET','',true) } function bindEvent(){ $('#makeSure').on('tap', function(){ //点击确定的时候判断是否选择了健管师 var careManagerSum = $(".n-list input[name=care_manager]:checked"); if(!(careManagerSum.length!=0)){ dialog({ contentType: 'tipsbox', skin: 'bk-popup', content: '请选择健管师!', closeTime: 2000 }).showModal(); return false } var manageUrl = '/doctor/specialist/saveHealthAssistant'; var params = { json:JSON.stringify(arr) }; plus.nativeUI.showWaiting(); sendPost(manageUrl, params, null, function(res){ if (res.status == 200) { plus.nativeUI.closeWaiting(); var wv = plus.webview.getWebviewById('huanzhe-specal.html'); if (wv) { mui.fire(wv,'refresh'); } mui.toast("分配健管师成功"); var lastWeb = plus.webview.getWebviewById("dingyibiaoqian"); if(lastWeb) { lastWeb.close() } mui.back() } else{ mui.toast(res.msg); } }) }) //点击选择健管师 $('.n-list').on('tap', '.n-list-link input' , function(){ var $that = $(this); var codeMiddle = $that.parent().parent().attr('data-code'); var nameMiddle = $that.parent().parent().attr('data-name'); if(p_aggregate){ for(var i = 0;i