123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077 |
- //家庭医生咨询分页参数
- var id = 0;
- var pageSize = 15;
- //续方咨询分页参数
- var xfId = 0;
- var xfPageSize = 15;
- var d = dialog({contentType:'load', skin:'bk-popup'});
- var patientcode ="";
- var isSearch = false;
- var userAgent = window.localStorage.getItem(agentName);
- var scroller1 = null;
- var pagetype=1;
- var chooseType;
- //页面初始化
- $(function(){
- initData();
- })
- //初始化数据
- var initData = function(){
- initScroller();
- checkUserAgent();
- bindEvents();
- },
- //初始化滚动条
- initScroller = function(){
- scroller1 = new IScrollPullUpDown('wrapper5',{
- probeType:2,
- bounceTime: 250,
- bounceEasing: 'quadratic',
- mouseWheel:false,
- scrollbars:true,
- click:true,
- fadeScrollbars:true,
- interactiveScrollbars:false
- },pullDownAction,pullUpAction);
- },
- //绑定事件
- bindEvents = function(){
- //新增按钮事件
- $(".div-add-btn").on("click",function(){
- $(this).hide();
- var data={};
- sendPost('patient/baseinfo', data, 'json', 'post', queryFailed, queryNewSuccess);
- });
-
- //点击遮罩事件
- $(".modal-overlay").on("click",function(){
- $(".modal-overlay").removeClass("modal-overlay-visible");
- $(".div-dialog-content").hide();
- $(".div-add-btn").removeClass("active");
- $(".div-add-btn").show();
- });
-
- //点击三师共管事件
- $(".sanshi-icon").on("click",function(){
- $(this).addClass("active");
- querySignType(1);
- // checkInWork(1);
- // isunfinished(1);
- });
-
- //点击家庭医生事件
- $(".jiating-icon").on("click",function(){
- $(this).addClass("active");
- querySignType(2);
- // checkInWork(2);
- // isunfinished(2);
- });
-
- //点击名医咨询事件
- $(".mingyi-icon").on("click",function(){
- $(this).addClass("active");
- checkInWork(6);
- // isunfinished(6);
- });
-
- //查看签约
- $('#signing-btn').on('click',function(){
- window.location.href = "../../qygl/html/signing_management.html";
- })
-
- //取消事件
- $(".quxiao").on("click",function(){
- $(".modal-overlay").trigger("click");
- });
-
- //点击发起咨询事件
- $("#launch-btn").on("click",function(){
- $(".div-add-btn").trigger("click");
- });
-
- //点击续方申请事件
- $(".xufangsq-icon").on("click",function(){
- $(this).addClass("active");
- //TODO 事件处理
-
- });
-
- $(".c-lab-mor li").click(function() {
- var index = $(this).index();
- $(".c-lab-mor li").removeClass("hit");
- $(this).addClass("hit");
- if(index==0){//家庭医生咨询
- $(".div-jiating-consultation").show();
- $(".div-xufang-consultation").hide();
- }else{//续方咨询
- $(".div-jiating-consultation").hide();
- $(".div-xufang-consultation").show();
- }
- });
-
- document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
- },
- //重写判断用户是否登录
- checkUserAgent = function(){
- if(!userAgent){
- var agentOpenid = window.localStorage.getItem(OpenidAgent);
- if(!agentOpenid){
- var Request = new Object();
- Request = GetRequest();
- var code = Request["code"];
- if(code == "" || code == null || code == undefined){
- d.close();
- dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'授权失败'}).show();
- }
- else{
- d.show();
- var data = {};
- data.code = code;
- sendPost('weixin/getOpenidByCode', data, 'json', 'post', openidFailed, openidSuccess);
- }
- }
- else{
- var jsonstr = $.parseJSON(agentOpenid);
- var openid = jsonstr.openid;
- window.location.href = server + "wx/html/home/html/zhmm-login.html?type=" + pagetype + "&openid=" + openid;
- }
- }
- else{
- appendFamilyMember($('#memberContainer'),function(){
- if($(".c-lab-mor li.hit").index()==0){//家庭医生咨询
- $("#ul_jiating_consultation").empty();
- id=0;
- $(".div-no-search-info").hide();
- $(".div-no-info").hide();
- $(".div-signing").hide();
- $(".div-no-sign").hide();
- $(".div-jiating-consultation").find('.inp-search').val('');
- }else if($(".c-lab-mor li.hit").index()==1){//续方咨询
- $("#ul_xufang_consultation").empty();
- xfId=0;
- $(".div-no-xf-search-info").hide();
- $(".div-xufang-consultation").find('.inp-search').val('');
- }
- pageInit();
- },function(){
- //判断有授权家人,修改样式
- if($('#memberContainer').is(':hidden')){
- $('#wrapper5').css('top','0px');
- }else{
- $('#wrapper5').css('top','90px');
- $('#nozixunimg').css('margin-top','230px');
- $('#fazixunimg').css('margin-top','190px');
- $('#nodoctor').css('margin-top','190px');
- $('#signingimg').css('margin-top','180px');
- }
- });
- pageInit();
- }
- },
- pageInit = function(){
- Request = GetRequest();
- $(".main").hide();
- $(".div-no-sign").hide();
- $(".div-no-info").hide();
- var openid = Request["openid"];
- var userInfo = null;
- var userAgent = window.localStorage.getItem(agentName);
- if(userAgent){
- userInfo= JSON.parse(userAgent);
- patientcode = userInfo.represented?userInfo.represented:userInfo.uid;
- }
- query();
- checkSignDoctor();
- var params = {};
- params.pageUrl = window.location.href;
- $.ajax(server + "weixin/getSign", {
- data: params,
- dataType: "json",
- type: "post",
- success: function(res){
- if (res.status == 200) {
- var t = res.data.timestamp;
- var noncestr = res.data.noncestr;
- var signature = res.data.signature;
- wx.config({
- //debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
- appId: appId, // 必填,公众号的唯一标识
- timestamp: t, // 必填,生成签名的时间戳
- nonceStr: noncestr, // 必填,生成签名的随机串
- signature: signature,// 必填,签名,见附录1
- jsApiList: [
- 'closeWindow'
- ] // 必填,需要使用的JS接口列表,所有JS接口列表见附录2
- });
- }
- }
- });
- },
- //查询家庭医生咨询记录
- consultRecord = function(){
- var data = {};
- data.id = id;
- data.pagesize = pageSize;
- data.title = $(".div-jiating-consultation").find(".inp-search").val();
- sendPost('patient/consult/records', data, 'json', 'get', queryFailed, queryRecordSuccess);
- },
- //查询家庭医生咨询记录成功处理
- queryRecordSuccess = function(res){
- if (res.status == 200) {
- $(".main").show();
- $(".div-no-info").hide();
- if (res.list.length > 0) {
- var list = res.list;
- var $list = $("#ul_jiating_consultation");
- var $liList = "";
- $('#vertical_line').show();
- var searchText = $(".div-jiating-consultation").find(".inp-search").val().trim();
- for (var i = 0; i < list.length; i++) {
- if(list[i].type==1){
- appendSsDoc(list[i],$list);
- }else if(list[i].type==2){
- appendHomeDoc(list[i],$list);
- }else if(list[i].type==6){
- appendMingyiDoc(list[i],$list);
- }
- id = list[i].id;
- }
- $("#ul_jiating_consultation li").on("tap",function(){
- var code = this.getAttribute("data-code");
- var type = this.getAttribute("data-type");
- var doctor = this.getAttribute("data-doctor");
- var evaluate = this.getAttribute("data-evaluate");
- var userInfo = JSON.parse(userAgent);
- var jsonData = JSON.parse(this.getAttribute("data-json"));
- if(jsonData.type == 2 && jsonData.status == 0){
- var url = "patient/sign_status",
- params = {};
- d.show();
- sendPost(url, params, "json", "post", queryFailed, function(res){
- d.close();
- var teamCode = res["teamCode_2"];
- var signCode = res["signCode_2"];
- localStorage.setItem("signInfo_tab", "1");
- window.location.href = "../../qygl/html/sign_info.html?code="+signCode+"&consult="+code+"&teamCode="+jsonData.teamCode+"&type="+jsonData.type+"&doctor="+jsonData.doctorCode;
- });
- }else{
- localStorage.setItem("evaluate",evaluate);
- window.location.href = "consulting-doctor.html?consult=" + code+"&type="+type+"&toUser="+userInfo.uid+"&doctor="+doctor;
- }
- })
-
- ellipsisText($(".ul-consultation").find('.c-content-warp'),searchText);
- scroller1.myScroll.refresh();
-
- } else {
- $('#vertical_line').hide();
- if(isSearch){//查询无结果
- $(".main").show();
- $('#ul_jiating_consultation').show();
- $(".div-no-search-info").show();
- isSearch = false;
- }else if(id==0){//id为0的时候证明是第一次加载,第一次加载无数据,显示无数据界面
- $(".main").hide();
- $(".div-no-info").show();
- }else {
- dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'无更多数据'}).show();
- }
- }
- d.close();
- $(".pullUp").hide();
- } else {
- queryFailed(res);
- }
- },
- //查询续方咨询记录
- xfConsultRecord = function(){
- var data = {};
- data.id = xfId;
- data.pagesize = xfPageSize;
- data.title = $(".div-xufang-consultation").find(".inp-search").val();
- sendPost('patient/consult/records', data, 'json', 'get', queryFailed, xfQueryRecordSuccess);
- },
- //查询家庭医生咨询记录成功处理
- xfQueryRecordSuccess = function(res){
- if (res.status == 200) {
- $(".main").show();
- $(".div-no-info").hide();
- if (res.list.length > 0) {
- var list = res.list;
- var $list = $("#ul_xufang_consultation");
- var $liList = "";
- $('#xf_vertical_line').show();
- var searchText = $(".div-xufang-consultation").find(".inp-search").val().trim();
- for (var i = 0; i < list.length; i++) {
- appendXuFangDoc(list[i],$list);
- xfId = list[i].id;
- }
- $("#ul_xufang_consultation li").on("tap",function(){
- var code = this.getAttribute("data-code");
- var type = this.getAttribute("data-type");
- var doctor = this.getAttribute("data-doctor");
- var evaluate = this.getAttribute("data-evaluate");
- var userInfo = JSON.parse(userAgent);
- var jsonData = JSON.parse(this.getAttribute("data-json"));
- if(jsonData.type == 2 && jsonData.status == 0){
- var url = "patient/sign_status",
- params = {};
- d.show();
- sendPost(url, params, "json", "post", queryFailed, function(res){
- d.close();
- var teamCode = res["teamCode_2"];
- var signCode = res["signCode_2"];
- localStorage.setItem("signInfo_tab", "1");
- window.location.href = "../../qygl/html/sign_info.html?code="+signCode+"&consult="+code+"&teamCode="+jsonData.teamCode+"&type="+jsonData.type+"&doctor="+jsonData.doctorCode;
- });
- }else{
- localStorage.setItem("evaluate",evaluate);
- window.location.href = "prescription-consulting.html?consult=" + code+"&type="+type+"&toUser="+userInfo.uid+"&doctor="+doctor;
- }
- })
-
- ellipsisText($(".xf-ul-consultation").find('.c-content-warp'),searchText);
- scroller1.myScroll.refresh();
-
- } else {
- $('#xf_vertical_line').hide();
- if(isSearch){//查询无结果
- $(".main").show();
- $('#ul_xufang_consultation').show();
- $(".div-no-xf-search-info").show();
- isSearch = false;
- }else if(xfId==0){//xfId为0的时候证明是第一次加载,第一次加载无数据,显示无数据界面
- $(".main").hide();
- $(".div-no-info").show();
- }else {
- dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'无更多数据'}).show();
- }
- }
- d.close();
- $(".pullUp").hide();
- } else {
- queryFailed(res);
- }
- },
- //拼接家庭咨询
- appendHomeDoc = function(rowData,$list){
- //默认咨询结束状态div-ended//待评价div-novalue
- var divStatus = "";
- if(rowData.status==0){
- //咨询中
- divStatus = "div-beginning";
- }else if(rowData.evaluate ==1){
- divStatus = "div-hasvalue";//是否有评价 0无 1有
- }else{
- divStatus = "div-novalue";
- }
-
- var $li = document.createElement("li");
- $li.setAttribute('data-code', rowData.code);
- $li.setAttribute('data-type', rowData.type);
- $li.setAttribute('data-evaluate', rowData.evaluate ? rowData.evaluate :0);
- $li.setAttribute('data-doctor', rowData.doctorCode);
- $li.setAttribute('data-json', JSON.stringify(rowData));
- var content = '<div class="outer-circle">'+
- '<div class="inner-circle s-bc-12B7F5"></div>'+
- '</div>'+
- '<div class="'+divStatus+'"></div>'+
- '<div class="record-card">'+
- '<div class="card-title s-bc-12B7F5">'+
- '<span class="span-date">'+rowData.czrq+'</span>'+
- '<span class="f-fr">家庭医生咨询</span>'+
- '</div>'+
- '<p class="c-content-warp">'+
- '<span class="c-323232 c-f14 ">问题:</span><span class="c-dest-content c-f14 j-text-ellipsis" data-text="'+rowData.symptoms+'"></span>'+
- '</p>'+
- '</div>';
- $li.innerHTML=content;
- $list.append($li);
- },
- //拼接续方咨询
- appendXuFangDoc = function(rowData,$list){
- //默认咨询结束状态div-ended//待评价div-novalue
- var divStatus = "";
- if(rowData.status==0){
- //咨询中
- divStatus = "div-beginning";
- }else if(rowData.evaluate ==1){
- divStatus = "div-hasvalue";//是否有评价 0无 1有
- }else{
- divStatus = "div-novalue";
- }
-
- var $li = document.createElement("li");
- $li.setAttribute('data-code', rowData.code);
- $li.setAttribute('data-type', rowData.type);
- $li.setAttribute('data-evaluate', rowData.evaluate ? rowData.evaluate :0);
- $li.setAttribute('data-doctor', rowData.doctorCode);
- $li.setAttribute('data-json', JSON.stringify(rowData));
- var content = '<div class="outer-circle">'+
- '<div class="inner-circle s-bc-12B7F5"></div>'+
- '</div>'+
- '<div class="'+divStatus+'"></div>'+
- '<div class="record-card">'+
- '<div class="card-title s-bc-12B7F5">'+
- '<span class="span-date">'+rowData.czrq+'</span>'+
- '<span class="f-fr">续方咨询</span>'+
- '</div>'+
- '<p class="c-content-warp div-xufang-disease">'+
- '<span class="c-dest-content c-f14 j-text-ellipsis" data-text="'+rowData.symptoms+'"></span>'+
- '</p>'+
- '<div class="div-content-warp">'+
- '<div class="div-drug">'+
- '药品1 数量'+
- '</div>'+
- '<div class="div-drug">'+
- '药品2 数量'+
- '</div>'+
- '</div>'+
- '</div>';
- $li.innerHTML=content;
- $list.append($li);
- },
- //拼接三师咨询
- appendSsDoc = function(rowData,$list){
- //默认咨询结束状态
- var divStatus = "div-ended";
- if(rowData.status==0){
- //咨询中
- divStatus = "div-beginning";
- }
- var $li = document.createElement("li");
- $li.setAttribute('data-code', rowData.code);
- $li.setAttribute('data-type', rowData.type);
- $li.setAttribute('data-doctor', rowData.doctorCode);
- $li.setAttribute('data-json', JSON.stringify(rowData));
- var content = '<div class="outer-circle">'+
- '<div class="inner-circle s-bc-75BF00"></div>'+
- '</div>'+
- '<div class="'+divStatus+'"></div>'+
- '<div class="record-card">'+
- '<div class="card-title s-bc-75BF00">'+
- '<span class="span-date">'+rowData.czrq+'</span>'+
- '<span class="f-fr">慢病管理咨询</span>'+
- '</div>'+
- '<p class="c-content-warp">'+
- '<span class="c-323232 c-f14 ">问题:</span><span class="c-dest-content c-f14 j-text-ellipsis" data-text="'+rowData.symptoms+'"></span>'+
- '</p>'+
- '</div>';
- $li.innerHTML=content;
- $list.append($li);
- },
- //拼接名医咨询
- appendMingyiDoc = function(rowData,$list){
- //默认咨询结束状态
- var divStatus = "div-ended";
- if(rowData.status==0){
- //咨询中
- divStatus = "div-beginning";
- }
- var $li = document.createElement("li");
-
- $li.setAttribute('data-doctor', rowData.doctorCode);
- $li.setAttribute('data-code', rowData.code);
- $li.setAttribute('data-type', rowData.type);
- $li.setAttribute('data-json', JSON.stringify(rowData));
- var content = '<div class="outer-circle">'+
- '<div class="inner-circle s-bc-FF9526"></div>'+
- '</div>'+
- '<div class="'+divStatus+'"></div>'+
- '<div class="record-card">'+
- '<div class="card-title s-bc-FF9526">'+
- '<span class="span-date">'+rowData.czrq+'</span>'+
- '<span class="f-fr">名医咨询</span>'+
- '</div>'+
- '<p class="c-content-warp">'+
- '<span class="c-323232 c-f14 ">问题:</span><span class="c-dest-content c-f14 j-text-ellipsis" data-text="'+rowData.symptoms+'"></span>'+
- '</p>'+
- '</div>';
- $li.innerHTML=content;
- $list.append($li);
- },
- //下拉刷新
- pullDownAction = function(theScrollerTemp){
- // setTimeout(function () {
- // $("#ul_jiating_consultation").html("");
- // id=0;
- // consultRecord();
- // }, 1000);
- }
- //上拉加载数据
- pullUpAction = function(theScrollerTemp){
- $(".pullUp").show();
- setTimeout(function () {
- if($(".c-lab-mor li.hit").index()==0){//家庭医生咨询
- consultRecord();
- }else if($(".c-lab-mor li.hit").index()==1){//续方咨询
- xfConsultRecord();
- }
- }, 1000);
- }
- //查询用户信息
- query = function(){
- d.show();
- var data={};
- sendPost('patient/baseinfo', data, 'json', 'post', queryUserFailed, querySuccess);
- },
- //校验手机是否签约
- checkSignDoctor = function(){
- d.show();
- var userAgent = window.localStorage.getItem(agentName);
- if(userAgent){
- var data = {};
- $.ajax(server + "patient/is_sign", {
- data: data,
- type: 'POST',
- dataType: 'json',
- beforeSend: function(request) {
- request.setRequestHeader("userAgent", userAgent);
- },
- error: function(res) {
- $(".pullUp").hide();
- d.close();
- if(res.status == 999 || res.status == 998 || res.status == 997){
- loginUrl(res.status);
- return;
- }
- dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'校验失败'}).show();
- },
- success: function(res) {
- d.close();
- if(res.status == 999 || res.status == 998 || res.status == 997){
- loginUrl(res.status);
- }
- else if (res.status == 200) {
- var is_sign = res.data;//0未签约,1已签约
- if(is_sign==1 || is_sign <= -1){//1已经签约的 -1签约已到期或未签约
- consultRecord();
- xfConsultRecord();
- }else if(is_sign==0){
- //签约未完成
- $('.div-signing').show();
- }
- }
- else {
- //不为200
- $(".pullUp").hide();
- dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:res.msg}).show();
- }
- }
- })
- }
- else{
- $(".pullUp").hide();
- dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'用户信息错误'}).show();
- }
- },
- //查询用户成功
- querySuccess = function(res){
- if (res.status == 200) {
- var data = res.data;
- var ssc = data.ssc;
- if(!ssc) ssc = "";
- if(!ssc || ssc==""){
- //用户未办理医保卡
- dialog({
- content: '对不起,尚未办理医保卡或在16年6月份之后办理医保卡的用户暂不支持签约~',
- cancelValue: '我知道了',
- cancel: function () {
- wx.closeWindow();
- }
- }).showModal();
- }else{
- return;
- }
- } else {
- queryFailed(res);
- }
- },
- //查询用户失败
- queryUserFailed = function(res){
- dialog({
- content: '获取用户信息失败!',
- cancelValue: '我知道了',
- cancel: function () {
- wx.closeWindow();
- }
- }).showModal();
- },
- //查询失败提示
- queryFailed = 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();
- }
- },
- //查询患者基本信息成功处理
- queryNewSuccess = function(res){
- if(res.status == 200){
- var data = res.data;
- if(data.sign ==0){//未签约一般不会发生进来咨询意见校验
- dialog({
- content: '您还没有签约家庭医生哦,<br/>快去寻找属于您的家庭医生吧~',
- okValue:'前往签约',
- ok: function (){
- window.location.href = "../../qygl/html/signing_management.html";
- },
- cancelValue: '我知道了',
- cancel: function () {
- $(".div-add-btn").show();
- // wx.closeWindow();
- }
- }).showModal();
- }
- else if(data.sign ==1 || data.sign ==2 || data.sign ==3){//1三师签约 2家庭签约 3三师+家庭
- $(this).hide();
- $(".div-dialog-content").show();
- $(".modal-overlay").addClass("modal-overlay-visible");
- if(data.sign ==1){//1三师签约
- $(".jiating-icon").hide();
- $(".sanshi-icon").addClass("sanshi-icon1");
- }else if(data.sign ==2){//家庭签约
- $(".sanshi-icon").hide();
- }
- }else{
- queryFailed(res);
- }
- }
- }
- //获取签约医生
- checkInWork = function(type){
- if(type==6){//名医咨询
- window.location.href = "select-consult-doctor.html";
- } else {
- sendPost('/patient/sign_doctors', {patientCode:patientcode}, 'json', 'post', queryFailed, function(res){
- if(res.status==200){
- var doctorArray = res.familyDoctors;//家庭
- if(type==1&&doctorArray.length==0){//三师
- doctorArray = res.teamDoctors
-
- }
- if(doctorArray.length==0){
- doctorArray = res.teamDoctors
- }
- if(doctorArray){
- var doctorInfo ="",
- qkDoctor="";
- for(var j in doctorArray){
- var dataTemp = doctorArray[j];
- if(dataTemp.level=="3" || dataTemp.teamlevel=="3"){
- doctorInfo = dataTemp;//取出健康管理师
- }
- if(dataTemp.level == "2" || dataTemp.teamlevel=="2"){
- qkDoctor = dataTemp; //取出全科医生
- }
- }
- if(!doctorInfo){
- doctorInfo = qkDoctor;
- }
- if(doctorInfo!=""){
- checkDocInWork(type,doctorInfo);
- }else{
- //三师咨询或家庭签约咨询,跳转到新增咨询页面
- window.location.href = "add-consult.html?type="+type;
- }
- }
- }else{
- queryFailed(res);
- }
- })
- }
- }
- //判断医生是否在工作时间内
- checkDocInWork = function(type,doctor){
- sendPost('patient/consult/is_doctor_working', {doctor:doctor.code}, 'json', 'get', queryFailed, function(res){
- if(res.status==200){
- if(res.data==2){
- dialog({
- content: '您好,由于您的签约医生工作繁忙,设置了每日回复咨询的时间段,所以,在该时间段外的时间,您的咨询将不会马上获得医生的回复。',
- okValue:'查看医生工作时间',
- ok: function (){
- window.location.href = "doctor-work-hours.html?doctor=" + doctor.code;
- },
- cancelValue: '继续新增咨询',
- cancel: function () {
- window.location.href = "add-consult.html?type=" +type+"&doctorCode="+doctor.code;
- }
- }).showModal();
- }
- /* 解决bug2825,家庭医生咨询不做是否接受咨询的判断
- else if(res.data==0){//医生不接受咨询
- dialog({
- content: '对不起,该医生暂时关闭了咨询功能,<br/>暂时无法咨询该医生',
- cancelValue: '我知道了',
- cancel: function () {
- wx.closeWindow();
- }
- }).showModal();
- }*/
- else{
- //三师咨询或家庭签约咨询,跳转到新增咨询页面
- window.location.href = "add-consult.html?type="+type+"&doctorCode="+doctor.code;
- }
- }else{
- queryFailed(res);
- }
- })
- },
- //判断咨询是否结束
- isunfinished = function(type){
- sendPost('/patient/consult/unfinished', {}, 'json', 'get', queryFailed, function(res){
- if(res.status===200){
- if(res.data.length<=0){//无咨询记录
- checkInWork(type);
- }else{
- var isMax = false;
- var consult = null;
- for(var j in res.data){
- if(type == res.data[j].type){
- consult = res.data[j].consult;
- isMax = true;
- }
- }
- if(isMax){//三师咨询或家庭签约咨询或名医咨询
- dialog({
- content: '十分抱歉,您的上一次咨询<br/>还未结束,所以不能再发起新的咨询哦',
- okValue:'前往查看',
- ok: function (){
- var rep = userInfo.represented?userInfo.represented:userInfo.uid;
- window.location.href = "consulting-doctor.html?consult=" + consult+"&toUser="+rep;
- },
- cancelValue: '我知道了',
- cancel: function () {
- $(".modal-overlay").trigger("click");
- $(".sanshi-icon").removeClass("active");
- $(".jiating-icon").removeClass("active");
- $(".mingyi-icon").removeClass("active");
- return;
- }
- }).showModal();
- }else{
- if(type==6){//名医咨询
- window.location.href = "select-consult-doctor.html";
- }else{//三师咨询或家庭签约咨询,跳转到新增咨询页面
- alert(2)
- window.location.href = "add-consult.html?type="+type;
- }
- }
-
- }
- }else{
- queryFailed(res);
- }
-
- });
- },
- //查询签约类型
- querySignType = function(type){
- chooseType = type;
- d.show();
- sendPost('patient/sign_doctors', {}, 'json', 'post', querySignTypeFailed, querySignTypeSuccess);
- },
- //查询签约类型失败处理
- querySignTypeFailed = 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();
- }
- },
- //查询签约类型成功处理
- querySignTypeSuccess = function(data){
- if (data.status == 200) {
- var doctors = "";
- switch(Number(chooseType)) {
- case 1: doctors = data.teamDoctors; break;
- case 2: doctors = data.familyDoctors; break;
- default: break;
- }
-
- var docInfo,docQkInfo;
- $.each(doctors, function(i, v) {
- if(v.teamlevel){
- if(v.teamlevel == 3){
- docInfo = v;
- }
- if(v.teamlevel == 2){
- docQkInfo = v;
- }
- }else{
- if(v.level == 3){
- docInfo = v;
- }
- if(v.level == 2){
- docQkInfo = v;
- }
- }
- });
-
- if(!docInfo){
- docInfo = docQkInfo;
- }
-
- sendPost('patient/consult/is_consult_unfinished', {doctor: docInfo ? docInfo.code : docQkInfo.code}, '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 == ""){
- //不存在
- checkInWork(chooseType);
- } else {
- dialog({
- content: '十分抱歉,您与'+ docInfo.name +'医生还有<br/>未结束咨询,无法发起新的咨询',
- okValue:'前往查看',
- ok: function (){
- 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();
- }
- }
- );
- } else {
- querySignTypeFailed(res);
- }
- };
- // 搜索框
- var $searchbar = $('.searchbar'),
- // 搜索输入框
- $searchbarInput = $('.searchbar input'),
- // 搜索取消按钮
- $searchCancelBtn = $('.searchbar-cancel'),
- // 家庭医生咨询-搜索框下面悬浮的搜索提示
- $searchSuggest = $('#search_suggest_text');
- // 续方咨询-搜索框下面悬浮的搜索提示
- $xfSearchSuggest = $('#xf_search_suggest_text');
- // 搜索框初始化
- $searchbar.addClass("searchbar-active");
-
- // 控制搜索关键字悬浮提示的显示
- var 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();
- // 开启示例数据
- //resolve({});
- }
- , function success(req) {
- resolve(req);
- });
- });
- },
- showSearchSuggest = function(text) {
- var suggestText = '搜索“'+text+'”';
- // 如果text不为空,则显示;否则隐藏
- if(text&&text.trim().length) {
- if($(".c-lab-mor li.hit").index()==0){//家庭医生咨询
- $searchSuggest.text(suggestText);
- $searchSuggest.show();
- }else if($(".c-lab-mor li.hit").index()==1){//续方咨询
- $xfSearchSuggest.text(suggestText);
- $xfSearchSuggest.show();
- }
- } else {
- if($(".c-lab-mor li.hit").index()==0){//家庭医生咨询
- $searchSuggest.text('');
- $searchSuggest.hide();
- }else if($(".c-lab-mor li.hit").index()==1){//续方咨询
- $xfSearchSuggest.text('');
- $xfSearchSuggest.hide();
- }
- }
- },
- getRowProps = function ($el) {
- var $textEllipsis = $el.find('.j-text-ellipsis'),
- $text = $textEllipsis.eq(0),
- $chart = $text.text('a'),
- enWidth = $chart.width(),
- $chart = $text.text('中'),
- zhWidth = $chart.width(),
- lineHeight = parseFloat($chart.css("lineHeight"), 10),
- rowHeight = $chart.height();
- $chart.text('');
- return {
- chartWidth: {
- zh: zhWidth,
- en: enWidth
- },
- rowHeight: Math.max(rowHeight, lineHeight),
- rowWidth: $el.width()
- };
- },
- replaceAll = function (text, arr) {
- var html = text;
- _.each(arr,function(kw) {
- var reg = new RegExp(kw+"(?!>)","gi");
- html = html.replace(reg,'<em>'+kw+'</em>');
- });
- return html;
- },
- highlineKeyword = function ($el,searchText) {
- var props = getRowProps($el),
- chartWidth = props.chartWidth,
- rowHeight = props.rowHeight,
- rowWidth = props.rowWidth,
- // 每行显示字符数(以中文字符为标准计算)
- chartNum = Math.floor(rowWidth / chartWidth.zh),
- // 排除“咨询问题:”字符及前后“...”所占宽度
- exceptNum = 5,
- // 行数
- rowNum = 3,
- // 预计显示总字符数
- expectedNum = chartNum * rowNum - exceptNum,
- $target = $el.find('.j-text-ellipsis'),
- // 目标文本
- text = $target.attr('data-text').trim(),
- length = text.length,
- // 关键字数组
- kws = searchText.trim().replace(/\s+/g," ").split(" ");
-
- var fidx = 0,preFidx,diff = 0;
- $target.html(replaceAll(text, kws));
- if(Math.floor($target.height() / rowHeight) <= rowNum) {
- return ;
- }
- if(text.length > expectedNum) {
- fidx = text.indexOf(kws[0])+kws[0].length-1;
- diff = fidx - expectedNum + 1;
- preFidx = fidx;
- diff = (diff<0)?0:diff;
- var preChar = (diff>0)?"...":"";
- $target.html(preChar+replaceAll(text.slice(diff,preFidx+1), kws)+"...");
- while((Math.floor($target.height() / rowHeight) <= rowNum) && (preFidx < length)) {
- preFidx++;
- $target.html(preChar+replaceAll(text.slice(diff,preFidx+1), kws)+"...");
- }
- if(preFidx == length && (Math.floor($target.height() / rowHeight) <= rowNum)) {
- diff = diff>0?(diff - 1):0;
- $target.html(preChar+replaceAll(text.slice(diff,preFidx), kws));
- } else if((Math.floor($target.height() / rowHeight) > rowNum)) {
- $target.html(preChar+replaceAll(text.slice(diff,preFidx), kws)+"...");
- }
- }
- },
- ellipsisText = function ($elements, searchText) {
- //$el.ellipsis({ row: 2});
- _.each($elements,function(el) {
- highlineKeyword($(el),searchText)
- });
- },
- // 搜索框搜索执行方法
- search = function () {
- isSearch = true;
- d.show();
- if($(".c-lab-mor li.hit").index()==0){//家庭医生咨询
- $searchSuggest.text('');
- $searchSuggest.hide();
- }else if($(".c-lab-mor li.hit").index()==1){//续方咨询
- $xfSearchSuggest.text('');
- $xfSearchSuggest.hide();
- }
- $searchCancelBtn.hide();
- $searchCancelBtn.css("opacity","0");
- $(".c-lab-mor li.hit").index()==0?$("#ul_jiating_consultation").html(""):$("#ul_xufang_consultation").html("");
- if($(".c-lab-mor li.hit").index()==0){//家庭医生咨询
- id=0;
- consultRecord();
- }else if($(".c-lab-mor li.hit").index()==1){//续方咨询
- xfId=0;
- xfConsultRecord();
- }
-
- $(".div-no-info").hide();
- $(".div-no-search-info").hide();
- $(".div-no-sign").hide();
- $(".c-lab-mor li.hit").index()==0?$('#ul_jiating_consultation').show():$('#ul_xufang_consultation').show();
- },
- // 重置搜索结果的容器高度(为了让滚动条出现在容器内部,而不引起外部内容滚动)
- resetResultWrapHeight = function() {
- var winHeight = $(window).height(),
- diff = 45,
- $wrap = $('.div-content');
- $wrap.height(winHeight-diff);
- },
- // 监听窗口大小变化,重置所属区列表、社区列表列表容器高度
- resultWrapAutoAdapt = function() {
- resetResultWrapHeight();
- $(window).on('resize',function() {
- resetResultWrapHeight();
- });
- };
-
- //取消事件
- $searchCancelBtn.on('click',function() {
- $(this).hide();
- $('.inp-search').val('');
- if($(".c-lab-mor li.hit").index()==0){//家庭医生咨询
- $searchSuggest.text('');
- $searchSuggest.hide();
- }else if($(".c-lab-mor li.hit").index()==1){//续方咨询
- $xfSearchSuggest.text('');
- $xfSearchSuggest.hide();
- }
- search();
- });
-
- $searchSuggest.on('click',function() {
- search();
- });
- $xfSearchSuggest.on('click',function() {
- search();
- });
- //搜索框事件
- $(".inp-search").on("input",function(){
- var text = $(this).val().trim();
- if($(".c-lab-mor li.hit").index()==0){//家庭医生咨询
- $('#ul_jiating_consultation').hide();
- $('#vertical_line').hide();
- }else if($(".c-lab-mor li.hit").index()==1){//续方咨询
- $('#ul_xufang_consultation').hide();
- $('#xf_vertical_line').hide();
- }
-
- showSearchSuggest(text);
- if(text){
- $searchCancelBtn.show();
- $searchCancelBtn.css("opacity","1");
- }else{
- $searchCancelBtn.hide();
- $searchCancelBtn.css("opacity","0");
- search();
- }
- }).on('keydown',function(e) {
- if (e.which === 13) {
- search();
- }
- })
-
|