|
- var pagesize =10;
- var aa='';
-
- var tttHTML = "";
- var tttHTML2="";
-
- var test_test = '';
-
- function reload_Info(httpData,myURL2){
- var currpage = getPar("currpage");
- // aa = currpage;
- // if(currpage){
- // }else{
- // currpage = 1;
- // }
- var sum = httpData['totalNum'];
-
- test_test = sum;
- if(sum == 0){
- alert('没有相关产品!');
- return;
- }
- var tag ="test";
- var sendurl = myURL2;
-
- var parent=httpData['parent'];
- // var tttHTML=$('#row').prop('outerHTML');
- // var tttHTML2=$('#two').prop('outerHTML');
- var newHTML=''
- for(var i=0;i<parent.length;i++){
- var tempDict=parent[i];
- var tempHTML=tttHTML;
-
- tempHTML=tempHTML.replace('row','row-'+i);
- tempHTML=tempHTML.replace('[名称]',tempDict['parentsId']);
- // tempHTML=tempHTML.replace('[已售]',tempDict['parentSale']);
- var child=tempDict['children'];
- for(var j=0;j<child.length;j++){
- var tempDict2=child[j];
- var tempHTML2=tttHTML2;
- tempHTML2=tempHTML2.replace('child-row','child-row-'+i);
- tempHTML2=tempHTML2.replace('[row名称]',tempDict2['productName']);
- tempHTML2=tempHTML2.replace('[row供应商]',tempDict2['supplierName']);
- tempHTML2=tempHTML2.replace('[row支付方式]',tempDict2['payStyle']);
- tempHTML2=tempHTML2.replace('[pay_id]',tempDict2['prod_id']);
- tempHTML+=tempHTML2;
- }
- newHTML+=tempHTML;
- }
- $('#one').html(newHTML);
- getPager(sendurl, sum, currpage, pagesize,tag,'currpage');
-
- }
-
- window.onload=function (){
-
- var keywords=getPar("keywords");
- // var pagesize=getPar("pagesize");
- var currpage=getPar("currpage");
-
- tttHTML=$('#row').prop('outerHTML');
- tttHTML=tttHTML.replace('none','table-row');
- tttHTML2=$('#two').prop('outerHTML');
- tttHTML2=tttHTML2.replace('none','table-row');
-
- // var myUrl1 = "http://temp.zhizhuchuxing.com/st-xm/Api/select_product.php"
- // var myUrl2 = "selectProduct.html";
- if(!currpage){
- var keywords = $('#keywords').val();
- var myUrl1 = "./st-xm/Api/select_product.php?keywords="+keywords+"&pagesize="+pagesize+"&currpage=1";
- var myUrl2 = "./selectProduct.html?keywords="+keywords;
- get_virtual_user_list(myUrl1,myUrl2);
- }else{
- // var keywords = $('#keywords').val();
- var myUrl1 = "./st-xm/Api/select_product.php?keywords="+keywords+"&pagesize="+pagesize+"&currpage="+currpage;
- var myUrl2 = "./selectProduct.html?keywords="+keywords;
- get_virtual_user_list(myUrl1,myUrl2);
- }
-
- // else{
- // var keywords = $('#keywords').val();
- // $("#row").css('display','');
- // $("#two").css('display','');
- // var myUrl1 = "http://temp.zhizhuchuxing.com/st-xm/Api/select_product.php?keywords="+keywords+"&pagesize="+pagesize+"&currpage="+aa;
- // var myUrl2 = "./selectProduct.html?keywords="+keywords;
- // get_virtual_user_list(myUrl1,myUrl2);
- // }
- // else{
- // currpage = getPar("currpage");
- // aa = currpage;
- //
- // var myUrl1 = "http://temp.zhizhuchuxing.com/st-xm/Api/select_product.php?keywords="+keywords+"&pagesize="+pagesize+"&currpage="+aa;
- // var myUrl2 = "./selectProduct.html?keywords="+keywords+"&pagesize="+pagesize;
- // $("#row").css('display','');
- // $("#two").css('display','');
- // get_virtual_user_list(myUrl1,myUrl2);
- // }
-
- // get_virtual_user_list('./json/selectProductJson.html');
- }
-
- /*======================网络请求的Ajax的代码=======================*/
-
- // 创建一个Ajax对象
- if (window.ActiveXObject){
- var myreq = new ActiveXObject("Microsoft.XMLHTTP");
- }else{
- var myreq = new XMLHttpRequest();
- }
- function get_virtual_user_list(myURL,myURL2)
- {
- myreq.open("get",myURL,true);
-
- // 接收的数据交给哪个函数处理
- myreq.onreadystatechange = function(){
- if (myreq.readyState == 4)
- {
- // newstr 就是接收到的数据
- var newstr = myreq.responseText;
- var httpData=JSON.parse(newstr);
- reload_Info(httpData,myURL2);
- }
- };
- myreq.send();
- }
-
-
- $(document).ready(function() {
- $("#searchBtn").click(function() {
- $('#test').html('');
- var keywords = $('#keywords').val();
-
- // if(keywords.trim().length<=0){
- // alert('缺少关键字');
- // return;
- // }else{
- // $("#row").css('display','');
- // $("#two").css('display','');
-
- var myUrl1 = "./st-xm/Api/select_product.php?keywords="+keywords+"&pagesize="+pagesize+"&currpage=1";
- var myUrl2 = "./selectProduct.html?keywords="+keywords;
-
- get_virtual_user_list(myUrl1,myUrl2);
- // }
-
-
- })
- });
-
- function getPar(par){
- //获取当前URL
- var local_url = document.location.href;
- local_url = decodeURI(local_url);
- //获取要取得的get参数位置
- var get = local_url.indexOf(par +"=");
- if(get == -1){
- return false;
- }
- //截取字符串
- var get_par = local_url.slice(par.length + get + 1);
- //判断截取后的字符串是否还有其他get参数
- var nextPar = get_par.indexOf("&");
- if(nextPar != -1){
- get_par = get_par.slice(0, nextPar);
- }
- return get_par;
- }
- //折叠
- function click_parent(par_id){
- // $('#row-'+par_id).siblings('.child-'+par_id).toggle();
- //折叠功能
- // $('tr').each(function(){
- // if (this.className=='child-'+par_id) {
- // $(this).css('display')=='none'?$(this).css('display','table-row'):$(this).css('display','none')
- // }
- // })
- }
- //下单操作
- function pay_order(sender){
- var str = "hotelPlaceOrder.html?prod_id="+sender;
- var a = $('#'+sender).attr("href",str);
- }
|