ArticleDetails.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. <template>
  2. <view class="ArticleDetails">
  3. <view class="Articletitle">
  4. {{ info.title }}
  5. </view>
  6. <view class="subtitle">
  7. <view class="subtitle_left">
  8. <view class="subtitle_left_item">
  9. {{info.columnIdName}}
  10. <text style="color: #fff;margin: 0 10rpx;">{{ '|' }}</text>
  11. {{info.subIdName}}
  12. </view>
  13. <!-- <view class="subtitle_left_item">{{info.subIdName}}</view> -->
  14. </view>
  15. <view class="subtitle_right">
  16. <u--image width="40rpx" height="40rpx" src="/static/index/iconm_shitu.png" ></u--image>
  17. {{ info.views || 0 }}
  18. </view>
  19. </view>
  20. <view class="time">
  21. {{ info.time }}
  22. </view>
  23. <view class="vHtml" v-if="!showVido">
  24. <u-parse class="vHtml" :content="info.content"></u-parse>
  25. </view>
  26. <view class="videoBox" v-else>
  27. <!-- 视频组件 -->
  28. <video style="width: 710rpx;" :src="info.videoUrl"></video>
  29. </view>
  30. <view class="linebox">
  31. </view>
  32. <view>
  33. <!-- 评论组件 -->
  34. <comment :topicId="info.id"></comment>
  35. </view>
  36. </view>
  37. </template>
  38. <script>
  39. import comment from '@/pages/components/comment.vue'
  40. import {getArticleDetailByOpen} from '@/http/api/common.js'
  41. export default {
  42. data() {
  43. return {
  44. info:{
  45. title:'',
  46. readNum:999,
  47. time:'',
  48. content:'',
  49. columnIdName:'',
  50. subIdName:'',
  51. videoUrl:'',
  52. id:''
  53. },
  54. showVido:false
  55. }
  56. },
  57. components: {
  58. comment
  59. },
  60. async onLoad(e) {
  61. if (e?.id != '') {
  62. await this.initData(e?.id)
  63. }else{
  64. uni.showToast({
  65. title: '参数错误',
  66. duration: 2000
  67. });
  68. }
  69. },
  70. onShow() {
  71. },
  72. computed:{
  73. },
  74. methods: {
  75. async initData(id){
  76. let query = {
  77. id:id
  78. }
  79. //获取文章详情
  80. let res = await getArticleDetailByOpen(query)
  81. if (res.data.code == 200) {
  82. this.info = res.data.data
  83. if (this.info.subIdName == '视频资讯') {
  84. this.info.videoUrl = this.info.videoList[0].fileUrl
  85. this.showVido = true
  86. }else{
  87. this.showVido = false
  88. }
  89. }
  90. }
  91. }
  92. }
  93. </script>
  94. <style>
  95. .ArticleDetails{
  96. width: 750rpx;
  97. margin: 0 auto;
  98. display: flex;
  99. flex-direction: column;
  100. align-items: flex-start;
  101. padding-left: 20rpx;
  102. }
  103. .Articletitle{
  104. width: 710rpx;
  105. height: 112rpx;
  106. font-size: 40rpx;
  107. font-family: PingFang SC, PingFang SC;
  108. font-weight: bold;
  109. color: #333333;
  110. line-height: 56rpx;
  111. display: -webkit-box;
  112. word-break: break-all;
  113. text-overflow: ellipsis;
  114. overflow: hidden;
  115. -webkit-box-orient: vertical;
  116. -webkit-line-clamp:2;
  117. }
  118. .subtitle{
  119. width: 710rpx;
  120. height: 48rpx;
  121. display: flex;
  122. margin-top: 33rpx;
  123. justify-content: space-between;
  124. }
  125. .subtitle_left{
  126. width: 304rpx;
  127. height: 48rpx;
  128. display: flex;
  129. }
  130. .subtitle_left_item{
  131. width: 300rpx;
  132. height: 48rpx;
  133. margin-left: 4rpx;
  134. background: #EAF0FF;
  135. border-radius: 8rpx 8rpx 8rpx 8rpx;
  136. text-align: center;
  137. font-size: 28rpx;
  138. font-weight: 400;
  139. color: #46A6FF;
  140. line-height: 40rpx;
  141. }
  142. .subtitle_right{
  143. width: 85rpx;
  144. height: 48rpx;
  145. font-size: 28rpx;
  146. font-weight: 500;
  147. color: #999999;
  148. display: flex;
  149. }
  150. .time{
  151. width: 300rpx;
  152. height: 33rpx;
  153. font-size: 28rpx;
  154. font-weight: 400;
  155. color: #999999;
  156. line-height: 40rpx;
  157. margin-top: 20rpx;
  158. margin-bottom: 40rpx;
  159. }
  160. .vHtml{
  161. width: 710rpx;
  162. line-height: 48rpx;
  163. }
  164. .vHtml >>> img {
  165. vertical-align: middle;
  166. border-style: none;
  167. width: 100%;
  168. height: auto;
  169. border-radius: 16rpx;
  170. margin:40rpx 0 ;
  171. }
  172. .vHtml >>> p {
  173. margin-top: 30rpx;
  174. margin-bottom: 30rpx;
  175. }
  176. .vHtml >>> h1{
  177. margin-top: 30rpx;
  178. margin-bottom: 30rpx;
  179. }
  180. .videoBox{
  181. width: 710rpx;
  182. margin: 24rpx 0;
  183. }
  184. .linebox{
  185. width: 750rpx;
  186. height: 100rpx;
  187. border-bottom: 30rpx solid #EEEEEE;
  188. margin-left: -18rpx;
  189. }
  190. </style>