//选择居委会 jwcode基卫的code 有直接提交功能 //
var ddd = dialog({contentType:'load', skin:'bk-popup',content:'数据提交中'}); function selectCommittee(){ var content = '
\
\
所属居委会
\
确定
\
取消
\ \
\
\
    \
    \
    \
    \
    \
      \
      \
      \
      \
      \
        \
        \
        \
        \
        '; $('body').append(content) nextWork() function nextWork(){ var $tit = $('#showTitle'), $sel0 = '
      • 请选择
      • ', $sel1='', $sel2='', $list = $('.md-wrapper'), $true = $('.md-bttn-true'), $false = $('.md-bttn-false'); var countryCode, jwcode, countryName; $('#selectType').click(function(){ mui('#sheet').popover('show'); if(!$tit.text().trim()){ $tit.html($sel0); var data={}; sendPost('patient/sign/getTownList', data, 'json', 'get', queryAddrFailed ,function(res){ if(res.status == 200){ var list=""; $.map(res.data,function(item,index){ list +='
      • '+item.name+'
      • '; }) $('#district').find('ul').empty().append(list); }else{ queryAddrFailed(res); } }) } $true.hide(); $false.show(); }) //请求数据 function queryAddrFailed(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(); } } mui('#village').scroll({ bounce: false //是否启用回弹 }).scrollTo(0,0,100); mui('#district').scroll({ bounce: false //是否启用回弹 }) mui('#town').scroll({ bounce: false //是否启用回弹 }).scrollTo(0,0,100); //区 $('#district').on('click','li',function(){ var $this = $(this); changeList($('#town'),$this); $true.hide(); $false.show(); $sel1 = '
      • '+$this.text()+'
      • '; $tit.html($sel1+$sel0); var data={ town:$this.data('code') }; sendPost('patient/sign/getStreetListByTown', data, 'json', 'get', queryAddrFailed ,function(res){ if(res.status == 200){ var list=""; $.map(res.data,function(item,index){ list +='
      • '+item.name+'
      • '; }) $('#town').find('ul').empty().append(list); }else{ queryAddrFailed(res); } }) }) //街道 $('#town').on('click','li',function(){ var $this = $(this); changeList($('#village'),$this); $true.hide(); $false.show(); $sel2 = '
      • '+$this.text()+'
      • '; $tit.html($sel1+$sel2+$sel0); var data={ street:$this.data('code') }; sendPost('patient/sign/getCountryListByStreet', data, 'json', 'get', queryAddrFailed ,function(res){ if(res.status == 200){ var list=""; if(res.data.length>0){ $.map(res.data,function(item,index){ list +='
      • '+item.name+'
      • '; }) }else{ } $('#village').find('ul').empty().append(list); }else{ queryAddrFailed(res); } }) }) //居委会 $('#village').on('click','li',function(){ var $this = $(this); changeList($('#village'),$this); countryCode = $this.attr('data-code'); jwcode = $this.attr('data-jwcode'); countryName = $this.text(); $true.show(); $false.hide(); }) $tit.on('click','li',function(){ var $this = $(this); if(! $this.hasClass('active')){ $this.addClass('active').siblings().removeClass('active'); $list.hide(); $list.eq($this.index()).show(); } }) //取消 $false.click(function(){ mui('#sheet').popover('hide'); }) //确定 $true.click(function(){ mui('#sheet').popover('hide'); ddd.show(); var data={ countryCode:countryCode }; sendPost('patient/sign/updatePatientCountry', data, 'json', 'get',function(){ ddd.close(); dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'保存失败'}).show(); },function(res){ if(res.status == 200){ ddd.close(); $('#committee').text(countryName); dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'保存成功'}).show(); }else{ ddd.close(); dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'保存失败'}).show(); } }) }) function changeList($next,$li){ $li.addClass('active').siblings().removeClass('active'); $list.hide(); $next.show(); } } } //清空选择 function clearCommittee(){ $('#showTitle').text(''); $('.md-wrapper').hide(); $('#district').show(); }