Authored by 郭成尧

Merge branch 'feature/brand' into develop

... ... @@ -6,7 +6,7 @@ Name | Path | Note
品类 | /cate |
全部分类 | /cate-all |
品牌店铺 | /product/shop?domain=sctest1 |
品牌店铺分享页面 | /product/brand-share?domain=colormad |
品牌店铺分享页面 | /product/shop-share?domain=colormad |
商品详情 | /product/{productId} |
资讯列表 | /news |
退货申请 | /home/refund?orderId=160181661 |
... ...
... ... @@ -37,18 +37,18 @@ module.exports = {
cate: (req, res) => {
res.render('brand/cate', {
module: 'channel',
page: 'cate'
page: 'cate',
title: '全部分类'
});
},
// 全部分类api
getCateList: (req, res, next) => {
let params = req.query;
brandModel.getCateListData(params)
.then(result => {
res.json(result);
}).catch(next);
brandModel.getCateListData({
app_type: 1
}).then(result => {
res.json(result);
}).catch(next);
},
// 品类资源位
... ...
... ... @@ -79,6 +79,7 @@ const getCateListData = params => {
let oneClass = [];
let subitem = {};
let genderArr = {boy: '1,3', girl: '2,3', kids: '1,2,3', lifestyle: '1,2,3'};
let nameArr = {boy: 'MEN男士', girl: 'WOMEN女士', kids: 'TIDE潮童', lifestyle: 'LIFESTYLE生活'};
return brandApi.getCateListData(params).then(result => {
... ... @@ -87,7 +88,10 @@ const getCateListData = params => {
}
_.forEach(result.data, (category, categorykey) => {
oneClass = {name: categorykey, ca: []};
if (categorykey === 'kids') {
return true;
}
oneClass = {name: nameArr[categorykey], ca: []};
_.forEach(category, (cate) => {
item = {
... ...
... ... @@ -17,12 +17,13 @@ router.get('/', channel.index); // 首页
router.get('/channel/channel.json', channel.channel); // 查询所有频道
router.get('/channel/resources.json', channel.resources); // 资源位接口
router.get('/channel/goods.json', channel.goods); // 首页查询商品列表
router.get('/brands', brand.brandList); // 品牌列表页
router.get('/get-brand-list', brand.getBrandList); // 获取品牌列表数据
router.get('/brand/list.json', brand.getBrandList); // 获取品牌列表数据
router.get('/cate', brand.cateResource); // 品类资源位页面
router.get('/cate-all', brand.cate); // 全部分类
router.get('/get-cate-list', brand.getCateList); // 全部分类数据列表
router.get('/cate/list.json', brand.getCateList); // 全部分类数据列表
router.get('/sidebar', channel.sidebar); // 资源位接口
... ...
... ... @@ -19,19 +19,10 @@ module.exports = {
});
},
/* 获取资讯分类 */
getNewsCate: (req, res, next) => {
listModel.newsCate().then(result => {
res.json(result);
}).catch(next);
},
/* 获取资讯列表数据 */
getNewsList: (req, res, next) => {
let params = {
sortId: req.body.sortId,
page: req.body.page,
limit: req.body.limit,
gender: req.body.gender,
uid: req.user.uid
};
... ...
... ... @@ -10,21 +10,14 @@ const serviceAPI = global.yoho.ServiceAPI;
module.exports = {
/* 资讯分类数据获取 */
getNewsCateData() {
return serviceAPI.get('guang/api/v2/category/get', {
app_type: '1'
});
},
/* 资讯列表页数据获取 */
getNewsListData(params) {
return serviceAPI.get('guang/api/v2/article/getList', {
sort_id: params.sortId,
sort_id: '',
gender: params.gender,
uid: params.uid || '0',
page: params.page,
limit: params.limit,
limit: '10',
app_type: '1'
});
}
... ...
... ... @@ -12,26 +12,6 @@ const newsListApi = require('./list-api');
const camelCase = global.yoho.camelCase;
/**
* 资讯分类
* @returns {*|Promise.<TResult>}
*/
const newsCate = () => {
let finalResult = {};
return api.all([
newsListApi.getNewsCateData()
]).then(result => {
if (result[0].code === 200) {
Object.assign(finalResult, result[0].data);
} else {
logger.error('getNewsListData api code no 200 or allList is null');
}
return finalResult;
});
};
/**
* 资讯列表数据
* @param params
* @returns {*|Promise.<TResult>}
... ... @@ -42,8 +22,14 @@ const newsList = params => {
return api.all([
newsListApi.getNewsListData(params)
]).then(result => {
if (result[0].code === 200) {
Object.assign(finalResult, result[0].data.list.artList);
if (result[0].code === 200 && result[0].data.list) {
Object.assign(finalResult, {
data: {
list: result[0].data.list.artList,
totalPage: result[0].data.totalPage
},
code: 200
});
} else {
logger.error('getNewsListData api code no 200');
}
... ... @@ -53,6 +39,5 @@ const newsList = params => {
};
module.exports = {
newsList,
newsCate
newsList
};
... ...
... ... @@ -19,7 +19,6 @@ router.get(/news_(\d+)\.json/, detail.news);
const news = require(`${cRoot}/index`);
router.get('', news.index); // 首页
router.get('/get-news-cate', news.getNewsCate); // 获取资讯分类
router.post('/get-news-list', news.getNewsList); // 获取资讯数据
router.post('/list.json', news.getNewsList); // 获取资讯数据
module.exports = router;
... ...
... ... @@ -36,10 +36,10 @@ router.get('/sub-filter', subFilter.page);
const shop = require(`${cRoot}/shop`);
router.get('/shop', shop.index); // 店铺首页
router.get('/get-shop-info', shop.getShopInfo); // 店铺介绍
router.post('/get-brand-shop-goods', shop.getBrandShopGoods); // 店铺商品列表
router.post('/collect-shop', shop.collectShop); // 收藏品牌店铺
router.get('/shop-share', shop.shopShare); // 品牌店铺分享页面
router.get('/shop/info.json', shop.getShopInfo); // 店铺介绍
router.post('/shop/goods.json', shop.getBrandShopGoods); // 店铺商品列表
router.post('/shop/collect.json', shop.collectShop); // 收藏品牌店铺
router.get('/shop/share', shop.shopShare); // 品牌店铺分享页面
// 商品详情controller
const detail = require(`${cRoot}/detail`);
... ...
... ... @@ -2,7 +2,7 @@
<div class="cate-page" id='cate-page'>
<div class="cate-nav clearfix">
<ul>
<li v-for="(index, cate) in brandCate" v-on:click='cateNavTopFun(index)' v-bind:class="{focus: index === topcurrent}" >
<li v-for="(index, cate) in brandCate" v-on:click='cateNavTopFun(index)' v-bind:class="{focus: index === topcurrent}" v-bind:style="{width: widthli + '%'}">
<span>{{cate.name}}</span>
</li>
</ul>
... ... @@ -68,13 +68,14 @@
.cate-nav {
height: 120px;
border-bottom: 1px solid #e6e6e6;
font-size: 24px;
li {
display: block;
box-sizing: border-box;
float: left;
height: 100%;
padding: 20px 10px;
padding: 20px 0;
width: 25%;
text-align: center;
color: #999;
... ... @@ -206,6 +207,7 @@
cateNavLeftData: [],
cateNavRightData: [],
topcurrent: 0,
widthli: 25,
leftcurrent: 0
};
},
... ... @@ -216,12 +218,15 @@
};
$.ajax({
url: '/get-cate-list',
url: '/cate/list.json',
data: data
}).then(result => {
this.brandCate = result;
this.cateNavLeftData = this.brandCate[0].ca;
this.cateNavRightData = this.cateNavLeftData[0].sub;
if (result.length > 0) {
this.brandCate = result;
this.widthli = 100 / result.length;
this.cateNavLeftData = this.brandCate[0].ca;
this.cateNavRightData = this.cateNavLeftData[0].sub;
}
}).fail(() => {
tip('网络错误');
});
... ...
... ... @@ -80,7 +80,7 @@
};
$.ajax({
url: '/get-brand-list',
url: '/brand/list.json',
data: data
}).then(result => {
this.brandList = result.brandList;
... ...
<template>
<ul class="new-cate clearfix">
<li v-for="cate in newsCate" v-bind:class='{"current" : cate.id === crntCateId}' @click="changeCate(cate.id)">{{cate.name}}</li>
</ul>
<resources v-bind:content-code.sync="contentCode"></resources>
<div v-for="news in newsList" class="news-box">
<span class="tag">{{news.categoryName}}</span>
<div class="img">
<a href='{{"/news/" + news.id}}'>
<img v-lazy="news.src | resize 750 470" alt="" />
</a>
</div>
<div class="title"><a href='{{"/news/" + news.id}}'>{{news.title}}</a></div>
<div class="news-des">
{{news.intro}}
</div>
<hr>
<div class="bottom clearfix">
<span class="icon time-icon">&#xe612;</span>
<span class="time">{{news.publishTime}}</span>
<span class="icon share" @click="share(news.title, news.intro, news.src, news.share.url)">&#xe611;</span>
<div v-infinite-scroll="getNewsList()" infinite-scroll-disabled="scrollDisabled">
<div v-for="news in newsList" class="news-box">
<div class="img">
<a href='{{"/news/" + news.id}}'>
<img v-lazy="news.src | resize 750 470" alt="" />
</a>
</div>
<div class="title"><a href='{{"/news/" + news.id}}'>{{news.title}}</a></div>
<div class="news-des">
{{news.intro}}
</div>
<hr>
<div class="bottom clearfix">
<span class="icon time-icon">&#xe612;</span>
<span class="time">{{news.publishTime}}</span>
<span class="icon share" @click="share(news.title, news.intro, news.src, news.share.url)">&#xe611;</span>
</div>
</div>
</div>
</template>
<style>
.new-cate {
color: #b0b0b0;
width: 100%;
height: 90px;
li {
width: 20%;
float: left;
text-align: center;
padding: 28px 0;
}
.current {
color: #000;
}
}
.news-box {
background: #f6f6f6;
.tag {
position: relative;
top: 42px;
left: 0;
padding: 12px 24px;
background: #000;
color: #fff;
}
.img {
width: 100%;
height: 470px;
overflow: hidden;
padding-top: 30px;
img {
width: 100%;
... ... @@ -105,60 +78,42 @@
data() {
return {
contentCode: contentCode.news[qs.cate || 'new'],
crntCateId: -1,
newsCate: [],
newsList: [],
gender: qs.gender,
page: 1,
limit: 10,
page: 0,
scrollDisabled: false
};
},
watch: {
crntCateId() {
this.getNewsList();
},
gender() {
this.getNewsList();
}
},
methods: {
/* 获取资讯分类 */
getNewsCate() {
$.get({
url: '/news/get-news-cate'
}).done(result => {
if (result) {
this.newsCate = result;
this.crntCateId = result[0].id;
} else {
tip('服务端无数据返回');
}
}).fail();
},
/* 改变分类 */
changeCate(cateId) {
this.crntCateId = cateId;
},
/* 获取资讯列表数据 */
getNewsList() {
$.post({
url: '/news/get-news-list',
url: '/news/list.json',
data: {
sortId: this.crntCateId,
page: this.page,
limit: this.limit,
page: this.page++,
gender: this.gender || '1,2,3'
}
}).done(result => {
if (result) {
this.newsList = result;
if (result.code === 200) {
if (this.newsList.length > 0 && result.data.list.length > 0) {
this.$set('newsList', this.newsList.concat(result.data.list));
} else {
this.newsList = result.data.list;
}
} else {
tip('服务端无数据返回');
this.scrollDisabled = true;
tip('没有了...');
}
}).fail();
}).fail(() => {
tip('服务器错误');
});
},
/* 分享资讯 */
... ... @@ -175,7 +130,7 @@
resources
},
created() {
this.getNewsCate();
this.getNewsList();
}
};
</script>
... ...
... ... @@ -69,7 +69,7 @@
/* 获取店铺简介相关数据 */
getShopInfo() {
$.get({
url: '/product/get-shop-info',
url: '/product/shop/info.json',
data: { domain: qs.domain }
}).done(result => {
this.shopInfo = result;
... ...
... ... @@ -31,7 +31,7 @@
filterConfig: {},
// query
url: '/product/get-brand-shop-goods',
url: '/product/shop/goods.json',
sort: '',
filter: {
domain: qs.domain
... ... @@ -61,7 +61,7 @@
/* 获取店铺简介相关数据 */
getShopInfo() {
$.get({
url: '/product/get-shop-info',
url: '/product/shop/info.json',
data: { domain: this.domain }
}).done(result => {
if (result) {
... ... @@ -72,6 +72,7 @@
des: shareSubTitle,
url: '/product/shop-share?domain=' + this.domain,
img: result.brandBg,
isBlkShop: result.isBlkShop,
shopId: result.shopId, // 不是分享的参数,收藏店铺使用
isFav: result.isFav // 不是分享的参数,收藏店铺使用
};
... ... @@ -149,7 +150,7 @@
bus.$on('filter.change', ({val}) => {
Object.assign(this.filter, val);
this.search();
this.$refs.filter.on = false;
this.$refs.filter.isVisible = false;
});
/**
... ...
<template>
<div v-if="shopInfo.isBlkShop" class="brand-top-box" v-bind:style="{ 'background-image': `url(${shopInfo.brandBg})` }">
<div v-if="shopInfo.isBlkShop" class="brand-top-box" v-lazy:background-image="shopInfo.brandBg | resize 750 478">
<div class="brand-bottom">
<img v-if="shopInfo.brandLogo" v-lazy="brandIntro.brandLogo" alt="{{ shopInfo.brandName }}">
<img v-if="shopInfo.brandLogo" v-lazy="shopInfo.brandLogo | resize 80 80" alt="{{ shopInfo.brandName }}">
<div v-else class="brand-title">{{ shopInfo.brandName }}</div>
<hr>
<div v-show="showMore" transition="brand-intro" v-bind:class="{ 'brand-short': !showMore }">{{ shopInfo.brandIntro }}</div>
... ...
<template>
<div class="top-box clearfix" v-bind:class='{"top-box-left" : this.$parent.$refs.filter.on}'>
<div class="top-box clearfix" v-bind:class='{"top-box-left" : this.$parent.$refs.filter.isVisible,"top-change" : topChange }' v-infinite-scroll="changeTopStatus()">
<span class="icon back" @click="goBack()">&#xe606;</span>
<div class="right">
<span v-if="shareData.isFav" class="icon" @click="collectShop()">&#xe60d;</span>
<span v-else class="icon" @click="collectShop()">&#xe60c;</span>
<span class="icon" @click="goShare()">&#xe60e;</span>
<span v-if="shareData.isBlkShop" v-show="shareData.isFav" class="icon" @click="collectShop()">&#xe60d;</span>
<span v-if="shareData.isBlkShop" v-show="!shareData.isFav" class="icon" @click="collectShop()">&#xe60c;</span>
<span v-if="shareData.isBlkShop" class="icon" @click="goShare()">&#xe60e;</span>
<span class="icon" @click="showFilter()">&#xe60b;</span>
</div>
</div>
... ... @@ -13,8 +13,8 @@
<style>
.top-box {
width: 100%;
height: 60px;
padding: 0 20px;
height: 80px;
padding: 10px 20px;
position: fixed;
top: 60px;
left: 0;
... ... @@ -45,6 +45,14 @@
.top-box-left {
left: -655px;
}
.top-change {
background-color: #fff;
color: #000;
height: 140px;
top: 0;
padding: 70px 20px 10px;
}
</style>
<script>
... ... @@ -53,6 +61,11 @@
const tip = require('common/tip');
module.exports = {
data() {
return {
topChange: false
};
},
props: {
shareData: {
type: Object
... ... @@ -78,7 +91,7 @@
};
$.post({
url: '/product/collect-shop',
url: '/product/shop/collect.json',
data: data
}).done(result => {
tip(result.message);
... ... @@ -90,7 +103,16 @@
});
},
showFilter() {
this.$parent.$refs.drawer.on = !this.$parent.$refs.drawer.on;
this.$parent.$refs.filter.isVisible = !this.$parent.$refs.filter.isVisible;
},
changeTopStatus() {
let topHeight = document.body.scrollTop;
if (topHeight > 100) {
this.topChange = true;
} else {
this.topChange = false;
}
}
}
};
... ...