Authored by QC-L

兼容 App

... ... @@ -34,6 +34,7 @@ function goodsTab(req, res, next) {
function newIndex(req, res, next) {
req.ctx(GroupService).newGroupIndex().then(result => {
console.log('isApp: ', req.yoho.isApp);
return res.render('group/newIndex', {
title: '有货福利团',
page: 'group',
... ... @@ -45,11 +46,12 @@ function newIndex(req, res, next) {
tabs: result.tabData,
filterList: result.filterGroupList,
shareInfo: result.shareInfo,
isApp: req.yoho.isApp || false,
tabbarItems: {
active: 0,
items: [{
title: '拼团首页',
url: '/activity/group/newIndex',
url: '/activity/group',
style: 'group-tab-home',
style_unselect: 'group-tab-home-unselect',
}, {
... ... @@ -374,7 +376,7 @@ function order(req, res, next) {
active: 1,
items: [{
title: '拼团首页',
url: '/activity/group/newIndex',
url: '/activity/group',
style: 'group-tab-home',
style_unselect: 'group-tab-home-unselect',
}, {
... ...
... ... @@ -41,7 +41,9 @@ class GroupService extends global.yoho.BaseModel {
return result;
} catch (e) {
throw new Error('Group index fail to load resources.');
return {
error: e
};
}
}
... ... @@ -53,7 +55,9 @@ class GroupService extends global.yoho.BaseModel {
return result;
} catch (e) {
throw new Error('Group index fail to load resources.');
return {
error: e
};
}
}
async readyListResource() {
... ... @@ -64,7 +68,9 @@ class GroupService extends global.yoho.BaseModel {
return result;
} catch (e) {
throw new Error('fail to load ready list resources.');
return {
error: e
};
}
}
... ... @@ -124,7 +130,9 @@ class GroupService extends global.yoho.BaseModel {
};
} catch (e) {
throw new Error('Group result fail to load data.');
return {
error: e
};
}
}
... ... @@ -161,7 +169,9 @@ class GroupService extends global.yoho.BaseModel {
};
} catch (e) {
throw new Error('Group index fail to load resources.');
return {
error: e
};
}
}
async groupIndex() {
... ... @@ -255,7 +265,9 @@ class GroupService extends global.yoho.BaseModel {
return result.unionType || '';
} catch (e) {
throw new Error('can not get shareId.');
return {
error: e
};
}
}
... ... @@ -267,7 +279,9 @@ class GroupService extends global.yoho.BaseModel {
return result.shareId;
} catch (e) {
throw new Error('can not get shareId.');
return {
error: e
};
}
}
... ... @@ -358,14 +372,18 @@ class GroupService extends global.yoho.BaseModel {
}
return finalResult;
} catch (e) {
throw new Error('Group list fail to load resources.');
return {
error: e
};
}
}
async getShareInfo(params) {
try {
return await this.api._getShareInfo(params);
} catch (e) {
throw new Error('get shareInfo failed.');
return {
error: e
};
}
}
async goodsDetail(params, uid) {
... ... @@ -430,7 +448,9 @@ class GroupService extends global.yoho.BaseModel {
result.reasons = reasons;
return result;
} catch (error) {
throw new Error('Group order fail to load resources.');
return {
error: error
};
}
}
... ... @@ -446,7 +466,9 @@ class GroupService extends global.yoho.BaseModel {
return result;
} catch (error) {
throw new Error('Group delOrder fail.');
return {
error: error
};
}
}
... ... @@ -462,7 +484,9 @@ class GroupService extends global.yoho.BaseModel {
return result;
} catch (error) {
throw new Error('Group cancelOrder fail.');
return {
error
};
}
}
... ...
... ... @@ -382,8 +382,8 @@ router.post('/yoluck/:id.html', auth, swtichYoLuck(yoluck.getCode, yoluckBack.ge
router.post('/yoluck/detail/mylist.html', swtichYoLuck(yoluck.getActivityCodeList, yoluckBack.getActivityCodeList));
// 拼团
router.get('/group', group.index); // 拼团首页
router.get('/group/newIndex', group.newIndex); // 拼团首页
// router.get('/group', group.index); // 拼团首页
router.get('/group', group.newIndex); // 拼团首页
router.get('/group/list', group.groupListIndex); // 拼团列表页
router.get('/group/goods-list', group.groupList); // 拼团列表
router.get('/group/goods-tab', group.goodsTab);
... ...
<div class="group" data-share-img="{{shareInfo.bigImage}}" data-share-title="{{shareInfo.title}}" data-share-content="{{shareInfo.content}}">
<div class="group" data-share-img="{{shareInfo.bigImage}}" data-share-title="{{shareInfo.title}}" data-share-content="{{shareInfo.content}}" data-is-App="{{isApp}}">
<div class="resources">
<div class="floors">
{{#each floors}}
... ... @@ -49,8 +49,12 @@
</div>
{{!-- {{> group/resources/filter-page}} --}}
</div>
{{!-- <a class="bottom" href="/activity/group/order">我的拼团</a> --}}
{{#tabbarItems}}
{{> group/group-tabbar}}
{{/tabbarItems}}
{{#if isApp}}
{{!-- http://m.yohobuy.com/groupPurchase?union_type=undefined&type=2&title=%E6%9C%89%E8%B4%A7%E5%8F%8B%E6%8B%BC%E5%9B%A2&gender=1,2,3&showType=3&productPool=704&openby:yohobuy={%22action%22:%22go.activitytemplate%22,%22params%22:{%22gender%22:%221,2,3%22,%22showType%22:%223%22,%22type%22:%222%22,%22title%22:%22%E6%9C%89%E8%B4%A7%E5%8F%8B%E6%8B%BC%E5%9B%A2%22,%22productPool%22:%22704%22}} --}}
<a class="bottom" href="/activity/group/order?openby:yohobuy={%22action%22:%22go.mineGroupPurchase%22}">我的拼团</a>
{{else}}
{{#tabbarItems}}
{{> group/group-tabbar}}
{{/tabbarItems}}
{{/if}}
</div>
\ No newline at end of file
... ...
... ... @@ -173,8 +173,24 @@ class Group extends Page {
let $this = $(e.currentTarget);
let productSkn = $this.data('product-skn');
let activityId = $this.data('activity-id');
let isApp = $('.group').data('is-App');
if (isApp) {
let param = {
action: 'go.productDetail',
params: {
product_skn: productSkn,
activity_id: activityId,
activity_type: 'groupPurchase'
}
};
let paramStr = JSON.stringify(param);
window.location.href = `/activity/group/detail?activityId=${activityId}&productSkn=${productSkn}`;
paramStr = `?activityId=${activityId}&productSkn=${productSkn}&openby:yohobuy=${paramStr}`;
window.location.href = `/activity/group/detail?${paramStr}`;
} else {
window.location.href = `/activity/group/detail?activityId=${activityId}&productSkn=${productSkn}`;
}
}
guessLikeTabChange(e) {
... ...