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.
 
 
 
 

366 lines
11 KiB

  1. var pagesize =10;
  2. var aa='';
  3. var tttHTML='';
  4. var tttHTML2='';
  5. function reload_Info(httpData,myURL2){
  6. var currpage = getPar("currpage");
  7. if(currpage){
  8. }else{
  9. currpage = 1;
  10. }
  11. var sum = httpData['totalNum'];
  12. if(sum == 0){
  13. alert('没有相关产品!');
  14. }
  15. var tag ="test";
  16. var sendurl = myURL2;
  17. var parent=httpData['parent'];
  18. var newHTML=''
  19. var ho_id = '';
  20. for(var i=0;i<parent.length;i++){
  21. var tempDict=parent[i];
  22. var tempHTML=tttHTML;
  23. tempHTML=tempHTML.replace('row','row-'+i);
  24. tempHTML=tempHTML.replace('[名称]',tempDict['hotelName']);
  25. tempHTML=tempHTML.replace('[addInfo]',tempDict['hotelId']);
  26. tempHTML=tempHTML.replace('[addName]',tempDict['hotelName']);
  27. ho_id = tempDict['hotelId'];
  28. // tempHTML=tempHTML.replace('[已售]',tempDict['parentSale']);
  29. var child=tempDict['children'];
  30. var parStr = '';
  31. for(var j=0;j<child.length;j++){
  32. var tempDict2=child[j];
  33. var tempHTML2=tttHTML2;
  34. tempHTML2=tempHTML2.replace('child-row','child-row-'+i);
  35. tempHTML2=tempHTML2.replace('[row名称]',tempDict2['select_prod_name']);
  36. tempHTML2=tempHTML2.replace('[row供应商]',tempDict2['supplier']);
  37. tempHTML2=tempHTML2.replace('[row支付方式]',tempDict2['payStyle']);
  38. // tempHTML2=tempHTML2.replace('[changeInfo]',tempDict2['pro_id']);
  39. // tempHTML2=tempHTML2.replace('[hoid]',ho_id);
  40. // tempHTML2=tempHTML2.replace('[copyInfo]',tempDict2['pro_id']);
  41. // tempHTML2=tempHTML2.replace('[seeInfo]',tempDict2['pro_id']);
  42. // tempHTML2=tempHTML2.replace('[hotelInfo]',tempDict['hotelId']);
  43. tempHTML2=tempHTML2.replace('two',tempDict2['pro_id']);
  44. // tempHTML=tempHTML.replace('[oneCheck]',tempDict2['pro_id']);
  45. // var see= '<a onclick= "" target="_black">修改';
  46. // tempHTML2=tempHTML2.replace('修改',see);
  47. // tempHTML2=tempHTML2.replace('[row已售]',tempDict2['is_onsale']);
  48. parStr = parStr + tempDict2['pro_id']+','
  49. if(tempDict2['is_onsale']==1){
  50. tempHTML2=tempHTML2.replace('[row已售]','上架');
  51. }else{
  52. tempHTML2=tempHTML2.replace('[row已售]','下架');
  53. }
  54. 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>';
  55. 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>';
  56. 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>';
  57. tempHTML2=tempHTML2.replace('[row操作]',cz_str);
  58. tempHTML+=tempHTML2;
  59. }
  60. parStr = parStr.substr(0,parStr.length-1);
  61. // parStr = parStr;
  62. tempHTML=tempHTML.replace('oneCheck1',parStr);
  63. // alert(parStr);
  64. // alert($('.ace_check')[0].attr('name'));
  65. // var checkList = $('.ace_check');
  66. // checkList[i].attr("name",parStr);
  67. // var onestr = $('#oneCheck').val(parStr);
  68. newHTML+=tempHTML;
  69. }
  70. $('#one').html(newHTML);
  71. getPager(sendurl, sum, currpage, pagesize,tag,'currpage');
  72. }
  73. window.onload=function (){
  74. var keywords = getPar("keywords");
  75. var saleStyle =getPar("saleStyle");
  76. tttHTML=$('#row').prop('outerHTML');
  77. tttHTML=tttHTML.replace('none','table-row');
  78. tttHTML2=$('#two').prop('outerHTML');
  79. tttHTML2=tttHTML2.replace('none','table-row');
  80. //以下为非优化正常版本
  81. // var myUrl1 = "./st-xm/Api/hotel_list.php";
  82. // var myUrl2 = "hotel_list.html";
  83. // if(keywords||saleStyle){
  84. // currpage = getPar("currpage");
  85. // aa = currpage;
  86. // var myUrl1 = "./st-xm/Api/hotel_list.php?keywords="+keywords+"&saleStyle="+saleStyle+"&pagesize="+pagesize+"&currpage="+aa;
  87. // var myUrl2 = "./hotel_list.html?keywords="+keywords+"&saleStyle="+saleStyle+"&pagesize="+pagesize;
  88. // get_virtual_user_list(myUrl1,myUrl2);
  89. // }
  90. var currpage = getPar("currpage");
  91. if(!currpage){
  92. var keywords = $('#keywords').val();
  93. var saleStyle = $('#if_onSale').val();
  94. var myUrl1 = "./st-xm/Api/hotel_list.php?keywords="+keywords+"&saleStyle="+saleStyle+"&pagesize="+pagesize+"&currpage=1";
  95. var myUrl2 = "./hotel_list.html?keywords="+keywords+"&saleStyle="+saleStyle+"&pagesize="+pagesize;
  96. get_virtual_user_list(myUrl1,myUrl2);
  97. }else{
  98. var keywords = $('#keywords').val();
  99. var saleStyle = $('#if_onSale').val();
  100. var myUrl1 = "./st-xm/Api/hotel_list.php?keywords="+keywords+"&saleStyle="+saleStyle+"&pagesize="+pagesize+"&currpage="+currpage;
  101. var myUrl2 = "./hotel_list.html?keywords="+keywords+"&saleStyle="+saleStyle+"&pagesize="+pagesize;
  102. get_virtual_user_list(myUrl1,myUrl2);
  103. }
  104. }
  105. /*======================网络请求的Ajax的代码=======================*/
  106. // 创建一个Ajax对象
  107. if (window.ActiveXObject){
  108. var myreq = new ActiveXObject("Microsoft.XMLHTTP");
  109. }else{
  110. var myreq = new XMLHttpRequest();
  111. }
  112. // 请求方法,传入URL
  113. function get_virtual_user_list(myURL,myURL2)
  114. {
  115. myreq.open("get",myURL,true);
  116. // 接收的数据交给哪个函数处理
  117. myreq.onreadystatechange = function(){
  118. if (myreq.readyState == 4)
  119. {
  120. // newstr 就是接收到的数据
  121. var newstr = myreq.responseText;
  122. var httpData=JSON.parse(newstr);
  123. reload_Info(httpData,myURL2);
  124. }
  125. };
  126. myreq.send();
  127. }
  128. function getPar(par){
  129. //获取当前URL
  130. var local_url = document.location.href;
  131. local_url = decodeURI(local_url);
  132. //获取要取得的get参数位置
  133. var get = local_url.indexOf(par +"=");
  134. if(get == -1){
  135. return false;
  136. }
  137. //截取字符串
  138. var get_par = local_url.slice(par.length + get + 1);
  139. //判断截取后的字符串是否还有其他get参数
  140. var nextPar = get_par.indexOf("&");
  141. if(nextPar != -1){
  142. get_par = get_par.slice(0, nextPar);
  143. }
  144. return get_par;
  145. }
  146. function search(){
  147. var keywords = $('#keywords').val();
  148. var saleStyle = $('#if_onSale').val();
  149. // var cansee = $('#row').css("display","");
  150. // var cansee1 = $('#two').css("display","");
  151. var myUrl1 = "./st-xm/Api/hotel_list.php?keywords="+keywords+"&saleStyle="+saleStyle+"&pagesize="+pagesize+"&currpage="+aa;
  152. var myUrl2 = "./hotel_list.html?keywords="+keywords+"&saleStyle="+saleStyle;
  153. get_virtual_user_list(myUrl1,myUrl2);
  154. }
  155. function addOneLine(){
  156. }
  157. //复选框选中判断
  158. function select_checked(index) {
  159. //index=0最上面的全选 index=1表示的是下面所有的
  160. var cur_check = $('.ace_check')[0];
  161. var checkList = $('.ace_check');
  162. var checkCount = checkList.length - 1;
  163. var true_count = 0;
  164. for (var i = 1; i < checkList.length; i++) {
  165. if (index == '0') {
  166. checkList[i].checked = cur_check.checked;
  167. } else {
  168. if (checkList[i].checked == false) {
  169. cur_check.checked = false
  170. } else {
  171. true_count = true_count + 1;
  172. }
  173. }
  174. }
  175. //判断下面是否选中完
  176. if (checkCount == true_count) {
  177. cur_check.checked = true;
  178. }
  179. }
  180. //function all_select_checked(sender){
  181. // var checkList = $('.one_ace_check');
  182. // var listCount = checkList.length;
  183. // var allStyle = sender.checked;
  184. // if(allStyle == true){
  185. // for(var i = 0 ; i<listCount; i++){
  186. // checkList[i].checked = true;
  187. // //id
  188. // alert(checkList[i].id);
  189. // var parentID = $('#'+checkList[i].id).parent.id;
  190. // alert(parentID);
  191. //
  192. // }
  193. // }else{
  194. // for(var i = 0 ; i<listCount; i++){
  195. // checkList[i].checked = false;
  196. // }
  197. // }
  198. //}
  199. function one_select_checked(sender){
  200. }
  201. //修改产品信息
  202. //function changeInfo(sender){
  203. // var str = "./change_hotel.html?productId="+sender;
  204. // alert('dfafda'+str);
  205. // var b = $('#'+sender).attr("href",str);
  206. //}
  207. //添加酒店
  208. function add_product_by_hotel(sender){
  209. var hotelName = $('#'+sender).attr("name");
  210. var str = "./add_hotel.html?hotelId="+sender+"&hotelName="+hotelName;
  211. var a = $('#'+sender).attr("href",str);
  212. }
  213. //上架产品
  214. function up_on_sale(){
  215. var checkList = $('.ace_check');
  216. var parStr = '(';
  217. for (var i=0;i<checkList.length;i++) {
  218. if(i!=0 && checkList[i].checked == true){
  219. //jquery 得到的对象 要用源生的继续取值
  220. parStr=parStr + checkList[i].getAttribute("name");
  221. }
  222. }
  223. parStr = parStr+')';
  224. $.ajax({
  225. url:'./st-xm/Api/hotel_prod_del.php', //请求地址
  226. type: "post", //请求方式
  227. data: { method:2,prod_id:parStr,added:1}, //请求参数
  228. async:false,
  229. dataType: "json",
  230. success: function (response) {
  231. // jieguo =response;
  232. var listURL = "hotel_list.html";
  233. // 跳转前将URL编码
  234. listURL = encodeURI(listURL);
  235. window.location.href = listURL;
  236. },
  237. fail: function (status) {
  238. // 此处放失败后执行的代码
  239. }
  240. });
  241. // var onsale=$.ajax({
  242. // type:'get',
  243. // url:'http://192.168.6.108:8082/st-xm/Api/hotel_prod_del.php?method=2&prod_id='+parStr+'&added=1',
  244. // data:{},
  245. // dataType:'json',
  246. // success:function(data){
  247. // alert('111');
  248. // alert(data);
  249. // },
  250. // error:function(){}
  251. // });
  252. }
  253. //下架产品
  254. function down_on_sale(){
  255. var checkList = $('.ace_check');
  256. var parStr ='(';
  257. for (var i=0;i<checkList.length;i++) {
  258. if(i!=0 && checkList[i].checked == true){
  259. //jquery 得到的对象 要用源生的继续取值
  260. parStr=parStr + checkList[i].getAttribute("name");
  261. }
  262. }
  263. parStr = parStr+')';
  264. $.ajax({
  265. url:'./st-xm/Api/hotel_prod_del.php', //请求地址
  266. type: "post", //请求方式
  267. data: { method:2,prod_id:parStr,added:0}, //请求参数
  268. async:false,
  269. dataType: "json",
  270. success: function (response) {
  271. // jieguo =response;
  272. var listURL = "hotel_list.html";
  273. // 跳转前将URL编码
  274. listURL = encodeURI(listURL);
  275. window.location.href = listURL;
  276. },
  277. fail: function (status) {
  278. // 此处放失败后执行的代码
  279. }
  280. });
  281. }
  282. //删除产品
  283. function del_product(){
  284. var checkList = $('.ace_check');
  285. var parStr = '(';
  286. for (var i=0;i<checkList.length;i++) {
  287. if(i!=0 && checkList[i].checked == true){
  288. //jquery 得到的对象 要用源生的继续取值
  289. parStr=parStr + checkList[i].getAttribute("name");
  290. }
  291. }
  292. parStr = parStr+')';
  293. $.ajax({
  294. url:'./st-xm/Api/hotel_prod_del.php', //请求地址
  295. type: "post", //请求方式
  296. data: { method:1,prod_id:parStr,added:0}, //请求参数
  297. async:false,
  298. dataType: "json",
  299. success: function (response) {
  300. // jieguo =response;
  301. alert('删除产品成功');
  302. var listURL = "hotel_list.html";
  303. // 跳转前将URL编码
  304. listURL = encodeURI(listURL);
  305. window.location.href = listURL;
  306. },
  307. fail: function (status) {
  308. // 此处放失败后执行的代码
  309. }
  310. });
  311. }