storyDetail.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <template>
  2. <view class="content" >
  3. <template v-if="detail">
  4. <view class="top">
  5. <image :src="detail.image_input[0]" mode=""></image>
  6. </view>
  7. <view class="detail">
  8. <view class="detail-top">
  9. <view class="tit">
  10. {{detail.title}}
  11. </view>
  12. <view class="time">
  13. 更新时间: {{detail.add_time}}
  14. </view>
  15. </view>
  16. <view class="jg">
  17. </view>
  18. <view class="detail-content" v-html="detail.content">
  19. </view>
  20. </view>
  21. </template>
  22. </view>
  23. </template>
  24. <script>
  25. import {article,details} from '@/api/index.js'
  26. export default {
  27. data() {
  28. return {
  29. content: '',
  30. detail: '',
  31. }
  32. },
  33. onLoad(opt) {
  34. if(opt.id) {
  35. this.getDetail(opt.id)
  36. }
  37. },
  38. methods: {
  39. getDetail(id) {
  40. let obj = this
  41. uni.showLoading({
  42. title: '加载中...'
  43. })
  44. details({},id).then( ({data}) => {
  45. uni.hideLoading()
  46. console.log(data)
  47. data.content = data.content.replace(/\<img/gi, '<img class="rich-img"')
  48. this.detail = data
  49. // obj.content = res.data.content
  50. // obj.detail = res.data
  51. }).catch(err => {
  52. console.log(err)
  53. })
  54. }
  55. }
  56. }
  57. </script>
  58. <style lang="scss" scoped>
  59. page {
  60. height: 100%;
  61. }
  62. .content {
  63. background-color: #fff;
  64. height: 100%;
  65. .top {
  66. width: 750rpx;
  67. height: 668rpx;
  68. image {
  69. width: 100%;
  70. height: 100%;
  71. background-color: #999;
  72. }
  73. }
  74. .detail {
  75. position: relative;
  76. top: -57rpx;
  77. .jg {
  78. width: 670rpx;
  79. height: 2rpx;
  80. background: #F5F5F5;
  81. margin: auto;
  82. }
  83. .detail-top {
  84. min-height: 190rpx;
  85. padding: 57rpx 40rpx 40rpx;
  86. background-color: #fff;
  87. border-radius: 30rpx 30rpx 0 0;
  88. .tit {
  89. font-size: 48rpx;
  90. font-family: PingFang SC;
  91. font-weight: 500;
  92. color: #333333;
  93. line-height: 51rpx;
  94. }
  95. .time {
  96. padding-top: 10rpx;
  97. font-size: 26rpx;
  98. font-family: PingFang SC;
  99. font-weight: 500;
  100. color: #999;
  101. line-height: 51rpx;
  102. }
  103. }
  104. .detail-content {
  105. font-size: 28rpx;
  106. font-family: PingFang SC;
  107. font-weight: 500;
  108. color: #333333;
  109. line-height: 48rpx;
  110. padding: 37rpx 40rpx;
  111. width: 750rpx;
  112. }
  113. }
  114. }
  115. /deep/ .detail-content {
  116. img{
  117. width: 100%;
  118. height: 100%;
  119. }
  120. table {
  121. width: 100%;
  122. height: 100%;
  123. }
  124. }
  125. .rich-img {
  126. width: 100% !important;
  127. }
  128. </style>