index.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <template>
  2. <view class="message-container">
  3. <view class="top-tabs">
  4. <view class="tab-item" :class="{ active: currentTab === 'system' }" @click="switchTab('system')">
  5. <text class="tab-text">系统消息</text>
  6. </view>
  7. <view class="tab-item" :class="{ active: currentTab === 'business' }" @click="switchTab('business')">
  8. <text class="tab-text">业务消息</text>
  9. </view>
  10. </view>
  11. <scroll-view class="message-list" scroll-y>
  12. <!-- 空状态 -->
  13. <EmptyState
  14. v-if="messageList.length === 0"
  15. text="暂无消息"
  16. sub-text="暂时没有新的消息"
  17. icon="chatbubble"
  18. />
  19. <view class="message-item" v-for="(item, index) in messageList" :key="index" @click="viewDetail">
  20. <view class="message-icon">
  21. <uni-icons type="bell" size="24" color="#1890ff"></uni-icons>
  22. </view>
  23. <view class="message-content">
  24. <view class="message-header">
  25. <text class="message-title">{{ item.title }}</text>
  26. <text class="message-time">{{ item.time }}</text>
  27. </view>
  28. <text class="message-desc">{{ item.content }}</text>
  29. </view>
  30. </view>
  31. </scroll-view>
  32. </view>
  33. </template>
  34. <script setup>
  35. import {
  36. ref,
  37. reactive
  38. } from 'vue'
  39. import EmptyState from '@/components/empty-state/index.vue'
  40. const currentTab = ref('system')
  41. const messageList = reactive([])
  42. const switchTab = (tab) => {
  43. currentTab.value = tab
  44. }
  45. const viewDetail = () => {
  46. uni.showToast({
  47. title: '阿斯顿发的是',
  48. icon: 'none'
  49. })
  50. }
  51. </script>
  52. <style lang="scss" scoped>
  53. .message-container {
  54. background: #f5f6f8;
  55. }
  56. .top-tabs {
  57. display: flex;
  58. align-items: center;
  59. padding: 20rpx 32rpx;
  60. margin-bottom: 20rpx;
  61. .tab-item {
  62. width: 182rpx;
  63. height: 72rpx;
  64. display: flex;
  65. align-items: center;
  66. justify-content: center;
  67. border-radius: 20rpx;
  68. background: #ffffff;
  69. .tab-text {
  70. font-size: 28rpx;
  71. color: #666666;
  72. }
  73. &.active {
  74. background: linear-gradient(90deg, #5B86F5 0%, #36D1DC 100%);
  75. .tab-text {
  76. color: #ffffff;
  77. font-weight: 600;
  78. }
  79. }
  80. &:not(:last-child) {
  81. margin-right: 24rpx;
  82. }
  83. }
  84. }
  85. .message-list {
  86. padding: 0 20rpx;
  87. .message-item {
  88. display: flex;
  89. background: #ffffff;
  90. border-radius: 16rpx;
  91. padding: 28rpx;
  92. margin-bottom: 20rpx;
  93. .message-icon {
  94. display: flex;
  95. align-items: center;
  96. justify-content: center;
  97. width: 60rpx;
  98. height: 60rpx;
  99. background: #e6f7ff;
  100. border-radius: 50%;
  101. margin-right: 20rpx;
  102. flex-shrink: 0;
  103. }
  104. .message-content {
  105. flex: 1;
  106. .message-header {
  107. display: flex;
  108. justify-content: space-between;
  109. align-items: center;
  110. margin-bottom: 12rpx;
  111. .message-title {
  112. font-size: 30rpx;
  113. font-weight: 600;
  114. color: #333333;
  115. }
  116. .message-time {
  117. font-size: 22rpx;
  118. color: #999999;
  119. flex-shrink: 0;
  120. margin-left: 16rpx;
  121. }
  122. }
  123. .message-desc {
  124. display: block;
  125. font-size: 26rpx;
  126. color: #666666;
  127. line-height: 1.6;
  128. overflow: hidden;
  129. text-overflow: ellipsis;
  130. }
  131. }
  132. }
  133. }
  134. </style>