Authored by ccbikai

Merge branch 'develop' of git.yoho.cn:fe/yohoblk-wap into develop

... ... @@ -5,10 +5,12 @@ Name | Path | Note
品牌列表 | /brands |
品类 | /cate |
全部分类 | /cate-all |
商品列表 | /product/list?sort=1 |
品牌店铺 | /product/shop?domain=sctest1 |
品牌店铺分享页面 | /product/shop-share?domain=colormad |
商品详情 | /product/{productId} |
新品抢先看 | /product/new |
搜索页 | /product/search?query=xxx |
资讯列表 | /news |
资讯详情 | /news/{newsId} |
个人中心 | /home |
... ... @@ -19,6 +21,7 @@ Name | Path | Note
待收货 | /home/orders?type=4 |
订单详情 | /home/order-detail?orderCode=xxx |
退货申请 | /home/refund?orderId=160181661 |
换货申请 | /home/exchange?orderId=160181661 |
收藏商品 | /home/favorite |
收藏品牌 | /home/favorite?tab=brand |
yoho币 | /home/mycurrency |
... ...
... ... @@ -101,11 +101,11 @@ const getCateListData = params => {
sub: []
};
if (_.isEmpty(cate.sub)) {
item.url = helpers.urlFormat('/', {
item.url = helpers.urlFormat('/product/list', {
sort: item.sort,
sort_name: item.name,
gender: genderArr[categorykey]
}, 'list');
});
oneClass.ca.push(item);
return true;// equal continue;
}
... ... @@ -115,11 +115,11 @@ const getCateListData = params => {
id: item.id,
name: '全部' + item.name,
sort: item.sort,
url: helpers.urlFormat('/', {
url: helpers.urlFormat('/product/list', {
sort: item.sort,
sort_name: item.name,
gender: genderArr[categorykey]
}, 'list'),
}),
sub: []
});
... ... @@ -130,11 +130,11 @@ const getCateListData = params => {
sort: sub.relation_parameter.sort,
url: ''
};
subitem.url = helpers.urlFormat('/', {
subitem.url = helpers.urlFormat('/product/list', {
sort: subitem.sort,
sort_name: subitem.name,
gender: genderArr[categorykey]
}, 'list');
});
item.sub.push(subitem);
});
... ...
... ... @@ -45,9 +45,9 @@ const component = {
var gender = '';
if (data.gender === '1') {
gender = 'men'
gender = 'men';
} else if (data.gender === '2') {
gender = 'women'
gender = 'women';
}
res.render('mydetails', {
... ...
... ... @@ -19,7 +19,7 @@ exports.index = (req, res) => {
/* 获取 筛选配置 */
exports.fetchFilters = (req, res, next) => {
const params = Object.assign({
uid: req.user.uid,
uid: req.user.uid || 0,
page: 1,
order: 1,
yh_channel: 'all',
... ... @@ -34,10 +34,12 @@ exports.fetchFilters = (req, res, next) => {
/* 查询 产品列表 */
exports.fetchProducts = (req, res, next) => {
const params = Object.assign({
uid: req.user.uid,
page: 1,
order: 1
uid: req.user.uid || 0
}, req.query);
newModel.getNewData(params).catch(next);
newModel.getNewData(params)
.then(result => {
res.json(result);
})
.catch(next);
};
... ...
... ... @@ -17,25 +17,6 @@ exports.index = (req, res) => {
res.render('product-list', view);
};
/* 筛选的二级页面 */
exports.subFilter = (req, res) => {
const view = {
module: 'product',
page: 'filter-sub'
};
res.render('filter-sub', view);
};
/* 获取 筛选配置 */
exports.fetchFilters = (req, res, next) => {
const params = req.query;
searchModel.products(params)
.then(result => res.json(result))
.catch(next);
};
/* 查询 产品列表 method:GET */
exports.fetchProducts = (req, res, next) => {
const params = req.query;
... ...
/* 筛选的二级页面 */
exports.page = (req, res) => {
const view = {
module: 'product',
page: 'filter-sub'
};
res.render('filter-sub', view);
};
... ... @@ -11,11 +11,9 @@ exports.getNewData = (params) => {
method: 'app.search.newProduct',
}, params);
api.post('', params, {
cache: true,
code: 200
}).then(result => {
return api.get('', params).then(result => {
if (result.data) {
prettyFilter(result.data.filter);
result.data.productList = processProductList(result.data.productList);
result = camelCase(result);
}
... ... @@ -30,7 +28,7 @@ exports.getNewFilterData = (params) => {
method: 'app.search.newProduct',
}, params);
api.post('', params, {
return api.post('', params, {
cache: true,
code: 200
}).then(result => {
... ...
... ... @@ -13,11 +13,13 @@ const router = expressRouter();
// 产品 搜索 页面
const search = require(`${cRoot}/search`);
const newProduct = require(`${cRoot}/new`);
router.get('/search', search.index);
router.get('/search.json', search.fetchProducts); // ajax
// 新品页
const newProduct = require(`${cRoot}/new`);
router.get('/new', newProduct.index);
router.get('/new.json', newProduct.fetchProducts);
... ... @@ -26,12 +28,6 @@ const productList = require(`${cRoot}/product-list`);
router.get('/list', productList.index);
router.get('/list.json', productList.fetchProducts);
router.get('/list/filter', productList.subFilter);
// sub filter
const subFilter = require(`${cRoot}/sub-filter`);
router.get('/sub-filter', subFilter.page);
// 品牌店铺页面
const shop = require(`${cRoot}/shop`);
... ...
{{! 筛选的 二级菜单}}
<div id="filter-sub">
<filter-sub><filter-sub>
</div>
\ No newline at end of file
const Vue = require('yoho-vue');
const filterSub = require('component/product/filter/filter-sub.vue');
// TODO: 该mock数据 应该有 上级页面传过来
// const page = {
// 二级筛选的 类型
// type: 'brand',
// data: [ // 二级筛选的 数据
// { id: 1, name: '红色' },
// { id: 2, name: '红色' },
// { id: 3, name: '红色' }
// ],
// data: [{
// domain: 'converse',
// alif: 'C',
// ico: 'http://img12.static.yhbimg.com/brandLogo/2015/12/09/14/02752d2839e7001a09ecf71dcc9a996387.jpg?imageMogr2/thumbnail/{width}x{height}/extent/{width}x{height}/background/d2hpdGU=/position/center/quality/80',
// name: 'converse',
// keyword: 'converse,街头,摇滚,百搭,朋克,简约,个性,自然,潮流,环保',
// id: 27,
// hotKeyword: 'converse',
// isHot: 'Y',
// nameEn: 'converse',
// nameCn: '匡威'
// }, {
// domain: 'eightguys',
// alif: 'E',
// ico: 'http://img11.static.yhbimg.com/brandLogo/2013/07/02/19/01959c3b33245e16e786bda6b1e91234be.jpg?imageMogr2/thumbnail/{width}x{height}/extent/{width}x{height}/background/d2hpdGU=/position/center/quality/80',
// name: 'Eight Guys',
// keyword: '8Guys,八个男人',
// id: 396,
// hotKeyword: '',
// isHot: 'Y',
// nameEn: 'eight guys',
// nameCn: 'Eight Guys'
// }, {
// domain: 'soulandsole',
// alif: 'S',
// ico: 'http://img13.static.yhbimg.com/brandLogo/2014/01/27/11/02cfe4044dfb82230c1868211b814d6192.jpg?imageMogr2/thumbnail/{width}x{height}/extent/{width}x{height}/background/d2hpdGU=/position/center/quality/80',
// name: 'SOUL&SOLE',
// keyword: '',
// id: 335,
// hotKeyword: '',
// isHot: '',
// nameEn: 'SOUL&SOLE ',
// nameCn: 'SOUL&SOLE '
// }, {
// domain: 'thething',
// alif: 'T',
// ico: 'http://img11.static.yhbimg.com/brandLogo/2015/12/09/16/018d25bf4481ed2998bf33b294673a8535.jpg?imageMogr2/thumbnail/{width}x{height}/extent/{width}x{height}/background/d2hpdGU=/position/center/quality/80',
// name: 'THETHING',
// keyword: 'thething,tee,polo,衬衫,裤类,包类,配件类',
// id: 138,
// hotKeyword: 'thething',
// isHot: 'Y',
// nameEn: 'THETHING',
// nameCn: 'THETHING'
// }, {
// domain: 'roxy',
// alif: 'R',
// ico: 'http://img12.static.yhbimg.com/brandLogo/2012/05/28/13/0242bc746fa4ddbc9519c14c3b769b6774.jpg?imageMogr2/thumbnail/{width}x{height}/extent/{width}x{height}/background/d2hpdGU=/position/center/quality/80',
// name: 'Roxy',
// keyword: 'roxy',
// id: 273,
// hotKeyword: '',
// isHot: '',
// nameEn: 'Roxy',
// nameCn: 'Roxy'
// }, {
// domain: 'roxy',
// alif: 'R',
// ico: 'http://img12.static.yhbimg.com/brandLogo/2012/05/28/13/0242bc746fa4ddbc9519c14c3b769b6774.jpg?imageMogr2/thumbnail/{width}x{height}/extent/{width}x{height}/background/d2hpdGU=/position/center/quality/80',
// name: 'Roxy',
// keyword: 'roxy',
// id: 273,
// hotKeyword: '',
// isHot: '',
// nameEn: 'Roxy',
// nameCn: 'Roxy'
// }, {
// domain: 'roxy',
// alif: 'R',
// ico: 'http://img12.static.yhbimg.com/brandLogo/2012/05/28/13/0242bc746fa4ddbc9519c14c3b769b6774.jpg?imageMogr2/thumbnail/{width}x{height}/extent/{width}x{height}/background/d2hpdGU=/position/center/quality/80',
// name: 'Roxy',
// keyword: 'roxy',
// id: 273,
// hotKeyword: '',
// isHot: '',
// nameEn: 'Roxy',
// nameCn: 'Roxy'
// }, {
// domain: 'roxy',
// alif: 'R',
// ico: 'http://img12.static.yhbimg.com/brandLogo/2012/05/28/13/0242bc746fa4ddbc9519c14c3b769b6774.jpg?imageMogr2/thumbnail/{width}x{height}/extent/{width}x{height}/background/d2hpdGU=/position/center/quality/80',
// name: 'Roxy',
// keyword: 'roxy',
// id: 273,
// hotKeyword: '',
// isHot: '',
// nameEn: 'Roxy',
// nameCn: 'Roxy'
// }, {
// domain: 'roxy',
// alif: 'R',
// ico: 'http://img12.static.yhbimg.com/brandLogo/2012/05/28/13/0242bc746fa4ddbc9519c14c3b769b6774.jpg?imageMogr2/thumbnail/{width}x{height}/extent/{width}x{height}/background/d2hpdGU=/position/center/quality/80',
// name: 'Roxy',
// keyword: 'roxy',
// id: 273,
// hotKeyword: '',
// isHot: '',
// nameEn: 'Roxy',
// nameCn: 'Roxy'
// }, {
// domain: 'roxy',
// alif: 'R',
// ico: 'http://img12.static.yhbimg.com/brandLogo/2012/05/28/13/0242bc746fa4ddbc9519c14c3b769b6774.jpg?imageMogr2/thumbnail/{width}x{height}/extent/{width}x{height}/background/d2hpdGU=/position/center/quality/80',
// name: 'Roxy',
// keyword: 'roxy',
// id: 273,
// hotKeyword: '',
// isHot: '',
// nameEn: 'Roxy',
// nameCn: 'Roxy'
// }, {
// domain: 'roxy',
// alif: 'R',
// ico: 'http://img12.static.yhbimg.com/brandLogo/2012/05/28/13/0242bc746fa4ddbc9519c14c3b769b6774.jpg?imageMogr2/thumbnail/{width}x{height}/extent/{width}x{height}/background/d2hpdGU=/position/center/quality/80',
// name: 'Roxy',
// keyword: 'roxy',
// id: 273,
// hotKeyword: '',
// isHot: '',
// nameEn: 'Roxy',
// nameCn: 'Roxy'
// }, {
// domain: 'roxy',
// alif: 'R',
// ico: 'http://img12.static.yhbimg.com/brandLogo/2012/05/28/13/0242bc746fa4ddbc9519c14c3b769b6774.jpg?imageMogr2/thumbnail/{width}x{height}/extent/{width}x{height}/background/d2hpdGU=/position/center/quality/80',
// name: 'Roxy',
// keyword: 'roxy',
// id: 273,
// hotKeyword: '',
// isHot: '',
// nameEn: 'Roxy',
// nameCn: 'Roxy'
// }, {
// domain: 'roxy',
// alif: 'R',
// ico: 'http://img12.static.yhbimg.com/brandLogo/2012/05/28/13/0242bc746fa4ddbc9519c14c3b769b6774.jpg?imageMogr2/thumbnail/{width}x{height}/extent/{width}x{height}/background/d2hpdGU=/position/center/quality/80',
// name: 'Roxy',
// keyword: 'roxy',
// id: 273,
// hotKeyword: '',
// isHot: '',
// nameEn: 'Roxy',
// nameCn: 'Roxy'
// }, {
// domain: 'roxy',
// alif: 'R',
// ico: 'http://img12.static.yhbimg.com/brandLogo/2012/05/28/13/0242bc746fa4ddbc9519c14c3b769b6774.jpg?imageMogr2/thumbnail/{width}x{height}/extent/{width}x{height}/background/d2hpdGU=/position/center/quality/80',
// name: 'Roxy',
// keyword: 'roxy',
// id: 273,
// hotKeyword: '',
// isHot: '',
// nameEn: 'Roxy',
// nameCn: 'Roxy'
// }, {
// domain: 'roxy',
// alif: 'R',
// ico: 'http://img12.static.yhbimg.com/brandLogo/2012/05/28/13/0242bc746fa4ddbc9519c14c3b769b6774.jpg?imageMogr2/thumbnail/{width}x{height}/extent/{width}x{height}/background/d2hpdGU=/position/center/quality/80',
// name: 'Roxy',
// keyword: 'roxy',
// id: 273,
// hotKeyword: '',
// isHot: '',
// nameEn: 'Roxy',
// nameCn: 'Roxy'
// }, {
// domain: 'roxy',
// alif: 'R',
// ico: 'http://img12.static.yhbimg.com/brandLogo/2012/05/28/13/0242bc746fa4ddbc9519c14c3b769b6774.jpg?imageMogr2/thumbnail/{width}x{height}/extent/{width}x{height}/background/d2hpdGU=/position/center/quality/80',
// name: 'Roxy',
// keyword: 'roxy',
// id: 273,
// hotKeyword: '',
// isHot: '',
// nameEn: 'Roxy',
// nameCn: 'Roxy'
// }, {
// domain: 'roxy',
// alif: 'R',
// ico: 'http://img12.static.yhbimg.com/brandLogo/2012/05/28/13/0242bc746fa4ddbc9519c14c3b769b6774.jpg?imageMogr2/thumbnail/{width}x{height}/extent/{width}x{height}/background/d2hpdGU=/position/center/quality/80',
// name: 'Roxy',
// keyword: 'roxy',
// id: 273,
// hotKeyword: '',
// isHot: '',
// nameEn: 'Roxy',
// nameCn: 'Roxy'
// }, {
// domain: 'roxy',
// alif: 'R',
// ico: 'http://img12.static.yhbimg.com/brandLogo/2012/05/28/13/0242bc746fa4ddbc9519c14c3b769b6774.jpg?imageMogr2/thumbnail/{width}x{height}/extent/{width}x{height}/background/d2hpdGU=/position/center/quality/80',
// name: 'Roxy',
// keyword: 'roxy',
// id: 273,
// hotKeyword: '',
// isHot: '',
// nameEn: 'Roxy',
// nameCn: 'Roxy'
// }, {
// domain: 'natkiel',
// alif: 'N',
// ico: 'http://img11.static.yhbimg.com/brandLogo/2015/11/17/10/01032e9fba6bc0770077f2c645bad46127.jpg?imageMogr2/thumbnail/{width}x{height}/extent/{width}x{height}/background/d2hpdGU=/position/center/quality/80',
// name: 'Natkiel',
// keyword: '奈凯儿',
// id: 393,
// hotKeyword: '',
// isHot: 'N',
// nameEn: 'Natkiel',
// nameCn: 'Natkiel'
// }, {
// domain: 'natkiel',
// alif: 'N',
// ico: 'http://img11.static.yhbimg.com/brandLogo/2015/11/17/10/01032e9fba6bc0770077f2c645bad46127.jpg?imageMogr2/thumbnail/{width}x{height}/extent/{width}x{height}/background/d2hpdGU=/position/center/quality/80',
// name: 'Natkiel',
// keyword: '奈凯儿',
// id: 393,
// hotKeyword: '',
// isHot: 'N',
// nameEn: 'Natkiel',
// nameCn: 'Natkiel'
// }, {
// domain: 'natkiel',
// alif: 'N',
// ico: 'http://img11.static.yhbimg.com/brandLogo/2015/11/17/10/01032e9fba6bc0770077f2c645bad46127.jpg?imageMogr2/thumbnail/{width}x{height}/extent/{width}x{height}/background/d2hpdGU=/position/center/quality/80',
// name: 'Natkiel',
// keyword: '奈凯儿',
// id: 393,
// hotKeyword: '',
// isHot: 'N',
// nameEn: 'Natkiel',
// nameCn: 'Natkiel'
// }, {
// domain: 'natkiel',
// alif: 'N',
// ico: 'http://img11.static.yhbimg.com/brandLogo/2015/11/17/10/01032e9fba6bc0770077f2c645bad46127.jpg?imageMogr2/thumbnail/{width}x{height}/extent/{width}x{height}/background/d2hpdGU=/position/center/quality/80',
// name: 'Natkiel',
// keyword: '奈凯儿',
// id: 393,
// hotKeyword: '',
// isHot: 'N',
// nameEn: 'Natkiel',
// nameCn: 'Natkiel'
// }, {
// domain: 'natkiel',
// alif: 'N',
// ico: 'http://img11.static.yhbimg.com/brandLogo/2015/11/17/10/01032e9fba6bc0770077f2c645bad46127.jpg?imageMogr2/thumbnail/{width}x{height}/extent/{width}x{height}/background/d2hpdGU=/position/center/quality/80',
// name: 'Natkiel',
// keyword: '奈凯儿',
// id: 393,
// hotKeyword: '',
// isHot: 'N',
// nameEn: 'Natkiel',
// nameCn: 'Natkiel'
// }, {
// domain: 'natkiel',
// alif: 'N',
// ico: 'http://img11.static.yhbimg.com/brandLogo/2015/11/17/10/01032e9fba6bc0770077f2c645bad46127.jpg?imageMogr2/thumbnail/{width}x{height}/extent/{width}x{height}/background/d2hpdGU=/position/center/quality/80',
// name: 'Natkiel',
// keyword: '奈凯儿',
// id: 393,
// hotKeyword: '',
// isHot: 'N',
// nameEn: 'Natkiel',
// nameCn: 'Natkiel'
// }, {
// domain: 'natkiel',
// alif: 'N',
// ico: 'http://img11.static.yhbimg.com/brandLogo/2015/11/17/10/01032e9fba6bc0770077f2c645bad46127.jpg?imageMogr2/thumbnail/{width}x{height}/extent/{width}x{height}/background/d2hpdGU=/position/center/quality/80',
// name: 'Natkiel',
// keyword: '奈凯儿',
// id: 393,
// hotKeyword: '',
// isHot: 'N',
// nameEn: 'Natkiel',
// nameCn: 'Natkiel'
// }],
// val: 3 // 二级筛选 的值
// };
new Vue({
el: '#filter-sub',
data: function() {
return {};
},
components: {
filterSub
}
});
... ... @@ -37,10 +37,10 @@
padding-left: 30px;
padding-right: 30px;
width: 100%;
height: 60px;
height: 120px;
line-height: 60px;
font-size: 48px;
background-color: #fff;
background-color: transparent;
.icon,
.header-title {
vertical-align: middle;
... ... @@ -66,6 +66,7 @@
}
.header-gap {
height: 60px;
height: 120px;
background-color: #fff;
}
</style>
... ...
... ... @@ -10,7 +10,7 @@
<li class="filter-cate" v-for="classify in config" @click="entrySub($key)">
<i class="icon icon-right right"></i>
<span class="filter-cate-label">{{$key | filter-en-cn }}</span>
<span class="filter-cate-val">{{params[$key] && params[$key].name }}</span>
<span class="filter-cate-val">{{showLabel($key)}}</span>
</li>
</ul>
</div>
... ... @@ -50,26 +50,21 @@
this.overlay.show();
} else {
this.overlay.hide();
this.$set('params', {});
}
}
},
methods: {
clearVals: function() {
// remove all value
this.$set('selected', {});
this.$set('params', {});
},
/**
* 当二级筛选, 返回数据时, 调用该方法
* @param {[type]} cate [description]
* @param {[type]} val [description]
*/
setCateParams: function(cate, val) {
this.$set(`params.${cate}`, val);
},
okAction: function() {
this.$set('selected', Object.assign({}, this.selected,this.params));
bus.$emit('filter.change', {
val: this.params,
val: this.selected,
ref: this._uid
});
},
... ... @@ -78,8 +73,24 @@
this.$refs.filterSub.isVisible = true;
},
/**
* 当二级筛选, 返回数据时, 调用该方法
* @param {[type]} cate [description]
* @param {[type]} val [description]
*/
setParams: function(item) {
this.$set(`params.${this.subType}`, item);
},
showLabel: function(key){
const newSelected = this.params[key];
const oldSelected = this.selected[key];
if(newSelected) {
return newSelected.name || '';
} else {
return oldSelected && oldSelected.name || '';
}
}
},
filters: {
... ...
... ... @@ -73,6 +73,8 @@
this.queryProductFeature(msg.pid);
});
yoho.addNativeMethod('submitForm', this.submit.bind(this));
// 获取 换货商品
$.ajax({
url: '/home/exchange/order',
... ... @@ -111,6 +113,11 @@
}
});
},
computed: {
selectedGoods() {
return this.goodsArr.filter(goods => goods.checked);
}
},
methods: {
changeAddress() {
yoho.goAddress({
... ...
... ... @@ -168,7 +168,7 @@
</show-box>
<div class="control-box">
<div class="control-box" v-if="isApp">
<button class="button control-button">
<span @click="yoho.goShopingCart()" style="position: relative;">
<i class="icon icon-bag"></i>
... ... @@ -191,6 +191,10 @@
</button>
</div>
<div v-if="!isApp">
<share-bottom></share-bottom>
</div>
<feature-selector :is-visible="showFeatureSelector" :entity="entity"
:on-add-to-cart="onAddToCart"></feature-selector>
</template>
... ... @@ -293,7 +297,7 @@
justify-content: space-around;
align-items: stretch;
position: fixed;
width: 100%;
width: 750px;
height: 99px;
bottom: 0;
... ... @@ -453,6 +457,7 @@
featureSelector: require('component/product/feature-selector.vue'),
showBox: require('./show-box.vue'),
topNav: require('./top-nav.vue'),
shareBottom: require('component/tool/share-bottom.vue'),
},
methods: {
/**
... ... @@ -477,9 +482,9 @@
} else if (result.code === 403) {
// 未登陆
yoho.goLogin('', function() {
alert('登录成功回调')
}, function() {
alert('登录失败回调')
});
}
});
... ...
<template>
<div>
<template v-if="productList.length">
<order :config="orderConfig" :val="order">
</Sort>
<List :data="productList"></List>
</template>
<div class="empty-tip" v-if="empty">
<i class="icon icon-search"></i>
<p class="empty-tip-cn">未找到相关商品</p>
<p class="empty-tip-en">Did not find the relevant goods</p>
</div>
<cheader title="新品抢先看">
<i class="icon icon-filter" slot="right" @click="openFilter"></i>
</cheader>
<order :config="orderConfig" :val="order"></order>
<List :data="productList"></List>
<Filter :config="filterConfig" action="/product/list.json" v-ref:filter></Filter>
</div>
</template>
<script>
const $ = require('yoho-jquery');
const Vue = require('yoho-vue');
const lazyload = require('yoho-vue-lazyload');
const infinitScroll = require('yoho-vue-infinite-scroll');
const qs = require('yoho-qs');
const qs = require('yoho-qs/parse');
const bus = require('common/vue-bus');
const tip = require('common/tip');
const sort = require('component/product/order.vue');
const cheader = require('component/header.vue');
const order = require('component/product/order.vue');
const list = require('component/product/list.vue');
const filter = require('component/product/filter.vue');
let locationQuery = qs(decodeURIComponent(location.search.replace(/^\?/, '')));
Vue.use(lazyload);
Vue.use(infinitScroll);
require('common/vue-filter');
module.exports = {
el: '#product-new',
data: function() {
return {
orderConfig: global.orderConfig,
filterConfig: global.filterConfig,
sortName: locationQuery.sort_name,
orderConfig: [],
filterConfig: null,
// query
url: '/product/search.json',
order: null,
query: qs.query,
url: '/product/new.json',
order: '',
filter: {},
page: 0, // 未搜索 page=0; 全部加载完 page = totalPage; 无数据: page !=0 && productList.length=0
totalPage: null,
... ... @@ -50,21 +49,18 @@
inSearching: false // 请求中
};
},
computed: {
// 无数据
empty: function() {
return this.page !== 0 && !this.productList.length;
}
},
components: {
cheader,
list,
order
order,
filter
},
methods: {
search: function() {
const self = this;
const nextPage = this.page + 1;
console.log(nextPage);
if (this.inSearching) {
return;
}
... ... @@ -75,20 +71,22 @@
}
this.inSearching = true;
console.log(nextPage);
$.get(this.url, {
order: this.order, // 排序 信息
query: this.query,
$.get(this.url, Object.assign({
order: this.order,
page: nextPage
})
}, this.filter, locationQuery))
.done(res => {
if (res.code === 200) {
self.page = res.data.page;
self.totalPage = res.data.pageTotal;
self.$set('productList', self.productList.concat(res.data.productList));
if (!self.filterConfig) {
self.$set('filterConfig', res.data.filter);
}
}
})
.fail(() => {
.fail(error => {
tip('网络出错~');
})
.always(() => {
... ... @@ -96,6 +94,14 @@
});
},
openFilter() {
this.$refs.filter.isVisible = true;
},
// openFilterSub: function(classify) {
// console.log('TODO: open filter sub', classify);
// },
/**
* 清空数据(page=0) 重新搜索
*/
... ... @@ -106,9 +112,12 @@
}
},
watch: {
/* order 改变 都会触发 重新搜索 */
/* order 和 filter 改变 都会触发 重新搜索 */
order: function() {
this.research();
},
filter: function() {
this.research();
}
},
... ... @@ -120,36 +129,33 @@
self.search();
});
bus.$on('order.change', function({
val
}) {
bus.$on('order.change', function({val}) {
console.log(val);
self.order = val;
});
/**
* 筛选组件 筛选值变更,触发 filter.change事件
* 1. 重新搜索
* 2. 关闭 drawer 组件
*/
bus.$on('filter.change', function({val}) {
console.log(val);
let filter = {};
$.each(val, (type, item) => {
if (item.id) {
filter[type] = item.id;
}
});
self.$set('filter', filter);
self.$refs.filter.isVisible = false;
});
this.search();
}
};
</script>
<style>
.empty-tip {
margin-top: 380px;
color: #b0b0b0;
text-align: center;
.icon-search {
display: inline-block;
font-size: 200px;
margin-bottom: 56px;
}
}
.empty-tip-cn {
font-size: 34px;
margin-bottom: 30px;
}
.empty-tip-en {
font-size: 20px;
}
</style>
... ...