dynamicdetails.vue 2.9 KB

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