Authored by 邱骏

修改分享逻辑

<!--活动模板分享领券组件-->
<div class="web-share">
{{log .}}
{{#webShare}}
<a href="javascript:void(0)" class="web-share-button" data-stid="{{../share_template_id}}" data-scoupon="{{../share_condition}}"
data-spic="{{pic}}" data-sdesc="{{content}}" data-stitle="{{title}}" data-surl="{{url}}"></a>
... ...
... ... @@ -207,7 +207,42 @@ function goLogin(shareData) { // 跳转登录判断
}
}
function initWxShare(data) {
let shareData = {
title: data.title,
imgUrl: data.imgUrl,
desc: data.desc,
link: data.link,
success: function() {
setTimeout(getCoupon, 500);
}
};
yo_sdk.wxShare(shareData);
}
function initWebShareButtons(env = '') { // 初始化分享按钮事件
let webShareData = {
title: $('#shareTitle').val(),
desc: $('#shareImg').val(),
imgUrl: $('#shareDesc').val(),
link: $('#shareLink').val()
};
if ($('.web-share-button')[0]) {
let webShareButton = $('.web-share-button');
webShareData = {
title: webShareButton.data('stitle'),
desc: webShareButton.data('sdesc'),
imgUrl: webShareButton.data('spic'),
link: webShareButton.data('surl').replace('https://activity.yoho.cn', 'http://m.yohobuy.com/activity')
};
}
initWxShare(webShareData);
$('.web-share-button').each(function() {
let webShareButton = $(this);
... ... @@ -217,13 +252,18 @@ function initWebShareButtons(env = '') { // 初始化分享按钮事件
return;
}
getParams();
let webShareData = {
webShareData = {
title: webShareButton.data('stitle'),
desc: webShareButton.data('sdesc'),
imgUrl: webShareButton.data('spic'),
link: webShareButton.data('surl').replace('https://activity.yoho.cn', 'http://m.yohobuy.com/activity')
};
$('#shareTitle').val(webShareData.title);
$('#shareImg').val(webShareData.desc);
$('#shareDesc').val(webShareData.imgUrl);
$('#shareLink').val(webShareData.link);
if (isApp) {
Object.assign(webShareData, {
hideType: ['4', '5', '6', '7', '8', '9'],
... ... @@ -243,20 +283,6 @@ function initWebShareButtons(env = '') { // 初始化分享按钮事件
$('.web-share-img-wrapper').on('click', hideShare);
}
function initWxShare() {
let shareData = {
title: $('#shareTitle').val(),
imgUrl: $('#shareImg').val(),
desc: $('#shareDesc').val(),
link: $('#shareLink').val(),
success: function() {
setTimeout(getCoupon, 500);
}
};
yo_sdk.wxShare(shareData);
}
// 分享领券模板功能初始化
function initWebShare() {
getParams();
... ... @@ -272,7 +298,6 @@ function initWebShare() {
$('.web-share-buttons-container .button-download').hide();
initWebShareButtons('miniprogram');
} else if (isWechat) {
initWxShare();
initWebShareButtons('wechat');
} else {
initWebShareButtons();
... ...