details.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <template>
  2. <view class="d-flex flex-column bg-base pb-45">
  3. <SimplePageContentLoader :loader="loader">
  4. <template v-if="loader.content.value">
  5. <view class="d-flex flex-col">
  6. <swiper
  7. v-if="loader.content.value.images.length > 0"
  8. circular
  9. :indicator-dots="true"
  10. :autoplay="true"
  11. :interval="3000"
  12. :duration="1000"
  13. class="height-500"
  14. >
  15. <swiper-item v-for="(item, key) in loader.content.value.images" :key="key">
  16. <view class="item">
  17. <image
  18. :src="item"
  19. class="w-100 height-500 radius-base"
  20. mode="aspectFill"
  21. @click="onPreviewImage(key)"
  22. />
  23. </view>
  24. </swiper-item>
  25. </swiper>
  26. <image
  27. v-else-if="loader.content.value.image"
  28. class="w-100 radius-base"
  29. :src="loader.content.value.image"
  30. mode="widthFix"
  31. />
  32. <view class="d-flex flex-col p-3">
  33. <view class="size-ll color-title-text">{{ loader.content.value.title }}</view>
  34. <view class="d-flex flex-row mt-2">
  35. <text class="size-s color-text-content-second">{{ loader.content.value.author }}</text>
  36. <text class="size-s color-text-content-second">{{ DataDateUtils.formatDate(loader.content.value.publishAt, 'YYYY-MM-dd HH:ii:ss') }}</text>
  37. </view>
  38. </view>
  39. <view class="p-3 radius-ll bg-light mt-3">
  40. <u-parse
  41. v-if="loader.content.value.content"
  42. :content="loader.content.value.content"
  43. :tagStyle="commonParserStyle"
  44. ></u-parse>
  45. </view>
  46. <ContentNote />
  47. </view>
  48. <view class="bottom-actions">
  49. <view class="action">
  50. <text class="iconfont icon-read"></text>
  51. {{ loader.content.value.views }}
  52. </view>
  53. <view class="action">
  54. <text class="iconfont icon-like" v-if="!loader.content.value.isLike"></text>
  55. <text class="iconfont icon-liked" v-else></text>
  56. {{ loader.content.value.likes }}
  57. </view>
  58. </view>
  59. </template>
  60. </SimplePageContentLoader>
  61. </view>
  62. </template>
  63. <script setup lang="ts">
  64. import type { GetContentDetailItem } from "@/api/CommonContent";
  65. import { useSimplePageContentLoader } from "@/common/composeabe/SimplePageContentLoader";
  66. import { DataDateUtils } from "@imengyu/js-request-transform";
  67. import { useLoadQuerys } from "@/common/composeabe/LoadQuerys";
  68. import NewsIndexContent from "@/api/news/NewsIndexContent";
  69. import commonParserStyle from "@/common/style/commonParserStyle";
  70. import SimplePageContentLoader from "@/common/components/SimplePageContentLoader.vue";
  71. import { useSwiperImagePreview } from "@/common/composeabe/SwiperImagePreview";
  72. import ContentNote from "../parts/ContentNote.vue";
  73. const loader = useSimplePageContentLoader<
  74. GetContentDetailItem,
  75. { id: number }
  76. >(async (params) => {
  77. if (!params)
  78. throw new Error("!params");
  79. const res = await NewsIndexContent.getContentDetail(params.id);
  80. //console.log(res);
  81. uni.setNavigationBarTitle({ title: res.title });
  82. return res;
  83. });
  84. const { onPreviewImage } = useSwiperImagePreview(() => loader.content.value?.images || [])
  85. useLoadQuerys({ id : 0, }, (p) => loader.loadData(p));
  86. </script>
  87. <style lang="scss" scoped>
  88. .bottom-actions {
  89. position: fixed;
  90. bottom: 0;
  91. left: 0;
  92. right: 0;
  93. display: flex;
  94. align-items: center;
  95. justify-content: flex-end;
  96. width: 100%;
  97. height: 75rpx;
  98. background: #FFFFFF;
  99. .action {
  100. margin-left: 48rpx;
  101. font-weight: 800;
  102. font-size: 24rpx;
  103. color: #191919;
  104. display: flex;
  105. align-items: center;
  106. &:last-child {
  107. margin-right: 70rpx;
  108. }
  109. .iconfont {
  110. font-size: 30rpx;
  111. margin-right: 14rpx;
  112. }
  113. .iconfont.icon-liked {
  114. color: #FF8719;
  115. }
  116. }
  117. }
  118. </style>