comment.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <style lang="sass">
  2. @import "./../../sass/page/comment.scss";
  3. </style>
  4. <template>
  5. <section class="comment-bd">
  6. <ul class="list-comment">
  7. <li class="item-comment" v-for="(filmComment,commentIndex) in filmComments" :key="commentIndex" v-if="commentIndex<5">
  8. <div class="item-fl">
  9. <img :src='filmComment.user.head' v-if="filmComment.user">
  10. </div>
  11. <div class="item-fr">
  12. <div class="info">
  13. <div class="info-fl">
  14. <h4 v-if="filmComment.user">{{filmComment.user.nick}}</h4>
  15. <p>{{filmComment.createTime | parseTime}}</p>
  16. </div>
  17. <div class="info-fr">
  18. <span class="icon-zan">{{filmComment.zanCount}}</span>
  19. <span class="icon-comment">{{filmComment.replyCount}}</span>
  20. </div>
  21. </div>
  22. <div class="cont">
  23. <p>{{filmComment.extend.text}}</p>
  24. <ul class="list-pic ext-list" v-if="filmComment.extend.pics.length==1">
  25. <li v-for="(pic,picIndex) in filmComment.extend.pics" :key="picIndex" class="item-pic" :style="{backgroundImage : 'url('+pic+'?imageview/4/0/w/400/h/400/format/)'}" @click="previewImage(commentIndex,picIndex)"></li>
  26. </ul>
  27. <ul class="list-pic" v-else>
  28. <li v-for="(pic,picIndex) in filmComment.extend.pics" :key="picIndex" class="item-pic" :style="{backgroundImage : 'url('+pic+'?imageview/4/0/w/400/h/400/format/)'}" @click="previewImage(commentIndex,picIndex)"></li>
  29. </ul>
  30. <ul class="list-post">
  31. <li v-for="(replie,index) in filmComment.replies" :key="index"><span v-if="replie.user">{{replie.user.nick}}:</span>{{replie.content}}</li>
  32. </ul>
  33. </div>
  34. <p class="tip" v-if="filmComment.commentaryTitle">评:{{filmComment.commentaryTitle}}</p>
  35. </div>
  36. </li>
  37. </ul>
  38. <div class="no-comment" v-if="filmComments.length==0">
  39. <p>暂无评论</p>
  40. </div>
  41. <a class="btn-more" :href="downloadUrl" v-if="filmComments.length>5">进入APP查看更多影评</a>
  42. </section>
  43. </template>
  44. <script>
  45. import lib from 'lib'
  46. import _ from 'underscore'
  47. export default {
  48. data() {
  49. return{
  50. downloadUrl : lib.downloadUrl,
  51. filmComments : [],
  52. isiOS : navigator.userAgent.match(/(iPhone|iPod|iPad);?/i) //ios终端
  53. }
  54. },
  55. props : ["type","id","hasPlayer"],//评论类型,id,是否属于播放页
  56. methods : {
  57. //电影影评列表
  58. getFilmCommentsByAid(){
  59. let self = this;
  60. let url = `${lib.apiUrl}/share/getFilmCommentsByAid.do`;
  61. let param = {
  62. aid : self.id,
  63. channel : "LuciferChannel",
  64. ver : 1,
  65. os : 1,
  66. uid : 1,
  67. token : "lucifer_test_token"
  68. }
  69. $.ajax({
  70. type: "get",
  71. url: url,
  72. data: param,
  73. dataType: "jsonp",
  74. success: function (ret) {
  75. var ret = lib.formatHttpProtocol(ret);
  76. if (ret.result == 1){
  77. let filmComments = ret.data.filmComments;
  78. self.filmComments = filmComments ? filmComments : [];
  79. setTimeout(function(){
  80. $("#commentNum").text(self.filmComments.length)
  81. },0)
  82. }
  83. }
  84. });
  85. },
  86. //电影解说影评列表
  87. getFilmCommentsByCid(){
  88. let self = this;
  89. let url = `${lib.apiUrl}/share/getFilmCommentsByCid.do`;
  90. let param = {
  91. cid : self.id,
  92. channel : "LuciferChannel",
  93. ver : 1,
  94. os : 1,
  95. uid : 1,
  96. token : "lucifer_test_token"
  97. }
  98. $.ajax({
  99. type: "get",
  100. url: url,
  101. data: param,
  102. dataType: "jsonp",
  103. success: function (ret) {
  104. var ret = lib.formatHttpProtocol(ret);
  105. if (ret.result == 1){
  106. let filmComments = ret.data.filmComments;
  107. self.filmComments = filmComments ? filmComments : [];
  108. }
  109. }
  110. });
  111. },
  112. previewImage(commentIndex,picIndex){
  113. let self = this;
  114. let items = [],picList = [],arr = [];
  115. picList = self.filmComments[commentIndex].extend.pics;
  116. lib.setPreviewImage(picList,picIndex);
  117. }
  118. },
  119. filters : {
  120. parseTime(value){
  121. return lib.handleTime(value).substring(5,17)
  122. }
  123. },
  124. mounted(){
  125. let self = this
  126. switch(self.type) {
  127. case 1 : //电影
  128. self.getFilmCommentsByAid(self.id)
  129. break;
  130. case 2 : //解说视频
  131. self.getFilmCommentsByCid(self.id)
  132. break;
  133. default :
  134. break;
  135. }
  136. }
  137. }
  138. </script>