...
|
...
|
@@ -4,13 +4,25 @@ import $ from 'yoho-jquery'; |
|
|
import Page from 'js/yoho-page';
|
|
|
import qs from 'yoho-qs';
|
|
|
import ProductListLoader from './group/group-list';
|
|
|
import Clipboard from 'clipboard';
|
|
|
import tip from 'js/plugin/tip';
|
|
|
import dialog from 'js/plugin/dialog';
|
|
|
import sharePlugin from 'js/common/share';
|
|
|
import yoSdk from 'yoho-activity-sdk';
|
|
|
const querystring = require('querystring');
|
|
|
|
|
|
class ProductList extends Page {
|
|
|
constructor() {
|
|
|
super();
|
|
|
|
|
|
this.selector = {
|
|
|
$goodsContainer: $('.goods-list')
|
|
|
$pageContainer: $('.container'),
|
|
|
$goodsContainer: $('.goods-list'),
|
|
|
$share: $('.my-share')
|
|
|
};
|
|
|
this.shareData = {
|
|
|
shareImgUrl: this.selector.$pageContainer.data('share-img'),
|
|
|
shareTitle: this.selector.$pageContainer.data('share-title')
|
|
|
};
|
|
|
this.firstScreen = this.selector.$goodsContainer.children().size() > 0;
|
|
|
if (!this.firstScreen) {
|
...
|
...
|
@@ -26,13 +38,16 @@ class ProductList extends Page { |
|
|
new ProductListLoader(initParams, '/activity/group/goods-list', {
|
|
|
scrollActived: this.firstScreen
|
|
|
});
|
|
|
this.shareInfo();
|
|
|
this.bindEvents();
|
|
|
this.swiperTop();
|
|
|
|
|
|
}
|
|
|
|
|
|
bindEvents() {
|
|
|
this.selector.$goodsContainer.on('click', '.groupListCellTapped',
|
|
|
this.checkDetail.bind(this));
|
|
|
this.selector.$share.on('click', this.share.bind(this));
|
|
|
}
|
|
|
checkDetail(e) {
|
|
|
let $this = $(e.currentTarget);
|
...
|
...
|
@@ -42,6 +57,42 @@ class ProductList extends Page { |
|
|
console.log(productSkn, activityId);
|
|
|
window.location.href = `/activity/group/detail?activityId=${activityId}&productSkn=${productSkn}`;
|
|
|
}
|
|
|
shareInfo() {
|
|
|
let shareData = this.shareData;
|
|
|
let [link, paramsStr] = location.href.split('?');
|
|
|
let params = querystring.parse(paramsStr);
|
|
|
|
|
|
delete params['openby:yohobuy'];
|
|
|
paramsStr = querystring.stringify(params);
|
|
|
link = link + (paramsStr ? '?' + paramsStr : '');
|
|
|
|
|
|
sharePlugin({
|
|
|
title: shareData.shareTitle,
|
|
|
imgUrl: shareData.shareImgUrl,
|
|
|
link: link
|
|
|
});
|
|
|
|
|
|
let clipboardShare = new Clipboard('.h5-share-clipboard', {
|
|
|
text: () => {
|
|
|
return `${shareData.shareTitle}>>${link}`;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
clipboardShare.on('success', (e) => {
|
|
|
tip.show('复制成功,发送给好友', 3500);
|
|
|
e.clearSelection();
|
|
|
});
|
|
|
}
|
|
|
share() {
|
|
|
if (/QQ/i.test(navigator.userAgent) ||
|
|
|
/MicroMessenger/i.test(navigator.userAgent)) {
|
|
|
dialog.showDialog({
|
|
|
hasClass: 'group-guide-mask'
|
|
|
});
|
|
|
} else if (yoSdk.env === 'h5') {
|
|
|
$('.h5-share-clipboard').trigger('click');
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 顶部swiper
|
|
|
swiperTop() {
|
...
|
...
|
|