...
|
...
|
@@ -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(() => {
|
...
|
...
|
|