articleDetails.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <template>
  2. <view style="background-color: #fff;">
  3. <u-navbar title="文章详情" :title-size="elderStatus ? 40 : 35"></u-navbar>
  4. <view class="main">
  5. <view class="new-title oldTextjp" oldstyle="font-size: 22px;">
  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. elderStatus: false,
  28. myFontSize: 0,
  29. }
  30. },
  31. onLoad(op) {
  32. if (this.carhelp.getPersonInfo()) {
  33. if(this.carhelp.get("getElderModeClass") == "长辈模式") {
  34. this.elderStatus = true;
  35. } else {
  36. this.elderStatus = false;
  37. }
  38. }
  39. this.id =op.id;
  40. this.getNewsInfoDetail();
  41. },
  42. methods: {
  43. getNewsInfoDetail() {
  44. uni.showLoading({
  45. title: "加载中",
  46. mask: true,
  47. })
  48. newsApi.newsInfoDetail(this.id).then((res) => {
  49. uni.hideLoading()
  50. this.newsDetail = res.data;
  51. if(this.elderStatus) {
  52. this.myFontSize=16;
  53. this.newsDetail.content=this.newsDetail.content.replaceAll("font-size","font-size:"+this.myFontSize+"px;");
  54. }
  55. this.$nextTick(()=>{
  56. var list =document.getElementsByClassName("news-content")[0].getElementsByTagName("img");
  57. for(var i=0;i<list.length;i++){
  58. list[i].style='width: 100%;height: 100%;'
  59. }
  60. })
  61. }).catch(error => {
  62. uni.showToast({
  63. title: error,
  64. icon: "none"
  65. })
  66. })
  67. }
  68. }
  69. }
  70. </script>
  71. <style lang="scss" scoped>
  72. .main{
  73. margin: 0px 16px ;
  74. padding-bottom: 34px;
  75. .new-title{
  76. color: #101010;
  77. font-size: 18px;
  78. height: 48px;
  79. margin: 16px 0 35px;
  80. }
  81. .time{
  82. display: flex;
  83. justify-content: space-between;
  84. color: #888888;
  85. .num{
  86. margin-left: 4px;
  87. }
  88. }
  89. .news-content{
  90. margin-top: 13px;
  91. font-size: 14px;
  92. line-height: 28px;
  93. color: #101010;
  94. }
  95. }
  96. </style>