detalis.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. <template>
  2. <view>
  3. <u-navbar ></u-navbar>
  4. <view class="article">
  5. <view class="article-tit" v-text="detail.title">
  6. </view>
  7. <view class="article-row">
  8. <view class="article-time" v-text="detail.createTime" ></view>
  9. <view class="article-see">
  10. <u-icon custom-prefix="custom-icon" name="eye-line"></u-icon>
  11. <span v-text="detail.visitorsNum"> </span>
  12. </view>
  13. </view>
  14. <view class="article-con" v-html="detail.content" :style="{fontSize:myFontSize+'px'}">
  15. </view>
  16. <view class="article-foot">
  17. <view class="u-flex">
  18. <view class="article-btn" @click="fontSizeUp1()">
  19. <u-icon custom-prefix="custom-icon" name="zoom-in-line"></u-icon>
  20. <span>放大</span>
  21. </view>
  22. <view class="article-btn" @click="fontSizeDown2()">
  23. <u-icon custom-prefix="custom-icon" name="zoom-out-line"></u-icon>
  24. <span>缩小</span>
  25. </view>
  26. </view>
  27. <view class="article-btn" @click="scrollTop()">
  28. <u-icon custom-prefix="custom-icon" name="align-top"></u-icon>
  29. <span>回顶</span>
  30. </view>
  31. </view>
  32. </view>
  33. </view>
  34. </template>
  35. <script>
  36. import * as API from '@/apis/news.js'
  37. export default {
  38. data() {
  39. return {
  40. myFontSize:14,
  41. pageTitle: '文章详情',
  42. isLoading: false,
  43. id: '',
  44. detail: {
  45. title:"",
  46. createTime:"",
  47. visitorsNum:"",
  48. content:"",
  49. },
  50. }
  51. },
  52. onLoad(op) {
  53. this.id =op.id;
  54. this.getDetail();
  55. var myFontSize=this.carhelp.get("news-info-fontsize")
  56. if(myFontSize){
  57. this.myFontSize=myFontSize
  58. }
  59. },
  60. methods: {
  61. fontSizeUp1(){
  62. if(this.myFontSize>=28){
  63. uni.showToast({
  64. title: "当前已为最大字体"
  65. })
  66. return
  67. }
  68. this.myFontSize=this.myFontSize+2
  69. this.carhelp.set("news-info-fontsize",this.myFontSize)
  70. },
  71. fontSizeDown2(){
  72. if(this.myFontSize<=12){
  73. uni.showToast({
  74. title: "当前已为最小字体"
  75. })
  76. return
  77. }
  78. this.myFontSize=this.myFontSize-2
  79. this.carhelp.set("news-info-fontsize",this.myFontSize)
  80. },
  81. scrollTop(){
  82. uni.pageScrollTo({
  83. scrollTop: 0,
  84. duration: 300
  85. })
  86. },
  87. getDetail() {
  88. uni.showLoading({
  89. title: "加载中",
  90. mask: true,
  91. })
  92. API.newsdetail({id:this.id}).then(response => {
  93. this.detail = response.data;
  94. uni.hideLoading()
  95. }).catch(error => {
  96. uni.showToast({
  97. title: error,icon: "none"
  98. })
  99. })
  100. },
  101. }
  102. }
  103. </script>
  104. <style lang="scss" scoped>
  105. .article{
  106. padding: 15px;
  107. .article-tit{
  108. font-size: 20px;
  109. margin-bottom:10px;
  110. }
  111. .article-row{
  112. display: flex;
  113. justify-content: space-between;
  114. align-items: center;
  115. color: #888;
  116. font-size: 12px;
  117. border-bottom: 1px solid #F1F1F1;
  118. padding-bottom: 15px;
  119. .article-time{}
  120. .article-see{
  121. span{
  122. margin-left:3px;
  123. }
  124. }
  125. }
  126. .article-con{
  127. padding: 15px 0 35px;
  128. font-size: 14px;
  129. line-height: 28px;
  130. img{
  131. width: 100%;
  132. margin: 10px 0;
  133. }
  134. }
  135. .article-foot{
  136. height: 50px;
  137. position:fixed;
  138. left: 0;
  139. right: 0;
  140. bottom: 0;
  141. background-color: #fff;
  142. border-top: 1px solid #f7f7f7;
  143. display: flex;
  144. justify-content: space-between;
  145. align-items: center;
  146. padding:0 15px;
  147. .article-btn{
  148. background: #E5E7EA;
  149. padding:6px 10px;
  150. color: #606875;
  151. border-radius: 8px;
  152. span{
  153. margin-left: 3px;
  154. }
  155. }
  156. .u-flex .article-btn{
  157. margin-right: 10px;
  158. }
  159. }
  160. }
  161. </style>