Эх сурвалжийг харах

feat: 新增消息详情页面及导航功能

mcbaiyun 3 долоо хоног өмнө
parent
commit
6719a5a93a

+ 6 - 0
src/pages.json

@@ -48,6 +48,12 @@
 				"navigationBarTitleText": "个人中心"
 			}
 		},
+		{
+			"path": "pages/public/message-detail",
+			"style": {
+				"navigationBarTitleText": "消息详情"
+			}
+		},
 		{
 			"path": "pages/patient/index/index",
 			"style": {

+ 1 - 1
src/pages/patient/index/index.vue

@@ -460,7 +460,7 @@ function onItemClick(type: string) {
 }
 
 function onMessageClick() {
-  uni.showToast({ title: '功能正在开发中', icon: 'none' })
+  uni.navigateTo({ url: '/pages/public/message-detail?id=1' })
 }
 
 function onQrClick() {

+ 227 - 0
src/pages/public/message-detail.vue

@@ -0,0 +1,227 @@
+<template>
+  <CustomNav title="消息详情" leftType="back" />
+  <view class="page-container">
+    <view class="message-card" v-for="msg in messages" :key="msg.id">
+      <view class="message-header">
+        <view class="header-top">
+          <view class="header-left">
+            <text class="message-title">{{ getMessageTitle(msg.type) }}</text>
+          </view>
+          <view class="header-right">
+            <view class="action-buttons">
+              <button class="action-btn primary" v-if="!msg.isRead" @click="markAsRead(msg.id)">标记已读</button>
+              <view v-else class="read-indicator">
+                <uni-icons type="checkmarkempty" size="24" color="#07C160" />
+                <text class="read-text">已读</text>
+              </view>
+            </view>
+          </view>
+        </view>
+        <view class="header-bottom">
+          <view class="header-left">
+            <text class="sender">发送者: {{ msg.senderName || '系统' }}</text>
+          </view>
+          <view class="header-right">
+            <text class="message-time">发送时间: {{ msg.createTime }}</text>
+          </view>
+        </view>
+      </view>
+      <view class="message-content">
+        <text class="content-text">{{ msg.content }}</text>
+      </view>
+    </view>
+  </view>
+</template>
+
+<script setup lang="ts">
+import { ref, computed } from 'vue'
+import { onLoad } from '@dcloudio/uni-app'
+import CustomNav from '@/components/custom-nav.vue'
+
+interface Message {
+  id: string
+  type: string
+  content: string
+  createTime: string
+  senderName?: string
+  isRead: boolean
+}
+
+const messages = ref<Message[]>([
+  {
+    id: '1',
+    type: 'DOCTOR',
+    content: '这是未读的医生消息内容详情。',
+    createTime: '2023-12-05 10:00:00',
+    senderName: '医生',
+    isRead: false
+  },
+  {
+    id: '2',
+    type: 'SYSTEM_ANOMALY',
+    content: '这是已读的异常通知内容详情。',
+    createTime: '2023-12-04 15:30:00',
+    senderName: '系统',
+    isRead: true
+  }
+])
+
+const getMessageTitle = (type: string) => {
+  switch (type) {
+    case 'SYSTEM_DAILY':
+      return '系统通知'
+    case 'DOCTOR':
+      return '医生消息'
+    case 'SYSTEM_ANOMALY':
+      return '异常通知'
+    default:
+      return '消息'
+  }
+}
+
+const markAsRead = (id: string) => {
+  const msg = messages.value.find(m => m.id === id)
+  if (msg) {
+    msg.isRead = true
+    uni.showToast({ title: '已标记为已读', icon: 'success' })
+  }
+}
+</script>
+
+<style scoped>
+.page-container {
+  min-height: 100vh;
+  background-color: #f5f5f5;
+  padding-top: calc(var(--status-bar-height) + 44px + 20rpx);
+  padding-bottom: 40rpx;
+}
+
+.message-card {
+  background-color: #fff;
+  margin: 32rpx 20rpx;
+  border-radius: 12rpx;
+  overflow: hidden;
+  box-shadow: 0 8rpx 24rpx rgba(0, 0, 0, 0.348);
+  transition: transform 0.12s ease, box-shadow 0.12s ease;
+}
+
+.message-card:hover {
+  transform: translateY(-4rpx);
+  box-shadow: 0 12rpx 36rpx rgba(0, 0, 0, 0.15);
+}
+
+.message-header {
+  padding: 20rpx;
+  border-bottom: 1rpx solid #f5f5f5;
+  display: flex;
+  flex-direction: column;
+  gap: 12rpx;
+  background-color: rgba(0, 0, 0, 0.03);
+  box-shadow: 0 1rpx 6rpx rgba(0, 0, 0, 0.2);
+}
+
+.header-top,
+.header-bottom {
+  display: flex;
+  justify-content: space-between;
+  align-items: center;
+}
+
+.header-left {
+  flex: 1;
+}
+
+.header-right {
+  display: flex;
+  align-items: center;
+}
+
+.message-title {
+  font-size: 38rpx;
+  line-height: 1.4;
+  color: #222;
+  font-weight: 600;
+  display: block;
+  margin-bottom: 12rpx;
+}
+
+.sender {
+  font-size: 28rpx;
+  color: #666;
+  display: block;
+  margin-bottom: 8rpx;
+}
+
+.message-time {
+  font-size: 28rpx;
+  color: #666;
+}
+
+.message-content {
+  padding: 20rpx;
+}
+
+.content-text {
+  font-size: 34rpx;
+  color: #333;
+  line-height: 1.6;
+}
+
+.action-buttons {
+  display: flex;
+  gap: 12rpx;
+  flex-wrap: wrap;
+}
+
+.action-btn {
+  padding: 10rpx 22rpx;
+  border-radius: 20rpx;
+  min-width: 110rpx;
+  height: 64rpx;
+  line-height: 44rpx;
+  background: #fff;
+  color: #333;
+  font-size: 28rpx;
+  border: 1rpx solid #e6e6e6;
+  box-shadow: none;
+  display: inline-flex;
+  align-items: center;
+  justify-content: center;
+  transition: transform 0.12s ease, box-shadow 0.12s ease;
+}
+
+.action-btn:active {
+  transform: translateY(2rpx);
+}
+
+.action-btn:hover {
+  box-shadow: 0 6rpx 12rpx rgba(0, 0, 0, 0.06);
+}
+
+.primary {
+  background: linear-gradient(180deg, #6fb7ff, #2d8cf0);
+  color: #fff;
+  border: none;
+  box-shadow: 0 10rpx 28rpx rgba(45, 140, 240, 0.12);
+}
+
+.danger {
+  background: linear-gradient(180deg, #ff8a8a, #ff6b6b);
+  color: #fff;
+  border: none;
+  box-shadow: 0 10rpx 28rpx rgba(255, 107, 107, 0.12);
+}
+
+.read-indicator {
+  display: flex;
+  align-items: center;
+  gap: 8rpx;
+  color: #07C160;
+  font-size: 28rpx;
+  font-weight: bold;
+}
+
+.read-text {
+  color: #07C160;
+}
+</style>