123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354 |
- var patiCode = "";
- var patiName = "";
- var scrollerObArr=[],baseEnv;
- var menuData = [{code:"1",name:"随访计划",url:"doctor/followup/list_by_team",page: 1,template: 'suifang_tmpl'},
- {code:"2",name:"随访记录",url:"doctor/followup/list_by_team",page: 1,template: 'suifang_tmpl'}];
- var slider = null;
- var noResultWrap = '<div id="no_result_wrap">'+
- '<img class="no-result-img" src="../../../images/shujuweikong_img.png" />'+
- '</div>';
- var activeIndex = 0;
- var pageSize = 10;
- var docInfo ='';
- var type = ""; //记录前一个页面的id
- // 获取基础环境信息
- var getBaseEnvPromise = function () {
- var env = {
- webview: plus&&plus.webview.currentWebview()
- };
- return Promise.resolve().then(function(res) {
- return env;
- });
- },
- //初始化iscroll对象
- initScroller = function(menuData){
- for(var x in menuData){
- var $dom = $("#div-container"+x);
- //实例化iscroll
- var contentIscroll = $dom.lscroll({
- iscrollOpt: {
- click:true
- },
- pullDownAction: function(g){
- var curPage = g.options.page;
- getList(g.iScroll,curPage, true);
- },
- pullUpAction: function(g){
- var curPage = g.options.page;
- getList(g.iScroll,curPage, false);
- }
- });
- scrollerObArr.push({myscroll:contentIscroll});
- }
- },
- //加载数据
- getList = function(myscroll,page,isInit){
- var target = $(myscroll.wrapper).find(".div-content").find("ul.dest_list_wrap");
- var index = parseInt($(myscroll.wrapper).find(".div-content").attr("id").replace("div-container",""));
- var menu = menuData[index];
- var teamCode = $(".lin-sel-group li").eq(activeIndex).attr('data-code');
- if(isInit) {
- menu.page = page
- }
- getReqPromise(menu.url,{
- type: index+1,
- patient: patiCode,
- teamCode: teamCode||"",
- page: page,
- pagesize: pageSize
- }).then(function(res) {
- if(res.status==200){
- var list = res.list || res.data;
- if(list.length > 0){
- var len = list.length;
- menu.page++;
- var html = template(menu.template, {list: list});
- if(isInit){//下拉刷新
- target.html(html);
- }else{//上拉加载
- target.append(html);
- }
- setTimeout(function(){
- scrollerObArr[index].myscroll.refresh(len<pageSize);
- },500)
- }else{//无数据
- setTimeout(function(){
- scrollerObArr[index].myscroll.refresh(true);
- },500)
- if(page==1){
- $(myscroll.wrapper).find(".div-content ul.dest_list_wrap").html(noResultWrap);
- }
- }
- }else{
- $(myscroll.wrapper).find(".div-content ul.dest_list_wrap").empty();
- mui.toast(res.msg)
- }
- });
- slider.gotoItem(index);
- },
- //获取反馈类型字典
- initArticleType = function(){
- var menuStr = "";
- var contentStr = "";
- var activeClass,contentClass;
- for(var x in menuData){
- //菜单
- activeClass = "";
- if(x==0){activeClass = "mui-active";}
- menuStr+='<a class="mui-control-item c-f16 '+activeClass+'" data-index="'+x+'">'+menuData[x].name+'</a>';
- //内容
- contentStr+='<div class="mui-slider-item mui-control-content '+activeClass+'">'+
- '<div class="div-content" id="div-container'+x+'">'+
- '<ul class="dest_list_wrap"></ul></div>'+
- '</div>';
- }
- $(".div-menu").html(menuStr);
- $(".mui-slider-group").html(contentStr);
-
- initScroller(menuData);//初始化iscroll事件
- initPage(1,$("#Dtitle").attr("data-index"));
- slider = mui('.mui-slider').slider();
- $('.mui-scroll-wrapper').addClass('mui-slider-indicator');
- mui('.mui-scroll-wrapper').scroll();
- },
- //页面初始化
- initPage = function(page,status) {
- var reqUrl = [];
- var teamCode = $(".lin-sel-group li").eq(activeIndex).attr('data-code');
- var params = _.map(menuData,function(o) {
- return {
- url: o.url,
- data: {
- patient: patiCode,
- teamCode: teamCode||"",
- type: 1,
- page: o.page,
- pagesize: pageSize,
- }
- }
- });
- var firstReq = [];
- firstReq.push(params[0]);
- getReqPromises(firstReq).then(function(datas) {
- _.each(datas,function(o,i) {
- var res = datas[i];
- if(res.status == 200) {
- var list = res.list || res.data;
- if(list.length > 0) {
- var len = list.length;
- menuData[i].page++;
- var html = template(menuData[i].template, {list: list});
- $(".mui-slider-group").find(".div-content").find("ul.dest_list_wrap").eq(i).html(html);
- setTimeout(function(){
- scrollerObArr[i].myscroll.refresh(len<pageSize);
- },500)
- } else {
- $(".mui-slider-group").find(".div-content").find("ul.dest_list_wrap").eq(i).html(noResultWrap);
- setTimeout(function(){
- scrollerObArr[i].myscroll.refresh(true);
- },500)
- }
- } else{
- mui.toast(res.msg)
- }
- });
-
- plus.nativeUI.closeWaiting();
- }).catch(function(e) {
- console && console.error(e);
- });
- },
- // 绑定页面事件
- bindEvents = function () {
- //切换菜单
- $('.mui-slider').on('tap','.mui-control-item:not(.mui-active)',function(){
- var index = this.getAttribute('data-index');
- getList(scrollerObArr[index].myscroll.iScroll,1, true)
- })
-
- $(".demo-comtop").on("click","h1",function(){
- $(".lin-mask").show();
- $(".lin-sel-group").show();
- });
-
- $(".lin-mask").on("click",function(){
- $(".lin-mask").hide();
- $(".lin-sel-group").hide();
- });
-
- $(".lin-sel-group").on("click","li",function(){
- slider.gotoItem(0);
- activeIndex = $(this).index();
- var index = $(this).attr("data-code");
- $(".lin-sel-group li").removeClass("checked");
- $(this).addClass("checked");
- $(".lin-mask").trigger("click");
- $("#Dtitle").html($(this).find("label").html()).attr("data-index",index);
- _.each(menuData,function(o) {
- o.page = 1;
- })
- //重新加载数据
- initPage(1,index);
- });
-
- //模板中的item的点击事件
- $('body').on("tap", ".sf_detail", function(){
- openSuiFangDetail(this);
- })
- },
- // 修复bug#2580 【医生端】居民服务:团队长只能查看居民的服务记录信息问题。
- hasSigned = function() {
- return $(".lin-sel-group li").eq(activeIndex).attr('data-has-sign')=="1";
- },
- openSuiFangDetail = function(ele) {
- var info = JSON.parse(ele.getAttribute("data-info"));
- //不是随访医生,团队长且状态没完成 1-->已完成 3-->进行中2-->未开始(计划中)
- if(docInfo.code != info.doctorCode && !(docInfo.isLeader=="1" && docInfo.adminTeamCode ==$("#Dtitle").attr("data-index")) && info.status!=1 ){
- mui.toast("您暂时无法查看哦");
- return ;
- }
- var str = ele.getAttribute("data-info");
- var docMsg = JSON.stringify(docInfo);
- var strObj = JSON.parse(str);
- var otherPeople = false;
- if(docInfo.code != info.doctorCode && !(docInfo.isLeader=="1" && docInfo.adminTeamCode ==$("#Dtitle").attr("data-index"))){
- otherPeople = true
- }
- if(strObj.prescriptionCode){
- if(strObj.status!='2'){
- openWebview("../../suifang/html/fvDetail.html", {followup_id: strObj.id,status:strObj.status,prescriptionCode:strObj.prescriptionCode,otherPeople:otherPeople});
- }else{
- var patientInfo={}
- patientInfo.code = strObj.patientCode
- mui.openWindow('../../suifang/html/follow_way.html', 'follow_way', {
- extras: {
- followup_id:strObj.id,
- followClass:strObj.followupClass,
- patientInfo:patientInfo,
- prescriptionCode: strObj.prescriptionCode
- }
- })
- }
- }else{
- openWebview("../../suifang/html/suifang_detail.html", {data: str,docInfo:docMsg});
- }
- },
- addNew = function() {
- openWebview("choose_suifang.html", {patiCode: patiCode});
- },
- prepareData = function(){
- if(type && type == "sf"){ //显示随访的数据
- menuData = [
- {code:"2",name:"随访",url:"doctor/followup/list_by_team",page: 1,template: 'suifang_tmpl'}
- ];
- $("#statistics_btn").hide();
- }else{
- $("#statistics_btn").show();
- }
- }
- // 页面业务处理流程开始
- new Promise(function(resolve, reject) {
- // TODO 临时放开
- //resolve(true);
- mui.plusReady(function() {
- // plus已经准备好,可以往下执行
- resolve(true);
- });
- }).then(function() {
- template.helper('toInfo', function(v){
- v.patientCode = patiCode;
- return JSON.stringify(v);
- });
-
- template.helper("setSex", function(s) {
- if(s == 1) {
- return "男"
- } else if(s == 2) {
- return "女"
- }
- });
- template.helper("setPhoto", function(p) {
- return getImgUrl(p);
- });
-
- template.helper("setTime", function(p) {
- if(p){
- p = p.split('.')[0];
- return new Date(Date.parse(p.replace(/-/g, "/"))).format("yyyy-MM-dd hh:mm:ss")
- }else{
- return "";
- }
-
- });
- //随访
- template.helper("setTime2", function(p) {
- // 为了防止类似“2016-12-21 14:08:10.0”在IOS上无法识别问题
- if(p){
- p = p.split('.')[0];
- return new Date(Date.parse(p.replace(/-/g, "/"))).format("yyyy-MM-dd hh:mm")
- }else{
- return "";
- }
-
- });
- }).then(function() {
- docInfo = JSON.parse(plus.storage.getItem("docInfo"));
- // 获取基础环境信息
- return getBaseEnvPromise().then(function(env) {
- baseEnv = env;
- patiCode =baseEnv.webview.patientCode;
- patiName = baseEnv.webview.patientName;
- })
- })
- .then(function() {
- // plus.nativeUI.showWaiting();
- // // TODO 团队选择
- // return getReqPromise("doctor/family_contract/patient_doctor_teams",{
- // patient: patiCode
- // }).then(function(res) {
- // if(res.status == 200) {
- // var data = res.data,teams = [];
- // // 是否有签约关系 1:有 0:无,此时jtTeam与ssTeam都没有
- // if(data.hasSign=="1") {
- // data.ssTeam && (function() {
- // var team = data.ssTeam.team;
- // team.hasSign = data.ssTeam.hasSign; // 医生与患者是否有签约关系
- // team.isLeader = data.ssTeam.isLeader; // 是否是团队长
- // teams.push(team)
- // })();
- // data.jtTeam && (function() {
- // var team = data.jtTeam.team;
- // team.hasSign = data.jtTeam.hasSign; // 医生与患者是否有签约关系
- // team.isLeader = data.jtTeam.isLeader; // 是否是团队长
- // teams.push(team)
- // })();
- // }
- // }
- // $('.lin-sel-group').html(template('teams_tmpl', {data:teams}));
- // //初始默认选中第一个团队信息
- // var $select = $(".lin-sel-group li").eq(activeIndex);
- // var code = $select.attr("data-code");
- // $(".lin-sel-group li").removeClass("checked");
- // $select.addClass("checked");
- // $("#Dtitle").html($select.find("label").html()).attr("data-index",code);
- // })
-
- })
- .then(function() {
- reference = baseEnv.webview.reference || 0;
- type = baseEnv.webview.type;
- prepareData();
- initArticleType();
- bindEvents();
- })
- .catch(function(e) {
- plus.nativeUI.closeWaiting();
- console && console.error(e);
- })
- window.addEventListener("refresh2", function(event){
- $(".lin-sel-group li").eq(activeIndex).trigger("click");
- })
|