comment.php 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <?php defined('InShopNC') or exit('Access Invalid!');?>
  2. <link type="text/css" rel="stylesheet" href="<?php echo SHOP_SITE_URL;?>/templates/default/css/home_login.css">
  3. <script type="text/javascript">
  4. $(document).ready(function(){
  5. var url_comment_list = "<?php echo CMS_SITE_URL.DS;?>index.php?act=comment&op=comment_list&type=<?php echo $_GET['act'];?>&comment_object_id=<?php echo $output['detail_object_id'];?>&comment_all=<?php echo $output['comment_all'];?>";
  6. $("#btn_comment_submit").click(function(){
  7. if($("#input_comment_message").val() != '') {
  8. $.post("<?php echo CMS_SITE_URL.DS.'index.php?act=comment&op=comment_save';?>", $("#add_form").serialize(),
  9. function(data){
  10. if(data.result == 'true') {
  11. $("#input_comment_message").val("");
  12. $("#comment_list").load(url_comment_list);
  13. $("#comment_list dl").first().hide().fadeIn("fast");
  14. } else {
  15. showError(data.message);
  16. }
  17. }, "json");
  18. }
  19. });
  20. //初始加载评论
  21. $("#comment_list").load(url_comment_list);
  22. //评论翻页
  23. $("#comment_list .demo").live('click',function(e){
  24. $("#comment_list").load($(this).attr('href'));
  25. return false;
  26. });
  27. //评论删除
  28. $("[nctype=comment_drop]").live('click',function(){
  29. if(confirm('<?php echo $lang['nc_ensure_del'];?>')) {
  30. var item = $(this).parents("dl");
  31. $.post("index.php?act=comment&op=comment_drop&type=<?php echo $_GET['act'];?>", { comment_id: $(this).attr("comment_id")}, function(json){
  32. if(json.result == "true") {
  33. item.remove();
  34. } else {
  35. showError(json.message);
  36. }
  37. },'json');
  38. }
  39. });
  40. <?php if($_SESSION['is_login'] != '1'){?>
  41. //登陆窗口
  42. $("#btn_login").nc_login({
  43. nchash:'<?php echo getNchash();?>',
  44. formhash:'<?php echo Security::getTokenValue();?>',
  45. anchor:'cms_comment_flag'
  46. });
  47. <?php } ?>
  48. $('#comment_list').on('click', '[nctype="comment_quote"]', function() {
  49. <?php if($_SESSION['is_login'] != '1'){?>
  50. //登陆窗口
  51. $.show_nc_login({
  52. nchash:'<?php echo getNchash();?>',
  53. formhash:'<?php echo Security::getTokenValue();?>',
  54. anchor:'cms_comment_flag'
  55. });
  56. <?php } else { ?>
  57. var $comment = $(this).parents('p').next('.comment-quote');
  58. if($comment.length > 0) {
  59. $comment.remove();
  60. } else {
  61. $(this).parents('p').after('<p class="comment-quote">' + $('#comment_quote').html() + '<input name="comment_id" value="' + $(this).attr('comment_id') + '" type="hidden" />' + '</p>');
  62. }
  63. <?php } ?>
  64. });
  65. //回复
  66. $('#comment_list').on('click', '[nctype="btn_comment_quote_publish"]', function() {
  67. var comment_id = $(this).parents('p').find('input').val();
  68. var comment_object_id = $('#input_comment_object_id').val();
  69. var comment_type = $('#input_comment_type').val();
  70. var comment_message = $(this).parents('p').find('textarea').val();
  71. $.post("<?php echo CMS_SITE_URL.DS.'index.php?act=comment&op=comment_save';?>", {comment_id:comment_id, comment_object_id:comment_object_id, comment_type:comment_type, comment_message:comment_message},
  72. function(data){
  73. if(data.result == 'true') {
  74. $("#input_comment_message").val("");
  75. $("#comment_list").load(url_comment_list);
  76. $("#comment_list dl").first().hide().fadeIn("fast");
  77. } else {
  78. showError(data.message);
  79. }
  80. }, "json");
  81. });
  82. $('#comment_list').on('click', '[nctype="btn_comment_quote_cancel"]', function() {
  83. $(this).parents('p').remove();
  84. });
  85. $('#comment_list').on('click', '[nctype="comment_up"]', function() {
  86. <?php if($_SESSION['is_login'] != '1'){?>
  87. //登陆窗口
  88. $.show_nc_login({
  89. nchash:'<?php echo getNchash();?>',
  90. formhash:'<?php echo Security::getTokenValue();?>',
  91. anchor:'cms_comment_flag'
  92. });
  93. <?php } else { ?>
  94. var comment_id = $(this).attr('comment_id');
  95. var $count = $(this).find('em');
  96. $.post("<?php echo CMS_SITE_URL.DS.'index.php?act=comment&op=comment_up';?>", {comment_id:comment_id},
  97. function(data){
  98. if(data.result == 'true') {
  99. var old_count = parseInt($count.text());
  100. $count.text(old_count + 1);
  101. } else {
  102. showError(data.message);
  103. }
  104. }, "json");
  105. <?php } ?>
  106. });
  107. });
  108. </script>
  109. <div id="cms_comment_flag" class="article-comment-title">
  110. <h3></h3>
  111. <span><?php echo $lang['cms_comment1'];?><a href="<?php echo CMS_SITE_URL.DS;?>index.php?act=<?php echo $_GET['act'];?>&op=<?php echo $_GET['act'];?>_comment_detail&<?php echo $_GET['act'];?>_id=<?php echo $output['detail_object_id'];?>"><em><?php echo $output[$_GET['act'].'_detail'][$_GET['act'].'_comment_count'];?></em></a><?php echo $lang['cms_comment2'];?><em><?php echo $output[$_GET['act'].'_detail'][$_GET['act'].'_click'];?></em><?php echo $lang['cms_comment3'];?></span> </div>
  112. <form id="add_form" action="" class="article-comment-form">
  113. <input id="input_comment_type" name="comment_type" type="hidden" value="<?php echo $_GET['act'];?>" />
  114. <input id="input_comment_object_id" name="comment_object_id" type="hidden" value="<?php echo $output['detail_object_id'];?>" />
  115. <textarea id="input_comment_message" name="comment_message" class="article-comment-textarea"></textarea>
  116. <input id="btn_comment_submit" type="button" class="article-comment-btn" value="发布" />
  117. <?php if($_SESSION['is_login'] != '1'){?>
  118. <div class="article-comment-login"><?php echo $lang['cms_comment4'];?><a id="btn_login" href="###">[<?php echo $lang['cms_login'];?>]</a><?php echo $lang['cms_comment5'];?></div>
  119. <?php }?>
  120. </form>
  121. <div id="comment_list" class="article-comment-list"></div>
  122. <div id="comment_quote" style="display:none;"><a nctype="btn_comment_quote_cancel" href="JavaScript:;" class="cancel-btn" title="取消"></a>
  123. <textarea name="comment_quote" rows="3" cols="30"></textarea>
  124. <a nctype="btn_comment_quote_publish" href="JavaScript:;" class="publish-btn">发布</a></div>