dynamicdetails.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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="aspectFill"></u--image>
  26. <view class="" v-html="swiperDetails.detail"></view>
  27. </view>
  28. <view v-else class="content-wrap">
  29. <u--image :src="pageData.mainImg" :showLoading="true" width="100%" mode="aspectFill"></u--image>
  30. <view class="content">
  31. {{pageData.content}}
  32. </view>
  33. </view>
  34. </view>
  35. </view>
  36. </template>
  37. <script>
  38. export default{
  39. data(){
  40. return{
  41. id:null,
  42. type:'',
  43. pageData:{
  44. title:'',
  45. content:''
  46. },
  47. swiperDetails:{},
  48. }
  49. },
  50. onLoad(page) {
  51. this.id = page.id;
  52. this.type = page.type;
  53. if(this.type=='swiperDetail'){
  54. console.log('this.id',this.id);
  55. this.getSwiperDetails(this.id);
  56. }else{
  57. this.getDetails(this.id);
  58. this.addViewCount(this.id);
  59. }
  60. },
  61. methods:{
  62. getDetails(id){
  63. this.$u.api.shopNews({id:id}).then(res=>{
  64. this.pageData = res.data;
  65. // console.log('res',res);
  66. }).catch(err=>{
  67. console.log('shopNews',err.data);
  68. })
  69. },
  70. getSwiperDetails(id){
  71. this.$u.api.swiperDetails({id:id}).then(res=>{
  72. this.swiperDetails = res.data;
  73. // console.log('res',res);
  74. }).catch(err=>{
  75. console.log('getSwiperDetails',err.data);
  76. })
  77. },
  78. addViewCount(id){
  79. this.$u.api.addViewCount({id:id}).then(res=>{
  80. // console.log('res',res);
  81. }).catch(err=>{
  82. console.log('addViewCount',err.data);
  83. })
  84. }
  85. }
  86. }
  87. </script>
  88. <style>
  89. page{background-color: #F5F5F5;}
  90. </style>
  91. <style lang="scss" scoped>
  92. .title{
  93. font-size: 36rpx;
  94. font-weight: 600;
  95. color: #333333;
  96. line-height: 50rpx;
  97. margin-bottom: 20rpx;
  98. }
  99. .info{
  100. margin-bottom: 50rpx;
  101. font-size: 24rpx;
  102. font-weight: 400;
  103. color: #999999;
  104. line-height: 33rpx;
  105. }
  106. .page-wrap{
  107. font-size: 26rpx;
  108. font-weight: 400;
  109. color: #666666;
  110. line-height: 44rpx;
  111. p{
  112. text-indent: 2em;
  113. }
  114. /deep/ .u-image{
  115. margin-bottom: 20rpx;
  116. }
  117. }
  118. .content{
  119. font-size: 26rpx;
  120. font-weight: 400;
  121. color: #666666;
  122. line-height: 44rpx;
  123. margin: 20rpx 0;
  124. }
  125. .u-image{
  126. max-width: 100%;
  127. }
  128. </style>