Authored by 沈志敏

Merge branch 'develop' into feature/home

... ... @@ -37,9 +37,21 @@ module.exports = {
/* 获取商品列表 */
getBrandShopGoods: (req, res) => {
let params = req.query;
brandModel.getBrandShopGoodsData(params).then(result => {
brandModel.getBrandShopGoodsData({
sort: req.body.sort,
page: req.body.page,
channel: req.body.filter.channel || 'men',
gender: req.body.filter.gender || '1,2,3',
brand: req.body.filter.brand,
shopId: req.body.filter.shopId,
order: req.body.filter.order || 's_t_desc',
limit: req.body.filter.limit || '60',
color: req.body.filter.color,
price: req.body.filter.price,
size: req.body.filter.size,
pd: req.body.filter.pd,
tagsFilter: req.body.filter.tagsFilter
}).then(result => {
res.json(result);
});
},
... ... @@ -99,5 +111,14 @@ module.exports = {
.then(result => {
res.json(result);
});
},
// 品类资源位
cateResource: (req, res) => {
res.render('brand/cate-resource', {
module: 'channel',
page: 'cate-resource'
});
}
};
... ...
... ... @@ -4,7 +4,6 @@
* @date: 2016/05/09
*/
'use strict';
const brand = require('./brand');
/**
* 频道选择页
... ... @@ -18,4 +17,4 @@ const component = {
}
};
module.exports = Object.assign(component, brand);
module.exports = component;
... ...
... ... @@ -65,7 +65,20 @@ module.exports = {
*/
getBrandShopGoodsOriginData(params) {
return api.get('', {
method: ''
method: 'app.search.brand',
yh_channel: params.channel ? yhChannel[params.channel].channel : '1',
brand: params.brand,
shop_id: params.shopId,
order: params.order,
limit: params.limit,
page: params.page,
gender: params.gender,
color: params.color,
price: params.price,
size: params.size,
p_d: params.pd,
sort: params.sort,
tags_filter: params.tagsFilter
});
},
... ... @@ -82,7 +95,7 @@ module.exports = {
type: params.type
};
if (isFav) {
if (params.isFav) {
Object.assign(finalParams, {
method: 'app.favorite.add'
});
... ... @@ -114,5 +127,16 @@ module.exports = {
method: 'app.sort.get'
})
);
},
/**
* 从接口获取品类资源位数据
* @returns {*}
*/
getCateResource(params) {
return api.get('', Object.assign(params, {
method: 'app.sort.get'
})
);
}
};
... ...
... ... @@ -230,9 +230,23 @@ const getCateListData = params => {
});
};
/**
* 获取品类资源位数据
* @param params
* @returns {*|Promise.<TResult>}
*/
const getCateResource = params => {
let finalResult = {};
return brandApi.getCateResource(params).then(result => {
return finalResult;
});
};
module.exports = {
getBrandData,
getBrandShopGoodsData,
getBrandListData,
getCateListData
getCateListData,
getCateResource
};
... ...
... ... @@ -17,15 +17,16 @@ router.get('/', channel.index); // 首页
router.get('/resources', channel.resources); // 资源位接口
router.get('/brand', brand.index); // 店铺首页
router.get('/get-brand-intro', brand.getBrandIntro); // 店铺介绍
router.get('/get-brand-shop-goods', brand.getBrandShopGoods); // 店铺介绍
router.post('/get-brand-shop-goods', brand.getBrandShopGoods); // 店铺介绍
router.get('/brand-list', brand.brandList); // 品牌列表页
router.get('/get-brand-list', brand.getBrandList); // 获取品牌列表数据
router.get('/brand-share', brand.brandShare); // 获取品牌列表数据
router.get('/cate-resource', brand.cateResource); // 品类资源位页面
router.get('/collect-shop', brand.collectShop); // 收藏品牌店铺
router.get('/cate', brand.cate); // 全部分类
router.get('/get-cate-list', brand.getCateList); // 全部分类数据列表
router.get('/sidebar', channel.sidebar); // 资源位接口
module.exports = router;
... ...
<div id="cate-resource">
<cate-res></cate-res>
</div>
\ No newline at end of file
... ...
... ... @@ -21,9 +21,20 @@ exports.index = (req, res) => {
res.render('search', view);
};
/* 筛选的二级页面 */
exports.subFilter = (req, res) => {
const view = {
module: 'product',
page: 'filter-sub'
};
res.render('filter-sub', view);
};
/* 获取 筛选配置 */
exports.fetchFilters = (req, res, next) => {
const params = {
uid: 14741796, // mock data
page: req.body.page || 1,
order: req.body.order || 1,
yh_channel: req.body.yh_channel || 'all',
... ... @@ -41,10 +52,15 @@ exports.fetchFilters = (req, res, next) => {
.then(result => {
let filterConfig = {};
prettyFilter(result.data.filter);
filterConfig = camelCase(result.data.filter);
if (result.code === 200) {
prettyFilter(result.data.filter);
filterConfig = camelCase(result.data.filter);
}
res.json(filterConfig);
res.json({
code: result.code,
data: filterConfig
});
})
.catch(next);
};
... ... @@ -52,6 +68,7 @@ exports.fetchFilters = (req, res, next) => {
/* 查询 产品列表 */
exports.fetchProducts = (req, res, next) => {
const params = {
uid: 14741796, // mock data
page: req.body.page || 1,
order: req.body.order || 1,
yh_channel: req.body.yh_channel || 'all',
... ... @@ -67,9 +84,10 @@ exports.fetchProducts = (req, res, next) => {
code: 200
})
.then(result => {
result.data.productList = processProductList(result.data.productList);
result = camelCase(result);
if (result.code === 200) {
result.data.productList = processProductList(result.data.productList);
result = camelCase(result);
}
res.json(result);
})
.catch(next);
... ...
... ... @@ -16,6 +16,7 @@ const search = require(`${cRoot}/search`);
router.get('/search', search.index);
router.post('/search', search.fetchProducts);
router.get('/filter', search.subFilter);
router.get('/filters.json', search.fetchFilters);
// 商品详情controller
... ...
{{! 筛选的 二级菜单}}
<div id="filter-sub">
<filter-sub :data="data" :val="val" type="color"><filter-sub>
</div>
\ No newline at end of file
... ...
... ... @@ -14,7 +14,7 @@
"debug": "DEBUG=\"express:*\" nodemon -e js,hbs -i public/ app.js",
"lint-js": "eslint -c .eslintrc --cache --fix .",
"lint-css": "stylelint --config .stylelintrc public/scss/**/*.css",
"lint-vue": "stylelint --extract --config .stylelintrc public/vue/**/*.vue; eslint -c .eslintrc --cache --fix public/vue/**/*.vue",
"lint-vue": "stylelint --extract --config .stylelintrc public/vue/**/*.vue || eslint -c .eslintrc --cache --fix public/vue/**/*.vue",
"precommit": "node lint.js"
},
"license": "MIT",
... ...
const Vue = require('yoho-vue');
const lazyload = require('yoho-vue-lazyload');
const cateRes = require('channel/cate-resource-box.vue');
require('common/vue-filter');
Vue.use(lazyload);
new Vue({
el: '#cate-resource',
components: {
'cate-res': cateRes
}
});
... ...
... ... @@ -4,6 +4,6 @@ const brandCate = require('channel/brand-cate.vue');
new Vue({
el: '#brand-cate',
components: {
brandCate
'brand-cate': brandCate
}
});
... ...
const Vue = require('yoho-vue');
const filterSub = require('product/filter/filter-sub.vue');
// TODO: 该mock数据 应该有 上级页面传过来
const page = {
type: 'brand', // 二级筛选的 类型
data: [ // 二级筛选的 数据
{ id: 1, name: '红色' },
{ id: 2, name: '红色' },
{ id: 3, name: '红色' }
],
val: 3 // 二级筛选 的值
};
new Vue({
el: '#filter-sub',
data: function() {
return {
type: page.type,
data: page.data,
val: page.val
};
},
components: {
filterSub
}
});
... ...
... ... @@ -10,7 +10,6 @@
*/
const tip = require('common/tip');
const native = window.yohoInterface;
window.yohoWapInterface = {
headerRightTopBtn: function() {}
... ... @@ -35,7 +34,7 @@ const yoho = {
*/
goTap(args, success, fail) {
if (this.isApp) {
native.triggerEvent(success || function() {}, fail || function() {}, {
window.yohoInterface.triggerEvent(success || function() {}, fail || function() {}, {
method: 'go.tab',
arguments: args
});
... ... @@ -52,7 +51,7 @@ const yoho = {
*/
goLogin(args, success, fail) {
if (this.isApp) {
native.triggerEvent(success || function() {}, fail || function() {}, {
window.yohoInterface.triggerEvent(success || function() {}, fail || function() {}, {
method: 'go.login',
arguments: args
});
... ... @@ -69,7 +68,7 @@ const yoho = {
*/
goShopingCart(args, success, fail) {
if (this.isApp) {
native.triggerEvent(success || function() {}, fail || function() {}, {
window.yohoInterface.triggerEvent(success || function() {}, fail || function() {}, {
method: 'go.shopingCart',
arguments: args
});
... ... @@ -86,7 +85,7 @@ const yoho = {
*/
goAddress(args, success, fail) {
if (this.isApp) {
native.triggerEvent(success || function() {}, fail || function() {}, {
window.yohoInterface.triggerEvent(success || function() {}, fail || function() {}, {
method: 'go.address',
arguments: args
});
... ... @@ -103,7 +102,7 @@ const yoho = {
*/
goImageBrowser(args, success, fail) {
if (this.isApp) {
native.triggerEvent(success || function() {}, fail || function() {}, {
window.yohoInterface.triggerEvent(success || function() {}, fail || function() {}, {
method: 'go.imageBrowser',
arguments: args
});
... ... @@ -120,7 +119,7 @@ const yoho = {
*/
goNewPage(args, success, fail) {
if (this.isApp) {
native.triggerEvent(success || function() {}, fail || function() {}, {
window.yohoInterface.triggerEvent(success || function() {}, fail || function() {}, {
method: 'go.newPage',
arguments: args
});
... ... @@ -137,7 +136,7 @@ const yoho = {
*/
goPay(args, success, fail) {
if (this.isApp) {
native.triggerEvent(success || function() {}, fail || function() {}, {
window.yohoInterface.triggerEvent(success || function() {}, fail || function() {}, {
method: 'go.pay',
arguments: args
});
... ... @@ -154,7 +153,7 @@ const yoho = {
*/
goBack(args, success, fail) {
if (this.isApp) {
native.triggerEvent(success || function() {}, fail || function() {}, {
window.yohoInterface.triggerEvent(success || function() {}, fail || function() {}, {
method: 'go.back',
arguments: args
});
... ... @@ -171,7 +170,7 @@ const yoho = {
*/
goShare(args, success, fail) {
if (this.isApp) {
native.triggerEvent(success || function() {}, fail || function() {}, {
window.yohoInterface.triggerEvent(success || function() {}, fail || function() {}, {
method: 'go.share',
arguments: args
});
... ...
... ... @@ -31,8 +31,8 @@
filterConfig: global.filterConfig,
// query
url: '/product/list',
sort: 3,
url: '/get-brand-shop-goods',
sort: '',
filter: {},
page: 0, // page= 0 未搜索, 1 并且productList.length =0 没有数据, page = page_total 全部加载完
totalPage: 3,
... ... @@ -58,11 +58,10 @@
let data = {};
$.ajax({
method: 'post',
url: '/product/list',
url: this.url,
data: data
}).done(result => {
this.$set('productList', this.productList.concat(result.data.productList));
this.productList = result.data.productList;
}).fail(() => {
tip('网络错误');
});
... ... @@ -83,8 +82,8 @@
sort: this.sort,
filter: this.filter,
page: this.page
}).done(res => {
self.$set('productList', self.productList.concat(res.data.productList));
}).done(result => {
this.productList = result.data.productList;
}).fail(error => {
self.page--;
console.log(error);
... ...
... ... @@ -30,7 +30,8 @@
font-size: 36px;
font-family: helvetica, Arial, "黑体";
ul, li {
ul,
li {
margin: 0;
padding: 0;
list-style: none;
... ...
... ... @@ -57,6 +57,8 @@
const shareBottom = require('channel/share-bottom.vue');
module.exports = {
/* TODO 数据需要从接口获取 */
data() {
return {
brandName: 'COLORMAD',
... ...
<template>
<tab v-bind:page="page"></tab>
<resources v-bind:content-code.sync="contentCode"></resources>
<cate-resources></cate-resources>
</template>
<script>
const contentCode = require('content-code');
const qs = require('yoho-qs');
const tab = require('channel/tab.vue');
const resources = require('component/resources/index.vue');
const cateResources = require('channel/cate-resources.vue');
module.exports = {
data() {
return {
page: 'brand',
contentCode: contentCode.brand[qs.brand || 'men'],
channel: qs.channel
};
},
components: {
tab,
resources,
cateResources
}
};
</script>
\ No newline at end of file
... ...
<template>
<div class='cate-resource'>
<ul>
<li class='width50' style='
background:url(http://img11.static.yhbimg.com/brandLogo/2015/08/04/18/01a6f1a7600ab044d1577dd6c357298fb3.png?imageMogr2/thumbnail/150x150/extent/150x150/background/d2hpdGU=/position/center/quality/80);background-size:100% 100%;background-repeat:no-repeat;'>
<div>上衣</div>
</li>
<li class='width50' style='
background:url(http://img11.static.yhbimg.com/brandLogo/2015/08/04/18/01a6f1a7600ab044d1577dd6c357298fb3.png?imageMogr2/thumbnail/150x150/extent/150x150/background/d2hpdGU=/position/center/quality/80);background-size:100% 100%;background-repeat:no-repeat;'>
<div>上衣</div>
</li>
<li class='width100' style='
background:url(http://img10.static.yhbimg.com/yhb-img01/2016/07/22/15/014c3887f1320bf024a8bbc01fef5d2a1a.png?imageView2/2/w/750/h/365);background-size:100% 100%;background-repeat:no-repeat;'>
<div>全部分类</div>
</li>
</ul>
</div>
</template>
<style>
.cate-resource {
width: 100%;
ul,
li {
margin: 0;
padding: 0;
}
li {
float: left;
text-align: center;
color: #fff;
font-size: 60px;
cursor: pointer;
img {
width: 100%;
}
div {
margin-top: 50px;
}
}
.width25,
.width50,
.width100 {
width: 25%;
height: 200px;
overflow: hidden;
img {
height: 200px;
}
}
.width50 {
width: 50%;
}
.width100 {
width: 100%;
height: 360px;
img {
height: 360px;
}
div {
margin-top: 120px;
}
}
}
</style>
<script>
</script>
\ No newline at end of file
... ...
... ... @@ -2,7 +2,6 @@
<div>
<brand-filter v-if="type === 'brand'" :data="data" :val.sync="val"></brand-filter>
<normal-filter v-else :data="data" :val.sync="val">
<slot></slot>
</normal-filter>
</div>
</template>
... ... @@ -19,7 +18,7 @@ module.exports = {
watch: {
val: function(newV, oldV) {
console.log(`type: ${this.type}, value: ${newV}`);
}
}
}
};
</script>
... ...
<template>
<div class="filter-detail">
<div class="item" v-for="item in data" :class="{active: item.id === value}" @click="toggleCheck(item.id)">
<div class="item" v-for="item in data" :class="{active: item.id === val}" @click="toggleCheck(item.id)">
<div class="item-inner">
{{item.name}}
</div>
... ... @@ -10,12 +10,11 @@
</template>
<script>
module.exports = {
props: ['data', 'type', 'value'],
props: ['data', 'type', 'val'],
computed: {},
methods: {
toggleCheck: function(val) {
this.value = val;
this.$parent.select(val);
this.val = val;
}
}
};
... ...
... ... @@ -3,7 +3,7 @@
<ul class="cardlist card-large clearfix">
<li class="card" v-for="item in data">
<div class="card-pic">
<a href="">
<a href="/product/{{item.id}}">
<img v-lazy="item.goodsList[0].imagesUrl | resize 372 499" alt="{{item.productName}}">
</a>
</div>
... ... @@ -28,7 +28,7 @@ module.exports = {
/* 开启滚动加载 */
disableFetch: Boolean,
//数据
// 数据
data: Array
},
methods: {
... ...
<template>
<div>
<!--<filter-sub :data="brand" :value="3" type="brand"></filter-sub>-->
<Sort :config="sortConfig" :val="sort">
</Sort>
<List :data="productList"></List>
... ... @@ -19,7 +18,6 @@
const list = require('product/list.vue');
const drawer = require('product/drawer.vue');
const filter = require('product/filter.vue');
const filterSub = require('product/filter/filter-detail.vue');
Vue.use(lazyload);
Vue.use(infinitScroll);
... ... @@ -51,7 +49,6 @@
list,
sort,
filter,
filterSub,
drawer
},
methods: {
... ... @@ -76,9 +73,11 @@
page: nextPage
})
.done(res => {
self.page = res.data.page;
self.totalPage = res.data.pageTotal;
self.$set('productList', self.productList.concat(res.data.productList));
if (res.code === 200) {
self.page = res.data.page;
self.totalPage = res.data.pageTotal;
self.$set('productList', self.productList.concat(res.data.productList));
}
})
.fail(error => {
tip('网络出错~');
... ...