Authored by baoss

修改详情页路由、添加即将开始资源位

... ... @@ -26,6 +26,16 @@ function index(req, res, next) {
}
function groupListIndex(req, res, next) {
let params = Object.assign({}, req.query);
let showType = params.showType || 1; // 1、只展示已开始的 2、只展示即将开始的 3、展示全部
let resource = '';
console.log(params);
if (+showType === 2) {
req.ctx(GroupService).readyListResource().then(result => {
resource = result;
});
}
req.ctx(GroupService).groupList()
.then(result => {
return res.render('group/group-list', {
... ... @@ -35,7 +45,9 @@ function groupListIndex(req, res, next) {
nodownload: true,
width750: true,
wechatShare: true,
activityData: result
activityData: result,
resource,
showType
});
}).catch(next);
}
... ... @@ -43,6 +55,8 @@ function groupListIndex(req, res, next) {
function groupList(req, res, next) {
let params = Object.assign({}, req.query);
console.log(params);
req.ctx(GroupService).groupList(params)
.then(result => {
return res.render('group/group-list-ajax', {
... ...
... ... @@ -20,7 +20,17 @@ class GroupService extends global.yoho.BaseModel {
throw new Error('Group index fail to load resources.');
}
}
async readyListResource() {
try {
const result = await this.api._getResourceCode({
contentCode: '89141506b9926010f28915a82b3db61d'
});
return result;
} catch (e) {
throw new Error('Group index fail to load resources.');
}
}
async groupResult({
groupNo,
... ...
... ... @@ -4,6 +4,13 @@
<img class="img" src="{{activityData.banner.imagePath}}" alt="" style="display:block">
</a>
{{/if}}
{{#ifcond showType "==" '2'}}
{{#if resource}}
{{#ifcond template_name "==" 'focus'}}
{{> group/resources/focus}}
{{/ifcond}}
{{/if}}
{{/ifcond}}
<div id="goodsContainer">
<div class="goods-list">
{{#each activityData.activityList}}
... ...
... ... @@ -39,7 +39,7 @@ class ProductList extends Page {
let activityId = $this.data('activity-id');
console.log(productSkn, activityId);
window.location.href = `/activity/group/goodsDetail?activityId=${activityId}&productSkn=${productSkn}`;
window.location.href = `/activity/group/detail?activityId=${activityId}&productSkn=${productSkn}`;
}
}
... ...
... ... @@ -16,7 +16,8 @@ class Group extends Page {
floorsContentHeight: $('.floors').height(),
groupTab: $('.group-tab'),
filterTab: $('.filter-nav'),
groupListContent: $('.goods-list')
groupListContent: $('.goods-list'),
resourceList: $('.resource-collage-buy-prd-list')
};
this.navInfo = {
new: {
... ... @@ -122,6 +123,7 @@ class Group extends Page {
this.selector.groupTab.on('click', this.groupTabChange.bind(this));
this.selector.filterTab.on('click', 'li', this.filterTabChange.bind(this));
this.selector.groupListContent.on('click', '.group-product-cell', this.checkDetail.bind(this));
this.selector.resourceList.on('click', '.product-item', this.checkDetail.bind(this));
}
fixedTab() {
let listHeight = this.selector.groupListContent.height();
... ... @@ -143,7 +145,7 @@ class Group extends Page {
console.log(productSkn, activityId);
window.location.href = `/activity/group/goodsDetail?activityId=${activityId}&productSkn=${productSkn}`;
window.location.href = `/activity/group/detail?activityId=${activityId}&productSkn=${productSkn}`;
}
// 筛选tab切换
... ... @@ -234,11 +236,9 @@ class Group extends Page {
}
}
console.log(navInfo, 'filterTab', filterTab);
this.selector.filterTab.children('li').removeClass('active');
filterTab.$pre.addClass('active');
// 价格筛选状态设置
if (filterTab.$pre.hasClass('price')) {
navInfo.price.order = filterTab.order;
... ... @@ -341,11 +341,7 @@ class Group extends Page {
$.ajax({
type: 'GET',
url: '/activity/group/search',
data: {
...params,
...pageParams,
page
},
data: searchParams,
async: false,
beforeSend: () => {
let cacheData = cacheStore.get(catchKey);
... ...