index.vue 2.8 KB

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