newsDetails.vue 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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 }).then(res=>{
  34. if (res.code === 200) {
  35. this.newsInfo = res.data
  36. } else {
  37. this.$refs.uToast.show({
  38. title: res.msg,
  39. type: 'error'
  40. })
  41. }
  42. })
  43. .catch(err => {
  44. this.$refs.uToast.show({
  45. title: '操作失败!',
  46. type: 'error'
  47. })
  48. })
  49. },
  50. /**
  51. * 初始化日期 MM-dd hh:mm
  52. */
  53. formatDate(date) {
  54. let value;
  55. if (date) {
  56. value = this.$u.timeFormat(date.replace(/-/g, '/'), 'mm-dd hh:MM')
  57. }
  58. return value;
  59. }
  60. }
  61. }
  62. </script>
  63. <style lang="scss" scoped>
  64. // @import '@/static/css/quill.bubble.scss';
  65. // @import '@/static/css/quill.core.scss';
  66. // @import '@/static/css/quill.snow.scss';
  67. .news-details {
  68. padding: 30rpx 44rpx;
  69. font-family: 'PingFangSC-Regular, PingFang SC';
  70. &-header {
  71. border-bottom: solid 1px #DBDBDB;
  72. padding-bottom: 22rpx;
  73. &-title {
  74. color: #000;
  75. font-size: 40rpx;
  76. }
  77. &-subtitle {
  78. margin-top: 20rpx;
  79. display: flex;
  80. justify-content: space-between;
  81. color: #6F6F6F;
  82. font-size: 26rpx;
  83. }
  84. }
  85. &-content {
  86. padding: 18rpx 0;
  87. line-height: 50rpx;
  88. font-size: 28rpx;
  89. }
  90. }
  91. </style>