my-appointment.js 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. var d = dialog({contentType:'load', skin:'bk-popup'});
  2. var pagetype = 20;
  3. $(function(){
  4. checkUserAgent();
  5. })
  6. appendFamilyMember($('#memberContainer'),function(){
  7. $(".div-no-info").hide();
  8. initData();
  9. },function(){
  10. //判断有授权家人,修改样式
  11. if($('#memberContainer').is(':hidden')){
  12. $('#wrapper2').css('top','0px');
  13. }else{
  14. $('#wrapper2').css('top','90px');
  15. $('.div-no-info').css('padding-top','150px');
  16. }
  17. });
  18. function queryInit(){
  19. var pageIndex = 1;
  20. var pageSize = 10;
  21. var request = GetRequest();
  22. var toUser = request["toUser"];
  23. var openid = request["openid"];
  24. var toName = decodeURIComponent(Request["toName"]);
  25. var represented = Request["represented"];
  26. var userAgent = window.localStorage.getItem(agentName);
  27. if(!userAgent) {
  28. localStorage.setItem("toUser",toUser);
  29. window.location.href = server + "wx/html/home/html/login.html?openid=" + openid+"&type="+pagetype;
  30. return false;
  31. }
  32. var newUaObj = JSON.parse(window.localStorage.getItem(agentName))
  33. //判断关系
  34. function hasFamilyRelation(a,b){
  35. return new Promise(function(resolve, reject) {
  36. var data={
  37. patient:a,
  38. familyMember:b
  39. }
  40. sendPost("patient/family/is_authorize", data, "json", "get", function(res){
  41. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'请求家庭成员关系失败'}).show();
  42. }, function(res){
  43. if(res.status == 200) {
  44. window.localStorage.setItem('nowPatientName',res.data.name);
  45. resolve(res)
  46. }else if(res.status == 100) {
  47. dialog({
  48. content:'对不起,'+res.data.name+'未授权给您,如需查看,请切换'+res.data.name+'账号登录',
  49. okValue:'切换账号',
  50. ok: function() {
  51. window.localStorage.setItem(pageName, JSON.stringify({pageurl: location.href}))
  52. window.location.href = "../../grzx/html/change-login.html?type=0&openid="+ Request["openid"];
  53. },
  54. cancelValue: '我不看了',
  55. cancel: function () {
  56. wx.closeWindow();
  57. }
  58. }).showModal();
  59. }else{
  60. relogin();
  61. }
  62. })
  63. })
  64. }
  65. //重新登录操作
  66. function relogin(){
  67. dialog({
  68. content:'对不起,该消息是发给'+toName+',如需查看,请切换'+toName+'账号登录',
  69. okValue:'切换账号',
  70. ok: function() {
  71. window.localStorage.setItem(pageName, JSON.stringify({pageurl: location.href}))
  72. window.location.href = "../../grzx/html/change-login.html?type=0&openid="+ Request["openid"];
  73. },
  74. cancelValue: '我不看了',
  75. cancel: function () {
  76. wx.closeWindow();
  77. }
  78. }).showModal();
  79. }
  80. //保存信息
  81. function saveUserInfo(a,b){
  82. Promise.all([hasFamilyRelation(a,b)]).then(function () {
  83. newUaObj.represented = represented;
  84. window.localStorage.setItem(agentName,JSON.stringify(newUaObj));
  85. initData();
  86. bindEvents();
  87. })
  88. }
  89. function initFamilyData () {
  90. //从微信模板消息进入
  91. if(represented && userAgent && toUser){
  92. if(toUser == represented){
  93. saveUserInfo(represented,newUaObj.uid)
  94. }else if(toUser != represented && represented == newUaObj.uid){
  95. //本人代理
  96. saveUserInfo(represented,newUaObj.uid)
  97. }else if(toUser != represented && toUser == newUaObj.uid){
  98. //需要判定关系 200有授权 100家人 1无关系
  99. saveUserInfo(represented,newUaObj.uid)
  100. }else{
  101. //重新登录
  102. relogin();
  103. }
  104. }else{
  105. initData();
  106. bindEvents();
  107. }
  108. }
  109. initFamilyData();
  110. }
  111. function bindEvents(){
  112. $(".c-list").on("click",".n-list-li,.n-list-content",function(event){
  113. var parentLi = $(this).closest("li");
  114. var id = parentLi.attr("data-id");
  115. var orgCode = parentLi.attr("data-orgCode");
  116. location.href = "detail-appointment.html?id="+id+"&orgCode="+orgCode;
  117. }).on("click",".div-again",function(){
  118. var parentLi = $(this).closest("li");
  119. var id = parentLi.attr("data-id");
  120. var doctorCode = parentLi.attr("data-doctorCode");
  121. var orgCode = parentLi.attr("data-orgCode");
  122. var deptCode = parentLi.attr("data-deptCode");
  123. location.href = "doctor-detail.html?type=2&id="+id+"&doctorId="+doctorCode+"&hospitalId="+orgCode+"&hosDeptId="+deptCode;
  124. })
  125. $(".div-add-btn").on("click",function(){
  126. // $(this).hide();
  127. // $(".div-dialog-content").show();
  128. // $(".modal-overlay").addClass("modal-overlay-visible");
  129. location.href = "appointment-register.html";
  130. })
  131. //点击免疫预约事件
  132. $(".mianyi-icon").on("click",function(){
  133. $(this).addClass("active");
  134. location.href = "immune-appointment.html";
  135. });
  136. //点击普通预约事件
  137. $(".putong-icon").on("click",function(){
  138. $(this).addClass("active");
  139. location.href = "appointment-register.html";
  140. });
  141. }
  142. function initData(){
  143. $(".c-list").html("");
  144. pageIndex = 1;
  145. getMyAppo();
  146. }
  147. function getMyAppo(){
  148. d.show();
  149. var data={};
  150. var loginUser = JSON.parse(window.localStorage.getItem(agentName));
  151. data.patient=loginUser['represented']?loginUser['represented']:loginUser['uid'];
  152. sendPost('third/guahao/GetRegList', data, 'json', 'post', getListFail, successFun);
  153. }
  154. function successFun(res){
  155. if(res.status==200){
  156. if(res.data&&res.data.length>0){
  157. pageIndex=pageIndex+1;
  158. appendMyAppo(res.data);
  159. }else{
  160. if(pageIndex==1){
  161. $(".main").hide();
  162. $(".div-no-info").show();
  163. $("#footer").show();
  164. }else{
  165. dialog({contentType:'tipsbox', skin:'bk-popup' , content:'无更多数据!',bottom:true}).show();
  166. }
  167. d.close();
  168. }
  169. }else{
  170. getListFail(res);
  171. }
  172. }
  173. function getListFail(res){
  174. d.close();
  175. if (res && res.msg) {
  176. if((res.msg).indexOf("SOAP")>=0){
  177. dialog({contentType:'tipsbox', skin:'bk-popup' , content:"医院接口访问异常,请刷新后重试!",bottom:true}).show();
  178. return false;
  179. }
  180. dialog({contentType:'tipsbox', skin:'bk-popup' , content:res.msg,bottom:true}).show();
  181. } else {
  182. dialog({contentType:'tipsbox', skin:'bk-popup' , content:'加载失败',bottom:true}).show();
  183. }
  184. }
  185. function appendMyAppo(dataList){
  186. var appoHtml ="";
  187. for(var j in dataList){
  188. var data = dataList[j];
  189. //status:0 已撤销 1 预约成功 2 已就诊 3已停诊
  190. var clazz1 = "cb-47ABEF";
  191. var clazz2 = "c-47ABEF";
  192. var statusNm = "预约成功"
  193. if(data.status=="0"){
  194. clazz1 = "cb-FF6A56";
  195. clazz2 = "c-FF6A56";
  196. statusNm = "已撤销";
  197. }if(data.status=="1"){
  198. clazz1 = "cb-FF6A56";
  199. clazz2 = "c-FF6A56";
  200. statusNm = "预约创建";
  201. }
  202. else if(data.status=="2"){
  203. clazz1 = "cb-74BF00";
  204. clazz2 = "c-74BF00";
  205. statusNm = "预约确认";
  206. }else if(data.status=="3"){
  207. clazz1 = "cb-74BF00";
  208. clazz2 = "c-74BF00";
  209. statusNm = "已就诊";
  210. }
  211. else if(data.status=="4"){
  212. clazz1 = "cb-909090";
  213. clazz2 = "c-909090";
  214. statusNm = "已停诊";
  215. }
  216. appoHtml = template("doctor_list_tmp", {data:data});
  217. $(".c-list").append(appoHtml);
  218. }
  219. setTimeout(function(){
  220. scroller1.myScroll.refresh();
  221. },500)
  222. d.close();
  223. $(".main").show();
  224. $("#footer").show();
  225. }
  226. //下拉刷新
  227. function pullDownAction(theScrollerTemp) {
  228. // $(".main").hide();
  229. // $("#footer").hide();
  230. // $(".pullDown").show();
  231. // initData();
  232. // setTimeout(function () {
  233. // $(".pullDown").hide();
  234. // }, 1000);
  235. }
  236. //将scroller1的初始化代码放到外面来,不然从微信授权重定向过来这个页面的时候,
  237. //iscroll-pull-up-down 里监听的window的load方法不会触发,导致scroller初始化代码没有执行
  238. var scroller1 = new IScrollPullUpDown('wrapper2',{
  239. probeType:2,
  240. bounceTime: 250,
  241. bounceEasing: 'quadratic',
  242. mouseWheel:false,
  243. scrollbars:true,
  244. fadeScrollbars:true,
  245. click:true,
  246. interactiveScrollbars:false
  247. },pullDownAction,null);