Authored by 郝肖肖

默认选中tab

... ... @@ -8,6 +8,13 @@
const mRoot = '../models';
const plusstarModel = require(`${mRoot}/plusstar`);
const headerModel = require('../../../doraemon/models/header'); // 头部model
let channels = {
boys: 1,
girl: 2,
kids: 3,
lifestyle: 4
};
/**
* 潮流优选首页
*/
... ... @@ -15,6 +22,7 @@ exports.index = (req, res, next) => {
let isApp = req.query.app_version || req.query.appVersion || false;
let parameter = {};
let title = '潮流优选';
let gender = req.query.gender || req.cookies._Channel && channels[req.cookies._Channel] || 1;
if (isApp === false) {
parameter = {
... ... @@ -25,7 +33,7 @@ exports.index = (req, res, next) => {
};
}
plusstarModel.getAllChannels({}).then(result => {
plusstarModel.getAllChannels({gender: gender}).then(result => {
res.render('plusstar/index', Object.assign({
page: 'plusstar-index',
result: result,
... ...
... ... @@ -9,23 +9,29 @@ const productProcess = require('../../../utils/product-process');
* @return {[array]}
*/
const getAllChannels = (params) => {
params = params || {};
let gender = params.gender - 1 || 0;
return api.get('', Object.assign({
return api.get('', {
method: 'app.blk.getAllChannels'
}, params)).then(result => {
}).then(result => {
let data = {channel: []};
if (result.code !== 200) {
return data;
}
if (gender === 3 && result.data.length === 3) {
// 1:男,2:女,3:童装,4:创意生活
// 如果为3,说明童装没有配置,只配置了创意生活。所以要减一
gender = 2;
}
_.forEach(result.data, (res, index) => {
data.channel.push({
id: res.channel_id,
mame: res.channel_name,
code: res.content_code,
focus: index === 0 ? true : false
focus: index === gender ? true : false
});
});
... ...
... ... @@ -35,16 +35,10 @@ plusstar = {
});
// start -- 默认选中
switch (window.cookie('_Channel')) {
case 'girls':
$liDom = $('.plusstar-page .tab-nav ul li:eq(1)');
break;
case 'lifestyle':
$liDom = $('.plusstar-page .tab-nav ul li:eq(2)');
break;
default:
$liDom = $('.plusstar-page .tab-nav ul li:eq(0)');
break;
$liDom = $tabUlDom.find('li.focus');
if ($liDom.length <= 0) {
// 默认第一个
$liDom = $('.plusstar-page .tab-nav ul li:eq(0)');
}
$tabUlDom.find('li').removeClass('focus');
$liDom.addClass('focus');
... ...