newsdetails.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <template>
  2. <view class="pages">
  3. <view class="" :style="{height: navHeight+'px' }"></view>
  4. <view class="navbar-box">
  5. <u-navbar title="资讯详情" :safeAreaInsetTop="true" @leftClick="leftClick" :titleStyle="{color:'#000'}" leftIconColor="#000" bgColor="transparent"></u-navbar>
  6. </view>
  7. <view class="banner">
  8. <image class="img" :src="details.mainImg||staticUrl+'/img/newsdetails-banner.png'" alt="">
  9. </view>
  10. <view class="content-wrap">
  11. <view class="title">{{details.title}}</view>
  12. <view class="time">{{ $u.timeFormat(details.onlineTime, 'yyyy-mm-dd') }}</view>
  13. <view class="centent parse-content">
  14. <u-parse :content="details.centent"></u-parse>
  15. </view>
  16. </view>
  17. </view>
  18. </template>
  19. <script>
  20. import { systemInfo } from "@/mixin.js";
  21. export default {
  22. mixins:[systemInfo],
  23. data() {
  24. return {
  25. staticUrl:this.$commonConfig.staticUrl,
  26. id:'',
  27. details:{},
  28. }
  29. },
  30. onShow() {
  31. },
  32. onLoad(page) {
  33. let that = this;
  34. this.getSystemInfo();
  35. this.id = page.id;
  36. this.type = page.type;
  37. if(this.type=='swiperDetail'){
  38. // console.log('this.id',this.id);
  39. this.getSwiperDetails(this.id);
  40. }else{
  41. this.getDetails(this.id);
  42. setTimeout(()=>{
  43. that.addReadRecord()
  44. },2000);
  45. }
  46. // this.getDetails();
  47. },
  48. methods: {
  49. leftClick(e){
  50. let pages = getCurrentPages();
  51. if(pages.length==1){
  52. uni.$u.route('/pages/index/index')
  53. }else{
  54. uni.navigateBack()
  55. };
  56. },
  57. getSwiperDetails(id){
  58. this.$u.api.swiperDetails({id:id}).then(res=>{
  59. this.swiperDetails = res.data;
  60. // console.log('res',res);
  61. }).catch(err=>{
  62. console.log('getSwiperDetails',err.data);
  63. })
  64. },
  65. getDetails(){
  66. this.$u.api.newsdetails({id:this.id}).then(res=>{
  67. this.details = res.data;
  68. // console.log('res',res.data);
  69. }).catch(err=>{
  70. console.log('getDetails',err);
  71. })
  72. },
  73. addReadRecord(){
  74. this.$u.api.addReadRecord({keyId:this.id, accessedPage: "小程序",remark:'资讯浏览'},{custom:{noload:true}}).then(res=>{
  75. // console.log('res',res.data);
  76. }).catch(err=>{
  77. console.log('getDetails',err);
  78. })
  79. }
  80. }
  81. }
  82. </script>
  83. <style lang="scss" scoped>
  84. .banner{
  85. .img{
  86. display: block;
  87. width: 100%;
  88. height: 400rpx;
  89. }
  90. }
  91. .content-wrap{
  92. padding: 65rpx 32rpx;
  93. background: #FFFFFF;
  94. border-radius: 20rpx 20rpx 0rpx 0rpx;
  95. transform: translateY(-20rpx);
  96. .title{
  97. font-size: 32rpx;
  98. font-weight: bold;
  99. color: #333333;
  100. // line-height: 22rpx;
  101. margin-bottom: 30rpx;
  102. }
  103. .time{
  104. font-size: 24rpx;
  105. font-weight: 400;
  106. color: #C0C0C0;
  107. line-height: 22rpx;
  108. margin-bottom: 40rpx;
  109. }
  110. .centent{
  111. font-size: 28rpx;
  112. font-weight: 400;
  113. color: #6B6B6B;
  114. line-height: 44rpx;
  115. img,image{
  116. width: 100%;
  117. display: block;
  118. margin: 10rpx auto;
  119. }
  120. }
  121. }
  122. </style>