doctor-consultation_new.js 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852
  1. //家庭医生咨询分页参数
  2. var id = 0;
  3. var pageSize = 15;
  4. //续方咨询分页参数
  5. var xfId = 0;
  6. var xfPageSize = 15;
  7. var d = dialog({contentType:'load', skin:'bk-popup'});
  8. var patientcode ="",
  9. patientName = "";
  10. var isHealthSearch = false,
  11. isPreSearch = false;
  12. var userAgent = window.localStorage.getItem(agentName);
  13. var pagetype = 1;
  14. var chooseType; //记录选择的咨询类型
  15. var loaded = [true, false]; //标记两个tab是否已经加载过
  16. var chooseTab = 1; //默认选中的是家庭健康咨询
  17. var expensesStatus ="";//'扣费状态 【""没有签约信息 "0"未扣费 "1"已扣费 "2"已退费】'
  18. var is_sign;
  19. //页面初始化
  20. $(function(){
  21. checkUserAgent();
  22. });
  23. function queryInit(){
  24. initScroller();
  25. initFamilyData();
  26. initPageData();
  27. bindEvents();
  28. wxGetSign();
  29. }
  30. function initScroller(){
  31. //阻尼系数
  32. var deceleration = mui.os.ios?0.003:0.0009;
  33. mui('.mui-scroll-wrapper1').scroll({
  34. scrollY: false, //是否竖向滚动
  35. scrollX: true, //是否横向滚动
  36. startX: 0, //初始化时滚动至x
  37. startY: 0, //初始化时滚动至y
  38. bounce: false,
  39. indicators: true, //是否显示滚动条
  40. deceleration:deceleration
  41. });
  42. mui.ready(function() {
  43. //循环初始化所有下拉刷新,上拉加载。
  44. $.each(document.querySelectorAll('.mui-slider-group .mui-scroll-wrapper'), function(index, pullRefreshEl) {
  45. mui(pullRefreshEl).pullRefresh({
  46. up: {
  47. callback: function() {
  48. var self = this;
  49. setTimeout(function() {
  50. if(index == 0){
  51. getHealthConsulationList();
  52. }else{
  53. getPreConsultList();
  54. }
  55. self.endPullupToRefresh();
  56. }, 1000);
  57. }
  58. }
  59. });
  60. });
  61. });
  62. }
  63. function initFamilyData(){
  64. appendFamilyMember($('#memberContainer'),function(){
  65. //切换家庭成员,默认选中健康咨询tab显示
  66. id = 0;
  67. xfId = 0;
  68. chooseType = 1;
  69. loaded = [true, false];
  70. $("#healthTab a").click();
  71. initPageData();
  72. },function(t){
  73. //判断有授权家人,修改样式,只在初始的时候执行一次
  74. var height = $('#memberContainer').height();
  75. $("#slider").css({
  76. 'top': height,
  77. 'height': 'calc(100% - '+height+'px)'
  78. });
  79. });
  80. }
  81. function initPageData(){
  82. var userInfo= JSON.parse(userAgent);
  83. patientcode = userInfo.represented?userInfo.represented:userInfo.uid;
  84. getPatientInfo();
  85. }
  86. //获得患者信息
  87. function getPatientInfo(){
  88. d.show();
  89. var data={};
  90. sendPost('patient/baseinfo', data, 'json', 'post', queryFailed, function(res){
  91. if (res.status == 200) {
  92. var data = res.data,
  93. ssc = data.ssc;
  94. expensesStatus = res.data.expensesStatus;
  95. patientName = data.name;
  96. if(!ssc) ssc = "";
  97. if(!ssc || ssc==""){
  98. //用户未办理医保卡
  99. dialog({
  100. content: '对不起,尚未办理医保卡的用户暂不支持签约~',
  101. cancelValue: '我知道了',
  102. cancel: function () {
  103. wx.closeWindow();
  104. }
  105. }).showModal();
  106. }
  107. if(data.prescription == 1){ //慢病人员,可以续方
  108. //如果患者在白名单中,则显示续方咨询tab的信息
  109. if(canPrescription){
  110. $("#preTab").show();
  111. $(".xufangsq-icon").show();
  112. mui('#slider').slider().setStopped(false);
  113. }else{
  114. $("#preTab").hide();
  115. $(".xufangsq-icon").hide();
  116. mui('#slider').slider().setStopped(true);
  117. }
  118. }else{
  119. //两种情况,1-非慢病人员,2-过期患者
  120. checkCanPrescription();
  121. }
  122. //判断签约状态
  123. checkIsSign();
  124. } else {
  125. queryFailed(res);
  126. }
  127. });
  128. }
  129. //判断是否有续方记录
  130. function checkCanPrescription(){
  131. var url = "/patient/prescriptionInfo/checkPatientWithPrescription";
  132. sendPost(url, {}, 'JSON', 'get', queryFailed, function(res){
  133. if(res.status == 200){
  134. if(res.data){
  135. $("#preTab").show();
  136. $(".xufangsq-icon").show();
  137. mui('#slider').slider().setStopped(false);
  138. }else{
  139. mui('#slider').slider().gotoItem(0);
  140. $("#preTab").hide();
  141. $(".xufangsq-icon").hide();
  142. mui('#slider').slider().setStopped(true);
  143. }
  144. }else{
  145. queryFailed(res);
  146. }
  147. })
  148. }
  149. //判断是否已经签约
  150. function checkIsSign(){
  151. var url = 'patient/is_sign',
  152. params = {};
  153. sendPost(url, params, 'json', 'post', queryFailed, function(res){
  154. if(res.status == 200){
  155. is_sign = res.data;//0未签约,1已签约
  156. // if(is_sign==1 || is_sign == -1){//1已经签约的
  157. if(chooseTab == 1){
  158. mui('#healthConsulationPanel').pullRefresh().scrollTo(0, 0, 1000);
  159. getHealthConsulationList(); //获取健康咨询列表
  160. }else{
  161. mui('#re-prescriptionConsulationPanel').pullRefresh().scrollTo(0, 0, 1000);
  162. getPreConsultList(); //获取健康咨询列表
  163. }
  164. // }else
  165. // if(is_sign==0){
  166. // d.close();
  167. // //签约未完成
  168. // $(".mui-content").hide();
  169. // $('.div-signing').show();
  170. // }
  171. /*else if(is_sign == -1){//-1签约已到期或未签约
  172. d.close();
  173. $(".mui-content").hide();
  174. $(".div-no-sign").show();
  175. }*/
  176. }else{
  177. queryFailed(res);
  178. }
  179. });
  180. }
  181. //获取健康咨询列表
  182. function getHealthConsulationList(){
  183. var url = 'patient/consult/records',
  184. params = {
  185. id: id,
  186. pagesize: pageSize,
  187. title: $("#item1 .inp-search").val().trim()
  188. };
  189. sendPost(url, params, 'json', 'get', queryFailed, function(res){
  190. if(res.status == 200){
  191. if(is_sign == 1){
  192. $(".div-add-btn").show();
  193. }else{
  194. $(".div-add-btn").hide();
  195. }
  196. $("#healthConsulationPanel").css("top","50px");
  197. d.close();
  198. $('#healthConsulationPanel').show();
  199. if (res.list.length > 0) {
  200. $('#ul_jiating_consultation').show();
  201. $('#item1 .vertical-line').show();
  202. $("#item1 .div-no-search-info").hide();
  203. $("#item1 .div-no-info").hide();
  204. var searchText = $("#item1 .inp-search").val().trim();
  205. var list = _.map(res.list, function(o){
  206. o.jsonStr = JSON.stringify(o);
  207. //针对搜索字体
  208. if(searchText.length > 0){
  209. var reg = new RegExp(searchText,"g");
  210. o.symptoms = o.symptoms.replace(reg, '<em>'+searchText+"</em>");
  211. }
  212. var divStatus = "";
  213. if(o.type==2){
  214. if(o.status==0){
  215. //咨询中
  216. divStatus = "div-beginning";
  217. }else if(o.evaluate ==1){
  218. divStatus = "div-hasvalue";//是否有评价 0无 1有
  219. }else{
  220. divStatus = "div-novalue";
  221. }
  222. }
  223. o.statusClass = divStatus;
  224. return o;
  225. });
  226. var html = template('healthConsulation_tmp', {list: list});
  227. if(id == 0){
  228. $("#ul_jiating_consultation").empty().append(html);
  229. }else{
  230. $("#ul_jiating_consultation").append(html);
  231. }
  232. if(res.list.length < pageSize){
  233. mui("#item1 .mui-scroll-wrapper").pullRefresh().endPullupToRefresh(true);
  234. }
  235. id = res.list[res.list.length-1].id;
  236. }else{
  237. if(isHealthSearch){//查询无结果
  238. $('#ul_jiating_consultation').hide();
  239. $('#item1 .vertical-line').hide();
  240. $("#item1 .div-no-search-info").show();
  241. isHealthSearch = false;
  242. }else if(id==0){//id为0的时候证明是第一次加载,第一次加载无数据,显示无数据界面
  243. $('#ul_jiating_consultation').hide();
  244. $('#item1 .vertical-line').hide();
  245. $("#item1 .div-no-info").show();
  246. $("#healthConsulationPanel").css("top","0px");
  247. if(is_sign == 0){
  248. $(".mui-content").hide();
  249. $('.div-signing').show();
  250. }
  251. }
  252. }
  253. }else{
  254. queryFailed(res);
  255. }
  256. });
  257. }
  258. //获取续方咨询列表
  259. function getPreConsultList(){
  260. d.show();
  261. var url = 'patient/consult/getPreConsultList',
  262. params = {
  263. id: xfId,
  264. pagesize: xfPageSize,
  265. title: $("#item2 .inp-search").val().trim()
  266. };
  267. sendPost(url, params, 'json', 'get', queryFailed, function(res){
  268. if(res.status == 200){
  269. d.close();
  270. $("#re-prescriptionConsulationPanel").show();
  271. if(res.list.length > 0){
  272. $('#ul_xufang_consultation').show();
  273. $('#item2 .vertical-line').show();
  274. $("#item2 .div-no-info").hide();
  275. $("#item2 .div-no-search-info").hide();
  276. var searchText = $("#item2 .inp-search").val().trim();
  277. var list = _.map(res.list, function(o){
  278. o.jsonStr = JSON.stringify(o);
  279. //针对搜索字体
  280. if(searchText.length > 0){
  281. var reg = new RegExp(searchText,"g");
  282. o.symptoms = o.symptoms.replace(reg, '<em>'+searchText+"</em>");
  283. }
  284. var divStatus = "";
  285. if(o.status==0){
  286. //咨询中
  287. divStatus = "div-beginning";
  288. }else if(o.evaluate ==1){
  289. divStatus = "div-hasvalue";//是否有评价 0无 1有
  290. }else{
  291. divStatus = "div-novalue";
  292. }
  293. o.statusClass = divStatus;
  294. return o;
  295. });
  296. var html = template('re-prescriptionConsulation_tmp', {list: list});
  297. if(xfId == 0){
  298. $("#ul_xufang_consultation").empty().append(html);
  299. }else{
  300. $("#ul_xufang_consultation").append(html);
  301. }
  302. if(res.list.length < xfPageSize){
  303. mui("#item2 .mui-scroll-wrapper").pullRefresh().endPullupToRefresh(true);
  304. }
  305. xfId ++;
  306. }else{
  307. if(isPreSearch){//查询无结果
  308. $('#ul_xufang_consultation').hide();
  309. $('#item2 .vertical-line').hide();
  310. $("#item2 .div-no-search-info").show();
  311. isPreSearch = false;
  312. }else if(xfId==0){//id为0的时候证明是第一次加载,第一次加载无数据,显示无数据界面
  313. $('#ul_xufang_consultation').hide();
  314. $('#item2 .vertical-line').hide();
  315. $("#item2 .div-no-info").show();
  316. }
  317. }
  318. }else{
  319. queryFailed(res);
  320. }
  321. });
  322. }
  323. //查询签约类型
  324. function querySignType(type){
  325. chooseType = type;
  326. d.show();
  327. sendPost('patient/sign_doctors', {}, 'json', 'post', function(res){
  328. queryFailed(res, '获取咨询类型失败');
  329. }, querySignTypeSuccess);
  330. }
  331. //查询签约类型成功回调处理事件
  332. function querySignTypeSuccess(res){
  333. if (res.status == 200) {
  334. var doctors = "";
  335. switch(Number(chooseType)) {
  336. case 1: doctors = res.teamDoctors; break;
  337. case 2: doctors = res.familyDoctors; break;
  338. default: break;
  339. }
  340. var docInfo,docQkInfo;
  341. $.each(doctors, function(i, v) {
  342. if(v.teamlevel){
  343. if(v.teamlevel == 3){
  344. docInfo = v;
  345. }
  346. if(v.teamlevel == 2){
  347. docQkInfo = v;
  348. }
  349. }else{
  350. if(v.level == 3){
  351. docInfo = v;
  352. }
  353. if(v.level == 2){
  354. docQkInfo = v;
  355. }
  356. }
  357. });
  358. if(!docInfo){
  359. docInfo = docQkInfo;
  360. }
  361. //判断是否有未结束的咨询
  362. isConsultUnfinished(docInfo,docQkInfo);
  363. } else {
  364. queryFailed(res);
  365. }
  366. }
  367. //判断是否有未结束的咨询
  368. function isConsultUnfinished(docInfo,docQkInfo){
  369. var url = 'patient/consult/is_consult_unfinished',
  370. params = {doctor: docInfo.code};
  371. sendPost(url, params, 'json', 'post', function(res){
  372. queryFailed(res, '获取是否存在咨询失败');
  373. },function(res){
  374. d.close();
  375. if(res.status == 200){
  376. if(res.data == ""){
  377. //不存在
  378. checkDocInWork(chooseType, docInfo,docQkInfo);
  379. } else {
  380. dialog({
  381. content: '十分抱歉,您与'+ docInfo.name +'医生还有<br/>未结束咨询,无法发起新的咨询',
  382. okValue:'前往查看',
  383. ok: function (){
  384. var userInfo = JSON.parse(userAgent);
  385. var rep = userInfo.represented?userInfo.represented:userInfo.uid;
  386. window.location.href = "consulting-doctor.html?consult=" + res.data +"&toUser="+rep;
  387. },
  388. cancelValue: '我知道了',
  389. cancel: function () {
  390. $(".modal-overlay").trigger("click");
  391. $(".jiating-icon").removeClass("active");
  392. $(".mingyi-icon").removeClass("active");
  393. return;
  394. }
  395. }).showModal();
  396. }
  397. } else {
  398. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:res.msg}).show();
  399. }
  400. });
  401. }
  402. //获取签约医生的工作时间
  403. function checkDocInWork(type, doctor,docQkInfo){
  404. var url = 'patient/consult/isDoctorWorkWhenconsult',
  405. params = {doctor:docQkInfo.code,healthDoctor:doctor.code};
  406. sendPost(url, params, 'json', 'post', queryFailed, function(res){
  407. if(res.status == 200){
  408. // data:0-医生不接受咨询/1-医生当前接受咨询/2-全科医生和健管师当前都不在工作时间/3-全科医生当前不在工作时间/4-健管师当前不在工作时间 健管师当前不在工作时间
  409. if(res.data==2){
  410. dialog({
  411. content: '您好,由于您的签约医生工作繁忙,设置了每日回复咨询的时间段,所以,在该时间段外的时间,您的咨询将不会马上获得医生的回复。',
  412. okValue:'查看医生工作时间',
  413. ok: function (){
  414. window.location.href = "doctor-work-hours.html?doctor=" + docQkInfo.code+"&healthDoctor="+doctor.code;
  415. },
  416. cancelValue: '继续新增咨询',
  417. cancel: function () {
  418. window.location.href = "add-consult.html?type=" +type+"&doctorCode="+doctor.code;
  419. }
  420. }).showModal();
  421. }else if(res.data==3){
  422. dialog({
  423. content: '您好,由于您的签约全科医生工作繁忙……,您的咨询将不会马上获得全科医生的回复 。',
  424. okValue:'查看医生工作时间',
  425. ok: function (){
  426. window.location.href = "doctor-work-hours.html?doctor=" + docQkInfo.code+"&healthDoctor="+doctor.code;
  427. },
  428. cancelValue: '继续新增咨询',
  429. cancel: function () {
  430. window.location.href = "add-consult.html?type=" +type+"&doctorCode="+doctor.code;
  431. }
  432. }).showModal();
  433. }else if(res.data==4){
  434. dialog({
  435. content: '您好,由于您的签约健康管理师工作繁忙……,您的咨询将不会马上获得健康管理师的回复 。',
  436. okValue:'查看医生工作时间',
  437. ok: function (){
  438. window.location.href = "doctor-work-hours.html?doctor=" + docQkInfo.code+"&healthDoctor="+doctor.code;
  439. },
  440. cancelValue: '继续新增咨询',
  441. cancel: function () {
  442. window.location.href = "add-consult.html?type=" +type+"&doctorCode="+doctor.code;
  443. }
  444. }).showModal();
  445. }else{
  446. //跳转到新增咨询页面
  447. window.location.href = "add-consult.html?type="+type+"&doctorCode="+doctor.code;
  448. }
  449. }else{
  450. queryFailed(res);
  451. }
  452. });
  453. }
  454. //判断是否可以新增续方咨询
  455. function checkCanPreConsult(){
  456. var url = "/patient/consult/isPrescriptionConsult",
  457. params = {patient: patientcode};
  458. d.show();
  459. sendPost(url, params, 'json', 'get', queryFailed, function(res){
  460. if(res.status == 200){
  461. //成功及可以发起续方咨询,跳转去新增续方咨询页面
  462. //TODO 待处理事件
  463. window.location.href = "add-prescription-consult.html?patient="+patientcode+"&name="+patientName;
  464. }else{
  465. queryFailed(res);
  466. }
  467. });
  468. }
  469. //显示搜索输入文字
  470. function showSearchSuggest(text, type){
  471. var suggestText = '搜索“'+text+'”';
  472. // 如果text不为空,则显示;否则隐藏
  473. if(text&&text.trim().length) {
  474. if(type == 1){//家庭医生咨询
  475. $("#search_suggest_text").text(suggestText);
  476. $("#search_suggest_text").show();
  477. }else if(type == 2){//续方咨询
  478. $("#xf_search_suggest_text").text(suggestText);
  479. $("#xf_search_suggest_text").show();
  480. }
  481. } else {
  482. if(type == 1){//家庭医生咨询
  483. $("#search_suggest_text").text('');
  484. $("#search_suggest_text").hide();
  485. }else if(type == 2){//续方咨询
  486. $("#xf_search_suggest_text").text('');
  487. $("#xf_search_suggest_text").hide();
  488. }
  489. }
  490. }
  491. //搜索操作
  492. function search(type){
  493. d.show();
  494. if(type == 1){//家庭医生咨询
  495. isHealthSearch = true;
  496. id = 0;
  497. $("#search_suggest_text").text('');
  498. $("#search_suggest_text").hide();
  499. $("#item1 .searchbar-cancel").hide();
  500. $("#item1 .searchbar-cancel").css("opacity","0");
  501. $("#item1 .div-no-info").hide();
  502. $("#item1 .div-no-search-info").hide();
  503. d.show();
  504. getHealthConsulationList();
  505. }else if(type == 2){//续方咨询
  506. isPreSearch = true;
  507. xfId = 0;
  508. $("#xf_search_suggest_text").text('');
  509. $("#xf_search_suggest_text").hide();
  510. $("#item2 .searchbar-cancel").hide();
  511. $("#item2 .searchbar-cancel").css("opacity","0");
  512. $("#item2 .div-no-info").hide();
  513. $("#item2 .div-no-search-info").hide();
  514. getPreConsultList();
  515. }
  516. }
  517. function bindEvents(){
  518. //监听tab切换动作
  519. document.querySelector('.mui-slider').addEventListener('slide', function(event) {
  520. var index = event.detail.slideNumber;
  521. chooseTab = index + 1;
  522. if(!loaded[index]){ //tab未加载过,则加载数据
  523. d.show();
  524. getPreConsultList();
  525. loaded[index] = true;
  526. }
  527. });
  528. $("#ul_jiating_consultation").on("tap",'li', function(){
  529. var userInfo = JSON.parse(userAgent);
  530. var jsonData = JSON.parse(this.getAttribute("data-json"));
  531. if(jsonData.type == 2 && jsonData.status == 0){
  532. var url = "patient/sign_status",
  533. params = {};
  534. d.show();
  535. sendPost(url, params, "json", "post", queryFailed, function(res){
  536. d.close();
  537. var teamCode = res["teamCode_2"];
  538. var signCode = res["signCode_2"];
  539. localStorage.setItem("signInfo_tab", "1");
  540. window.location.href = "../../qygl/html/sign_info.html?code="+jsonData.signCode+"&consult="+jsonData.code+"&teamCode="+jsonData.teamCode+"&type="+jsonData.type+"&doctor="+jsonData.doctorCode;
  541. });
  542. }else{
  543. localStorage.setItem("evaluate",jsonData.evaluate);
  544. window.location.href = "consulting-doctor.html?consult=" + jsonData.code+"&type="+jsonData.type+"&toUser="+userInfo.uid+"&doctor="+jsonData.doctorCode;
  545. }
  546. });
  547. $("#ul_xufang_consultation").on("tap",'li', function(){
  548. var userInfo = JSON.parse(userAgent);
  549. var jsonData = JSON.parse(this.getAttribute("data-json"));
  550. localStorage.setItem("evaluate",jsonData.evaluate);
  551. //跳转去续方咨询页面
  552. window.location.href = 'prescription-consulting.html?consult='+jsonData.code+'&type='+jsonData.type+"&toUser="+userInfo.uid+"&doctor="+jsonData.doctorCode;
  553. });
  554. //新增按钮事件
  555. $(".div-add-btn").on("click",function(){
  556. //现在固定显示咨询可以选择类型,不做三师等的判断
  557. $(this).hide();
  558. $(".div-dialog-content").show();
  559. $(".modal-overlay").addClass("modal-overlay-visible");
  560. });
  561. //点击遮罩事件
  562. $(".modal-overlay").on("click",function(){
  563. $(".modal-overlay").removeClass("modal-overlay-visible");
  564. $(".div-dialog-content").hide();
  565. $(".div-add-btn").removeClass("active");
  566. if(is_sign == 1){
  567. $(".div-add-btn").show();
  568. }else{
  569. $(".div-add-btn").hide();
  570. }
  571. });
  572. //点击家庭医生事件
  573. $(".jiating-icon").on("click",function(){
  574. $(this).addClass("active");
  575. if(is_sign == 1){
  576. //判断该居民是否已经缴费 1为已经交费 ""没有签约信息 "0"未扣费 "1"已扣费 "2"已退费
  577. if(expensesStatus == 1){
  578. querySignType(2);
  579. }else{
  580. //未缴费居民限制咨询次数
  581. limitZxTimes();
  582. }
  583. }else{
  584. $(".div-dialog-content").show();
  585. dialog({
  586. content: '没有有效的签约信息,请前往签约',
  587. okValue:'前往签约',
  588. ok: function (){
  589. window.location.href = "../../qygl/html/signing_management.html";
  590. },
  591. cancelValue: '我知道了',
  592. cancel: function () {
  593. $(".modal-overlay").trigger("click");
  594. $(".jiating-icon").removeClass("active");
  595. $(".mingyi-icon").removeClass("active");
  596. return;
  597. }
  598. }).showModal();
  599. }
  600. // if(expensesStatus == 1){
  601. // querySignType(2);
  602. // }else if(expensesStatus == ""){
  603. // d.close();
  604. // $(".mui-content").hide();
  605. // $(".div-no-sign").show();
  606. // }else{
  607. // //未缴费居民限制咨询次数
  608. // limitZxTimes();
  609. // }
  610. });
  611. //点击名医咨询事件
  612. $(".mingyi-icon").on("click",function(){
  613. $(this).addClass("active");
  614. if(is_sign == 1){
  615. window.location.href = "select-consult-doctor.html";
  616. }else{
  617. dialog({
  618. content: '没有有效的签约信息,请前往签约',
  619. okValue:'前往签约',
  620. ok: function (){
  621. window.location.href = "../../qygl/html/signing_management.html";
  622. },
  623. cancelValue: '我知道了',
  624. cancel: function () {
  625. $(".modal-overlay").trigger("click");
  626. $(".jiating-icon").removeClass("active");
  627. $(".mingyi-icon").removeClass("active");
  628. return;
  629. }
  630. }).showModal();
  631. }
  632. });
  633. //取消事件
  634. $(".quxiao").on("click",function(){
  635. $(".modal-overlay").trigger("click");
  636. });
  637. //查看签约
  638. $('#signing-btn').on('click',function(){
  639. window.location.href = "../../qygl/html/signing_management.html";
  640. });
  641. //跳转去签约管理页面
  642. $("#goToSign").on('click', function(){
  643. window.location.href = "../../qygl/html/signing_management.html";
  644. });
  645. //点击发起咨询事件
  646. $("#launch-btn").on("tap",function(){
  647. $(".div-add-btn").trigger("click");
  648. });
  649. //点击续方tab内发起咨询的事件
  650. $("#launch-btn2").on("tap", function(){
  651. //判断是否可以续方咨询
  652. checkCanPreConsult();
  653. })
  654. //点击续方申请事件
  655. $(".xufangsq-icon").on("click",function(){
  656. $(this).addClass("active");
  657. //判断是否可以续方咨询
  658. checkCanPreConsult();
  659. });
  660. //搜索框事件
  661. $(".inp-search").on("input",function(){
  662. var text = $(this).val().trim(),
  663. type = $(this).attr("data-val");
  664. if(type == 1){//家庭医生咨询
  665. $('#healthConsulationPanel').hide();
  666. }else if(type == 2){//续方咨询
  667. $('#re-prescriptionConsulationPanel').hide();
  668. }
  669. showSearchSuggest(text, type);
  670. var $searchCancelBtn = $(".searchbar-clear");
  671. if(text){
  672. // $searchCancelBtn.css("opacity","1");
  673. }else{
  674. // $searchCancelBtn.css("opacity","0");
  675. search(type);
  676. }
  677. }).on('keydown',function(e) {
  678. var type = $(this).attr("data-val");
  679. if (e.which === 13) {
  680. search(type);
  681. }
  682. });
  683. $("#search_suggest_text").on("click", function(){
  684. search(1);
  685. });
  686. $("#xf_search_suggest_text").on("click", function(){
  687. search(2);
  688. });
  689. $(".searchbar-clear").on("click", function(){
  690. $(this).css("opacity","0");
  691. var $input = $(this).closest('.inp-search'),
  692. type = $input.attr("data-val");
  693. $input.val('');
  694. if(type == 1){//家庭医生咨询
  695. $("#search_suggest_text").text('');
  696. $("#search_suggest_text").hide();
  697. }else if(type == 2){//续方咨询
  698. $("#xf_search_suggest_text").text('');
  699. $("#xf_search_suggest_text").hide();
  700. }
  701. search(type);
  702. });
  703. //限制左右滑动
  704. // 左滑事件
  705. document.addEventListener("swipeleft", function(event) {
  706. console.log(event);
  707. event.preventDefault();
  708. return false;
  709. });
  710. // 右滑事件
  711. document.addEventListener("swiperight", function(event) {
  712. console.log(event);
  713. event.preventDefault();
  714. return false;
  715. });
  716. }
  717. //未缴费居民限制咨询次数
  718. function limitZxTimes(){
  719. //获取剩余家庭咨询次数
  720. var url = '/patient/consult/remainConsultTimes';
  721. var remainTimes;//剩余咨询次数
  722. var countTimes;//总咨询次数
  723. var zxTimes;//已咨询次数
  724. d.show();
  725. sendPost(url, {}, 'json', 'get', queryFailed, function(res){
  726. if(res.status == 200){
  727. d.close();
  728. remainTimes = res.data.amount;
  729. countTimes = res.data.count;
  730. zxTimes = countTimes - remainTimes;
  731. if(zxTimes == countTimes){
  732. //未缴费的总咨询次数已达上限 提示去缴费
  733. dialog({
  734. content: '您本年度家庭医生签约暂未缴费,当前10次免费健康咨询已全部使用.如果需要家庭医生继续为您提供服务,请尽快完成缴费操作',
  735. okValue:'前往缴费',
  736. ok: function (){
  737. window.location.href = "../../qygl/html/signing_management.html";
  738. }
  739. }).showModal();
  740. }else{
  741. dialog({
  742. content: '您本年度家庭医生签约暂未缴费,可使用10次免费健康咨询,当前剩余:'+remainTimes+'次.为避免影响您的服务体验,请尽快完成缴费操作',
  743. okValue:'前往缴费',
  744. ok: function (){
  745. window.location.href = "../../qygl/html/signing_management.html";
  746. },
  747. cancelValue: '开始咨询',
  748. cancel: function () {
  749. querySignType(2)
  750. }
  751. }).showModal();
  752. }
  753. }else{
  754. queryFailed(res);
  755. }
  756. });
  757. }
  758. //请求失败处理事件
  759. function queryFailed(res, message){
  760. d.close();
  761. if(message){
  762. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content: message}).show();
  763. }else{
  764. if (res && res.msg) {
  765. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:res.msg}).show();
  766. } else {
  767. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'加载失败'}).show();
  768. }
  769. }
  770. }
  771. //获取微信信息,并配置微信api接口
  772. function wxGetSign(){
  773. var params = {};
  774. params.pageUrl = window.location.href;
  775. $.ajax(server + "weixin/getSign", {
  776. data: params,
  777. dataType: "json",
  778. type: "post",
  779. success: function(res){
  780. if (res.status == 200) {
  781. var t = res.data.timestamp;
  782. var noncestr = res.data.noncestr;
  783. var signature = res.data.signature;
  784. wx.config({
  785. //debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
  786. appId: appId, // 必填,公众号的唯一标识
  787. timestamp: t, // 必填,生成签名的时间戳
  788. nonceStr: noncestr, // 必填,生成签名的随机串
  789. signature: signature,// 必填,签名,见附录1
  790. jsApiList: [
  791. 'closeWindow'
  792. ] // 必填,需要使用的JS接口列表,所有JS接口列表见附录2
  793. });
  794. }
  795. }
  796. });
  797. }