newsdetails.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <template>
  2. <view class="">
  3. <u-navbar
  4. title="详情"
  5. :placeholder="true"
  6. :autoBack="true"
  7. :safeAreaInsetTop="true"
  8. >
  9. </u-navbar>
  10. <view class="page-wrap">
  11. <view class="base-info" v-if="type=='swiperDetail'">
  12. <view class="title">{{swiperDetails.name}}</view>
  13. <view class="info u-flex u-row-between">
  14. <view class="time">{{swiperDetails.publicTime}}</view>
  15. <!-- <view class="view-count">{{swiperDetails.viewCount}}</view> -->
  16. </view>
  17. </view>
  18. <view v-else class="base-info">
  19. <view class="title">{{pageData.title}}</view>
  20. <view class="info u-flex u-row-between">
  21. <view class="time">{{pageData.publicTime}}</view>
  22. <view class="view-count">浏览量:{{pageData.viewCount}}</view>
  23. </view>
  24. </view>
  25. <view class="" v-if="type=='swiperDetail'">
  26. <u--image :src="swiperDetails.sliderImg" :showLoading="true" width="100%" mode="aspectFit"></u--image>
  27. <!-- <view class="" v-html="swiperDetails.detail"></view> -->
  28. <u-parse :content="swiperDetails.detail"></u-parse>
  29. </view>
  30. <view v-else class="content-wrap">
  31. <u--image :src="pageData.mainImg" :showLoading="true" width="100%" mode="aspectFit"></u--image>
  32. <view class="content">
  33. <u-parse :content="pageData.content"></u-parse>
  34. <!-- {{pageData.content}} -->
  35. </view>
  36. </view>
  37. </view>
  38. </view>
  39. </template>
  40. <script>
  41. export default{
  42. data(){
  43. return{
  44. id:null,
  45. type:'',
  46. pageData:{
  47. title:'',
  48. content:''
  49. },
  50. swiperDetails:{},
  51. }
  52. },
  53. onLoad(page) {
  54. this.id = page.id;
  55. this.type = page.type;
  56. if(this.type=='swiperDetail'){
  57. console.log('this.id',this.id);
  58. this.getSwiperDetails(this.id);
  59. }else{
  60. this.getDetails(this.id);
  61. this.addViewCount(this.id);
  62. }
  63. },
  64. methods:{
  65. getDetails(id){
  66. this.$u.api.shopNews({id:id}).then(res=>{
  67. this.pageData = res.data;
  68. // console.log('res',res);
  69. }).catch(err=>{
  70. console.log('shopNews',err.data);
  71. })
  72. },
  73. getSwiperDetails(id){
  74. this.$u.api.swiperDetails({id:id}).then(res=>{
  75. this.swiperDetails = res.data;
  76. // console.log('res',res);
  77. }).catch(err=>{
  78. console.log('getSwiperDetails',err.data);
  79. })
  80. },
  81. addViewCount(id){
  82. this.$u.api.addViewCount({id:id}).then(res=>{
  83. // console.log('res',res);
  84. }).catch(err=>{
  85. console.log('addViewCount',err.data);
  86. })
  87. }
  88. }
  89. }
  90. </script>
  91. <style>
  92. page{background-color: #F5F5F5;}
  93. </style>
  94. <style lang="scss" scoped>
  95. .title{
  96. font-size: 36rpx;
  97. font-weight: 600;
  98. color: #333333;
  99. line-height: 50rpx;
  100. margin-bottom: 20rpx;
  101. }
  102. .info{
  103. margin-bottom: 50rpx;
  104. font-size: 24rpx;
  105. font-weight: 400;
  106. color: #999999;
  107. line-height: 33rpx;
  108. }
  109. .page-wrap{
  110. font-size: 26rpx;
  111. font-weight: 400;
  112. color: #666666;
  113. line-height: 44rpx;
  114. p{
  115. text-indent: 2em;
  116. }
  117. /deep/ .u-image{
  118. margin-bottom: 20rpx;
  119. }
  120. }
  121. .content{
  122. font-size: 26rpx;
  123. font-weight: 400;
  124. color: #666666;
  125. line-height: 44rpx;
  126. margin: 20rpx 0;
  127. }
  128. .u-image{
  129. max-width: 100%;
  130. }
  131. </style>