Authored by 陈峰

Merge branch 'feature/yoluck' into 'release/6.8.3'

Feature/yoluck



See merge request !1616
... ... @@ -57,6 +57,8 @@
</div>
<div class="js-clipbroad"></div>
{{/tabpanel}}
... ...
{
"name": "yohobuywap-node",
"version": "6.8.52",
"version": "6.8.53",
"private": true,
"description": "A New Yohobuy Project With Express",
"repository": {
... ...
... ... @@ -8,6 +8,7 @@ let YolukcApi = require('./yoluck/api');
let api = new YolukcApi();
let tip = require('js/plugin/tip');
let yoSdk = require('yoho-activity-sdk');
let Clipboard = require('clipboard');
let makeShareData = require('./yoluck/share');
... ... @@ -27,6 +28,8 @@ let name = $product.data('name');
let img = $product.data('img');
let price = $product.data('price');
let id = $product.data('id');
let user;
let shareData;
new Swiper('.swiper-container', {
direction: 'vertical',
... ... @@ -36,28 +39,6 @@ new Swiper('.swiper-container', {
autoplay: 4000
});
function share() {
yoSdk.getUser().then(user => {
let shareData = makeShareData({
name: name,
imgUrl: img,
price: price,
shareUid: user.uid,
actPrizeId: id
});
if (yoSdk.env === 'app') {
yoSdk.invokeMethod('go.showshareaction', shareData.app);
} else if (yoSdk.env === 'h5') {
yoSdk.wxShare({
...shareData.h5,
success() {
tip.show('分享成功', 3500);
}
});
}
});
}
function fellow() {
$.yAlert({
... ... @@ -67,6 +48,35 @@ function fellow() {
});
}
function getUser() {
try {
if (user) {
return Promise.resolve();
}
return yoSdk.getUser().then(u => {
user = u;
shareData = makeShareData({
name: name,
imgUrl: img,
price: price,
shareUid: user && user.uid,
actPrizeId: id
});
});
} catch (e) {
return Promise.resolve();
}
}
getUser();
function share() {
if (yoSdk.env === 'app') {
yoSdk.invokeMethod('go.showshareaction', shareData && shareData.app);
}
}
let luckAlert = {
$el: $('.js-luck-alert'),
init() {
... ... @@ -97,17 +107,32 @@ let luckAlert = {
}
};
let clipboard = new Clipboard('.js-fellow', {
let clipboardFellow = new Clipboard('.js-fellow', {
text: function() {
return '潮流有货';
}
});
clipboard.on('success', function(e) {
clipboardFellow.on('success', function(e) {
fellow();
e.clearSelection();
});
let clipboardShare = new Clipboard('.js-share', {
text: function() {
return shareData && shareData.h5.link;
}
});
clipboardShare.on('success', function(e) {
if (yoSdk.env === 'app') {
return;
}
tip.show('复制成功,发送给好友为您助力', 3500);
e.clearSelection();
});
luckAlert.init();
setInterval(() => {
... ...
... ... @@ -12,6 +12,8 @@ const tip = require('js/plugin/tip');
const makeShareData = require('./yoluck/share');
const DETAIL_URI = location.protocol + '//m.yohobuy.com/activity/yoluck';
let Clipboard = require('clipboard');
require('js/plugin/modal.alert');
let footerText = ['内容加载中...', '暂无更多内容'];
... ... @@ -31,6 +33,8 @@ let store = {
footText: '',
running: false,
countDown: $(),
user: null,
shareData: null
};
let api = new Api();
... ... @@ -177,36 +181,66 @@ function fellow() {
});
}
function getUser() {
try {
if (store.user) {
return Promise.resolve();
}
return yoSdk.getUser().then(u => {
store.user = u;
});
} catch (e) {
// pass
return Promise.resolve();
}
}
function share($el) {
let name = $el.data('name');
let img = $el.data('img');
let price = $el.data('price');
let id = $el.data('id');
yoSdk.getUser().then(user => {
let shareData = makeShareData({
name,
imgUrl: img,
price: price,
actPrizeId: id,
shareUid: user.uid
});
store.shareData = makeShareData({
name,
imgUrl: img,
price: price,
actPrizeId: id,
shareUid: store.user && store.user.uid
});
if (yoSdk.env === 'app') {
yoho.invokeMethod('go.showshareaction', store.shareData && store.shareData.app);
} else if (yoSdk.env === 'h5') {
$('.js-clipbroad').trigger('click');
}
}
bus$.add(onTabClick);
bus$.add(onReachBottom);
function initClipboard() {
let clipboardShare = new Clipboard('.js-clipbroad', {
text: function() {
return store.shareData && store.shareData.h5.link;
}
});
clipboardShare.on('success', function(e) {
if (yoSdk.env === 'app') {
yoho.invokeMethod('go.showshareaction', shareData.app);
} else if (yoSdk.env === 'h5') {
yoSdk.wxShare({
...shareData.h5,
success() {
tip.show('分享成功', 3500);
}
});
return;
}
tip.show('复制成功,发送给好友为您助力', 3500);
e.clearSelection();
});
}
bus$.add(onTabClick);
bus$.add(onReachBottom);
initClipboard();
getUser();
$tabpanel.on('click', '.js-tab', function() {
let $tab = $(this);
... ... @@ -247,7 +281,9 @@ $tabpanel
return false;
})
.on('click', '.js-share', function() {
share($(this));
getUser().then(() => {
share($(this));
});
return false;
})
.on('click', '.js-fellow', function() {
... ...