_id.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. <template>
  2. <section class="cotainer">
  3. <div class="news-detail w1200">
  4. <div class="news-left">
  5. <div class="breadcrumb">
  6. <div class="breadcrumb-list">
  7. <ul>
  8. <li><nuxt-link to="/">首页</nuxt-link></li>
  9. <li>></li>
  10. <li><nuxt-link to="/news">新闻中心</nuxt-link></li>
  11. <li>></li>
  12. <template v-for="(item,index) in $store.state.newsNav">
  13. <li class="breadcrumb-active" v-if="item.id == $route.query.cateId" :key="index">
  14. <nuxt-link :to="{name: 'news', query: {cateId: item.id}}">{{item.type}}</nuxt-link>
  15. </li>
  16. </template>
  17. </ul>
  18. </div>
  19. </div>
  20. <div class="article">
  21. <div class="title">{{ news.articleTitle }}</div>
  22. <div class="info">
  23. <div class="info-item">{{ news.createTime }}</div>
  24. <div class="info-item">
  25. <span class="">观看人数:</span>
  26. <span class="text">{{ news.readSize }}</span>
  27. </div>
  28. <div class="info-item">
  29. <span>作者:</span>
  30. <span>{{ news.articleAuthor }}</span>
  31. </div>
  32. <div class="info-item">
  33. <span>分享</span>
  34. <div class="bdsharebuttonbox share">
  35. <img class="icon" src="~/assets/images/news/icon_wechat.png" data-cmd="weixin" alt="" srcset="" title="分享到微信" />
  36. <img class="icon" src="~/assets/images/news/icon_qq.png" data-cmd="sqq" alt="" srcset="" title="分享到QQ好友" />
  37. <img class="icon" src="~/assets/images/news/icon_sina.png" data-cmd="tsina" alt="" srcset="" title="分享到新浪微博" />
  38. <!-- <a href="#" data-cmd="tsina" title="分享到新浪微博">微博</a> -->
  39. <!-- <img class="icon" src="~/assets/images/news/icon_wechat.png" data-cmd="weixin" alt="" srcset="">
  40. <img class="icon" src="~/assets/images/news/icon_qq.png" data-cmd="sqq" alt="" srcset="">
  41. <img class="icon" src="~/assets/images/news/icon_sina.png" data-cmd="tsina" alt="" srcset=""> -->
  42. </div>
  43. </div>
  44. </div>
  45. <article>
  46. <div v-html="news.articleContent"></div>
  47. </article>
  48. </div>
  49. </div>
  50. <div class="news-hot new-right">
  51. <div class="news-hot-title">
  52. 热门文章
  53. </div>
  54. <div class="hot-list">
  55. <template v-for="(item, index) in articleList">
  56. <div class="hot-item" v-if="index < 3" :key="index">
  57. <div class="hot-title">
  58. <nuxt-link :to="{name: 'news-newsView-id', params: { id: item.id }, query: {cateId: item.typeId } }">
  59. {{ item.articleTitle }}
  60. </nuxt-link>
  61. </div>
  62. <div class="hot-info">
  63. <span class="time">{{ item.createTime }}</span>
  64. <span class="views">观看人数:{{ item.readSize }}</span>
  65. </div>
  66. </div>
  67. </template>
  68. </div>
  69. <div class="hot-top-style"></div>
  70. </div>
  71. </div>
  72. </section>
  73. </template>
  74. <script>
  75. import axios from "axios";
  76. export default {
  77. data() {
  78. return {
  79. };
  80. },
  81. async asyncData({ params, query, store }) {
  82. const { data: { data: news} } = await axios(`${store.state.wordpressAPI}/official-api/article/get/${params.id}`);
  83. const { data: { data: article }} = await axios(`${store.state.wordpressAPI}/official-api/article`, {
  84. params: {
  85. page: 1
  86. }
  87. });
  88. const articleList = article.entityList || [];
  89. return {
  90. news,
  91. articleList
  92. }
  93. },
  94. head() {
  95. return {
  96. };
  97. },
  98. created() {
  99. },
  100. mounted() {
  101. this.$nextTick(function (){
  102. window._bd_share_config = {
  103. "common": {
  104. "bdSnsKey": {},
  105. "bdText": "",
  106. "bdMini": "1",
  107. "bdMiniList": ["qzone", "tsina", "weixin", "sqq", "duitang", "hx", "fx", "youdao", "sdo", "qingbiji", "people", "xinhua", "mail", "isohu", "yaolan", "wealink", "ty", "iguba", "fbook", "twi", "linkedin", "h163", "evernotecn", "copy", "print"],
  108. "bdPic": "",
  109. "bdStyle": "2",
  110. "bdSize": "32"
  111. },
  112. "share": {}
  113. };
  114. const s = document.createElement('script');
  115. s.type = 'text/javascript';
  116. s.src = 'http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion=' + ~(-new Date() / 36e5);
  117. document.body.appendChild(s);
  118. });
  119. this.loadRead();
  120. },
  121. methods: {
  122. async loadRead() {
  123. const { data } = await axios.post(`${this.$store.state.wordpressAPI}/official-api/article/read/${this.$route.params.id}`);
  124. }
  125. }
  126. };
  127. </script>
  128. <style lang="scss">
  129. .news-detail {
  130. margin-top: 118px;
  131. display: flex;
  132. .news-left {
  133. flex: 1;
  134. }
  135. .breadcrumb-list {
  136. font-size: 15px;
  137. ul {
  138. display: flex;
  139. li {
  140. margin-right: 10px;
  141. color: #535F72;
  142. a {
  143. color: #535F72;
  144. }
  145. }
  146. }
  147. .breadcrumb-active {
  148. a {
  149. font-size: 15px;
  150. font-weight: 500;
  151. color: #2D71FA;
  152. line-height: 21px;
  153. }
  154. }
  155. }
  156. .el-breadcrumb {
  157. font-size: 15px;
  158. }
  159. .article {
  160. margin: 32px auto 200px;
  161. .title {
  162. font-size: 32px;
  163. font-weight: 600;
  164. color: #262626;
  165. line-height: 45px;
  166. }
  167. .info {
  168. margin-top: 30px;
  169. font-size: 15px;
  170. font-weight: 400;
  171. color: #535F72;
  172. .info-item {
  173. margin-right: 42px;
  174. .share {
  175. margin-left: 32px;
  176. font-size: 0;
  177. .icon {
  178. margin-right: 44px;
  179. width: 27px;
  180. height: 24px;
  181. }
  182. a {
  183. font-size: 12px;
  184. }
  185. }
  186. }
  187. }
  188. article {
  189. color: #333330;
  190. margin-top: 34px;
  191. p {
  192. font-size: 16px;
  193. font-weight: 400;
  194. color: #333330;
  195. line-height: 32px;
  196. letter-spacing: 1px;
  197. }
  198. img {
  199. max-width: 850px;
  200. }
  201. }
  202. }
  203. .info {
  204. display: flex;
  205. align-items: center;
  206. .info-item {
  207. display: flex;
  208. align-items: center;
  209. }
  210. }
  211. .new-right {
  212. position: relative;
  213. width: 290px;
  214. border-radius: 4px;
  215. padding: 30px 15px 40px;
  216. max-height: 450px;
  217. margin-left: 60px;
  218. border: 1px solid #F1F1F1;
  219. overflow: hidden;
  220. .hot-top-style {
  221. position: absolute;
  222. top: 0;
  223. left: 0;
  224. height: 8px;
  225. width: 100%;
  226. background: #236AFA;
  227. border-radius: 4px 4px 0px 0px;
  228. }
  229. .news-hot-title {
  230. font-size: 26px;
  231. font-weight: 400;
  232. color: #262626;
  233. line-height: 37px;
  234. }
  235. .hot-item {
  236. margin-top: 18px;
  237. padding-top: 30px;
  238. border-top: 1px solid #F1F1F1;
  239. .hot-title {
  240. font-size: 14px;
  241. font-weight: 400;
  242. color: #262626;
  243. line-height: 20px;
  244. letter-spacing: 1px;
  245. font-family: PingFangSC-Regular, sans-serif;
  246. overflow: hidden;
  247. text-overflow: ellipsis;
  248. display: -webkit-box;
  249. -webkit-box-orient: vertical;
  250. -webkit-line-clamp: 2;
  251. }
  252. .hot-info {
  253. font-size: 10px;
  254. font-weight: 400;
  255. color: #ABABAB;
  256. line-height: 14px;
  257. margin-top: 4px;
  258. .time {
  259. margin-right: 48px;
  260. }
  261. }
  262. }
  263. }
  264. }
  265. </style>