var loading = dialog({contentType:'load', skin:'bk-popup'});
(function ($) {
    function Page(option) {
        this.init();
    }
    Page.prototype = {
        //初始化
        init: function () {
        	var $this = this
            this.initMenu($this);
        },
        //事件相关处理
        initEvent: function () {
            $('#service_list').on('click','.es-li',function(){
            	var $id = $(this).attr('data-id');
            	if($id == 1){
            		dialog({
					    content:'0592-6708090' ,
					    okValue:'立即拨号',
					    ok: function (){				            		
					      	window.location.href="tel:05926708090";
					    },
					    cancelValue: '不了，谢谢',
					    cancel: function () {
							return;
					    }
					 }).showModal();
            	}
            	if($id == 2){
            		window.location.href='medical-examination.html';
            	}
            	if($id == 3){
            		window.location.href='../../jmxj/html/jiankangxuanjiao.html';
            	}
            })
        },
        initMenu: function($this){
            sendPost("/patient/sign/service/getPatientService", '', "json", "get",function(){
            	loading.close();
            	dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'请求失败'}).show();
            }, function(res){
                loading.close();
                if(res.status == 200){
                  var dataList = res.data.serviceItem;
                  if(dataList && dataList.length>0){
                  	var html = template('list_tmp',{data:dataList})
                  	$('#service_list').html(html)
                  	$this.initEvent();
                  	$('.view').show()
                  }else{
                    window.location.href='./expectancy-page.html';
                  }
                }else{
                  dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'数据获取失败'}).show();
                }
            })
        }
    }

    $(document).ready(function () {
    	loading.show();
        var page = new Page();
    });

})(jQuery);