show.blade.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. @extends('layouts.app')
  2. @section('title', $article->title ? $article->title : '实战教程')
  3. @section('body')
  4. {{-- 目录侧边栏 --}}
  5. <div class="ui basic primary launch right attached fixed button" id="right-menu-btn">
  6. <i class="content icon"></i>
  7. <span class="text">Menu</span>
  8. </div>
  9. <div class="ui vertical sidebar menu left book-side-menu" style="z-index: 99999;">
  10. <div class="item lh-2">
  11. <b>{{ $article->section->book->title }}</b>
  12. </div>
  13. @foreach($sections as $section)
  14. <div class="item">
  15. <div class="header">
  16. {{ $section->title }}
  17. </div>
  18. <div class="menu article">
  19. @foreach($section->articles as $item)
  20. <a class="item {{ active_class(if_route_param('article', $item->id)) }}"
  21. href="{{ route('course.articles.show', [$article->section->book->id, $item->id]) }}">
  22. {{ $item->title }}
  23. </a>
  24. @endforeach
  25. </div>
  26. </div>
  27. @endforeach
  28. </div>
  29. @endsection
  30. @section('content')
  31. <div class="ui centered grid container stackable">
  32. {{-- 主体 --}}
  33. <div class="twelve wide column js-computed-height-right">
  34. <div class="ui segment article-content">
  35. <div class="extra-padding">
  36. <h1>
  37. <i class="grey file text outline icon"></i>
  38. <span style="line-height: 34px;">{{ $article->title }}</span>
  39. </h1>
  40. <div class="book-article-meta">
  41. <a href="{{ route('course.books.show', $article->section->book->id) }}">
  42. <i class="icon book"></i> {{ $article->section->book->title }}
  43. </a>
  44. <span class="divider">/</span>
  45. <span class="relative ">
  46. <a class="chapter-title user-has-done-btn" data-act="chapter_sidebar_clicked"
  47. href="javascript:void(0);">
  48. <i class="icon map signs"></i> {{ $article->section->title }}
  49. </a>
  50. </span>
  51. @auth
  52. @if(\Illuminate\Support\Facades\Auth::user()->hasRole('Founder'))
  53. <span style="font-size: 13px;color: #adb1af;">(
  54. <a href="{{ route('course.articles.edit', [$data['book_id'], $article->id]) }}"><i class="icon edit"></i>编辑</a>
  55. <span class="divider">|</span>
  56. <a class=" top-admin-operation ml-0" href="javascript:;"
  57. data-method="delete"
  58. data-url="{{ route('course.articles.destroy', [$data['book_id'], $article->id]) }}"
  59. style="cursor: pointer;"><i class=" trash icon"></i>删除
  60. </a>)
  61. </span>
  62. @endif
  63. @endauth
  64. </div>
  65. <div class="ui divider"></div>
  66. {{-- 文章详情 --}}
  67. <div class="ui readme markdown-body content-body fluidbox-content">
  68. {{-- 需要付费教程文章 --}}
  69. @if($article->policy == '1')
  70. {{-- 已付款 --}}
  71. @if($article->section->book->order && $article->section->book->order['flag'] == '1')
  72. {!! markdownToHtml($article->body, 'markdown') !!}
  73. @else
  74. {{-- 未付款 --}}
  75. {!! markdownToHtml($article->body, 'markdown', 500) !!}
  76. <blockquote style="border: dashed 3px #9bacc1;">
  77. <p>为了保证课程的高品质,我们需要对课程进行收费。
  78. <a href="{{ route('course.purchases.index', $article->section->book->id) }}" target="_blank">付费后</a>
  79. 才能观看剩余内容。
  80. <a class="ui label green" href="{{ route('course.purchases.index', $article->section->book->id) }}" target="_blank">
  81. <i class="icon shop"></i> 购买
  82. </a>
  83. </p>
  84. </blockquote>
  85. @endif
  86. @else
  87. {{-- 免费教程文章 --}}
  88. {!! markdownToHtml($article->body, 'markdown') !!}
  89. @endif
  90. </div>
  91. </div>
  92. </div>
  93. <div>
  94. <a class="ui basic button small article-pager-btn pull-left disabled page-prev-btn"
  95. data-content="" href="javascript:;">
  96. <i class="icon arrow left"></i> 上一篇
  97. </a>
  98. <a class="ui basic button small article-pager-btn pull-right popover disabled page-next-btn"
  99. data-content=""
  100. href="javascript:;">
  101. 下一篇
  102. <i class="icon arrow right"></i>
  103. </a>
  104. <div class="clearfix"></div>
  105. </div>
  106. {{-- 回复 --}}
  107. @include('pages.replies._reply_list')
  108. @include('pages.replies._reply_box', ['input_model'=> \App\Models\CourseArticle::class ])
  109. </div>
  110. {{-- 侧边栏 --}}
  111. <div class="four wide column js-computed-height-left">
  112. <div class="item header sidebar book-article">
  113. <div class="ui segment orange text-center">
  114. 刻意练习,每日精进。
  115. </div>
  116. <div class="ui segment">
  117. <div class="two ui basic buttons small">
  118. <a class="ui labeled icon basic article-pager-btn button left attached disabled page-prev-btn"
  119. data-content="" href="javascript:;">
  120. <i class="left arrow icon"></i>
  121. 上一篇
  122. </a>
  123. <a class="ui right labeled article-pager-btn icon basic button right attached popover disabled page-next-btn"
  124. data-content=""
  125. href="javascript:;">
  126. <i class="right arrow icon"></i>
  127. 下一篇
  128. </a>
  129. </div>
  130. </div>
  131. <div class="ui segment">
  132. <div class="ui three statistics">
  133. <div class="ui huge statistic">
  134. <div class="value">~</div>
  135. <div class="label">点赞</div>
  136. </div>
  137. <div class="ui huge statistic">
  138. <div class="value">{{ $article->view_count }}</div>
  139. <div class="label">浏览</div>
  140. </div>
  141. <a class="ui huge statistic" href="#topics-list">
  142. <div class="value">{{ $article->reply_count }}</div>
  143. <div class="label">讨论</div>
  144. </a>
  145. </div>
  146. <br>
  147. </div>
  148. <div class="ui stackable cards">
  149. <div class="ui card column author-box grid authors-box responsive" style="margin-top: 20px;">
  150. <div class="ui fluid hide-on-mobile" style="margin-top: 20px;">
  151. <div class="ui teal ribbon label">
  152. <i class="star icon"></i> 作者
  153. </div>
  154. </div>
  155. <a href="javascript:;" class="avatar-link authors first">
  156. <img class="ui centered circular tiny image"
  157. src="{{ assert_images($article->user->info->image['path']) }}"><span
  158. class="author-name">{{ $article->user->name }}</span>
  159. </a>
  160. </div>
  161. </div>
  162. {{-- 文章导航 --}}
  163. <div class="ui sticky doc toc">
  164. <div class="ui card column author-box grid tocify" id="markdown-tocify"
  165. style="max-height: 100%;padding: 22px 4px;"></div>
  166. </div>
  167. </div>
  168. </div>
  169. </div>
  170. @endsection
  171. @section('script')
  172. {{-- 上一页、下一页 --}}
  173. <script type="text/javascript">
  174. let allHref = [];
  175. $('.book-side-menu').find('a').each(function () {
  176. allHref.push({
  177. 'href': $(this).attr('href'),
  178. 'title': $.trim($(this).text()),
  179. 'active': $(this).hasClass('active') ? true : false
  180. });
  181. });
  182. let activeIndex = allHref.findIndex(function(item){
  183. return item.active;
  184. });
  185. // 上一页
  186. let prev = allHref[activeIndex - 1];
  187. // 下一页
  188. let next = allHref[activeIndex + 1];
  189. if(prev){
  190. $('.page-prev-btn').attr('href', prev.href);
  191. $('.page-prev-btn').attr('data-content', prev.title);
  192. $('.page-prev-btn').removeClass('disabled');
  193. }
  194. if(next){
  195. $('.page-next-btn').attr('href', next.href);
  196. $('.page-next-btn').attr('data-content', next.title);
  197. $('.page-next-btn').removeClass('disabled');
  198. }
  199. </script>
  200. <script type="text/javascript">
  201. // 发表回复
  202. var markdown = new Markdown();
  203. markdown.init({
  204. 'textarea': {
  205. 'id': 'markdown-editor'
  206. },
  207. 'interval': false,
  208. 'markdown': {
  209. status: false,
  210. toolbar: false,
  211. },
  212. 'events': {
  213. change: function (html) {
  214. if ($.trim(html) !== '') {
  215. $("#preview-box").html(html).fadeIn();
  216. } else {
  217. $("#preview-box").fadeOut();
  218. }
  219. }
  220. }
  221. });
  222. </script>
  223. <script type="text/javascript">
  224. // 删除评论
  225. LearnkuNew.axiosDeleteForm(function (btn) {
  226. $(btn).closest('.comment').remove();
  227. })
  228. </script>
  229. <script type="text/javascript">
  230. var auth = Boolean("{{ Auth::check() }}");
  231. // 发表评论
  232. $("#comment-composing-form").submit(function () {
  233. if (auth) {
  234. axios({
  235. method: $(this).attr('method'),
  236. url: $(this).attr('action'),
  237. data: $(this).serialize(),
  238. }).then((res)=> {
  239. Swal.fire({
  240. type: 'success',
  241. title: '评论发表成功 . . .',
  242. text: '请耐心等待管理员审核',
  243. });
  244. // 重置 markdown
  245. window['markdown_markdown-editor'].value('');
  246. }).catch(function (error) {
  247. window.public.axios_catch(error);
  248. });
  249. } else {
  250. window.location.href = "{{ route('login') }}";
  251. }
  252. });
  253. </script>
  254. @endsection