123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295 |
- var request = GetRequest();
- var d = dialog({contentType:'load', skin:'bk-popup'});
- var doctorCode = request["state"], //医生二维码扫描连接的参数,doctorCode_type
- doctor = request["doctor"],
- type = ''; //如果是扫二维码的页面,则这个type值为1
- if(doctorCode){
- doctor = doctorCode.split("_")[0];
- type = 1;
- }
- var userAgent = window.localStorage.getItem(agentName);
- var pagetype = 0;
- var docInfo;
- $(function(){
- checkUserAgent();
- })
- function queryInit(){
- userAgent = JSON.parse(userAgent);
- pageInitData();
- bindEvents();
- wxGetSign();
- }
- function pageInitData(){
- d.show();
- var url = "family_contract/homepage/homepage",
- params = {
- doctor:doctor
- }
- sendPost(url, params, 'json', 'post', queryFailed, function(res){
- if(res.status==200){
- var data = res.data;
- docInfo = res.data;
- var photo = data.photo;
- if(!photo){
- var photo = "../../../images/noSexDoctor.jpg";
- if(doctor.sex==1){
- photo = "../../../images/d-male.png";
- }else if(doctor.sex==2){
- photo = "../../../images/d-female.png";
- }
- }
-
- $("#photo").attr("src", getImgUrl(photo));
- $("#concern").text(data.concernCount);
- //获得关注状态
- var concernStatus = data.sign; //-1没有关注,1已关注
- if(concernStatus < 0){
- $("#isFocus").text("关注");
- $("#isFocus").addClass("grey");
- }else{
- $("#isFocus").text("已关注");
- $("#isFocus").removeClass("grey");
- }
- $("#name").html(data.name);
- $("#jobName").html(data.jobName);
- $("#deptName").html(data.dept);
- $("#hospitalName").html(data.hospital);
- $("#expertise").html(data.expertise);
- $("#introduce").html(data.intro);
- d.close();
- }else{
- queryFailed(res);
- }
- });
- }
- function bindEvents(){
- //立即咨询事件
- $("#bang-btn").on("click",function(){
- //是否关注了这个医生
- if(docInfo.sign == -1){
- concernDoctor(true); //关注医生
- }else{
- //判断是否有未结束的咨询
- d.show();
- isdetailfull()
- }
- });
-
- $("#isFocus").on('click', function(){
- var $this = $(this);
- if($this.hasClass("disabled")){
- return false;
- }
- $this.addClass("disabled");
- if($this.hasClass("grey")){
- concernDoctor();
- }else{
- //先判断是否有未结束的咨询,如果有未结束的咨询则不允许取消关注
- d.show();
- is_consult_finished(true);
- }
- })
- }
- //关注医生
- function concernDoctor(addConsult){
- d.show();
- var url = "/patient/concern/addConcern",
- params = {
- patient: userAgent.uid,
- doctor: doctor,
- concernSource: type || '2'//(关注方式: 1扫描二维码 2咨询关注 3.其他)
- };
- sendPost(url, params, 'json', 'post', queryFailed, function(res){
- if(res.status == 200){
- docInfo.sign = 1;
- if(addConsult){
- isdetailfull();
- }else{
- //修改关注按钮的状态
- d.close();
- $("#isFocus").text("已关注");
- $("#isFocus").removeClass("grey");
- $("#isFocus").removeClass("disabled");
- //修改关注数
- var count = $("#concern").text();
- $("#concern").text(parseInt(count) + 1);
- }
- }else{
- $("#isFocus").removeClass("disabled");
- queryFailed(res);
- }
- })
- }
- //取消关注
- function cancelConcern(){
- // d.show();
- var url = "/patient/concern/deleteConcern",
- params = {
- patient: userAgent.uid,
- doctor: doctor
- };
- sendPost(url, params, 'json', 'post', queryFailed, function(res){
- d.close();
- if(res.status == 200){
- docInfo.sign = -1;
- $("#isFocus").text("关注");
- $("#isFocus").addClass("grey");
- $("#isFocus").removeClass("disabled");
- //修改关注数
- var count = $("#concern").text();
- $("#concern").text(parseInt(count) - 1);
- }else{
- $("#isFocus").removeClass("disabled");
- queryFailed(res);
- }
- })
- }
- //判断是否有未结束的咨询
- function is_consult_finished(isCancelConcern){
- var url = 'patient/consult/is_consult_unfinished',
- params = {doctor: docInfo.doctor};
- sendPost(url, params, 'json', 'post', function(res){
- queryFailed(res, '获取是否存在咨询失败');
- },function(res){
- if(res.status == 200){
- if(res.data == ""){
- if(isCancelConcern){
- cancelConcern();
- }else{
- checkDocInWork();
- // window.location.href = "add-consult.html?doctorCode="+docInfo.doctor+"&doctorName="+docInfo.name+"&jobName="+docInfo.jobName;
- }
- } else {
- d.close();
- $("#isFocus").removeClass("disabled");
- var content = '十分抱歉,您与'+ docInfo.name +'医生还有<br/>未结束咨询,';
- if(isCancelConcern){
- content += '需结束咨询后才能取消关注';
- }else{
- content += '无法发起新的咨询';
- }
- dialog({
- content: content,
- okValue:'前往查看',
- ok: function (){
- var url = "../../qygl/html/sign_info.html?consult="+res.data+"&doctor="+docInfo.doctor;
- window.location.href = url;
- },
- cancelValue: '我知道了',
- cancel: function () {
- return;
- }
- }).showModal();
- }
- } else {
- queryFailed(res)
- }
- });
- }
- //获取签约医生的工作时间
- function checkDocInWork(){
- var url = 'patient/consult/isDoctorWorkWhenconsult',
- params = {
- doctor: doctor
- };
- sendPost(url, params, 'json', 'post', queryFailed, function(res){
- $("#isFocus").removeClass("disabled");
- if(res.status == 200){
- d.close();
- // data:0-医生不接受咨询/1-医生当前接受咨询/2-全科医生和健管师当前都不在工作时间/3-全科医生当前不在工作时间/4-健管师当前不在工作时间 健管师当前不在工作时间
- if(!(res.data == "1")){
- dialog({
- content: '您好,由于您关注的医生工作繁忙,设置了每日回复咨询的时间段,所以,在该时间段外的时间,您的咨询将不会马上获得医生的回复。',
- okValue:'查看医生工作时间',
- ok: function (){
- window.location.href = "doctor-work-hours.html?doctor=" + doctor;
- },
- cancelValue: '继续新增咨询',
- cancel: function () {
- window.location.href = "add-consult.html?doctorCode="+docInfo.doctor;
- }
- }).showModal();
- }else{
- //跳转到新增咨询页面
- window.location.href = "add-consult.html?doctorCode="+docInfo.doctor;
- }
- }else{
- queryFailed(res);
- }
- });
- }
- function isdetailfull(){
- d.show();
- var reqParams = [{
- url: "patient/baseinfo",
- data: {},
- reqType: 'post'
- }]
- getReqPromises(reqParams).then(function(ress){
- d.close();
- if (ress[0].status == 200) {
- if(ress[0].data.label){
- is_consult_finished();
- }else{
- dialog({
- content: '请完善您的资料',
- okValue:'前往完善',
- ok: function (){
- window.location.href = "../../grzx/html/my-detail.html";
- // window.location.href = "../../grzx/html/updateService.html?doctor="+doctor;
- },
- cancelValue: '暂不咨询',
- cancel: function () {
- }
- }).showModal();
- }
- }
- });
- }
- function queryFailed(res){
- d.close();
- if (res && res.msg) {
- dialog({contentType:'tipsbox', skin:'bk-popup' , content:res.msg,bottom:true}).show();
- } else {
- dialog({contentType:'tipsbox', skin:'bk-popup' , content:'加载失败',bottom:true}).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
- });
- }
- }
- });
- }
|