article-detail.vue 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <template>
  2. <view>
  3. <view class="article">
  4. <view class="art_title">{{ article.title }}</view>
  5. <view style="display: flex;align-items: center;">
  6. <view class="recommend" v-if="article.recommended == 1">推荐</view>
  7. <view class="art_date gray">时间:{{ article.updated_at }}</view>
  8. </view>
  9. <view class="art_con" v-html="article.contents">{{ article.contents }}</view>
  10. </view>
  11. </view>
  12. </template>
  13. <script>
  14. import { GetArticleDetail } from '../../apis/commu.js';
  15. export default {
  16. data() {
  17. return {
  18. article: {}
  19. };
  20. },
  21. onLoad(ops) {
  22. if (ops) {
  23. this.getDetail(ops.id);
  24. }
  25. },
  26. // updated() {
  27. // document.getElementsByTagName('video').setAttribute('playsinline', true);
  28. // },
  29. methods: {
  30. //获取文章详情
  31. getDetail(id) {
  32. GetArticleDetail({ id }).then(res => {
  33. if (res.code == 200) {
  34. this.article = res.data;
  35. // console.log(this.article.contents);
  36. } else {
  37. uni.showModal({
  38. content: res.msg || '获取文章详情失败',
  39. showCancel: false
  40. });
  41. }
  42. });
  43. }
  44. }
  45. };
  46. </script>
  47. <style lang="scss" scoped>
  48. .article ::v-deep img {
  49. max-width: 100%;
  50. height: auto;
  51. }
  52. .art_con ::v-deep p {
  53. line-height: 2;
  54. margin-top:10rpx;
  55. }
  56. .art_con ::v-deep section {
  57. line-height: 60rpx;
  58. }
  59. .article {
  60. width: 690rpx;
  61. margin: 0 auto;
  62. padding-bottom: 50rpx;
  63. font-size: 28rpx;
  64. .recommend{
  65. width: 76rpx;
  66. line-height: 44rpx;
  67. text-align: center;
  68. background-color: #F8F8F8;
  69. color:#FB231F;
  70. font-size:28rpx;
  71. margin-right: 10rpx;
  72. }
  73. .art_title {
  74. font-size: 40rpx;
  75. font-weight: bold;
  76. margin-top: 30rpx;
  77. }
  78. .art_date {
  79. margin: 30rpx 0;
  80. }
  81. }
  82. </style>