123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649 |
- //家庭医生咨询分页参数
- var id = 0;
- var pageSize = 15;
- //续方咨询分页参数
- var xfId = 0;
- var xfPageSize = 15;
- var d = dialog({contentType:'load', skin:'bk-popup'});
- var patientcode ="",
- patientName = "";
- //var isHealthSearch = false,
- // isPreSearch = false;
- var userAgent = window.localStorage.getItem(agentName);
- var pagetype = 1;
- var chooseType; //记录选择的咨询类型
- var loaded = [true, false]; //标记两个tab是否已经加载过
- var chooseTab = 1; //默认选中的是家庭健康咨询
- var expensesStatus ="";//'扣费状态 【""没有签约信息 "0"未扣费 "1"已扣费 "2"已退费】'
- var is_sign = 0;
- //页面初始化
- $(function(){
- checkUserAgent();
- // queryInit();
- });
- function queryInit(){
- // 验证居民信息是否完善
- checkBaseInfo()
-
- initScroller();
- initFamilyData();
- initPageData();
- bindEvents();
- wxGetSign();
- }
- function initScroller(){
- //阻尼系数
- var deceleration = mui.os.ios?0.003:0.0009;
- mui('.mui-scroll-wrapper1').scroll({
- scrollY: false, //是否竖向滚动
- scrollX: true, //是否横向滚动
- startX: 0, //初始化时滚动至x
- startY: 0, //初始化时滚动至y
- bounce: false,
- indicators: true, //是否显示滚动条
- deceleration:deceleration
- });
- mui.ready(function() {
- //循环初始化所有下拉刷新,上拉加载。
- $.each(document.querySelectorAll('.mui-slider-group .mui-scroll-wrapper'), function(index, pullRefreshEl) {
- mui(pullRefreshEl).pullRefresh({
- up: {
- callback: function() {
- var self = this;
- setTimeout(function() {
- if(index == 0){
- getHealthConsulationList(false);
- // }else{
- // getPreConsultList();
- }
- self.endPullupToRefresh();
- }, 1000);
- }
- }
- });
- });
- });
- }
- function initFamilyData(){
- appendFamilyMember($('#memberContainer'),function(){
- //切换家庭成员,默认选中健康咨询tab显示
- id = 0;
- xfId = 0;
- chooseType = 1;
- loaded = [true, false];
- $("#healthTab a").click();
- initPageData();
- },function(t){
- //判断有授权家人,修改样式,只在初始的时候执行一次
- var height = $('#memberContainer').height();
- $("#slider").css({
- 'top': height,
- 'height': 'calc(100% - '+height+'px)'
- });
- });
- }
- function initPageData(){
- // var userInfo= JSON.parse(userAgent);
- // patientcode = userInfo.uid;
-
- getPatientInfo();
- }
- //获得患者信息
- function getPatientInfo(){
- d.show();
- var data={};
- sendPost('patient/baseinfo', data, 'json', 'post', queryFailed, function(res){
- if (res.status == 200) {
- var data = res.data,
- ssc = data.ssc;
- expensesStatus = res.data.expensesStatus;
- patientName = data.name;
- mui('#slider').slider().gotoItem(0);
- $("#preTab").hide();
- mui('#slider').slider().setStopped(true);
-
- //获得咨询列表数据
- getHealthConsulationList(true);
-
- } else {
- queryFailed(res);
- }
- });
- }
- //获取健康咨询列表
- function getHealthConsulationList(isInit){
- if(isInit){
- id = 0;
- }
- var url = 'patient/consult/records',
- params = {
- id: id,
- pagesize: pageSize,
- title: $("#item1 .inp-search").val().trim()
- };
- sendPost(url, params, 'json', 'get', queryFailed, function(res){
- if(res.status == 200){
- $("#healthConsulationPanel").css("top","50px");
- d.close();
- $('#healthConsulationPanel').show();
- if (res.list.length > 0) {
- $('#ul_jiating_consultation').show();
- $('#item1 .vertical-line').show();
- $("#item1 .div-no-search-info").hide();
- $("#item1 .div-no-info").hide();
- var searchText = $("#item1 .inp-search").val().trim();
- var list = _.map(res.list, function(o){
- o.jsonStr = JSON.stringify(o);
- //针对搜索字体
- if(searchText.length > 0){
- var reg = new RegExp(searchText,"g");
- o.symptoms = o.symptoms.replace(reg, '<em>'+searchText+"</em>");
- }
- var divStatus = "";
- // if(o.type==2){
- if(o.status==0){
- //咨询中
- divStatus = "div-beginning";
- }else if(o.evaluate ==1){
- divStatus = "div-hasvalue";//是否有评价 0无 1有
- }else{
- divStatus = "div-novalue";
- }
- // }
- o.statusClass = divStatus;
- return o;
- });
- var html = template('healthConsulation_tmp', {list: list});
- if(id == 0){
- $("#ul_jiating_consultation").empty().append(html);
- }else{
- $("#ul_jiating_consultation").append(html);
- }
- if(res.list.length < pageSize){
- mui("#item1 .mui-scroll-wrapper").pullRefresh().endPullupToRefresh(true);
- }
- id = res.list[res.list.length-1].id;
- }else{
- if(isInit){
- $('#ul_jiating_consultation').hide();
- $('#item1 .vertical-line').hide();
- $("#item1 .div-no-search-info").show();
- }else{
- mui("#item1 .mui-scroll-wrapper").pullRefresh().endPullupToRefresh(true);
- }
- }
- }else{
- queryFailed(res);
- }
- });
- }
- //判断是否有未结束的咨询
- function isConsultUnfinished(docInfo,docQkInfo){
- var url = 'patient/consult/is_consult_unfinished',
- params = {doctor: docInfo.code};
- sendPost(url, params, 'json', 'post', function(res){
- queryFailed(res, '获取是否存在咨询失败');
- },function(res){
- d.close();
- if(res.status == 200){
- if(res.data == ""){
- //不存在
- checkDocInWork(chooseType, docInfo,docQkInfo);
- } else {
- dialog({
- content: '十分抱歉,您与'+ docInfo.name +'医生还有<br/>未结束咨询,无法发起新的咨询',
- okValue:'前往查看',
- ok: function (){
- var userInfo = JSON.parse(userAgent);
- var rep = userInfo.uid;
- window.location.href = "consulting-doctor.html?consult=" + res.data +"&toUser="+rep;
- },
- cancelValue: '我知道了',
- cancel: function () {
- $(".modal-overlay").trigger("click");
- $(".jiating-icon").removeClass("active");
- $(".mingyi-icon").removeClass("active");
- return;
- }
- }).showModal();
- }
- } else {
- dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:res.msg}).show();
- }
- });
- }
- //获取签约医生的工作时间
- function checkDocInWork(type, doctor,docQkInfo){
- var url = 'patient/consult/isDoctorWorkWhenconsult',
- params = {doctor:docQkInfo.code,healthDoctor:doctor.code};
- sendPost(url, params, 'json', 'post', queryFailed, function(res){
- if(res.status == 200){
- // data:0-医生不接受咨询/1-医生当前接受咨询/2-全科医生和健管师当前都不在工作时间/3-全科医生当前不在工作时间/4-健管师当前不在工作时间 健管师当前不在工作时间
- if(res.data==2){
- dialog({
- content: '您好,由于您的签约医生工作繁忙,设置了每日回复咨询的时间段,所以,在该时间段外的时间,您的咨询将不会马上获得医生的回复。',
- okValue:'查看医生工作时间',
- ok: function (){
- window.location.href = "doctor-work-hours.html?doctor=" + docQkInfo.code+"&healthDoctor="+doctor.code;
- },
- cancelValue: '继续新增咨询',
- cancel: function () {
- window.location.href = "add-consult.html?type=" +type+"&doctorCode="+doctor.code;
- }
- }).showModal();
- }else if(res.data==3){
- dialog({
- content: '您好,由于您的签约全科医生工作繁忙……,您的咨询将不会马上获得全科医生的回复 。',
- okValue:'查看医生工作时间',
- ok: function (){
- window.location.href = "doctor-work-hours.html?doctor=" + docQkInfo.code+"&healthDoctor="+doctor.code;
- },
- cancelValue: '继续新增咨询',
- cancel: function () {
- window.location.href = "add-consult.html?type=" +type+"&doctorCode="+doctor.code;
- }
- }).showModal();
- }else if(res.data==4){
- dialog({
- content: '您好,由于您的签约健康管理师工作繁忙……,您的咨询将不会马上获得健康管理师的回复 。',
- okValue:'查看医生工作时间',
- ok: function (){
- window.location.href = "doctor-work-hours.html?doctor=" + docQkInfo.code+"&healthDoctor="+doctor.code;
- },
- cancelValue: '继续新增咨询',
- cancel: function () {
- window.location.href = "add-consult.html?type=" +type+"&doctorCode="+doctor.code;
- }
- }).showModal();
- }else{
- //跳转到新增咨询页面
- window.location.href = "add-consult.html?type="+type+"&doctorCode="+doctor.code;
- }
- }else{
- queryFailed(res);
- }
- });
- }
- //判断是否可以新增续方咨询
- function checkCanPreConsult(){
- var url = "/patient/consult/isPrescriptionConsult",
- params = {patient: patientcode};
- d.show();
- sendPost(url, params, 'json', 'get', queryFailed, function(res){
- if(res.status == 200){
- //成功及可以发起续方咨询,跳转去新增续方咨询页面
- //TODO 待处理事件
- window.location.href = "add-prescription-consult.html?patient="+patientcode+"&name="+patientName;
- }else{
- queryFailed(res);
- }
- });
- }
- //显示搜索输入文字
- function showSearchSuggest(text, type){
- var suggestText = '搜索“'+text+'”';
- // 如果text不为空,则显示;否则隐藏
- if(text&&text.trim().length) {
- if(type == 1){//家庭医生咨询
- $("#search_suggest_text").text(suggestText);
- $("#search_suggest_text").show();
- }else if(type == 2){//续方咨询
- $("#xf_search_suggest_text").text(suggestText);
- $("#xf_search_suggest_text").show();
- }
- } else {
- if(type == 1){//家庭医生咨询
- $("#search_suggest_text").text('');
- $("#search_suggest_text").hide();
- }else if(type == 2){//续方咨询
- $("#xf_search_suggest_text").text('');
- $("#xf_search_suggest_text").hide();
- }
- }
- }
- //搜索操作
- function search(type){
- d.show();
- if(type == 1){//家庭医生咨询
- // isHealthSearch = true;
- // id = 0;
- $("#search_suggest_text").text('');
- $("#search_suggest_text").hide();
- $("#item1 .searchbar-cancel").hide();
- $("#item1 .searchbar-cancel").css("opacity","0");
- $("#item1 .div-no-info").hide();
- $("#item1 .div-no-search-info").hide();
- d.show();
- getHealthConsulationList(true);
- }else if(type == 2){//续方咨询
- // isPreSearch = true;
- // xfId = 0;
- $("#xf_search_suggest_text").text('');
- $("#xf_search_suggest_text").hide();
- $("#item2 .searchbar-cancel").hide();
- $("#item2 .searchbar-cancel").css("opacity","0");
- $("#item2 .div-no-info").hide();
- $("#item2 .div-no-search-info").hide();
- getPreConsultList();
- }
-
- }
- function bindEvents(){
- //监听tab切换动作
- document.querySelector('.mui-slider').addEventListener('slide', function(event) {
- var index = event.detail.slideNumber;
- chooseTab = index + 1;
- if(!loaded[index]){ //tab未加载过,则加载数据
- d.show();
- getPreConsultList();
- loaded[index] = true;
- }
- });
-
- $("#ul_jiating_consultation").on("tap",'li', function(){
- var jsonData = JSON.parse(this.getAttribute("data-json"));
- var userInfo = JSON.parse(userAgent);
- patientcode = window.localStorage.getItem('nowPatientCode')
- if(jsonData.status == 0){
- window.location.href = "../../qygl/html/sign_info.html?consult="+jsonData.code+"&doctor="+jsonData.doctorCode+"&patientcode="+patientcode;
- }else{
- localStorage.setItem("evaluate",jsonData.evaluate);
- window.location.href = "consulting-doctor.html?consult=" + jsonData.code+"&type="+jsonData.type+"&toUser="+userInfo.uid+"&doctor="+jsonData.doctorCode;
- }
- });
-
- $("#ul_xufang_consultation").on("tap",'li', function(){
- var userInfo = JSON.parse(userAgent);
- var jsonData = JSON.parse(this.getAttribute("data-json"));
- localStorage.setItem("evaluate",jsonData.evaluate);
- //跳转去续方咨询页面
- window.location.href = 'prescription-consulting.html?consult='+jsonData.code+'&type='+jsonData.type+"&toUser="+userInfo.uid+"&doctor="+jsonData.doctorCode;
- });
-
- //新增按钮事件
- $(".div-add-btn").on("click",function(){
- //现在固定显示咨询可以选择类型,不做三师等的判断
- // $(this).hide();
- // $(".div-dialog-content").show();
- // $(".modal-overlay").addClass("modal-overlay-visible");
- //直接跳转去选择医生列表
- window.location.href = "select-consult-doctor.html";
- });
-
- //点击遮罩事件
- $(".modal-overlay").on("click",function(){
- $(".modal-overlay").removeClass("modal-overlay-visible");
- $(".div-dialog-content").hide();
- $(".div-add-btn").removeClass("active");
- if(is_sign == 1){
- $(".div-add-btn").show();
- }else{
- $(".div-add-btn").hide();
- }
-
- });
-
- //点击家庭医生事件
- $(".jiating-icon").on("click",function(){
- $(this).addClass("active");
- if(is_sign == 1){
- //判断该居民是否已经缴费 1为已经交费 ""没有签约信息 "0"未扣费 "1"已扣费 "2"已退费
- if(expensesStatus == 1){
- querySignType(2);
- }else{
- //未缴费居民限制咨询次数
- limitZxTimes();
- }
- }else{
- $(".div-dialog-content").show();
- dialog({
- content: '没有有效的签约信息,请前往签约',
- okValue:'前往签约',
- ok: function (){
- window.location.href = "../../qygl/html/signing_management.html";
- },
- cancelValue: '我知道了',
- cancel: function () {
- $(".modal-overlay").trigger("click");
- $(".jiating-icon").removeClass("active");
- $(".mingyi-icon").removeClass("active");
- return;
- }
- }).showModal();
- }
-
- // if(expensesStatus == 1){
- // querySignType(2);
- // }else if(expensesStatus == ""){
- // d.close();
- // $(".mui-content").hide();
- // $(".div-no-sign").show();
- // }else{
- // //未缴费居民限制咨询次数
- // limitZxTimes();
- // }
- });
-
- //点击名医咨询事件
- $(".mingyi-icon").on("click",function(){
- $(this).addClass("active");
- if(is_sign == 1){
- window.location.href = "select-consult-doctor.html";
- }else{
- dialog({
- content: '没有有效的签约信息,请前往签约',
- okValue:'前往签约',
- ok: function (){
- window.location.href = "../../qygl/html/signing_management.html";
- },
- cancelValue: '我知道了',
- cancel: function () {
- $(".modal-overlay").trigger("click");
- $(".jiating-icon").removeClass("active");
- $(".mingyi-icon").removeClass("active");
- return;
- }
- }).showModal();
- }
-
- });
-
- //取消事件
- $(".quxiao").on("click",function(){
- $(".modal-overlay").trigger("click");
- });
-
- //查看签约
- $('#signing-btn').on('click',function(){
- window.location.href = "../../qygl/html/signing_management.html";
- });
-
- //跳转去签约管理页面
- $("#goToSign").on('click', function(){
- window.location.href = "../../qygl/html/signing_management.html";
- });
-
- //点击发起咨询事件
- $("#launch-btn").on("tap",function(){
- // $(".div-add-btn").trigger("click");
- window.location.href = "select-consult-doctor.html";
- });
-
- //点击续方tab内发起咨询的事件
- $("#launch-btn2").on("tap", function(){
- //判断是否可以续方咨询
- checkCanPreConsult();
- })
-
- //点击续方申请事件
- $(".xufangsq-icon").on("click",function(){
- $(this).addClass("active");
- //判断是否可以续方咨询
- checkCanPreConsult();
- });
-
- //搜索框事件
- $(".inp-search").on("input",function(){
- var text = $(this).val().trim(),
- type = $(this).attr("data-val");
-
- if(type == 1){//家庭医生咨询
- $('#healthConsulationPanel').hide();
- }else if(type == 2){//续方咨询
- $('#re-prescriptionConsulationPanel').hide();
- }
-
- showSearchSuggest(text, type);
- var $searchCancelBtn = $(".searchbar-clear");
- if(text){
- // $searchCancelBtn.css("opacity","1");
- }else{
- // $searchCancelBtn.css("opacity","0");
- search(type);
- }
- }).on('keydown',function(e) {
- var type = $(this).attr("data-val");
- if (e.which === 13) {
- search(type);
- }
- });
-
- $("#search_suggest_text").on("click", function(){
- search(1);
- });
-
- $("#xf_search_suggest_text").on("click", function(){
- search(2);
- });
-
- $(".searchbar-clear").on("click", function(){
- $(this).css("opacity","0");
- var $input = $(this).closest('.inp-search'),
- type = $input.attr("data-val");
-
- $input.val('');
- if(type == 1){//家庭医生咨询
- $("#search_suggest_text").text('');
- $("#search_suggest_text").hide();
- }else if(type == 2){//续方咨询
- $("#xf_search_suggest_text").text('');
- $("#xf_search_suggest_text").hide();
- }
- search(type);
- });
-
- //限制左右滑动
- // 左滑事件
- document.addEventListener("swipeleft", function(event) {
- console.log(event);
- event.preventDefault();
- return false;
- });
- // 右滑事件
- document.addEventListener("swiperight", function(event) {
- console.log(event);
- event.preventDefault();
- return false;
- });
- }
- //未缴费居民限制咨询次数
- function limitZxTimes(){
- //获取剩余家庭咨询次数
- var url = '/patient/consult/remainConsultTimes';
- var remainTimes;//剩余咨询次数
- var countTimes;//总咨询次数
- var zxTimes;//已咨询次数
- d.show();
- sendPost(url, {}, 'json', 'get', queryFailed, function(res){
- if(res.status == 200){
- d.close();
- remainTimes = res.data.amount;
- countTimes = res.data.count;
- zxTimes = countTimes - remainTimes;
- if(zxTimes == countTimes){
- //未缴费的总咨询次数已达上限 提示去缴费
- dialog({
- content: '您本年度家庭医生签约暂未缴费,当前10次免费健康咨询已全部使用.如果需要家庭医生继续为您提供服务,请尽快完成缴费操作',
- okValue:'前往缴费',
- ok: function (){
- window.location.href = "../../qygl/html/signing_management.html";
- }
- }).showModal();
- }else{
-
- dialog({
- content: '您本年度家庭医生签约暂未缴费,可使用10次免费健康咨询,当前剩余:'+remainTimes+'次.为避免影响您的服务体验,请尽快完成缴费操作',
- okValue:'前往缴费',
- ok: function (){
- window.location.href = "../../qygl/html/signing_management.html";
- },
- cancelValue: '开始咨询',
- cancel: function () {
- querySignType(2)
- }
- }).showModal();
-
- }
- }else{
- queryFailed(res);
- }
- });
- }
- //请求失败处理事件
- function queryFailed(res, message){
- d.close();
- if(message){
- dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content: message}).show();
- }else{
- 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();
- }
- }
-
- }
- //获取微信信息,并配置微信api接口
- function wxGetSign(){
- 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
- });
- }
- }
- });
- }
|