articleDetails.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <template>
  2. <view style="background-color: #fff;">
  3. <ujp-navbar title="文章详情"></ujp-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. var key1="font-size"
  52. var key2="font-size:"+this.myFontSize+"px ; "
  53. var reg=new RegExp(key1,'gi')
  54. var content=this.newsDetail.content.replace(reg,key2)
  55. this.newsDetail.content=content;
  56. }
  57. this.$nextTick(()=>{
  58. var list =document.getElementsByClassName("news-content")[0].getElementsByTagName("img");
  59. for(var i=0;i<list.length;i++){
  60. list[i].style='width: 100%;height: 100%;'
  61. }
  62. })
  63. }).catch(error => {
  64. uni.showToast({
  65. title: error,
  66. icon: "none"
  67. })
  68. })
  69. }
  70. }
  71. }
  72. </script>
  73. <style lang="scss" scoped>
  74. .main{
  75. margin: 0px 16px ;
  76. padding-bottom: 34px;
  77. .new-title{
  78. color: #101010;
  79. font-size: 18px;
  80. height: 48px;
  81. margin: 16px 0 35px;
  82. }
  83. .time{
  84. display: flex;
  85. justify-content: space-between;
  86. color: #888888;
  87. .num{
  88. margin-left: 4px;
  89. }
  90. }
  91. .news-content{
  92. // margin-top: 13px;
  93. // font-size: 14px;
  94. padding-top: 8rpx;
  95. ::v-deepimg{
  96. margin: -6rpx auto;
  97. }
  98. // color: #101010;
  99. }
  100. }
  101. </style>