123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288 |
- var page = 1;
- var pageSize = 1000000;
- var d = dialog({contentType:'load', skin:'bk-popup'});
- var patientcode ="";
- var isSearch = false;
- // 搜索框
- var $searchbar = $('.searchbar'),
- // 搜索输入框
- $searchbarInput = $('.searchbar input'),
- // 搜索取消按钮
- $searchCancelBtn = $('.searchbar-cancel'),
- // 搜索框下面悬浮的搜索提示
- $searchSuggest = $('#search_suggest_text'),
- // 搜索结果展示容器
- $searchtResult = $('.div-content');
- // 搜索框初始化
- $searchbar.addClass("searchbar-active");
- var getReqPromise = null;
- var scroller1 = null;
- $(function(){
- //添加isrcoll
- scroller1 = new IScrollPullUpDown('wrapper2',{
- probeType:2,
- bounceTime: 250,
- bounceEasing: 'quadratic',
- mouseWheel:false,
- scrollbars:true,
- click:true,
- fadeScrollbars:true,
- interactiveScrollbars:false
- },pullDownAction);
-
- bindEvents();
- pageInit();
- })
- //下拉刷新
- function pullDownAction(theScrollerTemp) {
- setTimeout(function () {
- $(".c-list").html("");
- page=1;
- pageInit();
- }, 1000);
- }
-
- //上拉加载数据
- function pullUpAction(theScrollerTemp) {
- $(".pullUp").show();
- setTimeout(function () {
- page++;
- pageInit();
- }, 1000);
- }
- function pageInit(){
- d.show();
- var params = {};
- params.page = page;
- params.pagesize = pageSize;
- params.name = $(".inp-search").val();
- getReqPromise("patient/consult/famousDoctorList",params).then(function(data){
- if(data.status == 200){
- var rowData = data.list;
- if (rowData.length > 0) {
- var listResult = _.map(rowData,function(item,index){
- var countClass = "c-74bf00";
- var num = item.num || 0;
- var expertise = "";
- var job_name = "";
- var photo = item.photo;
- if(!photo){
- var photo = "../../../images/noSexDoctor.jpg";
- if(item.sex==1){
- photo = "../../../images/d-male.png";
- }else if(item.sex==2){
- photo = "../../../images/d-female.png";
- }
- }
- if(num==0){
- countClass = "c-FF6A56";
- }
- if(item.expertise){
- expertise = '<div class="c-f12 c-666666 mb10 pr10 pl10">'+
- '<span class="span-content">擅长:'+item.expertise || ""+'</span>'+
- '</div>';
- }
- if(item.job_name.trim()){
- job_name = '<span class="c-f14 c-666666 pl10">('+item.job_name+')</span>';
- }
- var content ='<li class="mt10" data-code="'+item.code+'" data-name="'+item.name+'" data-id="'+item.id+'">'+
- '<div class="n-list dr-item c-border c-100">'+
- '<div class="n-list-li">'+
- '<div class="n-list-key">'+
- '<div class="n-avatar-l img-round">'+
- '<img src="'+getImgUrl(photo)+'">'+
- '</div>'+
- '</div>'+
- '<div class="pl5">'+
- '<div>'+
- '<span class="c-f16 c-bold c-323232 search-target-text">'+item.name+'</span>'+
- job_name+
- '<span class="c-f14 '+countClass+' pl10" style="position: absolute;right: 10px;">剩余次数:'+num+'</span>'+
- ' </div>'+
- '<div class="c-f14 c-323232 pt5">'+
- '<span class="c-f14 c-323232 pr5">'+item.dept_name+'</span>'+
- '<span class="c-f14 c-323232">'+item.hospital_name+'</span>'+
- '</div>'+
- '</div>'+
- '</div>'+
- expertise+
- '</div>'+
- '</li>';
- id = item.id;
- return content;
- })
- $(".c-list").append(listResult);
- var kw = $(".inp-search").val();
- highlightKeyword(kw);
- scroller1.myScroll.refresh();
- }else {
- if(isSearch){//查询无结果
- $(".main").show();
- $(".div-content").hide();
- $(".div-no-search-info").show();
- $(".div-search-content").html("查无数据");
- isSearch = false;
- }else if(page==1){//page为1的时候证明是第一次加载,第一次加载无数据,显示无数据界面
- $(".main").hide();
- $(".div-no-search-info").show();
- $(".div-search-content").html("今天无名医坐诊哦,请改天再来~");
- }else {
- dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'无更多数据'}).show();
- }
- }
- } else {
- dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:data.msg}).show();
- }
- d.close();
- $(".pullUp").hide();
- });
- }
-
- function bindEvents(){
-
- $(".c-list").on("click","li",function(){
- d.show();
- var doctorCode = $(this).attr("data-code");
- var docName = $(this).attr("data-name");
- sendPost('patient/consult/is_consult_unfinished', {doctor: doctorCode}, 'json', 'post',
- function(res){
- d.close();
- 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();
- }
- }, function(res){
- d.close();
- if(res.status == 200){
- if(res.data == ""){
- window.location.href = "mingyi-homepage.html?doctorCode="+doctorCode;
- } else {
- dialog({
- content: '十分抱歉,您与'+ docName +'医生还有<br/>未结束咨询,无法发起新的咨询',
- okValue:'前往查看',
- ok: function (){
- var userAgent = window.localStorage.getItem(agentName);
- var userInfo = JSON.parse(userAgent);
- var rep = userInfo.represented?userInfo.represented:userInfo.uid;
- window.location.href = "consulting-doctor.html?consult=" + res.data +"&toUser="+rep;
- },
- cancelValue: '我知道了',
- cancel: function () {
- $(".modal-overlay").trigger("click");
- $(".sanshi-icon").removeClass("active");
- $(".jiating-icon").removeClass("active");
- $(".mingyi-icon").removeClass("active");
- return;
- }
- }).showModal();
- }
- } else {
- dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:res.msg}).show();
- }
- })
- })
-
- // 控制搜索关键字悬浮提示的显示
- getReqPromise = function(url, data) {
- return new Promise(function(resolve, reject) {
- sendPost(url, data, "json", "post",
- function queryFailed (req) {
- dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'加载失败'}).show();
- // TODO 开启示例数据
- //resolve({});
- }
- , function success(req) {
- resolve(req);
- });
- });
- }
-
- //取消事件
- $searchCancelBtn.on('click',function() {
- $(this).hide();
- $searchSuggest.text('');
- $searchSuggest.hide();
- $searchtResult.show();
- });
-
- $searchSuggest.on('click',function() {
- search();
- });
- //搜索框事件
- $(".inp-search").on("input",function(){
- var text = $(this).val().trim();
- $searchtResult.hide();
- showSearchSuggest(text);
- if(text){
- $searchCancelBtn.show();
- $searchCancelBtn.css("opacity","1");
- }else{
- $searchCancelBtn.hide();
- $searchCancelBtn.css("opacity","0");
- search();
- }
- })
-
- }
-
- var showSearchSuggest = function(text) {
- var suggestText = '搜索“'+text+'”';
- // 如果text不为空,则显示;否则隐藏
- if(text&&text.trim().length) {
- $searchSuggest.text(suggestText);
- $searchSuggest.show();
- } else {
- $searchSuggest.text('');
- $searchSuggest.hide();
- }
- },
- // 关键字高亮显示
- highlightKeyword = function(kw) {
- $searchTarget = $('.search-target-text');
- $searchTarget.hide();
- _.each($searchTarget,function(ele){
- var $ele = $(ele),
- text = $ele.text(),
- reg = new RegExp(kw+"(?!>)","gi"),
- html = text.replace(reg,'<em>'+kw+'</em>');
- $ele.html(html);
- });
- $searchTarget.show();
- },
- // TODO搜索框搜索执行方法
- search = function () {
- $(".div-no-search-info").hide();
- isSearch = true;
- $searchSuggest.text('');
- $searchSuggest.hide();
- $searchCancelBtn.hide();
- $searchCancelBtn.css("opacity","0");
- $searchtResult.show();
- $(".c-list").html("");
- id=0;
- pageInit();
- },
- // 重置搜索结果的容器高度(为了让滚动条出现在容器内部,而不引起外部内容滚动)
- resetResultWrapHeight = function() {
- var winHeight = $(window).height(),
- diff = 45,
- $wrap = $('.div-content');
- $wrap.height(winHeight-diff);
- },
- // 监听窗口大小变化,重置所属区列表、社区列表列表容器高度
- resultWrapAutoAdapt = function() {
- resetResultWrapHeight();
- $(window).on('resize',function() {
- resetResultWrapHeight();
- });
- };
-
-
-
|