|
|
import 'scss/activity/yoluck/yoluck-detail.page.scss';
|
|
|
|
|
|
|
|
|
let Swiper = require('yoho-swiper');
|
|
|
let timeCountDownTpl = require('hbs/activity/yoluck/time-countdown.hbs');
|
|
|
let luckAlertTpl = require('hbs/activity/yoluck/luck-alert.hbs');
|
|
|
let formatCountDown = require('./yoluck/formatCountDown');
|
|
|
let yoho = require('js/yoho-app');
|
|
|
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 shareData = require('./yoluck/share');
|
|
|
require('js/plugin/modal.alert');
|
|
|
|
|
|
let store = {
|
|
|
running: false,
|
|
|
shareUid: window.queryString['shareUid'] || ''
|
|
|
};
|
|
|
|
|
|
new Swiper('.swiper-container', {
|
|
|
direction: 'vertical',
|
...
|
...
|
@@ -14,6 +26,54 @@ new Swiper('.swiper-container', { |
|
|
autoplay: 3000
|
|
|
});
|
|
|
|
|
|
var luckAlert = {
|
|
|
$el: $('.js-luck-alert'),
|
|
|
init() {
|
|
|
this.bindEvent();
|
|
|
},
|
|
|
show(code) {
|
|
|
if (this.$el.find('.modal-mask').length === 0) {
|
|
|
this.$el.html(luckAlertTpl({
|
|
|
code
|
|
|
}));
|
|
|
} else {
|
|
|
this.$el.show();
|
|
|
}
|
|
|
},
|
|
|
hide() {
|
|
|
this.$el.hide();
|
|
|
},
|
|
|
bindEvent() {
|
|
|
this.$el.on('click', '.modal-mask', () => {
|
|
|
this.hide();
|
|
|
reload();
|
|
|
return true;
|
|
|
});
|
|
|
|
|
|
this.$el.on('click', '.share', function() {
|
|
|
share();
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
|
|
|
let clipboard = new Clipboard('.js-fellow', {
|
|
|
text: function() {
|
|
|
return '潮流有货';
|
|
|
}
|
|
|
});
|
|
|
|
|
|
clipboard.on('success', function(e) {
|
|
|
fellow();
|
|
|
e.clearSelection();
|
|
|
});
|
|
|
|
|
|
function reload() {
|
|
|
location = location;
|
|
|
}
|
|
|
|
|
|
luckAlert.init();
|
|
|
yoSdk.auth();
|
|
|
|
|
|
setInterval(() => {
|
|
|
let $countdown = $('.product_countdown');
|
|
|
|
...
|
...
|
@@ -25,16 +85,65 @@ setInterval(() => { |
|
|
}));
|
|
|
}, 1000);
|
|
|
|
|
|
// 分享弹框
|
|
|
$('.js-share').click(function() {
|
|
|
if (yoho && yoho.isApp) {
|
|
|
yoho.invokeMethod('go.showshareaction', {
|
|
|
shareType: 'yoluck',
|
|
|
function share() {
|
|
|
let $product= $('.product-name');
|
|
|
let name = $product.data('name');
|
|
|
let img = $product.data('img');
|
|
|
let price = $product.data('price');
|
|
|
let id = $product.data('id');
|
|
|
|
|
|
yoSdk.getUser().then(user => {
|
|
|
let share = shareData({
|
|
|
name: name,
|
|
|
imgUrl: img,
|
|
|
price: price,
|
|
|
shareUid: user.uid,
|
|
|
actPrizeId: id
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
|
|
|
if (yoho.isApp) {
|
|
|
yoho.invokeMethod('go.showshareaction', share.app);
|
|
|
} else {
|
|
|
yoSdk.wxShare({
|
|
|
...share.h5,
|
|
|
success() {
|
|
|
tip.show('分享成功', 3500);
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
function fellow() {
|
|
|
$.yAlert({
|
|
|
content: `<div>公众号<span style="font-weight: bolder">“潮流有货”</span>已经复制成功,</div><div>打开微信搜索去添加吧~</div>`
|
|
|
});
|
|
|
}
|
|
|
|
|
|
// 助力
|
|
|
$('.js-join').click(function() {
|
|
|
$('.action-bar-comp').on('click', '.js-join', function() {
|
|
|
if (store.running) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
store.running = true;
|
|
|
api.getCode(store.shareUid).then(result => {
|
|
|
if (result.code === 200) {
|
|
|
luckAlert.show(result.data.prizeCode);
|
|
|
} else {
|
|
|
if (result.code === 400) {
|
|
|
yoSdk.goLogin();
|
|
|
} else {
|
|
|
tip.show(result.message, 3500);
|
|
|
}
|
|
|
}
|
|
|
}).always(() => {
|
|
|
store.running = false;
|
|
|
});
|
|
|
});
|
|
|
|
|
|
// 分享
|
|
|
$('.action-bar-comp').on('click', '.js-share', function() {
|
|
|
share();
|
|
|
});
|
|
|
|
...
|
...
|
|