news-info.vue 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <template>
  2. <view class="news-info">
  3. <web-view v-if="detail.url" :src="detail.url"></web-view>
  4. <view v-if="detail.id && !detail.url">
  5. <view class="news-title">
  6. {{detail.title}}
  7. </view>
  8. <view class="u-flex news-header">
  9. <image :src="detail.head_image" class="head" mode=""></image>
  10. <text class="name">{{detail.source}} {{detail.create_at}} 发表于{{detail.publish}}</text>
  11. </view>
  12. <u-parse :html="detail.content" :show-with-animation="true" :lazy-load="true"></u-parse>
  13. <!-- <view class="" v-html="detail.content"></view> -->
  14. </view>
  15. </view>
  16. </template>
  17. <script>
  18. export default {
  19. data() {
  20. return {
  21. id: '',
  22. detail: {}
  23. }
  24. },
  25. onLoad(option) {
  26. this.id = option.id
  27. this.getdata()
  28. },
  29. methods: {
  30. getdata() {
  31. this.$u.post('/api/Headline/headline_detail', {
  32. id: this.id
  33. }).then(res => {
  34. this.detail = res.data
  35. const regex = new RegExp('<img', 'gi')
  36. this.detail.content = res.data.content.replace(regex, `<img style="max-width: 100%; height: auto"`)
  37. })
  38. }
  39. }
  40. }
  41. </script>
  42. <style lang="scss">
  43. .news-info {
  44. padding: 24rpx;
  45. .news-header {
  46. margin-bottom: 40rpx;
  47. .head {
  48. width: 36rpx;
  49. height: 36rpx;
  50. border-radius: 100rpx;
  51. margin-right: 10rpx;
  52. }
  53. .name {
  54. font-size: 28rpx;
  55. font-family: PingFangSC-Regular, PingFang SC;
  56. font-weight: 400;
  57. color: #999999;
  58. }
  59. }
  60. .news-title {
  61. font-size: 36rpx;
  62. font-family: PingFangSC-Medium, PingFang SC;
  63. font-weight: 500;
  64. color: #333333;
  65. margin-bottom: 24rpx;
  66. }
  67. }
  68. </style>