newsDetails.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <template>
  2. <view class="news-details">
  3. <view class="news-details-header">
  4. <view class="news-details-header-title">{{ newsInfo.artTitle }}</view>
  5. <view class="news-details-header-subtitle">
  6. <view>来源:{{ newsInfo.artAuthor }}</view>
  7. <view>{{ formatDate(newsInfo.createTime) }}</view>
  8. </view>
  9. </view>
  10. <view class="news-details-content">
  11. <u-parse :html="newsInfo.artContent"></u-parse>
  12. </view>
  13. <u-toast ref="uToast" />
  14. </view>
  15. </template>
  16. <script>
  17. export default{
  18. data(){
  19. return{
  20. newsInfo: ''
  21. }
  22. },
  23. onLoad(page){
  24. if (page.artId) {
  25. this.getDetails(page.artId)
  26. }
  27. },
  28. onShow(){
  29. },
  30. methods:{
  31. // 获取详情
  32. getDetails(id) {
  33. this.$u.api.getNewsDetails({ id: id })
  34. .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: 36rpx;
  77. }
  78. &-subtitle {
  79. margin-top: 20rpx;
  80. display: flex;
  81. justify-content: space-between;
  82. color: #6F6F6F;
  83. font-size: 20rpx;
  84. }
  85. }
  86. &-content {
  87. padding: 18rpx 0;
  88. }
  89. }
  90. </style>