appointment-register.js 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361
  1. var d = dialog({contentType:'load', skin:'bk-popup'});
  2. var scroller1,
  3. scroller2,
  4. scroller3;
  5. $(function(){
  6. //医院列表初始化信息
  7. var pageIndex = 1 ;
  8. var pageSize = 100;
  9. var hostpitallist = 0;
  10. //社区列表初始化信息
  11. var pageIndex1 = 1 ;
  12. var pageSize1 = 100;
  13. var communitylist = 0;
  14. //计划免疫列表初始化信息
  15. var pageIndex2 = 1 ;
  16. var pageSize2 = 100;
  17. var immunelist = 0;
  18. bindEvents();
  19. //初始化医院列表
  20. initHospital();
  21. //初始化社区列表
  22. initCommunity();
  23. //初始化计划免疫列表
  24. initImmune();
  25. //下拉刷新
  26. function pullDownAction(theScrollerTemp) {
  27. $(".pullDown").show();
  28. $(".ul-hospital").html("");
  29. initHospital();
  30. setTimeout(function () {
  31. $(".pullDown").hide();
  32. }, 1000);
  33. }
  34. //上拉加载数据
  35. function pullUpAction(theScrollerTemp) {
  36. if(hostpitallist%100==0){
  37. $(".pullUp").show();
  38. getHosptitalByType(1);
  39. }else{
  40. dialog({contentType:'tipsbox', skin:'bk-popup' , content:'无更多数据!',bottom:true}).show();
  41. }
  42. setTimeout(function () {
  43. $(".pullUp").hide();
  44. }, 1000);
  45. }
  46. //下拉刷新
  47. function pullDownAction2(theScrollerTemp) {
  48. $(".pullDown").show();
  49. $(".ul-community").html("");
  50. initCommunity();
  51. setTimeout(function () {
  52. $(".pullDown").hide();
  53. }, 1000);
  54. }
  55. //上拉加载数据
  56. function pullUpAction2(theScrollerTemp) {
  57. if(communitylist%100==0){
  58. $(".pullUp").show();
  59. getHosptitalByType(2);
  60. }else{
  61. dialog({contentType:'tipsbox', skin:'bk-popup' , content:'无更多数据!',bottom:true}).show();
  62. }
  63. setTimeout(function () {
  64. $(".pullUp").hide();
  65. }, 1000);
  66. }
  67. initScroller();
  68. function initScroller(){
  69. if(!scroller1) {
  70. scroller1 = new IScrollPullUpDown('wrapper6',{
  71. probeType:2,
  72. bounceTime: 250,
  73. bounceEasing: 'quadratic',
  74. mouseWheel:false,
  75. click:true,
  76. scrollbars:true,
  77. fadeScrollbars:true,
  78. interactiveScrollbars:false
  79. },null,null);
  80. }
  81. if(!scroller2) {
  82. scroller2 = new IScrollPullUpDown('wrapper7',{
  83. probeType:2,
  84. bounceTime: 250,
  85. bounceEasing: 'quadratic',
  86. mouseWheel:false,
  87. click:true,
  88. scrollbars:true,
  89. fadeScrollbars:true,
  90. interactiveScrollbars:false
  91. },null,null);
  92. }
  93. if(!scroller3) {
  94. scroller3 = new IScrollPullUpDown('wrapper8',{
  95. probeType:2,
  96. bounceTime: 250,
  97. bounceEasing: 'quadratic',
  98. mouseWheel:false,
  99. click:true,
  100. scrollbars:true,
  101. fadeScrollbars:true,
  102. interactiveScrollbars:false
  103. },null,null);
  104. }
  105. }
  106. function bindEvents(){
  107. $(".pt-tab").on("click","li",function(){
  108. var activeId = $(this).attr("id");
  109. $(".pt-tab li").removeClass("hit");
  110. $(this).addClass("hit");
  111. $(".area-list-wrap").hide();
  112. var ele = $(".area-list-wrap")[$(this).index()];
  113. var scroller = window["scroller"+($(this).index()+1)]
  114. $(ele).show();
  115. setTimeout(function() {
  116. scroller && scroller.myScroll.refresh();
  117. }, 500)
  118. })
  119. $(".ul-community").on("click","li",function(){
  120. var hospitalId = $(this).attr("data-id");
  121. location.href = "hospital-dept.html?hospitalId="+hospitalId;
  122. })
  123. $(".ul-hospital").on("click","li",function(){
  124. var hospitalId = $(this).attr("data-id");
  125. location.href = "hospital-dept.html?hospitalId="+hospitalId;
  126. })
  127. $(".ul-immune").on("click", "li", function() {
  128. var hospitalId = $(this).attr("data-id");
  129. location.href = "immune-date.html?hospitalId=" + hospitalId;
  130. })
  131. $(".div-yuyue-btn").on("click",function(){
  132. //location.href = "https://open.weixin.qq.com/connect/oauth2/authorize?appid="+appId+"&redirect_uri="+wxurl+"%2fwdyy%2fhtml%2fmy-appointment.html&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect";
  133. location.href = "my-appointment.html";
  134. })
  135. }
  136. /**
  137. * 接口数据获取
  138. */
  139. function getHosptitalByType(type){
  140. d.show();
  141. var data={};
  142. data.city = "350200";
  143. data.filter ="";
  144. data.type = type;
  145. if(type==1){
  146. data.pageIndex = pageIndex;
  147. data.pageSize = pageSize;
  148. }else if(type ==2){
  149. data.pageIndex = pageIndex1;
  150. data.pageSize = pageSize1;
  151. }
  152. var successFun = type == 1 ? getHosptitalSuccess : getCommunitySuccess;
  153. sendPost('third/guahao/GetOrgList', data, 'json', 'post', getListFail, successFun);
  154. }
  155. function getHosptitalSuccess(res){
  156. d.close();
  157. if(res.status==200){
  158. var dataList = res.data;
  159. if(dataList&&dataList.length>0){
  160. pageIndex = pageIndex+1;
  161. appendHopital(dataList);
  162. hostpitallist = hostpitallist+dataList.length;
  163. scroller1.myScroll.refresh();
  164. }else{
  165. dialog({contentType:'tipsbox', skin:'bk-popup' , content:'无更多数据!',bottom:true}).show();
  166. }
  167. }else{
  168. getListFail(res);
  169. }
  170. }
  171. function getCommunitySuccess(res){
  172. d.close();
  173. if(res.status==200){
  174. var dataList = res.data;
  175. if(dataList&&dataList.length>0){
  176. pageIndex1= pageIndex1+1;
  177. appendCommunity(dataList);
  178. communitylist = communitylist+dataList.length;
  179. scroller2.myScroll.refresh();
  180. }else{
  181. dialog({contentType:'tipsbox', skin:'bk-popup' , content:'无更多数据!',bottom:true}).show();
  182. }
  183. } else {
  184. getListFail(res);
  185. }
  186. $(".main").show();
  187. $("#footer").show();
  188. }
  189. function appendHopital(dataList){
  190. var hopitalLi ="";
  191. for(var j in dataList){
  192. var data = dataList[j];
  193. var photo = getImgUrl(data.photo);
  194. if(!photo){
  195. photo = "../images/hospital_default.png";
  196. }
  197. hopitalLi +='<li class="pt5 cb-ffffff pl10" data-id="'+data.id+'">'+
  198. '<a href="#" class="ui-grid">'+
  199. '<div class="ui-col-0 width-70 pt5 pb5" >'+
  200. '<img src="'+photo+'" class="br5 width-60 height-50"></img>'+
  201. '</div>'+
  202. '<div class="ui-col-1 item-name">'+
  203. '<div class="c-f16 c-fwb c-toe name-text c-333" style="line-height: 60px;">'+data.address+'</div>'+
  204. //等医院地址有值时,则上一句注释,下面两句注释放开
  205. // '<div class="mt5 c-f16 c-fwb c-toe name-text c-333">'+data.name+'</div>'+
  206. // '<div class="mt5 c-f14 c-666666 c-toe">'+data.address+'</div>'+
  207. '</div>'+
  208. '</a>'+
  209. '</a>'+
  210. '</li>';
  211. }
  212. $(".ul-hospital").append(hopitalLi);
  213. setTimeout(function(){
  214. if(!scroller1){
  215. initScroller();
  216. }
  217. scroller1.myScroll.refresh();
  218. },500);
  219. }
  220. function appendCommunity(dataList){
  221. var communitylLi ="";
  222. for(var j in dataList){
  223. var data = dataList[j];
  224. var photo = getImgUrl(data.photo);
  225. if(!photo){
  226. photo = "../images/hospital_default.png";
  227. }
  228. communitylLi +='<li class="pt5 cb-ffffff pl10" data-id="'+data.id+'">'+
  229. '<a href="#" class="ui-grid">'+
  230. '<div class="ui-col-0 width-70 pt5 pb5" >'+
  231. '<img src="'+photo+'" class="br5 width-60 height-50"></img>'+
  232. '</div>'+
  233. '<div class="ui-col-1 item-name">'+
  234. '<div class="c-f16 c-fwb c-toe name-text c-333" style="line-height:60px;">'+data.address+'</div>'+
  235. //等医院地址有值时,则上一句注释,下面两句注释放开
  236. // '<div class="mt5 c-f16 c-fwb c-toe name-text c-333">'+data.name+'</div>'+
  237. // '<div class="mt5 c-f14 c-666666 c-toe">'+data.address+'</div>'+
  238. '</div>'+
  239. '</a>'+
  240. '</li>';
  241. }
  242. $(".ul-community").append(communitylLi);
  243. if(!scroller2){
  244. initScroller();
  245. }
  246. scroller2.myScroll.refresh();
  247. }
  248. /**
  249. * 计划免疫列表数据获取
  250. */
  251. function getImmune() {
  252. var url = "/patient/guahao/imm/GetOrgImmuneList";
  253. sendPost(url, {},'json','get', getListFail, function(res){
  254. if(res.status == 200){
  255. appendImmune(res.data);
  256. }else{
  257. getListFail(res);
  258. }
  259. });
  260. }
  261. function appendImmune(dataList){
  262. var immuneLi ="";
  263. for(var j in dataList){
  264. var data = dataList[j];
  265. var photo = getImgUrl(data.photo);
  266. if(!photo){
  267. photo = "../images/hospital_default.png";
  268. }
  269. immuneLi +='<li class="pt5 cb-ffffff pl10" data-id="'+data.id+'">'+
  270. '<a href="#" class="ui-grid">'+
  271. '<div class="ui-col-0 width-70 pt5 pb5" >'+
  272. '<img src="'+photo+'" class="br5 width-60 height-50"></img>'+
  273. '</div>'+
  274. '<div class="ui-col-1 item-name">'+
  275. // '<div class="c-f16 c-fwb c-toe name-text c-333" style="line-height:60px;">'+data.address+'</div>'+
  276. //等医院地址有值时,则上一句注释,下面两句注释放开
  277. '<div class="mt5 c-f16 c-fwb c-toe name-text c-333">'+data.name+'</div>'+
  278. '<div class="mt5 c-f14 c-666666 c-toe">'+data.zone_name+data.shortName+'</div>'+
  279. '</div>'+
  280. '</a>'+
  281. '</li>';
  282. }
  283. $(".ul-immune").append(immuneLi);
  284. $(".main").removeClass("f-dn")
  285. setTimeout(function() {
  286. if(!scroller3){
  287. initScroller();
  288. }
  289. scroller3.myScroll.refresh();
  290. }, 500)
  291. }
  292. function getListFail(res){
  293. d.close();
  294. if (res && res.msg) {
  295. if((res.msg).indexOf("SOAP")>=0){
  296. dialog({contentType:'tipsbox', skin:'bk-popup' , content:"医院接口访问异常,请刷新后重试!",bottom:true}).show();
  297. return false;
  298. }
  299. dialog({contentType:'tipsbox', skin:'bk-popup' , content:res.msg,bottom:true}).show();
  300. } else {
  301. dialog({contentType:'tipsbox', skin:'bk-popup' , content:'加载失败',bottom:true}).show();
  302. }
  303. }
  304. /**
  305. * 初始化医院
  306. */
  307. function initHospital(){
  308. pageIndex = 1 ;
  309. hostpitallist = 0 ;
  310. getHosptitalByType(1);
  311. }
  312. /**
  313. * 初始化社区
  314. */
  315. function initCommunity(){
  316. pageIndex1 = 1 ;
  317. communitylist = 0;
  318. getHosptitalByType(2);
  319. }
  320. /**
  321. * 初始化计划免疫
  322. */
  323. function initImmune() {
  324. pageIndex2 = 1;
  325. immunelist = 0;
  326. getImmune();
  327. }
  328. });