Authored by hongweigao

修改

... ... @@ -7,7 +7,7 @@
'use strict';
const mRoot = '../models';
const brandsModel = require(`${mRoot}/brands-service`); // students model
const brandsService = require(`${mRoot}/brands-service`); // students model
/**
* brands 首页
... ... @@ -19,7 +19,7 @@ const brandsModel = require(`${mRoot}/brands-service`); // students 页 model
exports.index = (req, res, next) => {
let channel = req.query.channel || req.cookies._Channel || 'boys';
brandsModel.getBrandViewList(channel, req).then(result => {
brandsService.getBrandViewList(channel, req).then(result => {
res.render('brands', result);
... ... @@ -27,6 +27,19 @@ exports.index = (req, res, next) => {
};
/**
* brandList-Ajax调用
*/
exports.brandList = (req, res, next) => {
let channel = req.query.channel || req.cookies._Channel || 'boys';
brandsService.getBrandList(channel, req.body.start).then(result => {
res.render('brand-list', Object.assign({layout: false}, result));
}).catch(next);
};
/**
* 品牌接口数据
*
* @param string brandId 获取品牌ID
... ... @@ -36,7 +49,7 @@ exports.brandInfo = (req, res, next) => {
let brandId = req.query.brandId || 0;
brandsModel.brandInfo(brandId, req.user.uid).then(result => {
brandsService.brandInfo(brandId, req.user.uid).then(result => {
res.json(result);
}).catch(next);
};
... ...
... ... @@ -39,17 +39,27 @@ const getBrandListData = channel => {
* @return array 品牌介绍信息
*/
const getBrandIntro = (brandId, uid) => {
let param = {};
if (!uid) {
param.cache = 3600;
}
return api.get('', {
method: 'app.brand.getBrandIntro',
brand_id: brandId,
uid: uid
});
}, param);
};
/**
* 获取品牌中产品图片
* @param int 品牌ID
* @return array 品牌产品信息
*/
const getProductByBrand = (brandId, limit) => {
return api.get('', {
method: 'web.search.search',
brand_id: brandId,
brand: brandId,
limit: limit
});
};
... ...
... ... @@ -150,9 +150,6 @@ const getBrandViewList = (channel, start, length) => {
if (res.data.brands) {
_.forEach(res.data.brands, (subValue, key) => {
// if(_.isEmpty(subValue)){
// continue;
// }
let listTmp = [];
_.forEach(subValue, ssubValue => {
... ...
... ... @@ -40,6 +40,23 @@ exports.getBrandViewList = (channel) => {
};
/**
* brandList-Ajax调用
*/
exports.getBrandList = (channel, start) => {
let apiMethod = [
brandsModel.getBrandViewList(channel, start)
];
return api.all(apiMethod).then(result => {
let responseData = {};
// 品牌一览列表
responseData.category = result[0];
return responseData;
});
};
/**
* 品牌接口数据
*
* @param string brandId 获取品牌ID
... ...
... ... @@ -15,7 +15,10 @@ const brandsController = require(`${cRoot}/brands`);
// 品牌一览
router.get('', brandsController.index);
// 悬浮出现品牌信息
router.get('/brandinfo', brandsController.brandInfo);
// 品牌没有加载完全,继续加载
router.post('/brandList', brandsController.brandList);
module.exports = router;
... ...
... ... @@ -7,8 +7,7 @@
var $ = require('yoho-jquery'),
lazyLoad = require('yoho-jquery-lazyload');
var Handlebars = require('yoho-handlebars'),
dot = require('yoho-jquery-dotdotdot');
var Handlebars = require('yoho-handlebars');
var $tabs = $('.brands-tabs');
var $list = $('.brands-list');
... ... @@ -34,6 +33,7 @@ var tempdata = {};
var templete = '<div class="brands-dialog">';
require('../common');
require('yoho-jquery-dotdotdot')
templete += ' <div class="brands-layer">';
templete += ' <div class="layer-content">';
... ... @@ -133,7 +133,7 @@ $(window).scroll(function() {
// 点击字母,页面滚动到相关区域
$category.click(function() {
var name = $(this).attr('href').split('#')[1];
var targetTop = $list.find('[name=' + name + ']').offset().top - categoryHeight;
var targetTop = $list.find('[name="' + name + '"]').offset().top - categoryHeight;
if (!$gory.hasClass('category-fix')) {
targetTop -= categoryHeight;
... ... @@ -161,7 +161,7 @@ function bindTemplete($select, data, tmp) {
$list.find('.brands-dialog').remove();
myTemplate = Handlebars.compile(tmp);
$parent.append(myTemplate(data));
dot($parent.find('.right'));
$parent.find('.right').dotdotdot();
if (offset.right - 350 < 0) {
$parent.find('.brands-layer')
... ...