newsdetails.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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">
  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.getDetails();
  37. setTimeout(()=>{
  38. that.addReadRecord()
  39. },2000);
  40. },
  41. methods: {
  42. leftClick(e){
  43. let pages = getCurrentPages();
  44. if(pages.length==1){
  45. uni.$u.route('/pages/index/index')
  46. }else{
  47. uni.navigateBack()
  48. };
  49. },
  50. getDetails(){
  51. this.$u.api.newsdetails({id:this.id}).then(res=>{
  52. this.details = res.data;
  53. // console.log('res',res.data);
  54. }).catch(err=>{
  55. console.log('getDetails',err);
  56. })
  57. },
  58. addReadRecord(){
  59. this.$u.api.addReadRecord({keyId:this.id, accessedPage: "小程序",remark:'资讯浏览'},{custom:{noload:true}}).then(res=>{
  60. // console.log('res',res.data);
  61. }).catch(err=>{
  62. console.log('getDetails',err);
  63. })
  64. }
  65. }
  66. }
  67. </script>
  68. <style lang="scss" scoped>
  69. .banner{
  70. .img{
  71. display: block;
  72. width: 100%;
  73. height: 400rpx;
  74. }
  75. }
  76. .content-wrap{
  77. padding: 65rpx 32rpx;
  78. background: #FFFFFF;
  79. border-radius: 20rpx 20rpx 0rpx 0rpx;
  80. transform: translateY(-20rpx);
  81. .title{
  82. font-size: 32rpx;
  83. font-weight: bold;
  84. color: #333333;
  85. line-height: 22rpx;
  86. margin-bottom: 30rpx;
  87. }
  88. .time{
  89. font-size: 24rpx;
  90. font-weight: 400;
  91. color: #C0C0C0;
  92. line-height: 22rpx;
  93. margin-bottom: 40rpx;
  94. }
  95. .centent{
  96. font-size: 28rpx;
  97. font-weight: 400;
  98. color: #6B6B6B;
  99. line-height: 44rpx;
  100. img,image{
  101. width: 100%;
  102. display: block;
  103. margin: 10rpx auto;
  104. }
  105. }
  106. }
  107. </style>