data.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. // 城市数据
  2. var cityData = [];
  3. // 当前城市,所有接口根据当前城市获取数据
  4. var curCityInfo = localStorage.getItem('curCityInfo');
  5. // 宠物医院数据
  6. var hospitalData = [];
  7. // 宠物数据
  8. var petData = [];
  9. // 寻宠数据
  10. var searchPetsData = [];
  11. var searchPetsIndex = 0;
  12. var searchPetsInterval = 5;
  13. // 宠物品种统计数据
  14. var recordPetsPieData = [];
  15. // 上牌排行数据
  16. var recordRankingData = [];
  17. $.ajax({
  18. url: '/?s=pets_screen/getCityData',
  19. async: false,
  20. dataType: 'json',
  21. success: function(resp){
  22. if (resp.success === false) {
  23. alert(resp.message);
  24. return;
  25. }
  26. cityData = resp.data;
  27. if (curCityInfo === null) {
  28. curCityInfo = cityData[0] || [];
  29. localStorage.setItem('curCityInfo', JSON.stringify(curCityInfo));
  30. } else {
  31. curCityInfo = JSON.parse(curCityInfo);
  32. }
  33. }
  34. });
  35. // 宠物医院
  36. function getHospitalData() {
  37. $.ajax({
  38. url: '/?s=pets_screen/getHospitalData',
  39. async: false,
  40. data: 'cityId=' + curCityInfo.id,
  41. dataType: 'json',
  42. success: function(resp){
  43. if (!resp.success) {
  44. console.log('getHospitalData',resp.message);
  45. return;
  46. }
  47. hospitalData = resp.data;
  48. }
  49. });
  50. }
  51. // 宠物数据
  52. function getPetData() {
  53. $.ajax({
  54. url: '/?s=pets_screen/getPetData',
  55. async: false,
  56. data: 'cityId=' + curCityInfo.id,
  57. dataType: 'json',
  58. success: function(resp){
  59. if (!resp.success) {
  60. console.log('getPetData',resp.message);
  61. return;
  62. }
  63. petData = resp.data;
  64. }
  65. });
  66. }
  67. // 寻宠信息
  68. function getSearchPetsData() {
  69. $.ajax({
  70. url: '/?s=pets_screen/getSearchPetsData',
  71. async: false,
  72. data: 'cityId=' + curCityInfo.id,
  73. dataType: 'json',
  74. success: function(resp) {
  75. if (!resp.success) {
  76. console.log('getSearchPetsData',resp.message);
  77. return;
  78. }
  79. searchPetsData = resp.data.data;
  80. resp.interval && (searchPetsInterval = resp.interval)
  81. }
  82. });
  83. }
  84. // 宠物品种统计数据
  85. function getRecordPetsPieData() {
  86. $.ajax({
  87. url: '/?s=pets_screen/getPetBreedData',
  88. async: false,
  89. data: 'cityId=' + curCityInfo.id,
  90. dataType: 'json',
  91. success: function(resp) {
  92. if (!resp.success) {
  93. console.log('getPetBreedData',resp.message);
  94. return;
  95. }
  96. recordPetsPieData = resp.data;
  97. }
  98. });
  99. }
  100. // 上牌排行数据
  101. function getRecordRankingData() {
  102. $.ajax({
  103. url: '/?s=pets_screen/getRecordRankingData',
  104. async: false,
  105. data: 'cityId=' + curCityInfo.id,
  106. dataType: 'json',
  107. success: function(resp) {
  108. if (!resp.success) {
  109. console.log('getRecordRankingData',resp.message);
  110. return;
  111. }
  112. recordRankingData = resp.data;
  113. }
  114. });
  115. }