...
|
...
|
@@ -5,10 +5,9 @@ |
|
|
*/
|
|
|
|
|
|
var $ = require('yoho-jquery'),
|
|
|
Hammer = require('yoho-hammer'),
|
|
|
ellipsis = require('yoho-mlellipsis'),
|
|
|
lazyLoad = require('yoho-jquery-lazyload'),
|
|
|
Swiper = require('yoho-swiper');
|
|
|
Swiper = require('yoho-swiper2');
|
|
|
|
|
|
var tip = require('../plugin/tip');
|
|
|
var loading = require('../plugin/loading');
|
...
|
...
|
@@ -55,12 +54,15 @@ function initSwiper(typeId) { |
|
|
if (typeof typeId === undefined) {
|
|
|
return;
|
|
|
}
|
|
|
mySwiper[typeId] = new Swiper('.swiper-cont-' + typeId, {
|
|
|
lazyLoading: true,
|
|
|
wrapperClass: 'swiper-wrap-' + typeId,
|
|
|
pagination: '.swiper-pagi-' + typeId,
|
|
|
autoplay: 3000
|
|
|
});
|
|
|
|
|
|
if (!mySwiper[typeId]) {
|
|
|
mySwiper[typeId] = new Swiper('.swiper-cont-' + typeId, {
|
|
|
lazyLoading: true,
|
|
|
wrapperClass: 'swiper-wrap-' + typeId,
|
|
|
pagination: '.swiper-pagi-' + typeId,
|
|
|
autoplay: 3000
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -85,101 +87,79 @@ function setLazyLoadAndMellipsis($infos) { |
|
|
* @params $container 逛资讯列表容器
|
|
|
*/
|
|
|
function initInfosEvt($container) {
|
|
|
var cHammer;
|
|
|
|
|
|
if (typeof $container === 'undefined') {
|
|
|
return;
|
|
|
}
|
|
|
if (typeof $container[0] === 'undefined') {
|
|
|
return;
|
|
|
}
|
|
|
cHammer = new Hammer($container[0]);
|
|
|
|
|
|
// 点赞或者收藏事件
|
|
|
cHammer.on('tap', function(e) {
|
|
|
var $this = $(e.target),
|
|
|
opt = 'ok',
|
|
|
$btn,
|
|
|
$info,
|
|
|
yhChannel;
|
|
|
|
|
|
// e.preventDefault();
|
|
|
|
|
|
// 点赞
|
|
|
$btn = $this.closest('.like-btn');
|
|
|
if ($btn.length > 0 && !isLoading) {
|
|
|
e.preventDefault();
|
|
|
if ($btn.hasClass('like')) {
|
|
|
opt = 'cancel';
|
|
|
}
|
|
|
|
|
|
$info = $this.closest('.guang-info');
|
|
|
|
|
|
isLoading = true;
|
|
|
|
|
|
$.ajax({
|
|
|
type: 'POST',
|
|
|
url: '/guang/opt/praiseArticle',
|
|
|
data: {
|
|
|
id: $info.data('id'),
|
|
|
opt: opt
|
|
|
},
|
|
|
success: function(data) {
|
|
|
var code = data.code;
|
|
|
|
|
|
|
|
|
if (code === 200) {
|
|
|
$btn.next('.like-count').text(data.data);
|
|
|
|
|
|
// 切换点赞状态
|
|
|
$btn.toggleClass('like');
|
|
|
}
|
|
|
},
|
|
|
error: function() {
|
|
|
tip.show('网络断开连接了~');
|
|
|
},
|
|
|
complete: function() {
|
|
|
isLoading = false;
|
|
|
}
|
|
|
});
|
|
|
return;
|
|
|
$container.find('.like-btn').on('touchend touchcancel', function(e) {
|
|
|
var opt = 'ok', $btn = $(this), $info, isLoading;
|
|
|
e.preventDefault();
|
|
|
if ($btn.hasClass('like')) {
|
|
|
opt = 'cancel';
|
|
|
}
|
|
|
|
|
|
// APP收藏
|
|
|
$btn = $this.closest('.collect-btn');
|
|
|
if ($btn.length > 0) {
|
|
|
e.preventDefault();
|
|
|
if ($btn.hasClass('collected')) {
|
|
|
opt = 'cancel';
|
|
|
$info = $btn.closest('.guang-info');
|
|
|
isLoading = true;
|
|
|
$.ajax({
|
|
|
type: 'POST',
|
|
|
url: '/guang/opt/praiseArticle',
|
|
|
data: {
|
|
|
id: $info.data('id'),
|
|
|
opt: opt
|
|
|
},
|
|
|
success: function(data) {
|
|
|
var code = data.code;
|
|
|
|
|
|
if (code === 200) {
|
|
|
$btn.next('.like-count').text(data.data);
|
|
|
// 切换点赞状态
|
|
|
$btn.toggleClass('like');
|
|
|
}
|
|
|
},
|
|
|
error: function() {
|
|
|
tip.show('网络断开连接了~');
|
|
|
},
|
|
|
complete: function() {
|
|
|
isLoading = false;
|
|
|
}
|
|
|
});
|
|
|
return;
|
|
|
});
|
|
|
|
|
|
$info = $this.closest('.guang-info');
|
|
|
|
|
|
if (getUrlParam('yh_channel')) {
|
|
|
yhChannel = getUrlParam('yh_channel');
|
|
|
}
|
|
|
$container.find('.collect-btn').on('touchend touchcancel', function(e) {
|
|
|
var opt = 'ok', $btn = $(this), $info, isLoading, yhChannel;
|
|
|
e.preventDefault();
|
|
|
if ($btn.hasClass('collected')) {
|
|
|
opt = 'cancel';
|
|
|
}
|
|
|
$info = $btn.closest('.guang-info');
|
|
|
isLoading = true;
|
|
|
if (getUrlParam('yh_channel')) {
|
|
|
yhChannel = getUrlParam('yh_channel');
|
|
|
}
|
|
|
|
|
|
$.ajax({
|
|
|
type: 'POST',
|
|
|
url: '/guang/opt/collectArticle',
|
|
|
data: {
|
|
|
id: $info.data('id'),
|
|
|
opt: opt,
|
|
|
yh_channel: yhChannel,
|
|
|
uid: getUrlParam('uid')
|
|
|
},
|
|
|
success: function(data) {
|
|
|
if (data.code && data.code === 200) {
|
|
|
|
|
|
// 切换收藏状态
|
|
|
$btn.toggleClass('collected');
|
|
|
}
|
|
|
},
|
|
|
error: function() {
|
|
|
tip.show('网络断开连接了~');
|
|
|
$.ajax({
|
|
|
type: 'POST',
|
|
|
url: '/guang/opt/collectArticle',
|
|
|
data: {
|
|
|
id: $info.data('id'),
|
|
|
opt: opt,
|
|
|
yh_channel: yhChannel,
|
|
|
uid: getUrlParam('uid')
|
|
|
},
|
|
|
success: function(data) {
|
|
|
if (data.code && data.code === 200) {
|
|
|
|
|
|
// 切换收藏状态
|
|
|
$btn.toggleClass('collected');
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
},
|
|
|
error: function() {
|
|
|
tip.show('网络断开连接了~');
|
|
|
}
|
|
|
});
|
|
|
return;
|
|
|
});
|
|
|
|
|
|
setLazyLoadAndMellipsis($container.find('.guang-info'));
|
...
|
...
|
@@ -253,8 +233,6 @@ function loadMore($container, opt, url) { |
|
|
|
|
|
getDynamicData.getDynamicData();
|
|
|
window.rePosFooter();// 插入内容后重新计算底部位置
|
|
|
|
|
|
getDynamicData.getDynamicData();
|
|
|
}
|
|
|
|
|
|
opt.page++;
|
...
|
...
|
|