Authored by wangqing

换回旧的导航

@@ -204,7 +204,7 @@ function actionGoodsCart() { @@ -204,7 +204,7 @@ function actionGoodsCart() {
204 }; 204 };
205 var params = ''; 205 var params = '';
206 206
207 - if (typeof (domain) === undefined || domain === '') { 207 + if (typeof(domain) === undefined || domain === '') {
208 console.log('请设置请求的api地址'); 208 console.log('请设置请求的api地址');
209 return false; 209 return false;
210 } 210 }
@@ -503,6 +503,185 @@ function actionTopLogoAnimate() { @@ -503,6 +503,185 @@ function actionTopLogoAnimate() {
503 } 503 }
504 } 504 }
505 /** 505 /**
  506 + * 导航处理
  507 + *
  508 + */
  509 +
  510 +var newArr = [],
  511 + g_index = 0,
  512 + targetArr1 = [],
  513 + targetArr2 = [],
  514 + targetArr3 = [],
  515 + oh1 = 0,
  516 + oh2 = 0,
  517 + oh3 = 0,
  518 + valueIndex = 0,
  519 + nowIndex = 0;
  520 +var wrapperindex = 0;
  521 +var oj1 = '<ul class="cate_row1 cate_row"></ul>';
  522 +var oj2 = '<ul class="cate_row2 cate_row"></ul>';
  523 +var oj3 = '<ul class="cate_row3 cate_row"></ul>';
  524 +var inner1 = '';
  525 +var inner2 = '';
  526 +var inner3 = '';
  527 +var finalresult = '';
  528 +
  529 +function createNewArray(obj) {
  530 + var thirdnavpanel = $(obj);
  531 + thirdnavpanel.find('.thirdnavbar').each(function() {
  532 + var $that = $(this);
  533 + var $a_link = $that.find('a');
  534 + var _href = $a_link.attr('href');
  535 + var hottag = $a_link.attr('hot') === 'true' ? true : false;
  536 + var objt = {};
  537 + if ($that.hasClass('category-title')) {
  538 + objt = {
  539 + type: 'title',
  540 + height: 49,
  541 + content: $that.text(),
  542 + index: valueIndex,
  543 + href: _href,
  544 + hot: false
  545 + };
  546 + } else {
  547 + objt = {
  548 + type: 'catlist',
  549 + height: 36,
  550 + content: $a_link.text(),
  551 + index: valueIndex,
  552 + href: _href,
  553 + hot: hottag
  554 + };
  555 + }
  556 + valueIndex++;
  557 + newArr.push(objt);
  558 + })
  559 +}
  560 +
  561 +function createWrapper() {
  562 + var arrlength = newArr.length;
  563 + for (var i = 0; i < arrlength; i++) {
  564 + var obj_new = newArr[i];
  565 + if (g_index === 0) {
  566 + oh1 = (oh1 + obj_new.height);
  567 + if (oh1 >= 340 && i !== (arrlength - 1)) {
  568 + targetArr1 = newArr.slice(0, obj_new.index + 1);
  569 + nowIndex = obj_new.index + 1;
  570 + g_index++;
  571 + }
  572 + if (i === (arrlength - 1)) {
  573 + targetArr1 = newArr.slice(0, arrlength + 1);
  574 + break;
  575 + }
  576 + }
  577 + if (g_index === 1) {
  578 + oh2 = (oh2 + obj_new.height);
  579 + if (oh2 >= 340 && i !== (arrlength - 1)) {
  580 + targetArr2 = newArr.slice(nowIndex, obj_new.index + 1);
  581 + nowIndex = obj_new.index + 1;
  582 + g_index++;
  583 + }
  584 + if (i === (arrlength - 1)) {
  585 + targetArr2 = newArr.slice(nowIndex, arrlength + 1);
  586 + break;
  587 + }
  588 + }
  589 + if (g_index === 2) {
  590 + oh3 = (oh3 + obj_new.height);
  591 + if (oh3 >= 340 && i !== (arrlength - 1)) {
  592 + targetArr3 = newArr.slice(nowIndex, obj_new.index + 1);
  593 + nowIndex = obj_new.index + 1;
  594 + g_index++;
  595 + break;
  596 + }
  597 + if (i === (arrlength - 1)) {
  598 + targetArr3 = newArr.slice(nowIndex, arrlength + 1);
  599 + break;
  600 + }
  601 + }
  602 + }
  603 + for (var a = 0; a < targetArr1.length; a++) {
  604 + var aobj = targetArr1[a] || {};
  605 + if (aobj.type === 'title') {
  606 + inner1 = (inner1 + '<li class="cattitle"><h3><a href="' + aobj.href + '">' + aobj.content + '</a></h3></li>');
  607 + } else {
  608 + if (aobj.hot === true) {
  609 + inner1 = (inner1 + '<li class="catdetail"><a class="thirdcatelink hot" href="' + aobj.href + '">' + aobj.content + '</a></li>');
  610 + } else {
  611 + inner1 = (inner1 + '<li class="catdetail"><a class="thirdcatelink" href="' + aobj.href + '">' + aobj.content + '</a></li>');
  612 + }
  613 +
  614 + }
  615 + }
  616 + for (var b = 0; b < targetArr2.length; b++) {
  617 + var bobj = targetArr2[b] || {};
  618 + if (bobj.type === 'title') {
  619 + inner2 = (inner2 + '<li class="cattitle"><h3><a href="' + bobj.href + '">' + bobj.content + '</a></h3></li>');
  620 + } else {
  621 + if (bobj.hot === true) {
  622 + inner2 = (inner2 + '<li class="catdetail"><a class="thirdcatelink hot" href="' + bobj.href + '">' + bobj.content + '</a></li>');
  623 + } else {
  624 + inner2 = (inner2 + '<li class="catdetail"><a class="thirdcatelink" href="' + bobj.href + '">' + bobj.content + '</a></li>');
  625 + }
  626 +
  627 + }
  628 + }
  629 + for (var c = 0; c < targetArr3.length; c++) {
  630 + var cobj = targetArr3[c] || {};
  631 + if (cobj.type === 'title') {
  632 + inner3 = (inner3 + '<li class="cattitle"><h3><a href="' + cobj.href + '">' + cobj.content + '</a></h3></li>');
  633 + } else {
  634 + if (cobj.hot === true) {
  635 + inner3 = (inner3 + '<li class="catdetail"><a class="thirdcatelink hot" href="' + cobj.href + '">' + cobj.content + '</a></li>');
  636 + } else {
  637 + inner3 = (inner3 + '<li class="catdetail"><a class="thirdcatelink" href="' + cobj.href + '">' + cobj.content + '</a></li>');
  638 + }
  639 +
  640 + }
  641 + }
  642 + var final1 = '',
  643 + final2 = '',
  644 + final3 = '';
  645 + if (inner1 !== '') {
  646 + final1 = '<ul class="cate_row1 cate_row">' + inner1 + '</ul>';
  647 + }
  648 + if (inner2 !== '') {
  649 + final2 = '<ul class="cate_row2 cate_row">' + inner2 + '</ul>';
  650 + }
  651 + if (inner3 !== '') {
  652 + final3 = '<ul class="cate_row3 cate_row">' + inner3 + '</ul>';
  653 + }
  654 + finalresult = final1 + final2 + final3;
  655 + $('#' + wrapperindex).empty().append(finalresult);
  656 +}
  657 +
  658 +function actionNav() {
  659 + $('.categorywrapper').each(function(index) {
  660 + wrapperindex = $(this).attr('id');
  661 + newArr = [];
  662 + g_index = 0;
  663 + targetArr1 = [];
  664 + targetArr2 = [];
  665 + targetArr3 = [];
  666 + oh1 = 0;
  667 + oh2 = 0;
  668 + oh3 = 0;
  669 + valueIndex = 0;
  670 + nowIndex = 0;
  671 + oj1 = '<ul class="cate_row1 cate_row"></ul>';
  672 + oj2 = '<ul class="cate_row2 cate_row"></ul>';
  673 + oj3 = '<ul class="cate_row3 cate_row"></ul>';
  674 + inner1 = '';
  675 + inner2 = '';
  676 + inner3 = '';
  677 + createNewArray($(this).find('.category'));
  678 + createWrapper();
  679 + })
  680 +}
  681 +
  682 +
  683 +
  684 +/**
506 * 查询跳转后保留关键字 685 * 查询跳转后保留关键字
507 * @return {[type]} [description] 686 * @return {[type]} [description]
508 */ 687 */
@@ -1105,6 +1284,7 @@ function actionLoginInfo() { @@ -1105,6 +1284,7 @@ function actionLoginInfo() {
1105 * @return {[type]} [description] 1284 * @return {[type]} [description]
1106 */ 1285 */
1107 function init() { 1286 function init() {
  1287 + actionNav();//处理导航
1108 actionExeTemplate(); //处理模板 1288 actionExeTemplate(); //处理模板
1109 actionInitCookie(); //初始化cookie 1289 actionInitCookie(); //初始化cookie
1110 actionExeCookieMap(); //格式化cookie 1290 actionExeCookieMap(); //格式化cookie
@@ -532,7 +532,7 @@ @@ -532,7 +532,7 @@
532 532
533 .third-nav-wrapper { 533 .third-nav-wrapper {
534 box-sizing: border-box; 534 box-sizing: border-box;
535 - height: 300px; 535 + height: 410px;
536 position: absolute; 536 position: absolute;
537 left: 0; 537 left: 0;
538 top: 38px; 538 top: 38px;
@@ -602,8 +602,8 @@ @@ -602,8 +602,8 @@
602 box-sizing: border-box; 602 box-sizing: border-box;
603 padding-left: 19px; 603 padding-left: 19px;
604 padding-right: 19px; 604 padding-right: 19px;
605 - width: 268px;  
606 - height: 100%; 605 + width: 337px;
  606 + height: 250px;
607 float: right; 607 float: right;
608 } 608 }
609 609
@@ -945,12 +945,12 @@ @@ -945,12 +945,12 @@
945 .showdetail img { 945 .showdetail img {
946 display: block; 946 display: block;
947 box-sizing: border-box; 947 box-sizing: border-box;
948 - width: 226px;  
949 - height: 200px; 948 + width: 337px;
  949 + height: 250px;
950 } 950 }
951 .showdetail .title { 951 .showdetail .title {
952 display: block; 952 display: block;
953 - margin-top: 17px; 953 + margin-top: 40px;
954 width: 100%; 954 width: 100%;
955 height: 15px; 955 height: 15px;
956 text-align: center; 956 text-align: center;