news-show.htm 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <#include "/m/head-file.htm"/>
  5. <link rel="stylesheet" type="text/css" href="{ms:global.host/}/{ms:global.style/}/css/jquery.sinaemotion.css" />
  6. <script type="text/javascript" src="{ms:global.host/}/{ms:global.style/}/js/jquery.sinaEmotion.js"></script>
  7. </head>
  8. <body>
  9. <#include "/m/head.htm"/>
  10. <div class="ms-banner">
  11. <img src="{ms:global.host/}/{ms:global.style/}/images/case.png" class="am-img-responsive" alt="" />
  12. </div>
  13. <div class="ms-news-show" id="news-show-vue">
  14. <article class="am-article">
  15. <div class="am-article-hd ms-news-show-main">
  16. <div class="ms-news-show-title">{ms:field.title/}</div>
  17. <p class="am-article-meta">
  18. <div class="ms-news-show-icon">
  19. <div class="ms-news-show-icon-source"><lable class="ms-news-show-icon-title">来源:</lable><lable class="ms-news-show-icon-con">{ms:field.source/}</lable>
  20. <span>|</span>
  21. </div>
  22. <div class="ms-news-show-icon-time">
  23. <span>|</span>
  24. </div>
  25. <div class="ms-news-show-icon-clicks"></div>
  26. <div class="ms-news-show-icon-num">{ms:field.hit/}
  27. <span>|</span>
  28. </div>
  29. <!-- <div class="ms-news-show-icon-comment"></div>
  30. <div class="ms-news-show-icon-num">52<span>|</span></div> -->
  31. <div class="ms-news-show-icon-Fabulous"></div>
  32. <div class="ms-news-show-icon-num" v-text="attentionNum"></div>
  33. </div>
  34. </p>
  35. </div>
  36. <div class="am-article-bd ms-news-show-content">{ms:field.content/}</div>
  37. <div class="metfield">
  38. <p>上一篇:<a href="{ms:pre.link/}">{ms:pre.title/}</a></p>
  39. <p>下一篇:<a href="{ms:next.link/}">{ms:next.title/}</a></p>
  40. </div>
  41. </article>
  42. <div class="ms-news-show-comment">
  43. <div class="ms-news-show-comment-top">
  44. <div class="ms-news-show-comment-top-icon" @click="attentionNews" :class="{'ms-is-attention':isAttention}"></div>
  45. </div>
  46. <div class="ms-news-show-comment-bottom">
  47. <div class="ms-news-show-comment-input">
  48. <textarea v-model='isButAttention' class="emotion" type="text" name="comments" placeholder="我有话说..."></textarea>
  49. <div class="ms-news-show-comment-button">
  50. <div class="ms-news-show-comment-expression" id="ms-face"></div>
  51. <div class="ms-news-show-comment-submit" :class="{'ms-submit-comments-css':isButAttention.length > 0}" @click="submitComments()">提交</div>
  52. </div>
  53. </div>
  54. <div class="ms-news-show-comment-whole">全部评论</div>
  55. <div class="ms-news-show-comment-list">
  56. <template v-for="(comments,index) in commentsList">
  57. <div class="ms-news-show-comment-list-div" v-if="index <= listNum">
  58. <div class="ms-news-show-comment-list-left">
  59. <div class="ms-news-show-comment-list-portrait">
  60. <img :src="'{ms:global.host/}'+ comments.puIcon" onerror="this.src='http://cdn.mingsoft.net/global/images/msheader.png'">
  61. </div>
  62. <div class="ms-news-show-comment-list-content">
  63. <div class="ms-news-show-comment-list-top">
  64. <div class="ms-news-show-comment-list-name" v-text="comments.puNickname"></div>
  65. <!-- <div class="ms-news-show-comment-list-right">
  66. <div class="ms-news-show-main-icon-Fabulous"></div>
  67. <div class="ms-news-show-main-icon-num">28</div>
  68. </div> -->
  69. </div>
  70. <div class="ms-news-show-comment-list-bottom">
  71. <div class="ms-news-show-comment-list-comment" v-html="vueAnalyticEmotion(comments.commentContent)"></div>
  72. <div class="ms-news-show-comment-list-time" v-text="comments.commentTime"></div>
  73. </div>
  74. </div>
  75. </div>
  76. </div>
  77. </template>
  78. <div class="ms-news-show-comment-more" @click="listNum = listNum +4" v-show="listNum < commentsList.length">查看更多评论</div>
  79. <div class="ms-news-show-comment-more" v-show="listNum >= commentsList.length && commentsList.length != 0">没有更多评论</div>
  80. </div>
  81. </div>
  82. </div>
  83. </div>
  84. <#include "/m/footer.htm"/>
  85. </body>
  86. <script>
  87. var newsShowVue = new Vue({
  88. el: "#news-show-vue",
  89. data: {
  90. commentsList: [], //评论列表
  91. attentionNum: 0, //点赞数
  92. isAttention: false, //点赞状态
  93. isButAttention: '', //按钮状态
  94. listNum: 4, //列表数
  95. loginStatus: '', //登录状态
  96. vueAnalyticEmotion: function(val) {
  97. return AnalyticEmotion(val);
  98. },
  99. },
  100. methods: {
  101. //关注或者取消
  102. attentionNews: function() {
  103. var obj = this;
  104. if(this.loginStatus != true) {
  105. alert("请先登录后重试");
  106. return;
  107. }
  108. //判断关注还是取关
  109. if(obj.isAttention == false) {
  110. $.ajax({
  111. type: "POST",
  112. data: "basicAttentionBasicId={ms:field.id/}&basicAttentionType=2",
  113. url: "{ms:global.host/}/people/attention/save.do",
  114. success: function(msg) {
  115. if(msg.result) {
  116. obj.attentionNum++;
  117. obj.isAttention = true;
  118. }
  119. },
  120. error: function() {
  121. alert("操作失败,请检查是否已经安装关注插件");
  122. }
  123. })
  124. } else {
  125. $.ajax({
  126. type: "POST",
  127. data: "basicId={ms:field.id/}&basicAttentionType=2",
  128. url: "{ms:global.host/}/people/attention/delete.do",
  129. success: function(msg) {
  130. if(msg.result) {
  131. obj.attentionNum--;
  132. obj.isAttention = false;
  133. }
  134. },
  135. error: function() {
  136. alert("操作失败,请检查是否已经安装关注插件");
  137. }
  138. })
  139. }
  140. },
  141. //关注
  142. list: function() {
  143. var obj = this;
  144. $.ajax({
  145. type: "POST",
  146. data: "commentBasicId={ms:field.id/}",
  147. url: "{ms:global.host/}/comment/list.do",
  148. success: function(msg) {
  149. obj.commentsList = msg.list;
  150. }
  151. })
  152. },
  153. //提交
  154. submitComments: function() {
  155. if(this.isButAttention == '') {
  156. return;
  157. }
  158. if(this.loginStatus != true) {
  159. alert("请先登录后重试");
  160. return;
  161. }
  162. var obj = this;
  163. $.ajax({
  164. type: "POST",
  165. data: "commentContent=" + $("textarea[name=comments]").val() + "&isCode=false&commentBasicId={ms:field.id/}",
  166. url: "{ms:global.host/}/people/comment/save.do",
  167. success: function(msg) {
  168. if(msg.result) {
  169. alert("评论成功");
  170. obj.list();
  171. } else {
  172. alert(msg.resultMsg);
  173. }
  174. obj.isButAttention = '';
  175. },
  176. error: function() {
  177. alert("操作失败,请检查是否已经安装评论插件");
  178. }
  179. })
  180. }
  181. },
  182. mounted: function() {
  183. //调用表情
  184. $('#ms-face').SinaEmotion($('.emotion'));
  185. var obj = this;
  186. //验证登录
  187. $.ajax({
  188. type: "POST",
  189. url: "{ms:global.host/}/checkLoginStatus.do",
  190. success: function(msg) {
  191. obj.loginStatus = msg.result;
  192. }
  193. })
  194. //关注数
  195. $.ajax({
  196. type: "POST",
  197. data: "basicAttentionBasicId={ms:field.id/}&basicAttentionType=2",
  198. url: "{ms:global.host/}/attention/count.do",
  199. success: function(msg) {
  200. obj.attentionNum = msg;
  201. }
  202. })
  203. //是否关注了
  204. $.ajax({
  205. type: "POST",
  206. data: "basicAttentionBasicId={ms:field.id/}&basicAttentionType=2",
  207. url: "{ms:global.host/}/people/attention/isExists.do",
  208. success: function(msg) {
  209. obj.isAttention = msg.result;
  210. }
  211. })
  212. },
  213. beforeCreate: function() {
  214. var obj = this;
  215. var app_id = '1362404091';
  216. //获取标签列表
  217. $.ajax({
  218. async: true,
  219. dataType: 'jsonp',
  220. url: 'https://api.weibo.com/2/emotions.json?source=' + app_id,
  221. success: function(response) {
  222. var data = response.data;
  223. for(var i in data) {
  224. if(data[i].category == '') {
  225. data[i].category = '默认';
  226. }
  227. if(emotions[data[i].category] == undefined) {
  228. emotions[data[i].category] = new Array();
  229. categorys.push(data[i].category);
  230. }
  231. emotions[data[i].category].push({
  232. name: data[i].phrase,
  233. icon: data[i].icon
  234. });
  235. uSinaEmotionsHt.put(data[i].phrase, data[i].icon);
  236. }
  237. obj.list();
  238. }
  239. });
  240. },
  241. })
  242. </script>
  243. </html>