var comment_page = 1; var comment_timer; //载入评论 function loadComment(page = 1){ var id = $('.community_left').attr('data-oid') var getCommentListbyIdApi = domain_str +'/home/shortvideo/getAlbumCommentList' $.ajax({ type: "GET", dataType:"json", url: getCommentListbyIdApi, data: { service_key: identity.getServiceKey(), ccgq_uuid: identity.getCcgqUid(), service_type: identity.getServiceType(), platform: 'web-ccgq', uid: identity.getUid(), pageindex: page, theid: id, }, dataType: 'json', success: function(data) { if(data.returnCode == '0000'){ var data = data.datas if(data.list.length > 0){ comment_page++; $('.comment_num').text(data.total_count); }else{ clearInterval(comment_timer) $('.more-box a').text('没有更多内容了~'); $('.more-box a').css('background-color', '#bcbcbc'); if(page == 1){ $('._no_comment').css('display','block') } } setCommentShowList(data.list, true); } } }); } //载入关注 function loadCollect(){ var id = $('#follow').attr('data-oid') if(!id){ return } var getOpernCollectApi = domain_str +'/home/user/getUserCollect'; $.ajax({ type: "GET", dataType:"json", url: getOpernCollectApi, data: { service_key: identity.getServiceKey(), ccgq_uuid: identity.getCcgqUid(), service_type: identity.getServiceType(), uid: identity.getUid(), by_uid: id, platform: 'web-ccgq', }, dataType: 'json', success: function(res) { if(res.returnCode == '0000'){ if(res.is_follow_collect == true){ $('.follow').css('background', '#CCCCCC') $('.follow').text('已关注') }else{ $('.follow').css('background', '#201f1c') $('.follow').text('+ 关注') } } } }); } $('.shareBtn').click(function () { document.getElementById('c_d_dialog').style.display = 'block'; }); //弹窗隐藏 $("#c_d_dialog").click(function (event) { $('#c_d_dialog').hide(); $('.share_p_box_o').css('display','block'); $('.c_d_qr_code_box').css('display','none') }); $(".closeBtn").click(function (event) { console.log(1); $('#c_d_dialog').hide(); $('.share_p_box_o').css('display','block'); $('.c_d_qr_code_box').css('display','none') }); $('.share_toWX').click(function(){ $('.share_p_box_o').css('display','none'); $('.c_d_qr_code_box').css('display','block') }) $('#content').click(function () { event.stopPropagation(); // 阻止事件向上冒泡 }); $('.share_toWO').click(function(){ var title = $('.community_left h2').text(); title = title ? title : '虫虫钢琴网'; shareModel.sinaWeiBo(title, window.location.href); }) $('.share_toQQ').click(function(){ var title = $('.community_left h2').text(); title = title ? title : '虫虫钢琴网'; shareModel.shareQQ(window.location.href, title, ''); }) $('.share_toQQKJ').click(function(){ var title = $('.community_left h2').text(); title = title ? title : '虫虫钢琴网'; shareModel.shareQQZone(window.location.href, title, ''); }) $('.share_toWX').click(function(){ shareModel.weixin(); $('.share_p_box_o').css('display','none'); $('.c_d_qr_code_box').css('display','block') }) //评论 $('.a_t_publish_btn').click(function(e){ if(!identity.getUid()){ if(isMobile()){ $("body").append(''); }else{ $("body").append(''); } return } var id = $('.community_left').attr('data-oid') if(!id){ return } var content = $('textarea[name=content]').val(); if(!content){ $.message({ message:'请输入评论内容', type:'warning' }); return } var strlen = getByteLen(content) if(strlen > 100){ $.message({ message: '输入评论不得超过100个字符', type: 'warning' }); return } var addCollectApi = domain_str +'/home/shortvideo/AddShortvideoComment'; $.ajax({ type: "GET", dataType:"json", url: addCollectApi, data: { uid: identity.getUid(), theid: id, comment_content: content, comment_id: '', score_num: 5, platform: 'web-ccgq', ccgq_uuid: identity.getCcgqUid() }, dataType: 'json', success: function(res) { if(res.returnCode == '0000'){ $.message({ message: '评论成功', type: 'success' }); setCommentShowList([res.datas], false) }else{ $.message({ message: res.returnMsg, type: 'error' }); } } }); }); //回复 $('.a_t_comment').on('click','.reply_btn',function(){ event.stopPropagation(); if(!identity.getUid()){ if(isMobile()){ $("body").append(''); }else{ $("body").append(''); } return } var that = this if(!identity.getUid()){ $("body").append(''); return } var id = $('.community_left').attr('data-oid') if(!id){ return } var comment_id = $(that).parents('li').attr('data-comment-id') if(!comment_id){ return } var content = $(that).parents('li').find('input').val() if(!content){ $.message({ message:'请输入评论内容', type:'warning' }); return } var strlen = getByteLen(content) if(strlen > 100){ $.message({ message: '输入评论不得超过100个字符', type: 'warning' }); return } var addCollectApi = domain_str +'/home/shortvideo/AddShortvideoComment'; $.ajax({ type: "GET", dataType:"json", url: addCollectApi, data: { uid: identity.getUid(), theid: id, comment_content: content, comment_id: comment_id, score_num: 5, platform: 'web-ccgq', ccgq_uuid: identity.getCcgqUid() }, dataType: 'json', success: function(res) { if(res.returnCode == '0000'){ $.message({ message: '回复成功', type: 'success' }); reply(that) }else{ $.message({ message: res.returnMsg, type: 'error' }); } } }); }); $(".b_flowerBox").click(function (event) { if(isMobile()){ loadInstall() return } $.message({ message: '送花请前往"虫虫钢琴APP"', type: 'warning' }); }); $(".b_likeBox").click(function (event) { if(isMobile()){ loadInstall() return } $.message({ message:'点赞请前往"虫虫钢琴APP"', type:'warning' }); }); $('.a_t_comment').on('click','.dz_box',function(){ if(isMobile()){ $.message({ message: '请前往APP', type: 'warning' }); return } $.message({ message:'点赞前往"虫虫钢琴APP"', type:'warning' }); }) //关注 $('#follow').click(function(e){ if(identity.getUid()){ var text = $(this).text() if(text == '已关注'){ var collectApi = domain_str +'/home/user/delOneFollow' }else{ var collectApi = domain_str +'/home/user/addOneFollow' } var uid_by = $('#follow').attr('data-oid') if(!uid_by){ $.message({ message:'该用户无效', type:'info' }); return } $.ajax({ type: "GET", dataType:"json", url: collectApi, data: { service_key: identity.getServiceKey(), ccgq_uuid: identity.getCcgqUid(), service_type: identity.getServiceType(), uid: identity.getUid(), uid_by: uid_by, platform: 'web-ccgq', }, dataType: 'json', success: function(res) { if(res.returnCode == '0000'){ if(text == '已关注'){ $('#follow').css('background', '#201f1c') $('#follow').text('+ 关注') }else{ $('#follow').css('background', '#CCCCCC') $('#follow').text('已关注') } }else{ $.message({ message:res.returnMsg, type:'error' }); } } }); } else{ if(isMobile()){ $("body").append(''); }else{ $("body").append(''); } } }); $('.follow').click(function () { if(!identity.getUid()){ if(isMobile()){ $("body").append(''); }else{ $("body").append(''); } return } var id = $(this).attr('data-id'); var that = this; if($(that).text() == '已关注'){ // 取消关注 var addAlbumCollectApi = domain_str +'/home/user/delOneFollow' $.ajax({ type: "GET", contentType: "application/json", url: addAlbumCollectApi, data: { service_key: identity.getServiceKey(), ccgq_uuid: identity.getCcgqUuid(), service_type: identity.getServiceType(), uid: identity.getUid(), uid_by: id, platform: 'web-ccgq', }, dataType: 'json', success: function(res) { if(res.returnCode == '0000'){ $(that) .text('+ 关注') .css("background", "#201f1c"); }else{ $.message({ message: res.returnMsg, type: 'error' }); } } }); }else{ // 关注 var addAlbumCollectApi = domain_str +'/home/user/addOneFollow' $.ajax({ type: "GET", contentType: "application/json", url: addAlbumCollectApi, data: { service_key: identity.getServiceKey(), ccgq_uuid: identity.getCcgqUuid(), service_type: identity.getServiceType(), uid: identity.getUid(), uid_by: id, platform: 'web-ccgq', }, dataType: 'json', success: function(res) { if(res.returnCode == '0000'){ $(that) .text('已关注') .css("background", "#C5C7C7"); }else{ $.message({ message: res.returnMsg, type: 'error' }); } } }); } }); $(function(){ loadComment(comment_page) loadCollect() // 加载评论 $('.more-box a').click(function(){ $(this).html('加载中...') comment_timer = setTimeout(() => { $(this).html('查看更多') }, 1000); loadComment(comment_page) }) });