notice.uvue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <script setup lang='ts'>
  2. import { onMounted, ref, onUnmounted } from 'vue'
  3. import { type AppUpdateNoticePageResult, type AppUpdateNoticeResult, getAppUpdateNoticePage, fetchAppUpdateNotice } from '@/services/subject/notice'
  4. import { user, parse } from '@/.cool'
  5. const recordList = ref<UTSJSONObject[]>([])
  6. const record = ref<UTSJSONObject>({})
  7. const notice = ref<UTSJSONObject>({})
  8. async function handleDetail(item: UTSJSONObject) {
  9. record.value = item
  10. const res = await fetchAppUpdateNotice({
  11. id: item['noticeId'] as string
  12. })
  13. notice.value = res || {}
  14. console.log(notice.value)
  15. }
  16. async function getNoticeList() {
  17. if (user.info.value == null || user.info.value.userInfo.userId == null) {
  18. return
  19. }
  20. const res = await getAppUpdateNoticePage({
  21. userId: user.info.value?.userInfo.userId as string,
  22. pageNum: 1,
  23. pageSize: 20
  24. })
  25. recordList.value = res.rows || []
  26. if (recordList.value.length > 0) {
  27. handleDetail(recordList.value[0])
  28. }
  29. }
  30. onMounted(() => {
  31. getNoticeList()
  32. })
  33. onUnmounted(() => {
  34. recordList.value = []
  35. record.value = {}
  36. notice.value = {}
  37. })
  38. </script>
  39. <template>
  40. <view class=" shadow rounded-3xl mt-[20px] sidebar w-full">
  41. <cl-row :gutter="10" :pt="{
  42. className: 'w-full h-full'
  43. }">
  44. <cl-col :span="8" :pt="{
  45. className: ' h-full'
  46. }">
  47. <scroll-view direction="vertical" :show-scrollbar="false"
  48. class="w-full h-full bg-[#a5ddfe] p-[10rpx]">
  49. <view class="w-full mb-[10rpx] relative" v-for="item in recordList" :key="item['noticeId']"
  50. @tap="handleDetail(item)">
  51. <cl-badge type="error" dot position v-if="item['readFlag'] == false"> </cl-badge>
  52. <image v-if="item['noticeId'] == record['noticeId']" mode="widthFix" lazy-load
  53. src="https://oss.xiaoxiongcode.com/static/home/725.png" alt=""
  54. class="w-full h-full object-cover" />
  55. <image v-else mode="widthFix" lazy-load src="https://oss.xiaoxiongcode.com/static/home/726.png"
  56. alt="" class="w-full h-full object-cover" />
  57. <view
  58. class="absolute bottom-[0rpx] left-[0rpx] w-full h-full flex flex-row items-center justify-center">
  59. <view class="h-full w-[34rpx] flex flex-col items-center justify-end pb-[2rpx]">
  60. <text class="text-[12rpx] font-bold text-[#008DDF]">{{ item['month'] }}月</text>
  61. <text class="text-[12rpx] font-bold text-[#008DDF]">{{ item['day'] }}日</text>
  62. </view>
  63. <view class="flex-1 pt-[3rpx] pl-[5rpx]">
  64. <text class=" text-[12rpx] single-line font-bold text-[#008DDF]"
  65. :class="{ 'text-[#fff]': item['noticeId'] == record['noticeId'] }">
  66. {{ item['noticeName'] }}
  67. </text>
  68. </view>
  69. </view>
  70. </view>
  71. </scroll-view>
  72. </cl-col>
  73. <cl-col :span="16" :pt="{
  74. className: ' h-full'
  75. }">
  76. <scroll-view direction="vertical" :show-scrollbar="false" class="w-full h-full p-[10rpx]"
  77. v-if="notice['content'] != null">
  78. <view class="w-full flex flex-row items-center justify-center relative">
  79. <image mode="widthFix" lazy-load src="https://oss.xiaoxiongcode.com/static/home/724.png" alt=""
  80. class="w-[300rpx] h-full object-cover" />
  81. <text class=" title ">
  82. {{ record['noticeName'] }}
  83. </text>
  84. </view>
  85. <view class="w-full mt-[10rpx] flex flex-row items-center justify-center">
  86. <text class="text-[12rpx] mr-[15rpx] text-[#333]">
  87. 发布人:{{ notice['createdUserName']
  88. }}</text>
  89. <text class="text-[12rpx] text-[#333]">
  90. 发布时间:{{ notice['updateTime'] }}</text>
  91. </view>
  92. <rich-text class="w-full mt-[10rpx] " style="font-size: 12rpx;color: #333;" mode="web"
  93. :nodes="notice['content']">
  94. </rich-text>
  95. </scroll-view>
  96. </cl-col>
  97. </cl-row>
  98. </view>
  99. </template>
  100. <style lang="scss" scoped>
  101. .sidebar {
  102. height: calc(80vh - 90px);
  103. max-height: calc(620px - 90px);
  104. background-color: #fff;
  105. }
  106. .title {
  107. @apply text-[14rpx] font-bold text-[#fff] absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[280rpx] text-center;
  108. }
  109. .single-line {
  110. white-space: nowrap;
  111. text-overflow: ellipsis;
  112. width: 80%;
  113. }
  114. </style>