Authored by 陈峰

Merge branch 'hotfix/share_append_union_type' into 'release/318'

添加分享渠道号



See merge request !1721
... ... @@ -42,7 +42,8 @@ function groupListIndex(req, res, next) {
activityData: result.groupList,
resource: result.readyListResource,
shareInfo: result.shareInfo,
showType: result.showType
showType: result.showType,
unionType: result.unionType
});
}).catch(next);
}
... ... @@ -148,12 +149,16 @@ function goodsDetail(req, res, next) {
navBtn: false
});
let param = req.query;
let uid = 0;
if (typeof req.user.uid !== 'undefined') {
uid = req.user.uid;
}
req.ctx(GroupService).goodsDetail({
activityId: param.activityId,
productSkn: param.productSkn,
groupNo: param.groupNo
}).then((result) => {
}, uid).then((result) => {
if (_.isEmpty(result)) {
return next();
}
... ... @@ -165,6 +170,9 @@ function goodsDetail(req, res, next) {
finalResult.support = result.support;
finalResult.floor = result.floor;
finalResult.storage_sum = result.storage_sum;
if (uid !== 0) {
finalResult.unionType = result.unionType;
}
if (param.groupNo) {
finalResult.groupNo = param.groupNo;
}
... ...
... ... @@ -53,7 +53,9 @@ class GroupService extends global.yoho.BaseModel {
uid
} = {}) {
try {
let [detail, recommend, banner] = await Promise.all([
let unionType = '';
let [unionTypeResult, detail, recommend, banner] = await Promise.all([
this.getUnionType(uid),
this.api.groupDetail({
uid,
groupNo
... ... @@ -89,10 +91,15 @@ class GroupService extends global.yoho.BaseModel {
});
}
if (unionTypeResult.unionType) {
unionType = unionTypeResult.unionType;
}
return {
...detail,
recommend,
bannerResource: banner
bannerResource: banner,
unionType
};
} catch (e) {
... ... @@ -164,6 +171,9 @@ class GroupService extends global.yoho.BaseModel {
// 登录后获取分享信息
if (uid !== 0) {
// let share_id = await this.getShareId(uid);
let unionType = await this.getUnionType(uid);
result.unionType = unionType;
let share_id = isProd ? 5409 : 1124; // 线上:5409 ;测试:1124;
result.shareInfo = await this.getShareInfo({
... ... @@ -171,9 +181,23 @@ class GroupService extends global.yoho.BaseModel {
});
} else {
result.shareInfo = '';
result.unionType = '';
}
return result;
}
async getUnionType(uid) {
try {
const result = await this.api._getShareId({
uid
});
return result.unionType || '';
} catch (e) {
throw new Error('can not get shareId.');
}
}
async getShareId(uid) {
try {
const result = await this.api._getShareId({
... ... @@ -185,6 +209,7 @@ class GroupService extends global.yoho.BaseModel {
throw new Error('can not get shareId.');
}
}
async tabData() {
const result = await this.api._getPromoteCount();
let tabsData = {};
... ... @@ -282,9 +307,14 @@ class GroupService extends global.yoho.BaseModel {
throw new Error('get shareInfo failed.');
}
}
async goodsDetail(params) {
async goodsDetail(params, uid) {
let result = await this.api.getProductData(params);
if (uid !== 0) {
let unionType = await this.getUnionType(uid);
result.unionType = unionType;
}
if (result.shop_id) {
result.storeUrl = `/shop/${_.get(result, 'brand_info.brand_domain')}-${_.get(result, 'shop_id')}.html`;
}
... ...
... ... @@ -191,7 +191,7 @@
</div>
{{/if}}
</div>
<div class='my-share' id="share">
<div class='my-share' id="share" data-union-type="{{unionType}}">
<img src='//img13.static.yhbimg.com/brandBanner/2019/02/22/11/02b5bf3e1e3e3b66c15b7315bb96277609.png'>
</div>
{{#if introUrl}}
... ...
<div class="container" data-share-img="{{shareInfo.bigImage}}" data-share-title="{{shareInfo.title}}" data-share-content="{{shareInfo.content}}">
<div class="container" data-share-img="{{shareInfo.bigImage}}" data-share-title="{{shareInfo.title}}" data-share-content="{{shareInfo.content}}" data-union-type="{{unionType}}">
{{#if activityData.banner}}
<a href="{{activityData.banner.imageUrl}}" class="img-wrapper">
... ...
... ... @@ -7,7 +7,8 @@
data-product-skn="{{yourJoinItem.productSkn}}"
data-product-name="{{yourJoinItem.productName}}"
data-group-price="{{yourJoinItem.productGroupPrice}}"
data-share-img="{{image2 yourJoinItem.productIcon w=200 h=282}}">
data-share-img="{{image2 yourJoinItem.productIcon w=200 h=282}}"
data-union-type="{{unionType}}">
<div class="card">
<div class="inner-card go-join" data-product-skn="{{yourJoinItem.productSkn}}"
data-activity-id="{{activityId}}" data-group-no="{{groupNo}}" data-page-go="{{pageGo}}">
... ...
... ... @@ -33,7 +33,7 @@ function hiddenTips($ele) {
}
}
function getUser(title, name, imgUrl, activityId, productSkn, groupNo) {
function getUser(title, name, imgUrl, activityId, productSkn, groupNo, unionType) {
try {
if (user) {
return Promise.resolve();
... ... @@ -41,7 +41,7 @@ function getUser(title, name, imgUrl, activityId, productSkn, groupNo) {
return yoSdk.getUser().then(u => {
user = u;
shareData = makeShareData({title, name, imgUrl, activityId, productSkn, groupNo});
shareData = makeShareData({title, name, imgUrl, activityId, productSkn, groupNo, unionType});
sharePlugin(shareData.h5);
});
... ... @@ -95,7 +95,8 @@ class Detail extends Page {
$hours: $('#hours'),
$minutes: $('#minutes'),
$seconds: $('#seconds'),
$label: $('#label')
$label: $('#label'),
$share: $('#share')
};
this.getIntro();
this.goSwiper();
... ... @@ -285,6 +286,7 @@ class Detail extends Page {
let imgUrl = 'http://static.yohobuy.com/m/v1/img/touch/apple-touch-icon-144x144-precomposed-new.png';
let buynow = document.getElementById('buynow');
let formatCollagePrice = document.getElementById('collagePrice').value;
let unionType = this.selector.$share.data('union-type');
this.getProductData(productSkn);
if (buynow) {
... ... @@ -293,7 +295,7 @@ class Detail extends Page {
let title = `【包邮】${formatCollagePrice}${goodsName}`;
getUser(title, goodsName, imgUrl, activityId, productSkn, groupNo).then(() => {
getUser(title, goodsName, imgUrl, activityId, productSkn, groupNo, unionType).then(() => {
shareDom.onclick = function() {
if (/QQ/i.test(navigator.userAgent) || /MicroMessenger/i.test(navigator.userAgent)) {
dialog.showDialog({hasClass: 'group-guide-mask'});
... ...
... ... @@ -22,7 +22,8 @@ class ProductList extends Page {
};
this.shareData = {
shareImgUrl: this.selector.$pageContainer.data('share-img'),
shareTitle: this.selector.$pageContainer.data('share-title')
shareTitle: this.selector.$pageContainer.data('share-title'),
unionType: this.selector.$pageContainer.data('union-type')
};
this.firstScreen = this.selector.$goodsContainer.children().size() > 0;
if (!this.firstScreen) {
... ... @@ -61,6 +62,10 @@ class ProductList extends Page {
let [link, paramsStr] = location.href.split('?');
let params = querystring.parse(paramsStr);
if (shareData.unionType) {
params.union_type = shareData.unionType;
}
delete params['openby:yohobuy'];
paramsStr = querystring.stringify(params);
link = link + (paramsStr ? '?' + paramsStr : '');
... ...
... ... @@ -71,6 +71,7 @@ class GroupProgress extends Page {
let productSkn = this.selector.$page.data('product-skn');
let groupPrice = this.selector.$page.data('group-price');
let shareImgUrl = this.selector.$page.data('share-img');
let unionType = this.selector.$page.data('union-type');
this.data.groupNo = groupNo;
this.data.lackNum = lackNum;
... ... @@ -79,6 +80,7 @@ class GroupProgress extends Page {
this.data.groupPrice = groupPrice;
this.data.activityId = activityId;
this.data.shareImgUrl = shareImgUrl;
this.data.unionType = unionType;
this.getProductData(productSkn);
}
... ... @@ -93,8 +95,12 @@ class GroupProgress extends Page {
let _this = this;
let link = '';
let [domain] = location.href.split('?');
let unionType = this.data.unionType;
link = `${domain}?activityId=${this.data.activityId}&groupNo=${this.data.groupNo}`;
if (this.data.unionType) {
link = link + `&union_type=${unionType}`;
}
sharePlugin({
title: `【还差${_this.data.lackNum}人】${_this.data.groupPrice} ${_this.data.productName}`,
imgUrl: 'http://static.yohobuy.com/m/v1/img/touch/apple-touch-icon-144x144-precomposed-new.png',
... ...
function h5Path(activityId, productSkn, groupNo) {
function h5Path(activityId, productSkn, groupNo, unionType) {
let params = `${activityId}&productSkn=${productSkn}&groupNo=${groupNo || ''}`;
if (unionType) {
params = params + `&union_type=${unionType}`;
}
return location.protocol + '//m.yohobuy.com/activity/group/detail?activityId=' +
`${activityId}&productSkn=${productSkn}&groupNo=${groupNo || ''}`;
params;
}
function shareData({title, name, imgUrl, activityId, productSkn, groupNo}) {
let link = h5Path(activityId, productSkn, groupNo);
function shareData({title, name, imgUrl, activityId, productSkn, groupNo, unionType}) {
let link = h5Path(activityId, productSkn, groupNo, unionType);
let urls = imgUrl.split('?');
let shareImg = urls[0] || imgUrl;
... ...