Authored by 郝肖肖

品类api接口

... ... @@ -62,14 +62,19 @@ module.exports = {
/* 全部分类 */
cate: (req, res) => {
res.render('brand/cate', {
module: 'channel',
page: 'cate'
});
},
// 全部分类api
getCateList: (req, res) => {
let params = req.query;
brandModel.getCateListData(params).then(result => {
res.render('brand/cate', {
module: 'channel',
page: 'cate',
result: result
brandModel.getCateListData(params)
.then(result => {
res.json(result);
});
});
}
};
... ...
... ... @@ -57,8 +57,9 @@ module.exports = {
* @returns {*}
*/
getCateListData(params) {
return api.get('', {
method: ''
});
return api.get('', Object.assign(params, {
method: 'app.sort.get'
})
);
}
};
... ...
... ... @@ -108,17 +108,69 @@ const getBrandListData = params => {
* @returns {*|Promise.<TResult>}
*/
const getCateListData = params => {
let finalResult = {};
let finalResult = [];
let item = {};
let oneClass = [];
let subitem = {};
let genderArr = {boy: '1,3', girl: '2,3', kids: '1,2,3', lifestyle: '1,2,3'};
return api.all([brandApi.getCateListData(params)]).then(result => {
return brandApi.getCateListData(params).then(result => {
// 待处理,拼接输出模拟数据
Object.assign(finalResult, {
brandBg: 'http://7xwj52.com1.z0.glb.clouddn.com/brandbg.jpg',
brandLogo: '',
brandName: 'A.Dorad',
brandIntro: 'Dora毕业于中国美术学院的珠宝设计专业。毕业之后,Dora便开始游走于各国,吸收各地首饰设计的精髓,之后又在首尔修学了3年,A.Dorad饰品系列诞生于首尔, 设计师Dora将首尔设为起点并逐步推向国际。2013年,A.Dorad将旗下主力设计师带领进军广州,并以此为基地,以国际化的标准,设计出全新概念饰品。A.Dorad给人们提供高品质的服务,并且拥有独有的工艺。多样的珠宝首饰产品造型更衬托出其前卫、高雅的设计理念。珍贵的矿石搭配流行的创意理念,启迪了人类艺术。A.Dorad饰品符合现代年轻人对珠宝的追求与热爱,充满个性与时尚.它可以满足不同人的需求独家定制专属于自己的水晶饰品。A.Dorad将继续发挥无与伦比的创造力并开启通往浪漫梦幻的大门。',
showMore: false
if (result.code !== 200) {
return [];
}
_.forEach(result.data, (category, categorykey) => {
oneClass = {name: categorykey, ca: []};
_.forEach(category, (cate) => {
item = {
id: cate.category_id,
name: cate.category_name,
sort: cate.relation_parameter.sort,
sub: []
};
if (_.isEmpty(cate.sub)) {
item.url = helpers.urlFormat('/', {
sort: item.sort,
sort_name: item.name,
gender: genderArr[categorykey]
}, 'list');
oneClass.ca.push(item);
return true;// equal continue;
}
// 有子分类的,首先添加一级分类
item.sub.push({
name: '全部' + item.name,
id: item.sort,
url: helpers.urlFormat('/', {
sort: item.sort,
sort_name: item.name,
gender: genderArr[categorykey]
}, 'list'),
sub: []
});
_.forEach(cate.sub, (sub) => {
subitem = {
id: sub.category_id,
name: sub.category_name,
sort: sub.relation_parameter.sort,
url: ''
};
subitem.url = helpers.urlFormat('/', {
sort: subitem.sort,
sort_name: subitem.name,
gender: genderArr[categorykey]
}, 'list');
item.sub.push(subitem);
});
oneClass.ca.push(item);
});
finalResult.push(oneClass);
});
return finalResult;
... ...
... ... @@ -21,6 +21,7 @@ router.get('/get-brand-shop-goods', brand.getBrandShopGoods); // 店铺介绍
router.get('/brand-list', brand.brandList); // 品牌列表页
router.get('/get-brand-list', brand.getBrandList); // 获取品牌列表数据
router.get('/cate', brand.cate); // 全部分类
router.get('/get-cate-list', brand.getCateList); // 全部分类数据列表
router.get('/sidebar', channel.sidebar); // 资源位接口
... ...
... ... @@ -1275,6 +1275,18 @@
&.focus {
background-color: #fff;
&:after {
content: "";
width: 0;
height: 0;
border-top: 20px solid transparent;
border-bottom: 20px solid transparent;
border-right: 20px solid #efefef;
position: absolute;
margin-top: 32px;
right: 55%;
}
}
&.highlight {
... ... @@ -1286,7 +1298,7 @@
.sub-level-container {
float: left;
box-sizing: border-box;
background: #fff;
background: #f6f6f6;
width: 55%;
height: 100%;
}
... ... @@ -1311,25 +1323,9 @@
background: #eee;
}
&:last-child {
border-bottom: none;
}
&:hover {
background-color: #efefef;
}
&:first-child:before {
content: "";
width: 0;
height: 0;
border-top: 20px solid transparent;
border-bottom: 20px solid transparent;
border-right: 20px solid #efefef;
position: absolute;
margin-top: 32px;
margin-left: -40px;
}
}
a {
... ... @@ -1356,8 +1352,19 @@
},
methods: {
getBrandList() {
getCateList() {
let data = {
channel: ''
};
$.ajax({
url: '/get-cate-list',
data: data
}).then(result => {
console.log(result, '====');
}).fail(() => {
tip('网络错误');
});
},
cateNavTopFun(e) {
var $this = $(e.target).closest('li'),
... ... @@ -1396,15 +1403,11 @@
$subLevel.not('.hide').addClass('hide');
$subLevel.eq(index).removeClass('hide');
$subLevel.css({
top: $cur.offset().top - 60
});
}
}
},
created() {
this.getCateList();
}
};
</script>
... ...