You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

127 lines
4.1 KiB

  1. /**
  2. * Created by luocj on 2016/9/28.
  3. */
  4. var tr_list = '';
  5. var current = '1';
  6. var page_size = '25';
  7. var key_word = '';
  8. var url = '';
  9. var room_name = '';
  10. window.onload = function () {
  11. tr_list = $('.tr_list').prop('outerHTML');//获取tr中所有的字符串
  12. url = base_api;
  13. ZZLog(url);
  14. getProductList()
  15. };
  16. //得到产品列表
  17. function getProductList() {
  18. loading();
  19. ZZLog(url + JSON.stringify({
  20. type: "order_ChooseProduct",
  21. key_word: key_word,
  22. room_name:room_name
  23. }));
  24. $.ajax({
  25. url: url,
  26. type: "post",
  27. data: {
  28. type: "order_ChooseProduct",
  29. key_word: key_word,
  30. room_name: room_name,
  31. current: current,
  32. page_size: page_size
  33. },
  34. dataType: "json",
  35. success: function (res_data) {
  36. ZZLog(res_data);
  37. //进行页面替换
  38. setHTML(res_data);
  39. if (res_data['total_count'] < 1) {
  40. $('.pageDiv').hide();
  41. } else {
  42. $(".pageDiv").createPage({
  43. pageCount: res_data['total_page'],//总页数
  44. current: current,//当前页
  45. turndown: 'true',//是否显示跳转框,显示为true,不现实为false,一定记得加上引号...
  46. backFn: function (p) {
  47. current = p;
  48. //调用分页函数
  49. havePageData();
  50. }
  51. });
  52. $('.pageDiv').show();
  53. closeLoading();
  54. }
  55. }, error: function (e) {
  56. ZZLog(e);
  57. }
  58. })
  59. }
  60. //页面替换函数
  61. function setHTML(data) {
  62. var product_list = data['product_list'];
  63. var sumHTML = '';
  64. var firstHotelName = '';
  65. if (product_list.length > 0) {
  66. firstHotelName = product_list[0]['hotel_name'];
  67. }
  68. for (var i = 0; i < product_list.length; i++) {
  69. var dict = product_list[i];
  70. var HTML = tr_list;
  71. if (i == 0) {
  72. HTML = HTML.replace('[酒店名称]', dict['hotel_name']);
  73. HTML = HTML.replace('[最早入住时间]', dict['earliest_checkin_time'] ? dict['earliest_checkin_time'] : '不限');
  74. HTML = HTML.replace('[供应商]', dict['supplier_name']);
  75. } else {
  76. if (firstHotelName != dict['hotel_name']) {
  77. HTML = HTML.replace('[酒店名称]', dict['hotel_name']);
  78. HTML = HTML.replace('[最早入住时间]', dict['earliest_checkin_time'] ? dict['earliest_checkin_time'] : '不限');
  79. HTML = HTML.replace('[供应商]', dict['supplier_name']);
  80. } else {
  81. HTML = HTML.replace('[酒店名称]', '');
  82. HTML = HTML.replace('[最早入住时间]', '');
  83. HTML = HTML.replace('[供应商]','');
  84. }
  85. }
  86. firstHotelName = dict['hotel_name'];
  87. HTML = HTML.replace('[产品名称]', dict['room_name']);
  88. HTML = HTML.replace('[预订]', '预订');
  89. HTML = HTML.replace('[hotel_id]', dict['hotel_id']);
  90. HTML = HTML.replace('[hotel_name]', dict['hotel_name']);
  91. HTML = HTML.replace('[product_name]', dict['room_name']);
  92. HTML = HTML.replace('[room_type]', dict['room_type']);
  93. HTML = HTML.replace('[parent_room_type]', dict['parent_room_type']);
  94. sumHTML += HTML;
  95. }
  96. $('#product_list').html(sumHTML);
  97. $('#product_list').show();
  98. }
  99. function searchProduct() {
  100. key_word = $('#key_word').val();
  101. room_name = $('#room_name').val();
  102. // url = base_api + "?type=order_ChooseProduct&key_word='" + key_word;
  103. current = 1;
  104. getProductList();
  105. }
  106. function havePageData() {
  107. $.ajax({
  108. url: url,
  109. type: "post",
  110. data: {
  111. type: "order_ChooseProduct",
  112. key_word: key_word,
  113. room_name:room_name,
  114. current: current,
  115. page_size: page_size
  116. },
  117. dataType: "json",
  118. success: function (res_data) {
  119. ZZLog(res_data);
  120. setHTML(res_data);
  121. }, error: function (e) {
  122. ZZLog(e);
  123. }
  124. })
  125. }