newsDetails.vue 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <template>
  2. <view class="news-details">
  3. <u-navbar back-text="" title="" back-icon-color="#FFFFFF" :background="{ background: '#3D5D4C' }" :border-bottom="false"></u-navbar>
  4. <view class="news-details-header">
  5. <view class="news-details-header-title">{{ newsInfo.artTitle }}</view>
  6. <view class="news-details-header-subtitle">
  7. <view>来源:{{ newsInfo.artAuthor }}</view>
  8. <view>{{ formatDate(newsInfo.createTime) }}</view>
  9. </view>
  10. </view>
  11. <view class="news-details-content">
  12. <u-parse :html="newsInfo.artContent"></u-parse>
  13. </view>
  14. <u-toast ref="uToast" />
  15. </view>
  16. </template>
  17. <script>
  18. export default{
  19. data(){
  20. return{
  21. newsInfo: ''
  22. }
  23. },
  24. onLoad(page){
  25. if (page.artId) {
  26. this.getDetails(page.artId)
  27. }
  28. },
  29. onShow(){
  30. },
  31. methods:{
  32. // 获取详情
  33. getDetails(id) {
  34. this.$u.api.getNewsDetails({ id }).then(res=>{
  35. if (res.code === 200) {
  36. this.newsInfo = res.data
  37. } else {
  38. this.$refs.uToast.show({
  39. title: res.msg,
  40. type: 'error'
  41. })
  42. }
  43. })
  44. .catch(err => {
  45. this.$refs.uToast.show({
  46. title: '操作失败!',
  47. type: 'error'
  48. })
  49. })
  50. },
  51. /**
  52. * 初始化日期 MM-dd hh:mm
  53. */
  54. formatDate(date) {
  55. let value;
  56. if (date) {
  57. value = this.$u.timeFormat(date.replace(/-/g, '/'), 'mm-dd hh:MM')
  58. }
  59. return value;
  60. }
  61. }
  62. }
  63. </script>
  64. <style lang="scss" scoped>
  65. // @import '@/static/css/quill.bubble.scss';
  66. // @import '@/static/css/quill.core.scss';
  67. // @import '@/static/css/quill.snow.scss';
  68. .news-details {
  69. padding: 30rpx 44rpx;
  70. font-family: 'PingFangSC-Regular, PingFang SC';
  71. &-header {
  72. border-bottom: solid 1px #DBDBDB;
  73. padding-bottom: 22rpx;
  74. &-title {
  75. color: #000;
  76. font-size: 40rpx;
  77. }
  78. &-subtitle {
  79. margin-top: 20rpx;
  80. display: flex;
  81. justify-content: space-between;
  82. color: #6F6F6F;
  83. font-size: 26rpx;
  84. }
  85. }
  86. &-content {
  87. padding: 18rpx 0;
  88. line-height: 50rpx;
  89. font-size: 28rpx;
  90. }
  91. }
  92. </style>