Authored by QC-L

添加 tab 切换事件

... ... @@ -24,6 +24,12 @@ function index(req, res, next) {
}).catch(next);
}
function goodsTab(req, res, next) {
req.ctx(GroupService).goodsTab().then(result => {
return res.json({filterList: result.filterGroupList});
}).catch(next);
}
function newIndex(req, res, next) {
req.ctx(GroupService).newGroupIndex().then(result => {
console.log(result);
... ... @@ -399,5 +405,6 @@ module.exports = {
filter,
searchList,
delOrder,
cancelOrder
cancelOrder,
goodsTab
};
... ...
... ... @@ -39,7 +39,6 @@ class GroupService extends global.yoho.BaseModel {
contentCode: newContentCodes.home
});
console.log(result);
return result;
} catch (e) {
throw new Error('Group index fail to load resources.');
... ... @@ -192,7 +191,9 @@ class GroupService extends global.yoho.BaseModel {
}
});
console.log(filters);
filters.forEach(item => {
item.queryString = JSON.stringify(item.query);
});
let indexFilter = filters[tabCurrentIndex] || {};
let query = {};
... ... @@ -211,6 +212,14 @@ class GroupService extends global.yoho.BaseModel {
return result;
}
async goodsTab(query, result = {}) {
result.filterGroupList = await this.filterGroupList({
...query,
joinLimit: null
});
return result;
}
async groupListIndex(params, uid) {
let result = {};
... ...
... ... @@ -386,6 +386,7 @@ router.get('/group', group.index); // 拼团首页
router.get('/group/newIndex', group.newIndex); // 拼团首页
router.get('/group/list', group.groupListIndex); // 拼团列表页
router.get('/group/goods-list', group.groupList); // 拼团列表
router.get('/group/goods-tab', group.goodsTab);
router.get('/group/filter', group.filter); // 首页筛选结果页
router.get('/group/search', group.searchList); // 首页筛选列表
router.get('/group/progress', auth, group.progress); // 拼团状态详情页
... ...
... ... @@ -2,7 +2,7 @@
<div class="wapper">
<div class="guess-scroll">
{{#each data}}
<div class="guess-tab">
<div class="guess-tab" data-query="{{queryString}}">
<img src="{{image2 src w=160 h=80 q=60 mode=3}}" />
</div>
{{/each}}
... ...
<div class="new-index-filter-list-item" data-activity-id="{{activity_id}}" data-product-skn="{{product_skn}}">
<div class="group-product-header">
{{#ifcond joinLimitStr "==" "邀新团"}}
<div class="new-group-product-left-icon">
<span class="new-group-product-left-icon-number"></span>
</div>
{{/ifcond}}
{{#if @root.lazyLoad}}
<img class="lazy new-group-product-image" data-original="{{image2 default_images w=400 h=390 q=60 mode=3}}" />
{{else}}
<img class="new-group-product-image" src="{{image2 default_images w=400 h=390 q=60 mode=3}}" />
{{/if}}
</div>
<div class="new-group-product-info-bg">
<div class="new-group-product-name">{{product_name}}</div>
<div class="new-group-price">
<div class="group-free-number">
<div class="new-group-free-post"></div>
<div class="new-group-number forcefontsize10">已拼{{joinPeopleNum}}</div>
</div>
<div class="new-group-prict-bg">
<div class="new-group-number-price">
<span class="new-group-people-numer">{{people_num}}人团</span>
<span class="new-group-price-collage">{{collage_price_str}}</span>
</div>
<div class="new-market-button">
<span class="new-group-price-market">单人价{{market_price_str}}</span>
<div class="go-group-product"></div>
</div>
</div>
</div>
</div>
</div>
... ...
... ... @@ -8,6 +8,7 @@ import lazyLoad from 'yoho-jquery-lazyload';
import innerScroll from 'js/plugin/inner-scroll';
import sharePlugin from 'js/common/share';
const querystring = require('querystring');
let groupListItem = require('hbs/activity/group/group-list-product.hbs');
class Group extends Page {
constructor() {
... ... @@ -23,6 +24,7 @@ class Group extends Page {
resourceList: $('.resource-collage-buy-prd-list'),
resourceListC: $('.resource-collage-buy-prd-list-c'),
goodsList: $('.new-goods-list'),
guessLike: $('.guess-tab')
};
this.shareData = {
shareImgUrl: $('.group').data('share-img'),
... ... @@ -152,6 +154,7 @@ class Group extends Page {
this.selector.resourceList.on('click', '.product-item', this.checkDetail.bind(this));
this.selector.resourceListC.on('click', '.swiper-slide', this.checkDetail.bind(this));
this.selector.goodsList.on('click', '.new-index-filter-list-item', this.checkDetail.bind(this));
this.selector.guessLike.on('click', this.guessLikeTabChange.bind(this));
}
fixedTab() {
let listHeight = this.selector.groupListContent.height();
... ... @@ -174,6 +177,26 @@ class Group extends Page {
window.location.href = `/activity/group/detail?activityId=${activityId}&productSkn=${productSkn}`;
}
guessLikeTabChange(e) {
let $this = $(e.currentTarget);
let query = $this.data('query');
let queryObject = {};
query.forEach(item => {
queryObject = Object.assign(queryObject, item);
});
$.ajax({
type: 'GET',
url: '/activity/group/goods-tab',
data: queryObject,
success: (data) => {
// $('.filter-mask').remove();
// $('.group').append(data);
this.renderMoreData(data.filterList || []);
}
});
}
// 筛选tab切换
filterTabChange(e) {
let $this = $(e.currentTarget);
... ... @@ -447,6 +470,16 @@ class Group extends Page {
}
}
renderMoreData(list) {
console.log(list);
let appendHtml = '';
list.forEach(item => {
appendHtml += groupListItem(item);
});
$('.new-goods-list').html(appendHtml);
}
// 筛选初始化
filterInit() {
let selectedChannel = this.selectedChannel;
... ...