//选择居委会 jwcode基卫 id:committee
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,
jwcountryCode,
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()
}
})
}
$true.hide();
$false.show();
})
//请求数据
function queryAddrFailed() {
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()
}
})
})
//街道
$('#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()
}
})
})
//居委会
$('#village').on('click','li',function(){
var $this = $(this);
changeList($('#village'),$this);
countryCode = $this.attr('data-code');
jwcountryCode = $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');
$('#committee').val(countryName);
$('#committee').attr('data-code',countryCode);
$('#committee').attr('data-jwcode',jwcountryCode);
})
function changeList($next,$li){
$li.addClass('active').siblings().removeClass('active');
$list.hide();
$next.show();
}
}
}