search-community.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. var d = dialog({contentType:'load', skin:'bk-popup'}).show();
  2. var Request = GetRequest(),
  3. town = Request["town"];
  4. var state = Request["state"];
  5. if(state)town = state;
  6. var $communityView = $('#community_view'),
  7. $communityList = $('#community_list'),
  8. $noResultWrap = $('#no_result_wrap');
  9. // 搜索框
  10. $('.searchbar').searchBar();
  11. var reqPromise = function(url,data) {
  12. return new Promise(function(resolve, reject) {
  13. sendPost(url, data, "json", "post",
  14. function queryFailed (req) {
  15. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'加载失败'}).show();
  16. // TODO 开启示例数据
  17. //resolve({});
  18. }
  19. , function success(req) {
  20. resolve(req);
  21. });
  22. });
  23. };
  24. reqPromise("patient/hosptail/getHositalByTownCode",{town:town}).then(function(data) {
  25. // TODO 示例数据
  26. //data = {"msg":"查询成功","list":[{"code":"3502050100","name":"海沧区嵩屿街道社区卫生服务中心"},{"code":"3502050101","name":"海沧社区卫生服务站"},{"code":"3502050200","name":"石塘社区卫生服务中心"},{"code":"3502050300","name":"东孚卫生院"},{"code":"3502050301","name":"天竺社区卫生服务站"},{"code":"3502050302","name":"国营厦门第一农场社区卫生服务站"},{"code":"3502050400","name":"新阳社区卫生服务中心"},{"code":"0a11148d-5b04-11e6-8344-fa163e8aee56","name":"厦门市海沧医院","photo":""}],"status":200};
  27. if(data && data.list.length) {
  28. $noResultWrap.hide();
  29. var html = template("community_li_tmpl", data);
  30. $communityList.html(html);
  31. } else {
  32. $noResultWrap.show();
  33. }
  34. d.close();
  35. }).catch(function(e) {
  36. console && console.error(e)
  37. });
  38. template.helper('getHospitalImg', function(str){
  39. var url = getImgUrl(str);
  40. if(url == ''){
  41. url = '../images/hospital_default.png';
  42. }
  43. return url;
  44. });