articleDetails.vue 2.1 KB

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