您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 

184 行
5.1 KiB

  1. var pagesize =10;
  2. var aa='';
  3. var tttHTML = "";
  4. var tttHTML2="";
  5. var test_test = '';
  6. function reload_Info(httpData,myURL2){
  7. var currpage = getPar("currpage");
  8. // aa = currpage;
  9. // if(currpage){
  10. // }else{
  11. // currpage = 1;
  12. // }
  13. var sum = httpData['totalNum'];
  14. test_test = sum;
  15. if(sum == 0){
  16. alert('没有相关产品!');
  17. return;
  18. }
  19. var tag ="test";
  20. var sendurl = myURL2;
  21. var parent=httpData['parent'];
  22. // var tttHTML=$('#row').prop('outerHTML');
  23. // var tttHTML2=$('#two').prop('outerHTML');
  24. var newHTML=''
  25. for(var i=0;i<parent.length;i++){
  26. var tempDict=parent[i];
  27. var tempHTML=tttHTML;
  28. tempHTML=tempHTML.replace('row','row-'+i);
  29. tempHTML=tempHTML.replace('[名称]',tempDict['parentsId']);
  30. // tempHTML=tempHTML.replace('[已售]',tempDict['parentSale']);
  31. var child=tempDict['children'];
  32. for(var j=0;j<child.length;j++){
  33. var tempDict2=child[j];
  34. var tempHTML2=tttHTML2;
  35. tempHTML2=tempHTML2.replace('child-row','child-row-'+i);
  36. tempHTML2=tempHTML2.replace('[row名称]',tempDict2['productName']);
  37. tempHTML2=tempHTML2.replace('[row供应商]',tempDict2['supplierName']);
  38. tempHTML2=tempHTML2.replace('[row支付方式]',tempDict2['payStyle']);
  39. tempHTML2=tempHTML2.replace('[pay_id]',tempDict2['prod_id']);
  40. tempHTML+=tempHTML2;
  41. }
  42. newHTML+=tempHTML;
  43. }
  44. $('#one').html(newHTML);
  45. getPager(sendurl, sum, currpage, pagesize,tag,'currpage');
  46. }
  47. window.onload=function (){
  48. var keywords=getPar("keywords");
  49. // var pagesize=getPar("pagesize");
  50. var currpage=getPar("currpage");
  51. tttHTML=$('#row').prop('outerHTML');
  52. tttHTML=tttHTML.replace('none','table-row');
  53. tttHTML2=$('#two').prop('outerHTML');
  54. tttHTML2=tttHTML2.replace('none','table-row');
  55. // var myUrl1 = "http://temp.zhizhuchuxing.com/st-xm/Api/select_product.php"
  56. // var myUrl2 = "selectProduct.html";
  57. if(!currpage){
  58. var keywords = $('#keywords').val();
  59. var myUrl1 = "./st-xm/Api/select_product.php?keywords="+keywords+"&pagesize="+pagesize+"&currpage=1";
  60. var myUrl2 = "./selectProduct.html?keywords="+keywords;
  61. get_virtual_user_list(myUrl1,myUrl2);
  62. }else{
  63. // var keywords = $('#keywords').val();
  64. var myUrl1 = "./st-xm/Api/select_product.php?keywords="+keywords+"&pagesize="+pagesize+"&currpage="+currpage;
  65. var myUrl2 = "./selectProduct.html?keywords="+keywords;
  66. get_virtual_user_list(myUrl1,myUrl2);
  67. }
  68. // else{
  69. // var keywords = $('#keywords').val();
  70. // $("#row").css('display','');
  71. // $("#two").css('display','');
  72. // var myUrl1 = "http://temp.zhizhuchuxing.com/st-xm/Api/select_product.php?keywords="+keywords+"&pagesize="+pagesize+"&currpage="+aa;
  73. // var myUrl2 = "./selectProduct.html?keywords="+keywords;
  74. // get_virtual_user_list(myUrl1,myUrl2);
  75. // }
  76. // else{
  77. // currpage = getPar("currpage");
  78. // aa = currpage;
  79. //
  80. // var myUrl1 = "http://temp.zhizhuchuxing.com/st-xm/Api/select_product.php?keywords="+keywords+"&pagesize="+pagesize+"&currpage="+aa;
  81. // var myUrl2 = "./selectProduct.html?keywords="+keywords+"&pagesize="+pagesize;
  82. // $("#row").css('display','');
  83. // $("#two").css('display','');
  84. // get_virtual_user_list(myUrl1,myUrl2);
  85. // }
  86. // get_virtual_user_list('./json/selectProductJson.html');
  87. }
  88. /*======================网络请求的Ajax的代码=======================*/
  89. // 创建一个Ajax对象
  90. if (window.ActiveXObject){
  91. var myreq = new ActiveXObject("Microsoft.XMLHTTP");
  92. }else{
  93. var myreq = new XMLHttpRequest();
  94. }
  95. function get_virtual_user_list(myURL,myURL2)
  96. {
  97. myreq.open("get",myURL,true);
  98. // 接收的数据交给哪个函数处理
  99. myreq.onreadystatechange = function(){
  100. if (myreq.readyState == 4)
  101. {
  102. // newstr 就是接收到的数据
  103. var newstr = myreq.responseText;
  104. var httpData=JSON.parse(newstr);
  105. reload_Info(httpData,myURL2);
  106. }
  107. };
  108. myreq.send();
  109. }
  110. $(document).ready(function() {
  111. $("#searchBtn").click(function() {
  112. $('#test').html('');
  113. var keywords = $('#keywords').val();
  114. // if(keywords.trim().length<=0){
  115. // alert('缺少关键字');
  116. // return;
  117. // }else{
  118. // $("#row").css('display','');
  119. // $("#two").css('display','');
  120. var myUrl1 = "./st-xm/Api/select_product.php?keywords="+keywords+"&pagesize="+pagesize+"&currpage=1";
  121. var myUrl2 = "./selectProduct.html?keywords="+keywords;
  122. get_virtual_user_list(myUrl1,myUrl2);
  123. // }
  124. })
  125. });
  126. function getPar(par){
  127. //获取当前URL
  128. var local_url = document.location.href;
  129. local_url = decodeURI(local_url);
  130. //获取要取得的get参数位置
  131. var get = local_url.indexOf(par +"=");
  132. if(get == -1){
  133. return false;
  134. }
  135. //截取字符串
  136. var get_par = local_url.slice(par.length + get + 1);
  137. //判断截取后的字符串是否还有其他get参数
  138. var nextPar = get_par.indexOf("&");
  139. if(nextPar != -1){
  140. get_par = get_par.slice(0, nextPar);
  141. }
  142. return get_par;
  143. }
  144. //折叠
  145. function click_parent(par_id){
  146. // $('#row-'+par_id).siblings('.child-'+par_id).toggle();
  147. //折叠功能
  148. // $('tr').each(function(){
  149. // if (this.className=='child-'+par_id) {
  150. // $(this).css('display')=='none'?$(this).css('display','table-row'):$(this).css('display','none')
  151. // }
  152. // })
  153. }
  154. //下单操作
  155. function pay_order(sender){
  156. var str = "hotelPlaceOrder.html?prod_id="+sender;
  157. var a = $('#'+sender).attr("href",str);
  158. }