index.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. <template>
  2. <view class="page-container">
  3. <image class="bg" src="/static/message_top_bg.png"></image>
  4. <view class="status_bar" :style="{ height: statusBarHeight }"></view>
  5. <!-- 顶部标题栏 -->
  6. <view class="top-bar">
  7. <text class="title">消息(11)</text>
  8. </view>
  9. <!-- 搜索框 -->
  10. <view class="search-box">
  11. <image class="search-icon" src="/static/search_gray.png" mode="aspectFit"></image>
  12. <input class="search-placeholder" placeholder="请输入关键字搜索"></input>
  13. </view>
  14. <!-- 消息列表 -->
  15. <view class="message-list">
  16. <view class="message-item" v-for="(item, index) in messageData" :key="index" @click="openMessage(item)">
  17. <view class="message-left">
  18. <view class="avatar-box" :class="item.type">
  19. <image class="avatar" :src="item.avatar||'/static/avatar'" mode="aspectFit"></image>
  20. <view class="badge" v-if="item.badge > 0">{{ item.badge }}</view>
  21. </view>
  22. </view>
  23. <view class="message-right">
  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-content">{{ item.content }}</text>
  29. </view>
  30. </view>
  31. </view>
  32. </view>
  33. </template>
  34. <script>
  35. export default {
  36. data() {
  37. return {
  38. statusBarHeight: uni.getStorageSync('menuInfo').statusBarHeight,
  39. messageData: [
  40. {
  41. id: 1,
  42. type: 'doctor',
  43. avatar: '/static/avatar.png',
  44. title: '徐丽医生',
  45. content: '本次问诊小结:诊断结果',
  46. time: '12:23',
  47. badge: 0
  48. },
  49. {
  50. id: 2,
  51. type: 'system',
  52. avatar: '/static/avatar.png',
  53. title: '系统通知',
  54. content: '您已下处方订单,将于次日发货,请留...',
  55. time: '8/30',
  56. badge: 6
  57. },
  58. {
  59. id: 3,
  60. type: 'reminder',
  61. avatar: '/static/avatar.png',
  62. title: '消息提醒',
  63. content: '测试手表上时间检测到位佩戴,已进入...',
  64. time: '2025/8/30',
  65. badge: 0
  66. },
  67. {
  68. id: 4,
  69. type: 'health',
  70. avatar: '/static/avatar.png',
  71. title: '健康贴士',
  72. content: '猪油是非常好的动物脂肪,猪油含有丰...',
  73. time: '2025/1/12',
  74. badge: 6
  75. }
  76. ]
  77. };
  78. },
  79. methods: {
  80. openMessage(item) {
  81. // 打开消息详情
  82. uni.showToast({
  83. title: `打开${item.title}`,
  84. icon: 'none'
  85. });
  86. },
  87. navigateTo(url) {
  88. uni.switchTab({
  89. url: url
  90. });
  91. }
  92. }
  93. };
  94. </script>
  95. <style lang="scss" scoped>
  96. .page-container {
  97. width: 100%;
  98. min-height: 100vh;
  99. background-color: #f8f8f8;
  100. padding-bottom: 120upx; // 为底部导航栏留出空间
  101. position:relative;
  102. z-index:2;
  103. .bg{
  104. position:absolute;
  105. top:0;
  106. width: 100%;
  107. z-index:-1;
  108. // height:100%
  109. }
  110. .top-bar {
  111. display: flex;
  112. align-items: center;
  113. justify-content: center;
  114. padding: 16rpx 24upx;
  115. .title {
  116. font-size: 34rpx;
  117. font-family: PingFang SC;
  118. font-weight: 500;
  119. color: #000000;
  120. }
  121. }
  122. .search-box {
  123. display: flex;
  124. align-items: center;
  125. margin: 24upx;
  126. padding: 14rpx 24upx;
  127. background: #FFFFFF;
  128. border-radius: 34rpx 34rpx 34rpx 34rpx;
  129. .search-icon {
  130. width: 28upx;
  131. height: 28upx;
  132. margin-right: 10upx;
  133. }
  134. .search-placeholder {
  135. font-size: 24upx;
  136. color: #999999;
  137. }
  138. }
  139. .message-list {
  140. margin:24rpx;
  141. background: #FFFFFF;
  142. border-radius: 16rpx 16rpx 16rpx 16rpx;
  143. .message-item {
  144. display: flex;
  145. align-items: center;
  146. padding: 20upx;
  147. .message-left {
  148. margin-right: 20upx;
  149. .avatar-box {
  150. position: relative;
  151. width: 90upx;
  152. height: 90upx;
  153. border-radius: 50%;
  154. display: flex;
  155. align-items: center;
  156. justify-content: center;
  157. .avatar {
  158. width: 100%;
  159. height: 100%;
  160. border-radius: 50%;
  161. }
  162. .badge {
  163. position: absolute;
  164. top: -5upx;
  165. right: -5upx;
  166. padding:2rpx 10rpx;
  167. background: linear-gradient( 0deg, #FA432D 0%, #FD7148 100%);
  168. border-radius: 50%;
  169. border: 2rpx solid #FFFFFF;
  170. color: #ffffff;
  171. font-size: 22upx;
  172. font-weight: 500;
  173. }
  174. }
  175. }
  176. .message-right {
  177. flex: 1;
  178. .message-header {
  179. display: flex;
  180. align-items: center;
  181. justify-content: space-between;
  182. margin-bottom: 8upx;
  183. .message-title {
  184. font-weight: 500;
  185. font-size: 32rpx;
  186. color: #222222;
  187. }
  188. .message-time {
  189. font-size: 24rpx;
  190. color: #9B9B9B;
  191. }
  192. }
  193. .message-content {
  194. font-size: 26rpx;
  195. color: #9B9B9B;
  196. overflow: hidden;
  197. text-overflow: ellipsis;
  198. display: -webkit-box;
  199. -webkit-line-clamp: 1;
  200. -webkit-box-orient: vertical;
  201. }
  202. }
  203. }
  204. }
  205. }
  206. </style>