newsdetail.blade.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. @include('common.head')
  5. </head>
  6. <body>
  7. <div class="header">
  8. @include('common.header')
  9. </div>
  10. <div id="app">
  11. <!--- 解决方案 --->
  12. <div class="index-about" style="padding-top: 40px;">
  13. <div class="width-1200">
  14. <div class="flex-start">
  15. <div class="about-list news-detail">
  16. <p class="news-title overflow">{{ $info->title }}</p>
  17. <p class="news-time">发布日期:{{ date('Y-m-d H:i', $info->created_at) }}</p>
  18. <div class="news-content" id="news-content">
  19. {!! $info->content !!}
  20. </div>
  21. </div>
  22. <div class="about-detail">
  23. <div class="about-area">
  24. <div class="about-title">栏目分类</div>
  25. @foreach ($category as $item)
  26. <div class="news-item">
  27. <a href="{{ '/news/category/' . $item->mid }}">{{ $item->name }}</a>
  28. </div>
  29. @endforeach
  30. </div>
  31. </div>
  32. </div>
  33. </div>
  34. </div>
  35. @include('common.footer')
  36. </div>
  37. </body>
  38. <script type="text/javascript" src="/static/public/swiper/swiper-4.3.3.min.js"></script>
  39. <script>
  40. var vm = new Vue({
  41. el: '#app',
  42. data: {
  43. imgUrl: 'https://audio.yososoft.com/static',
  44. target: 'https://audio.yososoft.com',
  45. newsInfo: [],
  46. categoryList: [],
  47. },
  48. mounted: function() {
  49. var mySwiper = new Swiper('.swiper-container', {
  50. loop: true,
  51. // 如果需要分页器
  52. pagination: {
  53. el: '.swiper-pagination',
  54. }
  55. })
  56. this.init();
  57. },
  58. //方法
  59. methods: {
  60. init: function() {
  61. let _this = this;
  62. let mid = this.getQueryVariable('mid');
  63. axios.post(_this.target + '/api/index/m_news_info', {
  64. mid: mid
  65. }).then(function(response) {
  66. if (response.data.result) {
  67. this.newsInfo = response.data.data;
  68. this.newsInfo.created_at = new Date(this.newsInfo.created_at * 1000)
  69. .toLocaleString();
  70. let dom = document.getElementById('news-content');
  71. dom.innerHTML = this.newsInfo.content;
  72. }
  73. }.bind(_this)).catch(function(error) {
  74. console.log(error);
  75. });
  76. axios.post(_this.target + '/api/index/m_category_list', {
  77. size: 10,
  78. page: 1
  79. }).then(function(response) {
  80. if (response.data.result) {
  81. this.categoryList = response.data.data.list;
  82. }
  83. }.bind(_this)).catch(function(error) {
  84. console.log(error);
  85. });
  86. },
  87. getQueryVariable: function(variable) {
  88. var query = window.location.search.substring(1);
  89. var vars = query.split("&");
  90. for (var i = 0; i < vars.length; i++) {
  91. var pair = vars[i].split("=");
  92. if (pair[0] == variable) {
  93. return pair[1];
  94. }
  95. }
  96. return (false);
  97. }
  98. },
  99. });
  100. </script>
  101. </html>