Authored by QC-L

添加 tab 切换事件

@@ -24,6 +24,12 @@ function index(req, res, next) { @@ -24,6 +24,12 @@ function index(req, res, next) {
24 }).catch(next); 24 }).catch(next);
25 } 25 }
26 26
  27 +function goodsTab(req, res, next) {
  28 + req.ctx(GroupService).goodsTab().then(result => {
  29 + return res.json({filterList: result.filterGroupList});
  30 + }).catch(next);
  31 +}
  32 +
27 function newIndex(req, res, next) { 33 function newIndex(req, res, next) {
28 req.ctx(GroupService).newGroupIndex().then(result => { 34 req.ctx(GroupService).newGroupIndex().then(result => {
29 console.log(result); 35 console.log(result);
@@ -399,5 +405,6 @@ module.exports = { @@ -399,5 +405,6 @@ module.exports = {
399 filter, 405 filter,
400 searchList, 406 searchList,
401 delOrder, 407 delOrder,
402 - cancelOrder 408 + cancelOrder,
  409 + goodsTab
403 }; 410 };
@@ -39,7 +39,6 @@ class GroupService extends global.yoho.BaseModel { @@ -39,7 +39,6 @@ class GroupService extends global.yoho.BaseModel {
39 contentCode: newContentCodes.home 39 contentCode: newContentCodes.home
40 }); 40 });
41 41
42 - console.log(result);  
43 return result; 42 return result;
44 } catch (e) { 43 } catch (e) {
45 throw new Error('Group index fail to load resources.'); 44 throw new Error('Group index fail to load resources.');
@@ -192,7 +191,9 @@ class GroupService extends global.yoho.BaseModel { @@ -192,7 +191,9 @@ class GroupService extends global.yoho.BaseModel {
192 } 191 }
193 }); 192 });
194 193
195 - console.log(filters); 194 + filters.forEach(item => {
  195 + item.queryString = JSON.stringify(item.query);
  196 + });
196 197
197 let indexFilter = filters[tabCurrentIndex] || {}; 198 let indexFilter = filters[tabCurrentIndex] || {};
198 let query = {}; 199 let query = {};
@@ -211,6 +212,14 @@ class GroupService extends global.yoho.BaseModel { @@ -211,6 +212,14 @@ class GroupService extends global.yoho.BaseModel {
211 return result; 212 return result;
212 } 213 }
213 214
  215 + async goodsTab(query, result = {}) {
  216 + result.filterGroupList = await this.filterGroupList({
  217 + ...query,
  218 + joinLimit: null
  219 + });
  220 + return result;
  221 + }
  222 +
