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.
 
 
 
 
 
 

137 lines
2.7 KiB

  1. window.onload = function (){
  2. // $('#prod_name').focus();
  3. $('#div_body').removeClass('ui_hide');
  4. $('#prod_name').focus();
  5. httpHotProd();
  6. }
  7. //用户输入
  8. function inputSearchProd(){
  9. $$.delay(httpSearchProd,700);
  10. }
  11. //获取焦点
  12. //function focusSearchProd(){
  13. // httpSearchProd();
  14. //}
  15. //点关闭,重新查
  16. function refreshSearchProd(){
  17. $('#prod_name').val('');
  18. $('.hot_div').show();
  19. $('.pro_list').hide();
  20. }
  21. //取消删除
  22. function cancelSearchProd(){
  23. $('#prod_name').val('');
  24. $('.hot_div').show();
  25. $('.pro_list').hide();
  26. }
  27. //查询热门产品
  28. function httpHotProd(){
  29. $.ajax({
  30. type:"post",
  31. url:$$.base_api + 'home/home/get-hot',
  32. dataType: 'json',
  33. success : function(res_data){
  34. $$.ZZLog(res_data);
  35. if (res_data.flag == false) {
  36. $$.alert(res_data.msg);
  37. } else{
  38. $('.pro_list').hide();
  39. replaceHotInfo(res_data.data);
  40. }
  41. },
  42. error : function(){
  43. alert($$.infoApiError);
  44. }
  45. });
  46. }
  47. //替换热门数据
  48. function replaceHotInfo(data){
  49. var hot_list = data.list;
  50. var html = '';
  51. hot_list.forEach(function(name,index){
  52. html += '<div class="ufl ulev1 hot_city">'+name+'</div>';
  53. });
  54. $('.hot_name').html(html);
  55. $('.hot_div').show();
  56. }
  57. //查询检索产品
  58. function httpSearchProd(){
  59. var search_name = $('#prod_name').val();
  60. var data = {
  61. prod_name : search_name
  62. }
  63. $.ajax({
  64. type:"post",
  65. url:$$.base_api + 'home/home/search',
  66. data : data,
  67. dataType: 'json',
  68. success : function(res_data){
  69. $$.ZZLog(res_data);
  70. if (res_data.flag == false) {
  71. $$.alert(res_data.msg);
  72. } else{
  73. if (res_data.code == '1000') {
  74. $('.hot_div').show();
  75. $('.pro_list').hide();
  76. } else{
  77. replaceListInfo(res_data.data);
  78. $('.hot_div').hide();
  79. }
  80. }
  81. },
  82. error : function(){
  83. alert($$.infoApiError);
  84. }
  85. });
  86. }
  87. //替换数据
  88. function replaceListInfo(data){
  89. var list_ary = data.list;
  90. if (list_ary.length == 0) {
  91. $('.list_info').hide();
  92. $('.no_info').show();
  93. } else{
  94. $('.no_info').hide();
  95. var html = '';
  96. list_ary.forEach(function(dict,index){
  97. var temp_pro = '';
  98. dict.list.forEach(function(dict,index){
  99. var prod_name = $('#prod_name').val();
  100. var temp_name = dict.pro_cate_name.replace(prod_name,'<span class="ulev1" style="color:#3177f6;line-height:1.0;">'+prod_name+'</span>');
  101. temp_pro += '<div class="ulev1" style="padding: 0.08rem 0.12rem;color: #2d2e3a;border-bottom:1px solid #e9ebee ;" dict='+dict+'>'+temp_name+'</div>'
  102. })
  103. html += '<div class="ub ub-ver">'+
  104. '<div class="ub cms_title" cate_id='+dict.cate_id+'>'+dict.cate_name+'</div>'+
  105. '<div class="ub ub-ver cms_info">'+temp_pro+
  106. '</div>'+
  107. '</div>'
  108. });
  109. $('.list_info').html(html);
  110. $('.list_info').show();
  111. }
  112. $('.pro_list').show();
  113. }
  114. //返回
  115. function goBack(){
  116. window.history.go(-1);
  117. }