detail.vue 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <template>
  2. <view class="detail">
  3. <view class="article-tit">
  4. {{article.title}}
  5. </view>
  6. <view class="article-time" v-if="loaded">
  7. {{article.release_time}} | <text style="color: #c7455a;" @click="navTo(article.cid)">{{ ' ' + (article.cart_name || '')}}</text>
  8. </view>
  9. <view class="article-content" v-html="article.content">
  10. </view>
  11. </view>
  12. </template>
  13. <script>
  14. import { getDetail } from '../../api/index.js'
  15. export default {
  16. data() {
  17. return {
  18. articleId: '',
  19. article: {},
  20. loaded: false
  21. }
  22. },
  23. onLoad(opt) {
  24. console.log(opt)
  25. if(opt.id) {
  26. this.articleId = opt.id
  27. }
  28. this.getDetail()
  29. },
  30. methods: {
  31. navTo(cid) {
  32. let url = ''
  33. if(cid !=6 && cid != 14 && cid == 15 && cid == 16) {
  34. url = '/pages/article/list?cid=' + cid
  35. }else {
  36. url = '/pages/article/lists?cid=' + cid
  37. }
  38. uni.navigateTo({
  39. url: url
  40. })
  41. },
  42. getDetail() {
  43. let obj = this
  44. getDetail({},obj.articleId).then( ({data}) => {
  45. obj.article = data
  46. obj.article.content = obj.article.content.replace(/\<img/gi, '<img class="rich-img"');
  47. obj.loaded = true
  48. })
  49. }
  50. }
  51. }
  52. </script>
  53. <style lang="scss" scoped>
  54. page {
  55. background-color: #fff;
  56. height: 100%;
  57. }
  58. .detail {
  59. padding:0 20rpx;
  60. }
  61. /deep/ .rich-img {
  62. max-width: 100% !important;
  63. height: auto;
  64. }
  65. .article-tit {
  66. font-size: 32rpx;
  67. line-height: 1.5;
  68. padding: 40rpx 0 20rpx;
  69. }
  70. .article-time {
  71. padding-bottom: 35rpx;
  72. color: #b6b6b6;
  73. }
  74. .article-content {
  75. letter-spacing: 2rpx;
  76. }
  77. </style>