article.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <template>
  2. <view class="center">
  3. <view class="bg">
  4. <image :src="src" mode=""></image>
  5. </view>
  6. <view class="title">
  7. {{ title }}
  8. </view>
  9. <view class="main flex">
  10. <view class="">{{ author }}</view>
  11. <view class="" style="color: #e7e7e8;"><span>{{time}}</span></view>
  12. </view>
  13. <view v-html="content" class="content">
  14. {{ content }}
  15. </view>
  16. </view>
  17. </template>
  18. <script>
  19. import { details } from '@/api/index.js';
  20. import { mapState, mapMutations } from 'vuex';
  21. import { getTime } from '@/utils/rocessor.js'
  22. export default {
  23. data(){
  24. return{
  25. src: '',
  26. title: '',
  27. content:'',
  28. time:'',
  29. author:'',
  30. visit:''
  31. }
  32. },
  33. computed: {
  34. ...mapState(['baseURL']),
  35. },
  36. onLoad(option) {
  37. uni.setNavigationBarTitle({
  38. title:this.$t('foo.tgxq')
  39. })
  40. this.loadData(option.id);
  41. },
  42. methods: {
  43. async loadData(id){
  44. let obj = this;
  45. details({},id).then(e =>{
  46. console.log(e);
  47. let time = getTime(e.data.updatetime)
  48. obj.src = this.baseURL + e.data.coverimage;
  49. obj.title = e.data.title;
  50. obj.content = e.data.content
  51. obj.time = time;
  52. obj.author = e.data.author;
  53. obj.visit = e.data.visit;
  54. })
  55. }
  56. }
  57. }
  58. </script>
  59. <style lang="scss">
  60. .center{
  61. height: 100%;
  62. }
  63. .bg{
  64. width: 100%;
  65. height: 474rpx;
  66. image{
  67. width: 100%;
  68. height: 100%;
  69. }
  70. }
  71. .main {
  72. margin: 20rpx 50rpx;
  73. font-size: 24rpx;
  74. color: #fff;
  75. span {
  76. display: inline-block;
  77. padding-right: 20rpx;
  78. }
  79. }
  80. .title{
  81. width: 90%;
  82. margin: 20rpx auto 0;
  83. font-size: 40rpx;
  84. font-weight: 500;
  85. color: #ffffff;
  86. text-overflow: -o-ellipsis-lastline;
  87. overflow: hidden;
  88. display: -webkit-box;
  89. -webkit-line-clamp: 2;
  90. -webkit-box-orient: vertical;
  91. }
  92. .time {
  93. width: 90%;
  94. margin: 0 auto;
  95. margin-top: 16rpx;
  96. font-size: 24rpx;
  97. font-weight: 500;
  98. color: #ffffff;
  99. }
  100. .content{
  101. width: 90%;
  102. margin:0 auto;
  103. margin-top: 20rpx;
  104. font-size: 32rpx;
  105. font-weight: 500;
  106. color:#777777;
  107. }
  108. /deep/ .content{
  109. img{
  110. width: 100%;
  111. height: 100%;
  112. }
  113. }
  114. </style>