doctor-consultation_new.js 30 KB

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