var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var ObjId = $('#dataInput').attr('data-objid');
var ObjType = $('#dataInput').attr('data-objtype');
var idstr = location.pathname.substring(location.pathname.lastIndexOf('/') + 1, location.pathname.lastIndexOf('.'));
var isPreviewPage = location.pathname.indexOf('/preview/') !== -1;
var creatorId = $("input[name='creator']").val();
var productCates = $('#productCates').text().replace(/\/[^\u4e00-\u9fa5]/g, ',').replace(/\s+/g, '').split(',');
// 统计
var productTitle = $('#dataInput').attr('data-title');
var productContentTags = [];
_($('#productTags a')).forEach(function (item) {
productContentTags.push($(item).text());
});
// 更新推荐状态 | 更新收藏状态 | 更新关注(批量)状态
function recommendAndFavAndFocusStatus() {
ZcRecommend.recommendStatus();
ZcFolder.favStatus();
if (getUid() !== creatorId) {
getFocusStatus(creatorId, 1, $('.follow-box .attention'));
} else {
$('.js-detail-show-card .attention').addClass('hide');
}
}
// 更新状态
function doUpdatePageAllStatus() {
//每个页面自定义
// 侧边栏
updateSidebarText();
recommendAndFavAndFocusStatus();
// 更新评论状态
loginedUpdateCommentsTextarea();
// 三连
updateTripleStatus();
}
function updateSidebarText() {
if (getUid() === '0') {
$('.js-project-fav .sidebar-fixed_warm-prompt').text(messagesWeb.fav_unlogin);
$('.js-sidebar-comments .sidebar-fixed_warm-prompt').text(messagesWeb["details"].unlogin_comment);
$('.js-details-common-recommend .sidebar-fixed_warm-prompt').text(messagesWeb["details"].unlogin_recommend);
} else {
$('.js-project-fav .sidebar-fixed_warm-prompt').text(messagesWeb["details"].to_collections);
$('.js-sidebar-comments .sidebar-fixed_warm-prompt').text(messagesWeb["details"].comment);
$('.js-details-common-recommend .sidebar-fixed_warm-prompt').text(messagesWeb["details"].recommended_work);
$('.sidebar-unlogin').fadeOut();
}
}
updateSidebarText();
// 获取用户信息
function getUserPro(userId, FOLLOW_STATUS) {
var _getUserProSuccessCallback = getUserProSuccessCallback;
$.ajax({
type: "GET",
xhrFields: {
withCredentials: true
},
crossDomain: true,
headers: {
"X-Requested-With": "XMLHttpRequest"
},
url: proMainZDomain + "/member/card/" + userId + ".json",
dataType: "json",
success: function success(data) {
// 成功回掉函数
_getUserProSuccessCallback(data, FOLLOW_STATUS);
}
});
}
function getUserProSuccessCallback(datas, FOLLOW_STATUS) {
datas.contentType = $('input[name=creator]').attr('value');
var authorCardHtml = template('author-cards', datas);
$('.author-card').html(authorCardHtml);
// *********文章详情页左内容区的作者信息渲染:
if ($('#author-info').length > 0) {
var authorCardHtmlSmall = template('author-info', datas);
$('.left-author-card').html(authorCardHtmlSmall);
}
// *********
$('.author-card .js-project-focus-btn,.left-author-card .js-project-focus-btn').append(zcoolFocusLoadingTpl);
var data = datas.data;
var guanZhuStatus = data["guanzhuStatus"];
var userUrl = data["userUrl"];
var memberHonors = data["memberHonors"];
var authorCardId = data["id"];
// 超出三个作者身份icon
if (memberHonors.length > 3) {
$('.card-media .zcool-treetop').css({ 'width': '40px' });
$('.card-media .more-leaveout').css('display', 'inline-block');
$('.card-media .more-leaveout').find('.leaveout-tips').css({
'width': memberHonors.length * 21 + 32 + 'px',
'margin-left': -(memberHonors.length * 21 + 32) / 2 + 'px'
});
}
settingFollow(guanZhuStatus, $(".follow-box .attention"));
}
// 其他作品
function getUserOthPro(ObjType, ObjId) {
var _getUserOthProSuccessCallback = getUserOthProSuccessCallback;
$.ajax({
type: "GET",
xhrFields: {
withCredentials: true
},
crossDomain: true,
headers: {
"X-Requested-With": "XMLHttpRequest"
},
dataType: "json",
url: proMainZDomain + "/content/other.json?objectType=" + ObjType + "&objectId=" + ObjId + "&creator=" + creatorId,
success: function success(data) {
_getUserOthProSuccessCallback(data);
}
});
}
// function getTeamInfo() {
// $('.js-a-team-info').html(LoaddingDom);
// $.ajax({
// type: "GET",
// xhrFields: {
// withCredentials: true
// },
// crossDomain: true,
// headers: {
// "X-Requested-With": "XMLHttpRequest"
// },
// dataType: "json",
// url: proMainZDomain + "/zteamForDetail?id=" + $('.js-a-team-info').attr('data-zteamid'),
// success: function success(data) {
// if (data.code == 0) {
// if (data.result) {
// var html = template('details-team-info-tpl', data);
// $('.js-a-team-info').html(html);
// } else {
// $('.js-a-team-info').html('');
// if (ObjType === '8' && $('.info-list li').length === 0) $('.right-fixed-wrap').remove();
// }
// }
// }
// });
// }
// getTeamInfo();
//lazy load image
function lazyLoadImage(num) {
var num = num || 0;
var deferreds = [];
var i = 0;
var batchNum = 0;
var loadNumPerTime = 3;
var headNumUncontrol = 3;
var initScreenWidth = $(window).width() > 1600 ? 1280 : 1130;
$('.lazy-img-class').each(function (index, ele) {
var $this = this;
// init blur image screen width
if ($($this).data('width') > initScreenWidth) {
$('.reveal-work-wrap').eq(index + headNumUncontrol).find('img').width(initScreenWidth);
} else {
$('.reveal-work-wrap').eq(index + headNumUncontrol).find('img').width($($this).data('width'));
}
batchNum = Math.floor(index / loadNumPerTime);
if (batchNum === num) {
deferreds.push(new $.Deferred());
var img = new Image();
img.src = $($this).data('src');
img.onload = function () {
$($this).attr('src', $($this).data('src'));
};
img.onerror = function () {
$($this).attr('src', $($this).data('src'));
};
}
// When image is loaded, resolve the next deferred
$($this).load(function () {
if (!deferreds[i]) return;
deferreds[i].resolve();
i++;
}).error(function () {
if (!deferreds[i]) return;
deferreds[i].reject();
i++;
});
});
// When all deferreds are done (all images loaded) do some stuff
$.when.apply(null, deferreds).done(function () {
if (num < batchNum) lazyLoadImage(num + 1);
});
}
// 作品详情页 加载内容图片时
lazyLoadImage();
if ($('.no-right-key').length) {
// 禁止F12键盘事件
document.addEventListener('keydown', function(event){
return 123 != event.keyCode || (event.returnValue = false)
});
// 禁止右键、选择、复制
document.addEventListener('contextmenu', function(event){
return event.returnValue = false
})
}
$('.radio label').on('click', function (e) {
radioCheck($(this));
});
if (getUid() === '0') {
$('.unlogin li').addClass('active');
setTimeout(function () {
$('.unlogin li').removeClass('active');
typeof showSidebarUnlogin === 'function' && showSidebarUnlogin();
}, 3000);
}
$('.details-con-other .js-project-fav').hover(function () {
if (getUid() !== '0') {
return false;
}
$(this).before('
' + messagesWeb.fav_unlogin + '
');
$('.details-con-other .air-fff').css({
top: $('.details-con-other .js-project-fav').position().top - 50 - 10,
right: window.innerWidth - $('.details-con-other .js-project-fav').offset().left - $('.details-con-other .js-project-fav').innerWidth()
});
}, function () {
if (getUid() !== '0') {
return false;
}
$('.details-con-other .air-fff').remove();
});
var ZcRecommendDesigners = {
URL: proMainZDomain + '/getMoreRecommendDesigner',
offset: 10,
defaultShowNum: 9,
avatarPlusisLoading: true,
AVATARCONVER: $('#recommendedAvatar'),
createPlusNNode: function createPlusNNode() {
var num = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
ZcRecommendDesigners.AVATARCONVER.find('.js-recommended-avatar').append('+' + num + '
');
},
getRecommendDesigner: function getRecommendDesigner(offset) {
return $.ajaxPromise({
url: ZcRecommendDesigners.URL + '?objectId=' + ObjId + '&objectType=' + ObjType + (offset ? '&offset=' + offset : '')
});
},
initDesigners: function initDesigners() {
ZcRecommendDesigners.getRecommendDesigner().then(function (res) {
var total = res.data.total;
var allContent = res.data.content;
if (!$('#detail-recommend-div').hasClass('active')) {
allContent.forEach(function (item) {
if (item.id == getUid()) {
total = total - 1;
}
});
allContent = allContent.filter(function (i) {
return i.id != getUid();
});
}
if (total > 0) {
ZcRecommendDesigners.AVATARCONVER.removeClass('hide').find('.js-recommended-total').html(total).find('.js-recommended-avatar').attr('data-total', total);
var avatarTpl = template('avatar-40-templ', { content: allContent });
ZcRecommendDesigners.AVATARCONVER.find('.js-recommended-avatar').append(avatarTpl);
if (total > ZcRecommendDesigners.defaultShowNum) {
$('.js-recommended-avatar .avatar-container-40:eq(8)').nextAll('.avatar-container-40').hide();
ZcRecommendDesigners.createPlusNNode(total - ZcRecommendDesigners.defaultShowNum);
}
}
});
},
addOrDeleteCurrentUserAvatar: function addOrDeleteCurrentUserAvatar(isRecommendStatus) {
if (getUserInformationFromCookie() && getUserInformationFromCookie().isRecommender) {
var avatarTpl = template('avatar-40-templ', { content: [{
id: getUid(),
avatar1x: getUAvatar(),
pageUrl: getUPageurl(),
username: getUsername(),
memberType: getUserInformationFromCookie().memberType
}] });
var Total = $('.js-recommended-total').text() || 0;
var isTuckedUp = !$('.js-recommended-avatar').hasClass('recommended-designer_up');
if (!$('#recommendedAvatar').is(":visible")) $('#recommendedAvatar').removeClass('hide');
if (isRecommendStatus) {
if (!$('.js-recommended-avatar .avatar-container-40[data-id="' + getUid() + '"]').length) {
$('.js-recommended-avatar').prepend(avatarTpl);
}
if (isTuckedUp) {
// 收起状态
$('.js-recommended-avatar .avatar-container-40:eq(8)').nextAll('.avatar-container-40').hide();
}
Total = parseInt(Total) + 1;
} else {
Total = parseInt(Total) - $('.js-recommended-avatar > div[data-id=' + getUid() + ']').length;
$('.js-recommended-avatar > div[data-id=' + getUid() + ']').remove();
$('.js-recommended-avatar .avatar-container-40:eq(8)').show();
}
Total === 0 && $('#recommendedAvatar').addClass('hide');
$('.js-recommended-total').text(Total);
if (Total > 9) {
!$('.js-plus-n').length ? ZcRecommendDesigners.createPlusNNode() : $('.js-plus-n').removeClass('hide');
}
if (isTuckedUp) {
$('.js-plus-n').text('+' + (parseInt(Total) - $('.js-recommended-avatar .avatar-container-40:visible').length));
}
}
},
doPlusNListen: function doPlusNListen() {
ZcRecommendDesigners.AVATARCONVER.on('click', '.js-plus-n', function () {
var _this = $(this);
var recommendAvatarTotal = parseInt($('.js-recommended-total').text());
var hideAvatar = $('.js-recommended-avatar .avatar-container-40:eq(8)').nextAll('.avatar-container-40');
if (_this.attr('swichflag')) {
if (_this.attr('swichflag') === "0") {
_this.attr('swichflag', 1).text(messagesWeb["lifeCircle"].packUp);
hideAvatar.removeAttr('style');
$('.js-recommended-avatar').addClass('recommended-designer_up');
} else {
hideAvatar.hide();
_this.attr('swichflag', 0).text('+' + (recommendAvatarTotal - ZcRecommendDesigners.defaultShowNum));
$('.js-recommended-avatar').removeClass('recommended-designer_up');
}
} else {
if (!ZcRecommendDesigners.avatarPlusisLoading) return false;
ZcRecommendDesigners.avatarPlusisLoading = false;
ZcRecommendDesigners.getRecommendDesigner(ZcRecommendDesigners.offset).then(function (res) {
var data = res.data;
var avatarTpl = template('avatar-40-templ', data);
hideAvatar.removeAttr('style');
_this.before(avatarTpl);
ZcRecommendDesigners.offset = ZcRecommendDesigners.offset + data.content.length;
if ($('.js-recommended-avatar .avatar-container-40').length >= recommendAvatarTotal) {
_this.attr('swichflag', 1).text(messagesWeb["lifeCircle"].packUp);
} else {
_this.text('+' + (recommendAvatarTotal - $('.js-recommended-avatar .avatar-container-40:visible').length));
}
$('.js-recommended-avatar').addClass('recommended-designer_up');
ZcRecommendDesigners.avatarPlusisLoading = true;
});
}
});
}
};
$(function () {
$('.copy-con .copy-icon').hover(function () {
$(this).find("i").show().css({
'margin-left': -$(this).find("i").width() / 2 - 18 + 'px'
});
if ($(this).find("i").width() / 2 > $(this).position().left) {
$(this).find("i").show().css({
'margin-left': -$(this).find("i").width() / 2 - 18 + ($(this).find("i").width() / 2 - $(this).position().left) + 18 + 'px'
});
}
}, function () {
$(this).find("i").hide();
});
// 用户其他作品
getUserOthPro(ObjType, ObjId);
setTimeout(function () {
// 推荐状态返回成功后
ZcRecommendDesigners.initDesigners();
}, 1000);
ZcRecommendDesigners.doPlusNListen();
});
zcustomScrollbarFadeout($(".js-scroll-wrap"));
var GogoupAd = {
detailSearch: function detailSearch() {
var cateId = ObjType === '3' ? $('#dataInput').attr('data-cateid') : $('#dataInput').attr('data-catestr').split(',')[0];
$.ajax({
type: "get",
dataType: "jsonp",
jsonp: "jsonpcallback",
url: gogoupApi + "/p1/data/search?cateId=" + cateId + "&teacherId=" + creatorId + "&pageNo=1&pageSize=4",
success: function success(data) {
if (data.resultCode === 'SUCCESS' && data.total > 0) {
var dataList = data.datas;
var gogoupRecommendAd = template('details-gogoupad-templ', { data: dataList });
$('#detailsGogoupAd').append(gogoupRecommendAd).slideDown();
}
}
});
}
};
ZunloginedUpdateStatusCbs.push(function () {
$('.js-details-common-recommend').removeClass('active').addClass('normal');
$('#demoCanvas').remove();
$(".follow-box .attention").addClass('notfollow').removeClass('following');
$(".follow-box .attention").removeClass('btn-default-secondary').addClass('btn-default-main');
$(".follow-box .attention").val(messagesWeb.common_follow).attr('title', messagesWeb.common_follow_title);
$('.js-project-fav').attr('title', messagesWeb.fav_btn).val(messagesWeb.fav_btn);
});
$('body').on('click', '.js-edit-entry', function () {
var objtype = $('#dataInput').attr('data-objtype');
var objid = $('#dataInput').attr('data-objid');
var editUrl = proMyZDomain + (objtype === '3' ? '/editProduct?id=' : '/editArticle?id=') + objid;
zIsExistPhone.toggleToginShowMsgLayer(function () {
window.location.href = editUrl;
});
});
if (!isPreviewPage) {
// 获取微信小程序码 share.js中定义
ZWxShare.zwxShareGetminiqrcode(ObjId, ObjType);
typeof ZcFolder !== 'undefined' && ZcFolder.favStatus();
};
var randomTips = [{
tag: '1',
title: "每天都有超多优秀设计等你来看,
登录再浏览吧~"
}, {
tag: '2',
title: "小Z一直在等你,火速登录,
加入我们~"
}, {
tag: '3',
title: "工作使我快乐,
不如逛站酷快乐!"
}, {
tag: '4',
title: "小Z喊话:
你是不是忘了什么事,
比如登录…"
}, {
tag: '5',
title: "看在小Z强行营业的份上,
登录一下吧!"
}, {
tag: '6',
title: "小Z喊话:
加入站酷,我们一起肩并肩!"
}, {
tag: '7',
title: "我的小可爱在吗?
小Z请你来登录了~"
}, {
tag: '8',
title: "海量优质设计等待热爱学习的你,
去登录学习~"
}, {
tag: '9',
title: "等你好久了,快速登录,
一起来搞事情!"
}];
var randomNum = Math.floor(Math.random() * randomTips.length);
var loginTipsHtml = '\n
\n
' + randomTips[randomNum].title + '
\n
';
(function () {
if (getUid() === '0') {
var winAutoShowCount = parseInt(getCookieKey('r_drefresh_count')) || 0;
winAutoShowCount++;
document.cookie = "r_drefresh_count=" + escape(winAutoShowCount) + ";expires=1;path=/;domain=" + zRootDomain;
if (winAutoShowCount >= 4) {
var cb0 = function cb0() {
doUpdatePageAllStatus();
$.ajaxPromise({ url: proMainZDomain + '/showLoginWindow?picturetype=' + randomTips[randomNum].tag });
};
var cbs = [cb0];
openLoginWindow(cbs);
$('.login-close').css({ top: '72px' });
$('#popLogin').css({
background: 'url(' + proStaticZDomain + '/z/images/svg/login_bg.svg) no-repeat',
height: '613px',
padding: '203px 24px 0',
marginTop: '-371px'
}).append(loginTipsHtml);
}
}
})();
// 私信
function prepareSendMessageDetails(memberId, memberName) {
function openPMWindow() {
var privatePop = new PrivatePOP({ memberId: memberId, memberName: memberName });
privatePop.openPrivateWindow();
};
//var openPWindow = CreatePrivateMessageObj(memberId,memberName);
if (islogin() == true) {
openPMWindow();
} else {
var cb0 = openPMWindow;
var cb1 = doUpdatePageAllStatus;
var cbs = [cb0, cb1];
openLoginWindow(cbs);
}
}
(function () {
var praiseContentId = 0;
function getRandomPraise() {
$.get(zProtocol + zMainDomain + '/praiseContent/getRandomPraiseContent', function (res) {
if (res.code === 0) {
praiseContentId = res.data.id;
$('.kuak-text').html(res.data.comment).attr('data-id', praiseContentId);
}
});
}
function getDetailPraiseList(cb) {
$.get(zProtocol + zMainDomain + '/worksPraise/getDetailWorksPraise?objectId=' + ObjId + '&objectType=' + ObjType, function (res) {
var kList = res.data.worksPraiseList,
kAvatars = res.data.memberInfoSimpleDTOList,
memberL = res.data.memberTotal;
if (getUid() === creatorId) {
// 自己详情页 有数据 夸按钮隐藏
if (kList.length) {
$('.kuak-guide').addClass('zc-hide');
} else {
$('#kuak').hide();
return false;
}
}
if (!kList.length) {
// 别人作品 显示空状态夸夸
$('.js-empty-kua').removeClass('zc-hide');
return false;
}
// 只展示10个
if (kAvatars.length > 10) {
kAvatars = kAvatars.slice(0, 9);
}
$('.js-empty-kua').addClass('zc-hide');
$('.kuak-container-wrap').removeClass('zc-hide');
var avatarStr = template('kua-avatar-templ', {
content: kAvatars,
avTotal: memberL
});
// 更新头像显示
$('.kuak-avatar-box').html(avatarStr);
cb(res);
// 箭头显示
if ($('.kuak-list-box').innerHeight() > 94) {
$('.kuak-up').show();
}
// 夸夸列表事件
$('.kua-item').off('click');
doListenKuaItemSubmit();
});
}
function doListenKuaItemSubmit() {
function aniKItemFn(me) {
var _this = me;
getCheckPraise(function () {
var praiseId = _this.attr('data-id');
var countEle = _this.find('.ani-count');
var double = _this.find('strong');
var plusEle = _this.find('.plus');
var kCount = Number(countEle.eq(1).html()) + 1;
var kTextWidth = _this.find('.kua-text').outerWidth() + 14;
var xCountStr = '\n x\n 2\n 2\n \n ';
function aniPlusCircle() {
plusEle.addClass('aniBig');
setTimeout(function () {
plusEle.removeClass('aniBig').addClass('aniScaleOut');
}, 220);
setTimeout(function () {
plusEle.addClass('aniNormal');
}, 300);
}
if (double.length) {
// 原来有+1的
_this.addClass('aniEleNone').removeClass('aniWidth');
_this.find('strong').removeClass('t-down');
plusEle.addClass('aniEleNone');
plusEle[0].style.setProperty('--plusX', 'translateX(0)');
_this[0].style.setProperty('--wPr', '34px');
setTimeout(function () {
plusEle.removeClass('aniEleNone');
countEle.eq(0).addClass('t-out');
countEle.eq(1).html(kCount).addClass('t-in');
aniPlusCircle();
setTimeout(function () {
_this.removeClass('aniEleNone');
_this.find('.counts-box').append(_this.find('.ani-count:first')).find('.ani-count:first').removeClass('t-in');
_this.find('.ani-count:eq(1)').html(kCount).css('display', 'none').removeClass('t-out');
plusEle.removeClass('aniScaleOut aniNormal');
}, 300);
setTimeout(function () {
_this.find('.ani-count:eq(1)').css('display', 'block');
}, 300);
});
} else {
// 第一次叠加
plusEle[0].style.setProperty('--plusX', 'translateX(38px)');
_this[0].style.setProperty('--wPr', '72px');
_this.addClass('aniWidth');
plusEle.before(xCountStr);
setTimeout(function () {
_this.find('strong').addClass('t-normal');
aniPlusCircle();
_this.addClass('btn-default-main').removeClass('btn-default-secondary');
});
setTimeout(function () {
plusEle.removeClass('aniScaleOut aniNormal');
}, 500);
}
updateSubmitPraise(praiseId, function () {}, true);
});
}
$('.kua-item').on('click', function () {
var _this = $(this);
if (getUid() > 0) {
aniKItemFn(_this);
} else {
var cbs = [function () {
aniKItemFn(_this);
}, doUpdatePageAllStatus];
openLoginWindow(cbs);
}
sensorsPageEvents('contentPraise', {
is_first: false,
source_page: location.href,
praise_entrance: getCurrentPageText(),
'is_content_Praise_add': '是'
});
});
}
function getCheckPraise(cb) {
$.ajax({
url: zProtocol + zMainDomain + '/worksPraise/checkMemberWorksPraise?objectId=' + ObjId + '&objectType=' + ObjType,
xhrFields: {
withCredentials: true
},
success: function success(res) {
if (res.data) {
cb();
} else {
new Popup('', '每个内容最多夸三次哦~
这么喜欢TA,去评论一下吧!', '', '', '去评论', '', null, function () {
$('html,body').animate({ scrollTop: $('#detail-add-comment').offset().top - 200 }, 'normal', function () {
$('#comment-add-textarea').focus();
});
}).showDom();
}
}
});
}
function showKuaModal() {
getCheckPraise(function () {
getRandomPraise();
showGlobalMaskLayer();
$('.kuak-modal').show();
});
}
// 初始化夸夸数据
getDetailPraiseList(function (res) {
var kList = res.data.worksPraiseList;
var list = template('kuakua-list-tpl', {
data: kList
});
$('.kuak-list-box .kua-item').remove();
$('.kuak-list-box').prepend(list);
});
$('.kuak-guide').on('click', function () {
if (getUid() > 0) {
showKuaModal();
} else {
var cbs = [showKuaModal, doUpdatePageAllStatus];
openLoginWindow(cbs);
}
var kuaIsEmpty = $(this).hasClass('js-empty-kua');
sensorsPageEvents('contentPraise', {
is_first: kuaIsEmpty,
source_page: location.href,
praise_entrance: getCurrentPageText(),
'is_content_Praise_add': '否'
});
});
$('#kuak').on('mouseenter', '.kua-item', function () {
$(this).addClass('kua-item-hover');
var itemEle = $(this).parents('.kua-item-box');
// $('.kuak-list-box').css('margin-right', '-52px')
var kItemR = $('.kuak-list-con').innerWidth() - itemEle[0].offsetLeft - itemEle.outerWidth() - 34;
if (kItemR < 52) {
itemEle.css('margin-right', '-52px');
}
});
$('#kuak').on('mouseleave', '.kua-item', function () {
var _this = $(this);
if ($(this).hasClass('kua-item-hover')) {
setTimeout(function () {
_this.parents('.kua-item-box').removeAttr('style');
}, 100);
$(this).removeClass('kua-item-hover');
}
// setTimeout(function() {
// $('.kuak-list-box').css('margin-right', '0px')
// $(this).removeClass('kua-item-hover')
// }, 100)
});
function updateSubmitPraise(praiseContentId, cb, contentPraisePlus) {
$.ajax({
type: "POST",
url: proMainZDomain + "/worksPraise/doWorksPraise",
data: {
objectId: ObjId,
objectType: ObjType,
praiseContentId: praiseContentId,
contentPraisePlus: contentPraisePlus ? '是' : '否'
},
xhrFields: {
withCredentials: true
},
crossDomain: true,
headers: {
"X-Requested-With": "XMLHttpRequest"
},
dataType: "json",
success: function success(data) {
data.code === 0 ? cb(data) : pageToastFail(data.msg);
}
});
}
// 弹窗提交
$('.kuak-submit').on('click', function () {
updateSubmitPraise(praiseContentId, function () {
getDetailPraiseList(function () {});
var list = template('kuakua-list-tpl', {
data: [{
count: 0,
praiseContentId: praiseContentId,
praiseContent: $('.kuak-modal .kuak-text').text().trim()
}]
});
$('.kuak-list-box').prepend(list);
$('.kuak-modal').hide();
hideGlobalMaskLayer();
});
sensorsPageEvents('praiseTaCopyModalButton', {
source_page: location.href,
praise_entrance: getCurrentPageText()
});
});
$('.switch-btn').on('click', function () {
getRandomPraise();
sensorsPageEvents('changeLog', {
from_module: '夸夸弹窗',
source_page: window.location.href,
change_entrance: getCurrentPageText(),
praise_content_id: $('.kuak-text').attr('data-id'),
praise_content: $('.kuak-text').text()
});
});
$('.kuak-up').on('click', function () {
$(this).toggleClass('kuak-down');
$('.kuak-list-con').toggleClass('max');
if ($(this).hasClass('kuak-down')) {
sensorsPageEvents('unfoldButton', {
source_page: window.location.href,
button_position: '点击展开夸夸'
});
} else {
sensorsPageEvents('foldButton', {
source_page: window.location.href,
button_position: '点击收起夸夸'
});
}
});
})();
/*****夸夸 end */
function getRecommentTips() {
var RECOMMEND_TANKING = ['biu ~ 发射爱心', '有你的推荐,我又有动力继续更新了!', '有朝一日上榜单,定有你的一份功劳', '谢谢你的推荐!', '喜欢这个作品呀,多多关注我呦', '评论区可以多多交流呀', '你爱我,我爱你,作品多多甜蜜蜜'];
return RECOMMEND_TANKING[Math.floor(Math.random() * RECOMMEND_TANKING.length)];
}
function aniRecommendCool(thisDom) {
var aR = window.innerWidth - $('.work-details-box-wrap').offset().left - $('.work-details-box-wrap').innerWidth();
var creatorAvatar = $('#dataInput').attr('data-avatar');
$('body').append('' + getRecommentTips() + '
');
setTimeout(function () {
if (thisDom.attr('id') === 'detail-recommend-bigImage') {
$('.rec-tips').addClass('rec-tips-slideDown2');
} else {
$('.rec-tips').addClass('rec-tips-slideDown');
}
}, 100);
thisDom.find('.ani-cool').addClass('animate__zoomInUp').find('span:eq(1)').addClass('animate__zoomInUp_shatter');
thisDom.find('.ani-cool').find('span:first').addClass('animate__zoomInUp_shatter1');
setTimeout(function () {
$('.rec-tips').fadeOut(300);
}, 3000);
setTimeout(function () {
thisDom.find('.ani-cool').removeClass('animate__zoomInUp').find('span:eq(1)').removeClass('animate__zoomInUp_shatter');
thisDom.find('.ani-cool').find('span:first').removeClass('animate__zoomInUp_shatter1');
}, 1500);
}
function getTripleApi(cb) {
$.get(zProtocol + zMainDomain + '/oneKeyThreeLink/getOneKeyThreeLinkStatus?objectType=' + ObjType + '&objectId=' + ObjId + '&focusType=1' + '&focusMemberId=' + creatorId, function (res) {
cb(res);
});
}
function updateTripleStatus() {
getTripleApi(function (res) {
if (res.code !== 0) {
// 没三连显示小z
$('.z-triple-wrap').removeClass('zc-hide');
}
});
}
if (getUid() !== creatorId) {
updateTripleStatus();
}
function handleTriple(obj) {
if (!zupTripleFlag) return false;
zupTripleFlag = false;
getTripleApi(function (res) {
if (res.code === 0) {
pageToastFail("已完成Z-UP");
} else {
obj.parents('.z-triple').addClass('is-click');
$('.up1,.up2,.up3').addClass('ani-bouldles');
$('.t-up').addClass('ani-translate-top');
// 点赞、关注、收藏+1
setTimeout(function () {
$('.up1,.up2,.up3').removeClass('ani-bouldles').addClass('fadeOut');
$('.t-up').addClass('fadeOut');
}, 1000);
// 半圆小z动效
setTimeout(function () {
$('.js-z-triple').addClass('active');
}, 1400);
// 心,半圆
setTimeout(function () {
setTimeout(function () {
$('.hi-semicircle').addClass('hi-hand');
}, 100);
$('.Heart').addClass('heart-show');
$('.circle').addClass('up-scalce');
}, 1700);
// 半圆消失
setTimeout(function () {
$('.hi-circle').addClass('small');
}, 2800);
$.ajax({
type: "POST",
url: proMainZDomain + "/oneKeyThreeLink/doOneKeyThreeLink",
data: {
objectType: ObjType,
objectId: ObjId,
focusType: 1,
focusMemberId: creatorId
},
xhrFields: {
withCredentials: true
},
crossDomain: true,
headers: {
"X-Requested-With": "XMLHttpRequest"
},
dataType: "json",
success: function success(res) {
if (res.code === 0) {
recommendAndFavAndFocusStatus();
if (!$('#detail-recommend-div').hasClass('active')) {
$('.recommend-number').html(parseInt($('.recommend-number').html()) + 1);
}
ZcRecommendDesigners.addOrDeleteCurrentUserAvatar(true);
} else {
pageToastFail(res.msg);
}
zupTripleFlag = true;
}
});
}
});
}
var zUpAniBubbleTimer = null;
var zUpFlag = true;
function zUpTipAni() {
var userId = getUid();
var zUpViewCount = Number(getCookieKey('z_up_bubble_count_' + userId));
if (getCookieKey('z_up_bubble_' + userId) || zUpViewCount >= 5) {
// $('.z-triple-wrap .z-up').addClass('zc-hide')
// $('.z-bubble-circle').hide()
return;
}
$('.js-z-triple .z-bubble-circle').addClass('bubble-show');
$('.js-z-triple .z-bubble2').addClass('ani-b2');
$('.js-z-triple .z-bubble3').addClass('ani-b3');
$('.z-triple-wrap .z-up').addClass('ani-tip');
setTimeout(function () {
$('.js-z-triple .z-bubble-circle').removeClass('bubble-show');
$('.js-z-triple .z-bubble2').removeClass('ani-b2');
$('.js-z-triple .z-bubble3').removeClass('ani-b3');
$('.z-triple-wrap .z-up').removeClass('ani-tip');
}, 5000);
};
if (!isPreviewPage) {
(function () {
var userId = getUid();
var zUpViewCount = Number(getCookieKey('z_up_bubble_count_' + userId) || 0) + 1;
if (getCookieKey('z_up_bubble_' + userId) || zUpViewCount > 5) {
// $('.z-triple-wrap .z-up').addClass('zc-hide')
$('.z-bubble-circle').hide();
return;
}
setCookies_withDomain('z_up_bubble_count_' + userId, zUpViewCount);
zUpAniBubbleTimer = setTimeout(function () {
if ($('.js-z-triple').length && $(document).scrollTop() + document.body.clientHeight > $('.js-z-triple').offset().top + 50) {
zUpTipAni();
zUpFlag = false;
}
}, 500);
})();
}
$('.z-triple').on('mouseover', function () {
zUpAniBubbleTimer && clearTimeout(zUpAniBubbleTimer);
$('.js-z-triple .z-bubble-circle').removeClass('bubble-show');
$('.js-z-triple .z-bubble2').removeClass('ani-b2');
$('.js-z-triple .z-bubble3').removeClass('ani-b3');
$('.z-triple-wrap .z-up').removeClass('ani-tip');
setCookies_withDomain('z_up_bubble_' + getUid(), 1);
});
// 三连
var zupTripleFlag = true;
$('.js-z-triple').on('click', function () {
var _this = $(this);
if (getUid() === '0') {
var cb = function cb() {
handleTriple(_this);
},
cb2 = function cb2() {
doUpdatePageAllStatus();
};
openLoginWindow([cb, cb2]);
} else {
handleTriple(_this);
}
sensorsPageEvents('zupClick', {
zup_entrance: '内容详情页',
source_page: location.href,
content_id: ObjId,
content_name: productTitle,
content_tag: productContentTags.join(),
author_id: creatorId,
content_level_first: productCates[0],
content_level_second: productCates[1],
content_level_third: productCates[2]
});
});
// 统计
productPublishTime = $('#dataInput').attr('data-publish-time'), productSee = $('.head-data-show .see').text().trim(), productComment = $('.head-data-show .news').text().trim(), productLike = $('.head-data-show .recommend-show').text().trim(), productFire = $('#dataInput').attr('data-recommend'), pageStart = new Date(), sensIsTra = false;
function sensContentView(opts) {
var pageEnd = new Date();
var minutes = pageEnd.getMinutes() - pageStart.getMinutes();
var seconds = pageEnd.getSeconds() - pageStart.getSeconds();
var time = seconds + minutes * 60;
console.log(time + " s");
sensorsPageEvents('contentDetailView', {
content_id: ObjId,
content_name: productTitle,
publish_time: productPublishTime,
author_id: creatorId,
read_num: productSee,
comment_num: productComment,
like_num: productLike,
recommend_level: productFire,
source_page: location.href,
content_level_first: productCates[0],
content_level_second: productCates[1],
content_level_third: productCates[2],
content_read_duration: time,
is_finish: true
});
}
var zUpTimer = null;
$(window).on('scroll', function () {
if ($(document).scrollTop() >= $('#detail-recommend-div').offset().top && !sensIsTra) {
sensContentView();
sensIsTra = true;
}
// 三连
// clearTimeout(zUpTimer)
if (zUpFlag && !isPreviewPage) {
setTimeout(function () {
if ($('.js-z-triple').length && $(document).scrollTop() + document.body.clientHeight > $('.js-z-triple').offset().top + 50) {
zUpTipAni();
zUpFlag = false;
}
}, 500);
}
});
/**
* 侧边栏
*/
$(function () {
// 边栏点赞列表投放到回到顶部区域
$('.js-sidebar-fixed').prepend($('.js-details-sidebar').removeClass('hide'));
function sidebarAniGuide() {
// 侧边栏推荐引导提示
var time = 0;
if ($('#sidebar-recommend').hasClass('normal')) {
$('#sidebar-recommend').find('.sidebar-fixed_warm-prompt').text(messagesWeb["details"].Like_here).addClass('isfirst-show');
setTimeout(function () {
$('#sidebar-recommend').find('.sidebar-fixed_warm-prompt').addClass('warm-ani-fadeIn');
$('.pulse, .pulse1').addClass('play');
time = time + 1;
});
}
$('.pulse1').on('animationend', function () {
// 扩散动效执行3次后隐藏提示
if (time >= 3) {
$('#sidebar-recommend').find('.sidebar-fixed_warm-prompt').removeClass('warm-ani-fadeIn');
// 渐隐后更新文案
setTimeout(function () {
updateSidebarText();
$('#sidebar-recommend').find('.sidebar-fixed_warm-prompt').removeClass('isfirst-show');
}, 500);
return false;
}
$('.pulse, .pulse1').removeClass('play');
setTimeout(function () {
$('.pulse, .pulse1').addClass('play');
time = time + 1;
}, 1000);
});
}
setTimeout(function () {
sidebarAniGuide();
}, 10000);
/**
* 边栏未登录显示登录提示按钮
*/
function showSidebarUnlogin() {
if (!$('.sidebar-unlogin').length) $('.js-sidebar-fixed').prepend('');
$('.sidebar-unlogin').fadeIn();
}
inputKeyDownBtnUseable($('#fixedTextarea'), $('.fixed-comment-bar button'), 1);
/**
* 点击侧边评论展示评论浮窗
*/
$('.fixed-comment-bar .js-comment-close').on('click', function () {
$('.fixed-comment-bar').removeClass('z-fadeIn');
});
function getCommentFn(cIconDom) {
if (cIconDom.hasClass('comment-focus')) {
$('html,body').animate({ scrollTop: $('#detail-add-comment').offset().top - 200 }, 'normal', function () {
$('#comment-add-textarea').focus();
});
} else {
$('.fixed-comment-bar').toggleClass('z-fadeIn');
}
}
$('.js-sidebar-comments').on('click', function () {
var _this = $(this);
if (getUid() > 0) {
getCommentFn(_this);
return false;
}
openLoginWindow([function () {
doUpdatePageAllStatus();
getCommentFn(_this);
}]);
});
/** ********* */
window.onscroll = function () {
if ($('.js-sidebar-fixed').offset().top > $('.comment-module').offset().top - $('.js-sidebar-fixed').height()) {
$('.js-sidebar-comments').addClass('comment-focus');
$('.fixed-comment-bar').addClass('z-fadeOut').removeClass('z-fadeIn');
// $('.js-details-sidebar').fadeOut('fast')
} else {
$('.js-sidebar-comments').removeClass('comment-focus');
// $('.js-details-sidebar').fadeIn('fast')
}
if (getUid() !== '0') return false;
if ($(document).scrollTop() > 330) {
showSidebarUnlogin();
} else {
if ($('.unlogin .menu-list:visible').length) $('.sidebar-unlogin').fadeOut();
}
};
});
// 侧边栏登录后更新页面状态
function clickSidebarUnloginBtn() {
openLoginWindow([function () {
doUpdatePageAllStatus();
}]);
}
function getContentPageStatisProps() {
return {
content_id: ObjId,
content_name: productTitle,
publish_time: productPublishTime,
author_id: creatorId,
read_num: productSee,
comment_num: productComment,
like_num: productLike,
recommend_level: String(productFire),
content_level_first: productCates[0],
content_level_second: productCates[1],
content_level_third: productCates[2],
referrer: document.referrer
};
}
if (!isPreviewPage) {
sensors.track('contentPageView', getContentPageStatisProps());
var tpStart = new Date().getTime();
window.addEventListener('load', function () {
tpStart = new Date().getTime();
});
window.addEventListener('beforeunload', function () {
var tp = new Date().getTime() - tpStart;
var tpStr = String(tp / 1000);
sensors.track('contentPageBrowseDuration', _extends({}, getContentPageStatisProps(), {
browse_duration: tpStr
}));
});
$('.sidebar-share').on('click', function () {
ZWxShare.layerShow();
sensorsPageEvents('shareClick', {
content_id: $('#dataInput').attr('data-objid'),
content_name: productTitle,
publish_time: $('#dataInput').attr('data-publish-time'),
author_id: $('#dataInput').attr('data-author-id'),
content_tag: productContentTags.join(),
from_module: '侧边功能栏'
});
});
}
// $('.t-up').on('webkitAnimationEnd', function() {
// setTimeout(function() {
// $('.up1,.up2,.up3').removeClass('ani-bouldles fadeOut')
// $('.t-up').removeClass('ani-translate-top fadeOut')
// }, 1000)
// })
// function detailsWShowA() {
// if (getUid() === '0' && !getCookieKey('isw_showed')) {
// ZAjax('get', proMainZDomain + '/showLoginWindow')
// doLoginWindow(function() {
// doUpdatePageAllStatus()
// })
// $("#popLogin .login-close").hide()
// document.cookie = "isw_showed=" + escape(1) + ";expires=1;path=/;domain=" + zRootDomain;
// }
// }
// function mainAddRecommendDesigner(isRecommendStatus) {
// if (getUserInformationFromCookie() && getUserInformationFromCookie().isRecommender) {
// var avatarTpl = template('avatar-40-templ', { content: [{
// id: getUid(),
// avatar1x: getUAvatar(),
// pageUrl: getUPageurl(),
// username: getUsername(),
// memberType: getUserInformationFromCookie().memberType
// }] });
// var Total = $('.js-recommended-total').text() || 0;
// var isTuckedUp = !$('.js-recommended-avatar').hasClass('recommended-designer_up')
// if (!$('#recommendedAvatar').is(":visible")) $('#recommendedAvatar').removeClass('hide');
// if (isRecommendStatus) {
// $('.js-recommended-avatar').prepend(avatarTpl);
// if (isTuckedUp) {
// // 收起状态
// $('.js-recommended-avatar .avatar-container-40:eq(8)').nextAll('.avatar-container-40').hide();
// }
// Total = parseInt(Total) + 1
// $('.js-recommended-total').text(Total);
// } else {
// $('.js-recommended-avatar > div[data-id=' + getUid() + ']').remove();
// $('.js-recommended-avatar .avatar-container-40:eq(8)').show();
// Total = parseInt(Total) - 1;
// $('.js-recommended-total').text(Total);
// Total === 0 && $('#recommendedAvatar').addClass('hide');
// }
// if ($('.js-recommended-avatar .avatar-container-40').length > 9) {
// $('.js-plus-n').removeClass('hide');
// }
// if (isTuckedUp) {
// $('.js-plus-n').text('+' + (parseInt(Total) - $('.js-recommended-avatar .avatar-container-40:visible').length));
// }
// }
// }
// (function($){
// $.zPackUpToggle = function(options) {
// }
// })(jQuery)
// $.ajax({
// type: "get",
// url: serverApi + "/wxshare/getQrcode?id=" + ObjId + "&objectType=" + ObjType,
// dataType: "json",
// contentType: 'application/json',
// success: function(data) {
// $('#app-code').append('')
// }
// })
// $('#share').on('click', function () {
// showGlobalMaskLayer();
// $('#pop-share').removeClass('hide');
// })
// $('#pop-share .pop-close').on('click', function () {
// $(this).parents('#pop-share').addClass('hide');
// hideGlobalMaskLayer();
// })