214 async groupListIndex(params, uid) { 223 async groupListIndex(params, uid) {
215 let result = {}; 224 let result = {};
216 225
@@ -386,6 +386,7 @@ router.get('/group', group.index); // 拼团首页 @@ -386,6 +386,7 @@ router.get('/group', group.index); // 拼团首页
386 router.get('/group/newIndex', group.newIndex); // 拼团首页 386 router.get('/group/newIndex', group.newIndex); // 拼团首页
387 router.get('/group/list', group.groupListIndex); // 拼团列表页 387 router.get('/group/list', group.groupListIndex); // 拼团列表页
388 router.get('/group/goods-list', group.groupList); // 拼团列表 388 router.get('/group/goods-list', group.groupList); // 拼团列表
  389 +router.get('/group/goods-tab', group.goodsTab);
389 router.get('/group/filter', group.filter); // 首页筛选结果页 390 router.get('/group/filter', group.filter); // 首页筛选结果页
390 router.get('/group/search', group.searchList); // 首页筛选列表 391 router.get('/group/search', group.searchList); // 首页筛选列表
391 router.get('/group/progress', auth, group.progress); // 拼团状态详情页 392 router.get('/group/progress', auth, group.progress); // 拼团状态详情页
@@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
2 <div class="wapper"> 2 <div class="wapper">
3 <div class="guess-scroll"> 3 <div class="guess-scroll">
4 {{#each data}} 4 {{#each data}}
5 - <div class="guess-tab"> 5 + <div class="guess-tab" data-query="{{queryString}}">
6 <img src="{{image2 src w=160 h=80 q=60 mode=3}}" /> 6 <img src="{{image2 src w=160 h=80 q=60 mode=3}}" />
7 </div> 7 </div>
8 {{/each}} 8 {{/each}}
  1 +<div class="new-index-filter-list-item" data-activity-id="{{activity_id}}" data-product-skn="{{product_skn}}">
  2 + <div class="group-product-header">
  3 + {{#ifcond joinLimitStr "==" "邀新团"}}
  4 + <div class="new-group-product-left-icon">
  5 + <span class="new-group-product-left-icon-number"></span>
  6 + </div>
  7 + {{/ifcond}}
  8 + {{#if @root.lazyLoad}}
  9 + <img class="lazy new-group-product-image" data-original="{{image2 default_images w=400 h=390 q=60 mode=3}}" />
  10 + {{else}}
  11 + <img class="new-group-product-image" src="{{image2 default_images w=400 h=390 q=60 mode=3}}" />
  12 + {{/if}}
  13 + </div>
  14 + <div class="new-group-product-info-bg">
  15 + <div class="new-group-product-name">{{product_name}}</div>
  16 + <div class="new-group-price">
  17 + <div class="group-free-number">
  18 + <div class="new-group-free-post"></div>
  19 + <div class="new-group-number forcefontsize10">已拼{{joinPeopleNum}}</div>
  20 + </div>
  21 + <div class="new-group-prict-bg">
  22 + <div class="new-group-number-price">
  23 + <span class="new-group-people-numer">{{people_num}}人团</span>
  24 + <span class="new-group-price-collage">{{collage_price_str}}</span>
  25 + </div>
  26 + <div class="new-market-button">
  27 + <span class="new-group-price-market">单人价{{market_price_str}}</span>
  28 + <div class="go-group-product"></div>
  29 + </div>
  30 + </div>
  31 + </div>
  32 + </div>
  33 +</div>
@@ -8,6 +8,7 @@ import lazyLoad from 'yoho-jquery-lazyload'; @@ -8,6 +8,7 @@ import lazyLoad from 'yoho-jquery-lazyload';
8 import innerScroll from 'js/plugin/inner-scroll'; 8 import innerScroll from 'js/plugin/inner-scroll';
9 import sharePlugin from 'js/common/share'; 9 import sharePlugin from 'js/common/share';
10 const querystring = require('querystring'); 10 const querystring = require('querystring');
  11 +let groupListItem = require('hbs/activity/group/group-list-product.hbs');
11 12
12 class Group extends Page { 13 class Group extends Page {
13 constructor() { 14 constructor() {
@@ -23,6 +24,7 @@ class Group extends Page { @@ -23,6 +24,7 @@ class Group extends Page {
23 resourceList: $('.resource-collage-buy-prd-list'), 24 resourceList: $('.resource-collage-buy-prd-list'),
24 resourceListC: $('.resource-collage-buy-prd-list-c'), 25 resourceListC: $('.resource-collage-buy-prd-list-c'),
25 goodsList: $('.new-goods-list'), 26 goodsList: $('.new-goods-list'),
  27 + guessLike: $('.guess-tab')
26 }; 28 };
27 this.shareData = { 29 this.shareData = {
28 shareImgUrl: $('.group').data('share-img'), 30 shareImgUrl: $('.group').data('share-img'),
@@ -152,6 +154,7 @@ class Group extends Page { @@ -152,6 +154,7 @@ class Group extends Page {
152 this.selector.resourceList.on('click', '.product-item', this.checkDetail.bind(this)); 154 this.selector.resourceList.on('click', '.product-item', this.checkDetail.bind(this));
153 this.selector.resourceListC.on('click', '.swiper-slide', this.checkDetail.bind(this)); 155 this.selector.resourceListC.on('click', '.swiper-slide', this.checkDetail.bind(this));
154 this.selector.goodsList.on('click', '.new-index-filter-list-item', this.checkDetail.bind(this)); 156 this.selector.goodsList.on('click', '.new-index-filter-list-item', this.checkDetail.bind(this));
  157 + this.selector.guessLike.on('click', this.guessLikeTabChange.bind(this));
155 } 158 }
156 fixedTab() { 159 fixedTab() {
157 let listHeight = this.selector.groupListContent.height(); 160 let listHeight = this.selector.groupListContent.height();
@@ -174,6 +177,26 @@ class Group extends Page { @@ -174,6 +177,26 @@ class Group extends Page {
174 window.location.href = `/activity/group/detail?activityId=${activityId}&productSkn=${productSkn}`; 177 window.location.href = `/activity/group/detail?activityId=${activityId}&productSkn=${productSkn}`;
175 } 178 }
176 179
  180 + guessLikeTabChange(e) {
  181 + let $this = $(e.currentTarget);
  182 + let query = $this.data('query');
  183 + let queryObject = {};
  184 +
  185 + query.forEach(item => {
  186 + queryObject = Object.assign(queryObject, item);
  187 + });
  188 + $.ajax({
  189 + type: 'GET',
  190 + url: '/activity/group/goods-tab',
  191 + data: queryObject,
  192 + success: (data) => {
  193 + // $('.filter-mask').remove();
  194 + // $('.group').append(data);
  195 + this.renderMoreData(data.filterList || []);
  196 + }
  197 + });
  198 + }
  199 +
177 // 筛选tab切换 200 // 筛选tab切换
178 filterTabChange(e) { 201 filterTabChange(e) {
179 let $this = $(e.currentTarget); 202 let $this = $(e.currentTarget);
@@ -447,6 +470,16 @@ class Group extends Page { @@ -447,6 +470,16 @@ class Group extends Page {
447 } 470 }
448 } 471 }
449 472
  473 + renderMoreData(list) {
  474 + console.log(list);
  475 + let appendHtml = '';
  476 +
  477 + list.forEach(item => {
  478 + appendHtml += groupListItem(item);
  479 + });
  480 + $('.new-goods-list').html(appendHtml);
  481 + }
  482 +
450 // 筛选初始化 483 // 筛选初始化
451 filterInit() { 484 filterInit() {
452 let selectedChannel = this.selectedChannel; 485 let selectedChannel = this.selectedChannel;