Authored by wangqing

换回旧的导航

... ... @@ -204,7 +204,7 @@ function actionGoodsCart() {
};
var params = '';
if (typeof (domain) === undefined || domain === '') {
if (typeof(domain) === undefined || domain === '') {
console.log('请设置请求的api地址');
return false;
}
... ... @@ -503,6 +503,185 @@ function actionTopLogoAnimate() {
}
}
/**
* 导航处理
*
*/
var newArr = [],
g_index = 0,
targetArr1 = [],
targetArr2 = [],
targetArr3 = [],
oh1 = 0,
oh2 = 0,
oh3 = 0,
valueIndex = 0,
nowIndex = 0;
var wrapperindex = 0;
var oj1 = '<ul class="cate_row1 cate_row"></ul>';
var oj2 = '<ul class="cate_row2 cate_row"></ul>';
var oj3 = '<ul class="cate_row3 cate_row"></ul>';
var inner1 = '';
var inner2 = '';
var inner3 = '';
var finalresult = '';
function createNewArray(obj) {
var thirdnavpanel = $(obj);
thirdnavpanel.find('.thirdnavbar').each(function() {
var $that = $(this);
var $a_link = $that.find('a');
var _href = $a_link.attr('href');
var hottag = $a_link.attr('hot') === 'true' ? true : false;
var objt = {};
if ($that.hasClass('category-title')) {
objt = {
type: 'title',
height: 49,
content: $that.text(),
index: valueIndex,
href: _href,
hot: false
};
} else {
objt = {
type: 'catlist',
height: 36,
content: $a_link.text(),
index: valueIndex,
href: _href,
hot: hottag
};
}
valueIndex++;
newArr.push(objt);
})
}
function createWrapper() {
var arrlength = newArr.length;
for (var i = 0; i < arrlength; i++) {
var obj_new = newArr[i];
if (g_index === 0) {
oh1 = (oh1 + obj_new.height);
if (oh1 >= 340 && i !== (arrlength - 1)) {
targetArr1 = newArr.slice(0, obj_new.index + 1);
nowIndex = obj_new.index + 1;
g_index++;
}
if (i === (arrlength - 1)) {
targetArr1 = newArr.slice(0, arrlength + 1);
break;
}
}
if (g_index === 1) {
oh2 = (oh2 + obj_new.height);
if (oh2 >= 340 && i !== (arrlength - 1)) {
targetArr2 = newArr.slice(nowIndex, obj_new.index + 1);
nowIndex = obj_new.index + 1;
g_index++;
}
if (i === (arrlength - 1)) {
targetArr2 = newArr.slice(nowIndex, arrlength + 1);
break;
}
}
if (g_index === 2) {
oh3 = (oh3 + obj_new.height);
if (oh3 >= 340 && i !== (arrlength - 1)) {
targetArr3 = newArr.slice(nowIndex, obj_new.index + 1);
nowIndex = obj_new.index + 1;
g_index++;
break;
}
if (i === (arrlength - 1)) {
targetArr3 = newArr.slice(nowIndex, arrlength + 1);
break;
}
}
}
for (var a = 0; a < targetArr1.length; a++) {
var aobj = targetArr1[a] || {};
if (aobj.type === 'title') {
inner1 = (inner1 + '<li class="cattitle"><h3><a href="' + aobj.href + '">' + aobj.content + '</a></h3></li>');
} else {
if (aobj.hot === true) {
inner1 = (inner1 + '<li class="catdetail"><a class="thirdcatelink hot" href="' + aobj.href + '">' + aobj.content + '</a></li>');
} else {
inner1 = (inner1 + '<li class="catdetail"><a class="thirdcatelink" href="' + aobj.href + '">' + aobj.content + '</a></li>');
}
}
}
for (var b = 0; b < targetArr2.length; b++) {
var bobj = targetArr2[b] || {};
if (bobj.type === 'title') {
inner2 = (inner2 + '<li class="cattitle"><h3><a href="' + bobj.href + '">' + bobj.content + '</a></h3></li>');
} else {
if (bobj.hot === true) {
inner2 = (inner2 + '<li class="catdetail"><a class="thirdcatelink hot" href="' + bobj.href + '">' + bobj.content + '</a></li>');
} else {
inner2 = (inner2 + '<li class="catdetail"><a class="thirdcatelink" href="' + bobj.href + '">' + bobj.content + '</a></li>');
}
}
}
for (var c = 0; c < targetArr3.length; c++) {
var cobj = targetArr3[c] || {};
if (cobj.type === 'title') {
inner3 = (inner3 + '<li class="cattitle"><h3><a href="' + cobj.href + '">' + cobj.content + '</a></h3></li>');
} else {
if (cobj.hot === true) {
inner3 = (inner3 + '<li class="catdetail"><a class="thirdcatelink hot" href="' + cobj.href + '">' + cobj.content + '</a></li>');
} else {
inner3 = (inner3 + '<li class="catdetail"><a class="thirdcatelink" href="' + cobj.href + '">' + cobj.content + '</a></li>');
}
}
}
var final1 = '',
final2 = '',
final3 = '';
if (inner1 !== '') {
final1 = '<ul class="cate_row1 cate_row">' + inner1 + '</ul>';
}
if (inner2 !== '') {
final2 = '<ul class="cate_row2 cate_row">' + inner2 + '</ul>';
}
if (inner3 !== '') {
final3 = '<ul class="cate_row3 cate_row">' + inner3 + '</ul>';
}
finalresult = final1 + final2 + final3;
$('#' + wrapperindex).empty().append(finalresult);
}
function actionNav() {
$('.categorywrapper').each(function(index) {
wrapperindex = $(this).attr('id');
newArr = [];
g_index = 0;
targetArr1 = [];
targetArr2 = [];
targetArr3 = [];
oh1 = 0;
oh2 = 0;
oh3 = 0;
valueIndex = 0;
nowIndex = 0;
oj1 = '<ul class="cate_row1 cate_row"></ul>';
oj2 = '<ul class="cate_row2 cate_row"></ul>';
oj3 = '<ul class="cate_row3 cate_row"></ul>';
inner1 = '';
inner2 = '';
inner3 = '';
createNewArray($(this).find('.category'));
createWrapper();
})
}
/**
* 查询跳转后保留关键字
* @return {[type]} [description]
*/
... ... @@ -1105,6 +1284,7 @@ function actionLoginInfo() {
* @return {[type]} [description]
*/
function init() {
actionNav();//处理导航
actionExeTemplate(); //处理模板
actionInitCookie(); //初始化cookie
actionExeCookieMap(); //格式化cookie
... ...
... ... @@ -532,7 +532,7 @@
.third-nav-wrapper {
box-sizing: border-box;
height: 300px;
height: 410px;
position: absolute;
left: 0;
top: 38px;
... ... @@ -602,8 +602,8 @@
box-sizing: border-box;
padding-left: 19px;
padding-right: 19px;
width: 268px;
height: 100%;
width: 337px;
height: 250px;
float: right;
}
... ... @@ -945,12 +945,12 @@
.showdetail img {
display: block;
box-sizing: border-box;
width: 226px;
height: 200px;
width: 337px;
height: 250px;
}
.showdetail .title {
display: block;
margin-top: 17px;
margin-top: 40px;
width: 100%;
height: 15px;
text-align: center;
... ...