|
-
- var pagesize =10;
- var aa='';
- var tttHTML='';
- var tttHTML2='';
-
-
- function reload_Info(httpData,myURL2){
- var currpage = getPar("currpage");
- if(currpage){
- }else{
- currpage = 1;
- }
-
-
-
- var sum = httpData['totalNum'];
- if(sum == 0){
- alert('没有相关产品!');
- }
- var tag ="test";
- var sendurl = myURL2;
-
- var parent=httpData['parent'];
-
- var newHTML=''
- var ho_id = '';
- 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['hotelName']);
- tempHTML=tempHTML.replace('[addInfo]',tempDict['hotelId']);
- tempHTML=tempHTML.replace('[addName]',tempDict['hotelName']);
- ho_id = tempDict['hotelId'];
- // tempHTML=tempHTML.replace('[已售]',tempDict['parentSale']);
- var child=tempDict['children'];
- var parStr = '';
- 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['select_prod_name']);
- tempHTML2=tempHTML2.replace('[row供应商]',tempDict2['supplier']);
- tempHTML2=tempHTML2.replace('[row支付方式]',tempDict2['payStyle']);
-
-
-
-
- // tempHTML2=tempHTML2.replace('[changeInfo]',tempDict2['pro_id']);
- // tempHTML2=tempHTML2.replace('[hoid]',ho_id);
- // tempHTML2=tempHTML2.replace('[copyInfo]',tempDict2['pro_id']);
- // tempHTML2=tempHTML2.replace('[seeInfo]',tempDict2['pro_id']);
- // tempHTML2=tempHTML2.replace('[hotelInfo]',tempDict['hotelId']);
- tempHTML2=tempHTML2.replace('two',tempDict2['pro_id']);
- // tempHTML=tempHTML.replace('[oneCheck]',tempDict2['pro_id']);
- // var see= '<a onclick= "" target="_black">修改';
- // tempHTML2=tempHTML2.replace('修改',see);
-
- // tempHTML2=tempHTML2.replace('[row已售]',tempDict2['is_onsale']);
- parStr = parStr + tempDict2['pro_id']+','
-
- if(tempDict2['is_onsale']==1){
- tempHTML2=tempHTML2.replace('[row已售]','上架');
- }else{
- tempHTML2=tempHTML2.replace('[row已售]','下架');
- }
- var cz_str='<a style="margin-left: 10px;" name="changeInfo" target="_blank" href="change_hotel.html?productId='+tempDict2['pro_id']+'" class="changeInfo" id="'+tempDict2['pro_id']+'">修改</a>';
- cz_str+='<a style="margin-left: 10px;" onclick="open_new_path(this)" go_path="copy_hotel.html?productId='+tempDict2['pro_id']+'&hotelId='+ho_id+'" class="copyInfo" id="'+tempDict2['pro_id']+'" target="_blank">复制</a>';
- cz_str+='<a style="margin-left: 10px;" onclick="open_new_path(this)" go_path="ccss.html?prod_id='+tempDict2['pro_id']+'&hotelName='+tempDict['hotelId']+'" id="'+tempDict['hotelId']+'" target="_blank">价格库存</a>';
- tempHTML2=tempHTML2.replace('[row操作]',cz_str);
-
-
-
- tempHTML+=tempHTML2;
- }
- parStr = parStr.substr(0,parStr.length-1);
- // parStr = parStr;
- tempHTML=tempHTML.replace('oneCheck1',parStr);
- // alert(parStr);
- // alert($('.ace_check')[0].attr('name'));
- // var checkList = $('.ace_check');
- // checkList[i].attr("name",parStr);
- // var onestr = $('#oneCheck').val(parStr);
-
- newHTML+=tempHTML;
- }
- $('#one').html(newHTML);
-
- getPager(sendurl, sum, currpage, pagesize,tag,'currpage');
- }
-
-
- window.onload=function (){
-
-
-
- var keywords = getPar("keywords");
- var saleStyle =getPar("saleStyle");
-
- tttHTML=$('#row').prop('outerHTML');
- tttHTML=tttHTML.replace('none','table-row');
- tttHTML2=$('#two').prop('outerHTML');
- tttHTML2=tttHTML2.replace('none','table-row');
-
-
- //以下为非优化正常版本
- // var myUrl1 = "./st-xm/Api/hotel_list.php";
- // var myUrl2 = "hotel_list.html";
- // if(keywords||saleStyle){
- // currpage = getPar("currpage");
- // aa = currpage;
- // var myUrl1 = "./st-xm/Api/hotel_list.php?keywords="+keywords+"&saleStyle="+saleStyle+"&pagesize="+pagesize+"&currpage="+aa;
- // var myUrl2 = "./hotel_list.html?keywords="+keywords+"&saleStyle="+saleStyle+"&pagesize="+pagesize;
- // get_virtual_user_list(myUrl1,myUrl2);
- // }
- var currpage = getPar("currpage");
-
- if(!currpage){
- var keywords = $('#keywords').val();
- var saleStyle = $('#if_onSale').val();
- var myUrl1 = "./st-xm/Api/hotel_list.php?keywords="+keywords+"&saleStyle="+saleStyle+"&pagesize="+pagesize+"&currpage=1";
- var myUrl2 = "./hotel_list.html?keywords="+keywords+"&saleStyle="+saleStyle+"&pagesize="+pagesize;
- get_virtual_user_list(myUrl1,myUrl2);
- }else{
- var keywords = $('#keywords').val();
- var saleStyle = $('#if_onSale').val();
- var myUrl1 = "./st-xm/Api/hotel_list.php?keywords="+keywords+"&saleStyle="+saleStyle+"&pagesize="+pagesize+"&currpage="+currpage;
- var myUrl2 = "./hotel_list.html?keywords="+keywords+"&saleStyle="+saleStyle+"&pagesize="+pagesize;
- get_virtual_user_list(myUrl1,myUrl2);
- }
-
- }
-
-
-
- /*======================网络请求的Ajax的代码=======================*/
-
- // 创建一个Ajax对象
- if (window.ActiveXObject){
- var myreq = new ActiveXObject("Microsoft.XMLHTTP");
- }else{
- var myreq = new XMLHttpRequest();
- }
-
- // 请求方法,传入URL
- 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();
- }
- 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 search(){
-
- var keywords = $('#keywords').val();
- var saleStyle = $('#if_onSale').val();
- // var cansee = $('#row').css("display","");
- // var cansee1 = $('#two').css("display","");
- var myUrl1 = "./st-xm/Api/hotel_list.php?keywords="+keywords+"&saleStyle="+saleStyle+"&pagesize="+pagesize+"&currpage="+aa;
- var myUrl2 = "./hotel_list.html?keywords="+keywords+"&saleStyle="+saleStyle;
- get_virtual_user_list(myUrl1,myUrl2);
-
-
- }
-
- function addOneLine(){
-
- }
-
-
- //复选框选中判断
- function select_checked(index) {
- //index=0最上面的全选 index=1表示的是下面所有的
- var cur_check = $('.ace_check')[0];
- var checkList = $('.ace_check');
- var checkCount = checkList.length - 1;
- var true_count = 0;
- for (var i = 1; i < checkList.length; i++) {
- if (index == '0') {
- checkList[i].checked = cur_check.checked;
- } else {
- if (checkList[i].checked == false) {
- cur_check.checked = false
- } else {
- true_count = true_count + 1;
- }
- }
- }
- //判断下面是否选中完
- if (checkCount == true_count) {
- cur_check.checked = true;
- }
- }
-
- //function all_select_checked(sender){
- // var checkList = $('.one_ace_check');
- // var listCount = checkList.length;
- // var allStyle = sender.checked;
- // if(allStyle == true){
- // for(var i = 0 ; i<listCount; i++){
- // checkList[i].checked = true;
- // //id
- // alert(checkList[i].id);
- // var parentID = $('#'+checkList[i].id).parent.id;
- // alert(parentID);
- //
- // }
- // }else{
- // for(var i = 0 ; i<listCount; i++){
- // checkList[i].checked = false;
- // }
- // }
- //}
-
- function one_select_checked(sender){
-
- }
-
-
- //修改产品信息
- //function changeInfo(sender){
- // var str = "./change_hotel.html?productId="+sender;
- // alert('dfafda'+str);
- // var b = $('#'+sender).attr("href",str);
- //}
- //添加酒店
- function add_product_by_hotel(sender){
-
- var hotelName = $('#'+sender).attr("name");
- var str = "./add_hotel.html?hotelId="+sender+"&hotelName="+hotelName;
- var a = $('#'+sender).attr("href",str);
- }
- //上架产品
- function up_on_sale(){
- var checkList = $('.ace_check');
- var parStr = '(';
- for (var i=0;i<checkList.length;i++) {
- if(i!=0 && checkList[i].checked == true){
- //jquery 得到的对象 要用源生的继续取值
- parStr=parStr + checkList[i].getAttribute("name");
- }
- }
- parStr = parStr+')';
-
- $.ajax({
- url:'./st-xm/Api/hotel_prod_del.php', //请求地址
- type: "post", //请求方式
- data: { method:2,prod_id:parStr,added:1}, //请求参数
- async:false,
- dataType: "json",
- success: function (response) {
- // jieguo =response;
- var listURL = "hotel_list.html";
- // 跳转前将URL编码
- listURL = encodeURI(listURL);
- window.location.href = listURL;
- },
- fail: function (status) {
- // 此处放失败后执行的代码
- }
- });
-
- // var onsale=$.ajax({
- // type:'get',
- // url:'http://192.168.6.108:8082/st-xm/Api/hotel_prod_del.php?method=2&prod_id='+parStr+'&added=1',
- // data:{},
- // dataType:'json',
- // success:function(data){
- // alert('111');
- // alert(data);
- // },
- // error:function(){}
- // });
-
- }
- //下架产品
- function down_on_sale(){
- var checkList = $('.ace_check');
- var parStr ='(';
- for (var i=0;i<checkList.length;i++) {
- if(i!=0 && checkList[i].checked == true){
- //jquery 得到的对象 要用源生的继续取值
- parStr=parStr + checkList[i].getAttribute("name");
- }
- }
- parStr = parStr+')';
- $.ajax({
- url:'./st-xm/Api/hotel_prod_del.php', //请求地址
- type: "post", //请求方式
- data: { method:2,prod_id:parStr,added:0}, //请求参数
- async:false,
- dataType: "json",
- success: function (response) {
- // jieguo =response;
- var listURL = "hotel_list.html";
- // 跳转前将URL编码
- listURL = encodeURI(listURL);
- window.location.href = listURL;
- },
- fail: function (status) {
- // 此处放失败后执行的代码
- }
- });
- }
- //删除产品
- function del_product(){
- var checkList = $('.ace_check');
- var parStr = '(';
- for (var i=0;i<checkList.length;i++) {
- if(i!=0 && checkList[i].checked == true){
- //jquery 得到的对象 要用源生的继续取值
- parStr=parStr + checkList[i].getAttribute("name");
- }
- }
- parStr = parStr+')';
- $.ajax({
- url:'./st-xm/Api/hotel_prod_del.php', //请求地址
- type: "post", //请求方式
- data: { method:1,prod_id:parStr,added:0}, //请求参数
- async:false,
- dataType: "json",
- success: function (response) {
-
- // jieguo =response;
- alert('删除产品成功');
- var listURL = "hotel_list.html";
- // 跳转前将URL编码
- listURL = encodeURI(listURL);
- window.location.href = listURL;
-
- },
- fail: function (status) {
- // 此处放失败后执行的代码
- }
- });
- }
|