initGt:{
senseID:'94a6160514322a8c886c27dfae54770b',// 深知ID,如果使用深知模式必传,ID请找server确认,不同端不同页面都有可能不一致
handler:function(sense){
sense.setInfos(function () {
//设置可上传数据。请务必按照字段规范填写,否则会在服务验证时出错,导致程序无法运行或者后续数据分析出现混乱,参数需求参考api文档。
return {
interactive: 6
}
}).onSuccess(function (data) {
console.log(data)
postSubmit(data)
}).onClose(function(){
console.log('close')
$('#submit_reply').attr("disabled",false);
$('#submit_reply').val('提交回复');
}).onError(function(err){
console.log(err);
$('#submit_reply').attr("disabled",false);
$('#submit_reply').val('提交回复');
})
window.senseFn = sense
}
}
}
window.geetestSy = new window.GeetestSy(senseOptions)
$('#submit_reply').click(function(){
// editor.sync();
var len = 0
if (editorNew.$txt.find('img').length) {
editorNew.$txt.find('img').each(function () {
var value = $(this).attr('src');
if (value.indexOf('static.soyoung.com/images/newface') === -1 && value.indexOf('static.soyoung.com/pc/static/fe_pc/libs/editor/plugins/emoticons/images') === -1) {
len++
}
});
}
if(len > 9) {
alert('最多上传9张素材图片');
return false
}
var content = $.trim($("#reply_content").val());
var check_image_new = true;
if(content != ''){
$.ajax({
type:"post",
url:'/post/checkword',
data:{"content":content},
async: false,
dataType:"json",
success:function(obj){
if(obj.status=='2'){
alert(obj.msg)
$('#submit_pub').attr("disabled",false);
$('#submit_pub').val('发布');
check_image_new = false;
}/*else if(obj.status=='3'){
alert(obj.msg)
}*/
}
});
if(check_image_new == false){
return false;
}
}
checkForm();
})
function showCommentDiv(type, id, name, to_uid) {
notify_comment_id = to_uid;
$(".relative").hide();
$("."+type+"_commment_"+id).show();
$("#"+type+"_commment_"+id).focus();
// 回复漏乘
allCreateEditor(type+"_commment_"+id, "e"+id, name)
return
KindEditor.remove('.reply_commment_textarea, .post_commment_textarea');
KindEditor.create('#'+type+'_commment_'+id, {
readonlyMode : true,
width : '595px',
height : '50px',
minWidth : '200px',
minHeight : '10px',
allowFileManager : false,
allowFlashUpload : false,
allowMediaUpload : false,
pasteType : 1,
allowImageUpload : false,
items : ['emoticons'],
afterCreate : function(){
if(undefined != name && '' != name){
var comment_msg = '回复 ' + name + ':';
KindEditor.instances[1].html('').insertHtml(comment_msg);
}
KindEditor.instances[1].focus();
var self=this;
KindEditor.ctrl(self.edit.doc, 13, function(){
self.sync();
addComment(id, 'reply', 'N', notify_comment_id);
});
},
afterFocus : function(){
loginPop('http://www.soyoung.com/p25609029/');
}
});
}
window.allEditor = {}
window.allCreateEditor = function (id, editorExa, name) {
if (window.allEditor[editorExa]) {
window.allEditor[editorExa].destroy()
window.allEditor[editorExa].$txt.html('')
}
window.allEditor[editorExa] = new window.wangEditor(id)
window.allEditor[editorExa].config.menus = ['emotion', '|', 'img']
window.allEditor[editorExa].config.uploadImg = {
uploadUrl: '/editor/picture',
uploadParams: {
type: 1,
sys: 0
},
// compelWaterMark: 0,
compelWaterMark: 2,
imgLibraryUrl: '/editor/material',
// 待插入图片个数
awaitImgCount: 9,
// 替换水印接口url
replaceUrl: '/editor/replace'
}
window.allEditor[editorExa].config.uploadVideo = {
// 强制上传视频添加水印 0 不强制 1 强制添加 2 强制不添加
compelWaterMark: 0,
uploadType: 'POST',
// 上传时的参数
uploadParams: {
type: 1,
sys: 0
},
uploadDomain: 'https://videosy.soyoung.com/',
// 组装视频的拼接参数
assbParams: 'avinfo',
tokenUrl: '/editor/token',
getVideoUrl: '/editor/video',
videoLibrary: true,
// 视频素材库请求url (需配置imgLibrary 为true)
videoLibraryUrl: '/editor/material'
}
window.allEditor[editorExa].config.uploadWord = {
uploadType: 'POST',
// 上传word的url
uploadUrl: '/editor/word',
// 上传时的参数
uploadParams: {
type: 1,
sys: 0
}
}
// sys = 1 admin域名
// sys = 0 www域名
// sysType = 1 帖子
// sysType = 2 日记
// window.allEditor[editorExa].config.sys = 0
// window.allEditor[editorExa].config.sysType = 1
window.allEditor[editorExa].config.parseImg = false
// window.allEditor[editorExa].config.parseFilterRule = {
// // b: [],
// // strong: []
// // h1: [],
// // h2: [],
// // h3: [],
// // h4: [],
// // h5: [],
// // h6: [],
// // ol: [],
// // ul: [],
// // li: [],
// // ins: [],
// // i: [],
// // em: [],
// // b: [],
// // strong: [],
// // strike: [],
// // s: [],
// // del: [],
// // a: ['href', 'target'],
// // font: ['face','size','color','style'],
// // blockquote: [],
// // pre: ['style'],
// // code: ['class', 'codemark'],
// // hr: []
// }
window.allEditor[editorExa].config.editor_type = 'pc'
// 禁止换行
window.allEditor[editorExa].config.forbidEnter = true
// 上传图片
// window.allEditor[editorExa].config.uploadImgUrl = '/upload'
// window.allEditor[editorExa].config.uploadParams = {
// // token1: 'abcde',
// // token2: '12345'
// }
// window.allEditor[editorExa].config.uploadHeaders = {
// // 'Accept' : 'text/x-json'
// }
// 表情显示项
window.allEditor[editorExa].config.emotionsShow = 'icon'
// onchange 事件
// window.allEditor[editorExa].onchange = function () {
// $('#content-hidden').val(editorNew.$txt.html())
// }
// 取消粘贴过来
window.allEditor[editorExa].config.pasteFilter = true
window.allEditor[editorExa].create()
// 禁用
window.allEditor[editorExa].disable()
loginPop('http://www.soyoung.com/p25609029/')
return
// 名称
if(undefined != name && '' != name){
var comment_msg = name;
if (name.indexOf('回复') '+comment_msg+'')
var sel, range;
var editDom = document.querySelector('#'+id).querySelector('p');
if (window.getSelection && document.createRange) {
range = document.createRange();
range.selectNodeContents(editDom);
range.collapse(true);
range.setEnd(editDom, editDom.childNodes.length);
range.setStart(editDom, editDom.childNodes.length);
sel = window.getSelection();
sel.removeAllRanges();
sel.addRange(range);
} else if (document.body.createTextRange) {
range = document.body.createTextRange();
range.moveToElementText(editDom);
range.collapse(true);
range.select();
}
}
}
function addComment(item_id, type, is_beauty, comment_id) {
//alert(notify_comment_id);return false;
//var comment_ano=$("#comment_ano"+item_id).is (":checked")? 1: 0;//获取复选框按钮值
/*if(document.getElementById("comment_ano_"+item_id).checked){
var comment_ano = 1;
}else{
var comment_ano = 0;
}*/
var comment_ano = 0;
//alert(comment_ano);return false;
var post_id = parseInt('25609029');
var _item_id = item_id;
if ('reply' == type){
var class_id = 8;
var str_type = 'reply';
} else if ('post' == type) {
var class_id = 7;
var str_type = 'post';
if ('Y' == is_beauty) {
class_id = 6;
_item_id = '0';
}
}
if (undefined == item_id || '' == item_id) {
return false;
}
if (undefined == class_id || '' == class_id) {
return false;
}
//var content = $("#"+str_type+"_commment_" + item_id).val();
$('.blue_btn').html('发布中...');
$('.blue_btn').unbind('click');
// var content = KindEditor.instances[1].html();//获取KindEditor的值
var content = window.allEditor['e'+item_id].$txt.html();//获取wangEditor的值
console.log(content)
content = content.replace(/(]*>|( )*)/g,'');
content = $.trim(content);
if ($(content).find('img:not(.emoji)').length > 9) {
alert('最多上传9张图片');
$('.blue_btn').html('回复');
$('.blue_btn').bind('click');
return false;
}
if (undefined == content || '' == content) {
alert('内容不能为空');
// KindEditor.instances[1].focus();
$('.blue_btn').html('回复');
$('.blue_btn').bind('click');
//$("#"+str_type+"_commment_" + item_id).focus();
return false;
}
window.replyCommentObj001 = {
item_id: item_id,
type: type,
is_beauty: is_beauty,
str_type: str_type,
_item_id: _item_id,
class_id: class_id,
content: content,
primary_id: post_id,
anonymous: comment_ano,
notify_comment_id: notify_comment_id,
comment_id: comment_id,
}
// 是否需要验证
$.ajax({
url: '/verify/isCode',
type: 'post',
data: {},
dataType: 'json',
success:function (res) {
// 需要验证码
if (res.responseData.is_pop === 1) {
window.senseCommentFn.sense()
} else {
// window.senseCommentFn.sense()
ajaxReply(item_id, type, is_beauty, str_type, _item_id, class_id, content, post_id, comment_ano, notify_comment_id, comment_id)
}
}
})
}
var senseReplyOptions = {
initType:'sense', // 是否使用深知模式,不使用就不写
initGt:{
senseID:'94a6160514322a8c886c27dfae54770b',// 深知ID,如果使用深知模式必传,ID请找server确认,不同端不同页面都有可能不一致
handler:function(sense){
sense.setInfos(function () {
//设置可上传数据。请务必按照字段规范填写,否则会在服务验证时出错,导致程序无法运行或者后续数据分析出现混乱,参数需求参考api文档。
return {
interactive: 6
}
}).onSuccess(function (data) {
console.log(data)
ajaxReply(
window.replyCommentObj001.item_id,
window.replyCommentObj001.type,
window.replyCommentObj001.is_beauty,
window.replyCommentObj001.str_type,
window.replyCommentObj001._item_id,
window.replyCommentObj001.class_id,
window.replyCommentObj001.content,
window.replyCommentObj001.primary_id,
window.replyCommentObj001.anonymous,
window.replyCommentObj001.notify_comment_id,
window.replyCommentObj001.comment_id
)
}).onClose(function(){
console.log('close')
$('.blue_btn').html('回复');
$('.blue_btn').bind('click');
}).onError(function(err){
console.log(err);
$('.blue_btn').html('回复');
$('.blue_btn').bind('click');
})
window.senseCommentFn = sense
}
}
}
window.geetestReplySy = new window.GeetestSy(senseReplyOptions)
function ajaxReply(item_id, type, is_beauty, str_type, _item_id, class_id, content, primary_id, anonymous, notify_comment_id, comment_id) {
$.post('/comment/add/',{
item_id: _item_id,
class_id: class_id,
// content: content,
RichTextcontent: content,
primary_id: primary_id,
anonymous: anonymous,
notify_comment_id: notify_comment_id,
str_type: str_type,
comment_id: comment_id,
sm_device_id:sm_device_id
},function(data){
if(data.errorCode == 4){
alert(data.errorMsg);
}
if(data.errorCode == 3){
alert('系统忙,请稍后再试');
}
if(data.errorCode == -1){
alert(data.errorMsg);
}
if(data.errorCode == 10 || ( data.errorCode != 0 && data.errorCode != 200 ) ){
alert(data.errorMsg);
$('.blue_btn').html('回复');
return false;
}
notify_comment_id = 0;
$("#"+str_type+"_commment_" + item_id).val('');
$("#reply_box_"+_item_id).removeClass('empty_comment');
$("#reply_box_"+_item_id + ' .page_box .link').show();
// KindEditor.instances[1].html('');
window.allEditor['e'+item_id].$txt.html('')
//getComment(1, parseInt(item_id), parseInt(type), parseInt(is_beauty));
if(data.errorCode != 4){
getComment(1, item_id, type, is_beauty);
}
$('.blue_btn').html('回复');
$('.blue_btn').bind('click');
},'json');
}
function showComment(type, id, comment_cnt, is_beauty) {
$("."+type+"_comment_list_"+id + " li:hidden").slideDown("fast",function(){
$("."+type+"_comment_tip_"+id).hide();
$(this).show();
});
createPage(type, id, 1, comment_cnt, is_beauty);
}
function getComment(page, item_id, type, is_beauty) {
var _item_id = item_id;
if ('reply' == type){
var class_id = 8;
var str_type = 'reply';
} else if ('post' == type) {
var class_id = 7;
var str_type = 'post';
if ('Y' == is_beauty) {
class_id = 6;
_item_id = '0';
}
}
$.ajax({
type:"post",
url:'/comment/index',
data:{"page":page,"num":10,"item_id":_item_id,"class_id":class_id},
dataType:"json",
success:function(obj){
var admin_level = parseInt('0');
var errorCode = obj.errorCode;
if (0 == errorCode) {
var result = obj.responseData;
var total = parseInt(result.total) || 0;
var page = parseInt(result.page);
var comment_list = result.list;
var _html = '';
$(comment_list).each(function(i){
//var style = i > 4 ? 'style="display:none;"' : '';
var item_id = comment_list[i]['item_id'];
var comment_id = comment_list[i]['comment_id'];
var class_id = comment_list[i]['class_id'];
var anonymous = comment_list[i]['anonymous'];
var uid = comment_list[i]['uid'];
var user_name = comment_list[i]['user_name'];
var user_name_ni = '匿名用户';
var avatar = comment_list[i]['suo_avatar'];
var content = comment_list[i]['content'];
var create_date = comment_list[i]['create_date'];
var ding_cnt = comment_list[i]['ding_cnt'];
var comment_imgs = comment_list[i]['comment_imgs'];
var comment_imgsHtml = ''
for (var j = 0; j '
}
if(anonymous ==1){
_html += '\
\
\
\
:'+content+''+comment_imgsHtml+'
'+ create_date+' ';
}else if(avatar!=''){
_html += '\
\
\
\
:'+content+''+comment_imgsHtml+'
'+ create_date+' ';
}else{
_html += '\
\
\
\
:'+content+''+comment_imgsHtml+'
'+ create_date+' ';
}
if (1 == admin_level ) {
_html += ' ';
}
_html += '
\
\
';
});
$("."+type+"_comment_list_"+item_id).html(_html);
$("#"+type+"_comment_cnt_"+item_id).html('
G'+total);
createPage(type, item_id, page, total, is_beauty);
} else {
alert(obj.errorMsg);
}
},
error:function(){
alert('系统忙,请稍后再试');
}
});
}
function createPage(type, id, page, total, is_beauty, pageView) {
if (undefined == pageView || '' == pageView) {
pageView = 10;
}
var pageCount = parseInt(Math.ceil(total/pageView));
//var page = 1;
var pageStat = Math.floor((page-1)/pageView) * pageView + 1;
var pageEnd = Math.min(pageCount, pageStat+pageView-1);
var pageHtml = '';
if (pageCount > 1 && page >1) {
pageHtml += ' ';
}
if (page > 1) {
var previousPage = page - 1;
pageHtml += '';
}
if (pageCount > 1) {
for (var i=pageStat;i'+i+' ';
} else {
pageHtml += ' ';
}
}
}
if (page 下一页 ';
}
if (pageCount > 1 && page 尾页';
}
$("."+type+"_comment_page_"+id).html(pageHtml);
}
function addUp() {
var ftype = 7;
var fid = parseInt('25609029');
if (fid > 0) {
$.ajax({
type:"post",
url:'/favorites/add',
data:{"fid":fid,"ftype":ftype,"sort":2,sm_device_id:sm_device_id},
dataType:"json",
success:function(obj){
var errorCode = obj.errorCode;
if (0 == errorCode) {
//alert('添加成功');
$('.like_pop').show().animate({'opacity':'1'},300);
setTimeout(function(){
$('.like_pop').animate({'opacity':'0'},300,function(){
$(this).hide();
});
},6000);
$('.collect_btn .like_text').html('已喜欢');
var user_img = ' ';
var user_img_b = ' ';
var li_len = $('.user_list a').length;
if(li_len >0){
$('.user_list a:first').after(user_img);
}else{
$('.user_list').append(user_img_b);
}
var up_cnt = parseInt($("#up_cnt_"+fid).text()) + 1;
$("#up_cnt_"+fid).text(up_cnt);
//location.reload();
} else if(2 == errorCode) {
loginPop('http://www.soyoung.com/p25609029/');
} else {
alert(obj.errorMsg);
}
},
error:function(){
alert('系统忙,请稍后再试');
}
});
} else {
alert('ID错误');
return false;
}
}
function addReplyFavoritesCnt(reply_id, type) {
var post_id = parseInt('25609029');
reply_id = parseInt(reply_id);
if (!isNaN(reply_id) && reply_id > 0) {
$.ajax({
type:"post",
url:'/post/add_reply_favorites',
data:{"post_id":post_id,"reply_id":reply_id,"type":type},
dataType:"json",
success:function(obj){
var errorCode = obj.errorCode;
if (0 == errorCode) {
var data = obj.responseData;
var cnt = parseInt(data['cnt']);
if (1 == type) {
} else {
//cnt -= 1;
//if (cnt Z' + cnt);
} else if(2 == errorCode) {
loginPop('http://www.soyoung.com/p25609029/');
} else {
alert(obj.errorMsg);
}
},
error:function(){
alert('系统忙,请稍后再试');
}
});
}
}
// 对评论的回复进行点赞
function commentfavorites(reply_id,type, comment_id) {
// post_id=20869142&reply_id=382508090&type=1&comment_id=494830
var post_id = parseInt('25609029');
comment_id = parseInt(comment_id)
reply_id = parseInt(reply_id);
if (!isNaN(reply_id) && reply_id > 0 && !isNaN(comment_id) && comment_id > 0) {
$.ajax({
type:"post",
url:'/post/commentfavorites',
data:{"post_id":post_id,"reply_id":reply_id,"type":type, "comment_id": comment_id},
dataType:"json",
success:function(obj){
var errorCode = obj.errorCode;
if (errorCode == 0) {
var cnt = parseInt(parseInt($("#comment"+comment_id).data('cnt')) || 0) + 1
$("#comment"+comment_id).html('
Z' + cnt );
} else if(errorCode == 100) {
loginPop('http://www.soyoung.com/p25609029/');
} else {
alert(obj.errorMsg);
}
},
error:function(){
alert('系统忙,请稍后再试');
}
});
}
}
function showReplyBox(reply_id, comment_cnt) {
notify_comment_id = 0;
comment_cnt = parseInt(comment_cnt);
$('.empty_comment').hide();
$("#reply_box_"+reply_id).show();
//if(comment_cnt = 625){
// $(this).not($('.beauty_content_list .content .reply_box .list .pic img').css({'width':'36px','height':'36px'})).css({'width':'625px','height':new_H});
// }
// });
$('.brow > span').click(function () {
$(this).parent().find('.brow_pop').fadeIn();
});
$('.brow_pop span').click(function () {
$(this).parent().fadeOut();
});
$('.brow_pop span').hover(function () {
$(this).addClass('hover');
}, function () {
$(this).removeClass('hover');
});
$('.associate_project .price_content li').hover(function () {
$(this).find('.list_d').show();
$(this).css('z-index', '10');
}, function () {
$(this).find('.list_d').hide();
$(this).css('z-index', '0');
});
// addViewCnt();
var availHeight = window.screen.availHeight - 100;
var navHeight = $('#hd .nav').height();
$(window).scroll(function () {
var hdHeight = $('#hd').height() + $('#hd').offset().top;
var sidebarH = $('.sidebar').height();
var columnH = $('.column').height();
var top = document.documentElement.scrollTop || document.body.scrollTop;
var top_n = top + navHeight + 30;
if (top > (hdHeight) && columnH > sidebarH && sidebarH = availHeight && (top + availHeight) > sidebarH && columnH > sidebarH) {
if (typeof document.body.style.maxHeight === "undefined") {
$('.sidebar').css({ 'position': 'absolute', 'top': top - (sidebarH - availHeight + 30), 'left': '50%', 'margin-left': '258px' });
} else {
$('.sidebar').css({ 'position': 'fixed', 'top': 'auto', 'left': '50%', 'margin-left': '258px', 'bottom': '0' });
}
} if ((top + availHeight) >= (columnH + hdHeight) && columnH > sidebarH && columnH > availHeight) {
$('.sidebar').css({ 'position': 'absolute', 'top': columnH - sidebarH, 'bottom': 'auto','margin-left':'258px','left':'50%' });
} if (top bd_top) {
if (typeof document.body.style.maxHeight === "undefined") {
$('.beauty_tool').css({ 'position': 'absolute', 'top': top_ie6, 'left': '50%', 'margin-left': '-498px', 'width': '996px', 'z-index': '97' });
} else {
$('.beauty_tool').css({ 'position': 'fixed', 'top': '45px', 'left': '50%', 'margin-left': '-498px', 'width': '996px', 'z-index': '98' });
}
} else {
$('.beauty_tool').css({ 'position': 'relative', 'top': '0', 'left': '0%', 'margin-left': '0', 'width': '996px', 'z-index': '98' });
}