articleDetails.vue 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <template>
  2. <view style="background-color: #fff;">
  3. <u-navbar title="文章详情"></u-navbar>
  4. <view class="main">
  5. <view class="new-title">
  6. {{newsDetail.title}}
  7. </view>
  8. <view class="time">
  9. <view class="time-left">
  10. {{newsDetail.createTime}}
  11. </view>
  12. <view class="time-tight">
  13. <text class="iconfont">&#xe612;</text><text class="num">{{newsDetail.readNum}}</text>
  14. </view>
  15. </view>
  16. <view class="news-content" v-html="newsDetail.content"></view>
  17. </view>
  18. </view>
  19. </template>
  20. <script>
  21. import * as newsApi from '@/apis/news.js'
  22. export default {
  23. data() {
  24. return {
  25. id: '',
  26. newsDetail: '',
  27. }
  28. },
  29. onLoad(op) {
  30. this.id =op.id;
  31. this.getNewsInfoDetail();
  32. },
  33. methods: {
  34. getNewsInfoDetail() {
  35. uni.showLoading({
  36. title: "加载中",
  37. mask: true,
  38. })
  39. newsApi.newsInfoDetail(this.id).then((res) => {
  40. uni.hideLoading()
  41. this.newsDetail = res.data;
  42. this.$nextTick(()=>{
  43. var list =document.getElementsByClassName("news-content")[0].getElementsByTagName("img");
  44. for(var i=0;i<list.length;i++){
  45. list[i].style='width: 100%;height: 100%;'
  46. }
  47. })
  48. }).catch(error => {
  49. uni.showToast({
  50. title: error,
  51. icon: "none"
  52. })
  53. })
  54. }
  55. }
  56. }
  57. </script>
  58. <style lang="scss" scoped>
  59. .main{
  60. margin: 0px 16px ;
  61. padding-bottom: 34px;
  62. .new-title{
  63. color: #101010;
  64. font-size: 18px;
  65. height: 48px;
  66. margin: 16px 0 35px;
  67. }
  68. .time{
  69. display: flex;
  70. justify-content: space-between;
  71. color: #888888;
  72. .num{
  73. margin-left: 4px;
  74. }
  75. }
  76. .news-content{
  77. margin-top: 13px;
  78. font-size: 14px;
  79. line-height: 28px;
  80. color: #101010;
  81. }
  82. }
  83. </style>