diff --git a/store/chat/chat.js b/store/chat/chat.js
index fbab38c..f8ebf24 100644
--- a/store/chat/chat.js
+++ b/store/chat/chat.js
@@ -111,7 +111,8 @@ const ChatManager = {
id: message.id,
sender: message.sender_user_id,
type: this.getMessageType(message.message_type),
- content: message.content,
+ // type: message.type,
+ content: message.message_type === 4 ? JSON.parse(message.content) : message.content,
duration: message.duration,
time: this.formatTime(message.send_time),
timestamp: message.send_time
@@ -122,7 +123,10 @@ const ChatManager = {
id: item.id,
sender: item.sender_user_id,
type: this.getMessageType(item.message_type),
- content: item?.message_content || item.content,
+ content:
+ item.message_type === 4
+ ? JSON.parse(item.message_content)
+ : item.message_content,
duration: item.duration,
time: item?.created_at_text || item.send_time,
timestamp: item?.created_at || item.send_time
diff --git a/subPackages/chat/chat.vue b/subPackages/chat/chat.vue
index cba55b5..35d42d3 100644
--- a/subPackages/chat/chat.vue
+++ b/subPackages/chat/chat.vue
@@ -73,6 +73,30 @@
>
+
+
+
+
+
+
+ {{ msg.content.order_no }}
+
+
+
+ {{ msg.content.express_name || '待发货' }}
+
+
+
+
{{ msg.content }}
{{ msg.time }}
@@ -108,6 +132,30 @@
{{ msg.duration }}''
+
+
+
+
+
+
+ {{ msg.content.order_no }}
+
+
+
+ {{ msg.content.express_name || '待发货' }}
+
+
+
+
{{ msg.content }}
{{ msg.time }}
@@ -126,10 +174,6 @@
-
-
-
-
图片
@@ -138,10 +182,6 @@
拍照
-
-
-
-
文件
@@ -154,13 +194,8 @@
-
-
-
-
-
@@ -258,6 +293,15 @@ export default {
hasMore: true,
loading: false, // 新增加载状态
isEmpty: false, // 历史消息是否为空
+
+ // 处方数据
+ prescriptionData: {
+ id: 159,
+ order_no: "XY9478601753943762",
+ status: 0,
+ express_name: "李测试",
+ total_pay_price: "11.94"
+ }
};
},
onLoad: function (option) {
@@ -375,6 +419,9 @@ export default {
addMessage(message) {
// 避免重复添加
if (!this.messages.some(m => m.id === message.id)) {
+ if (message.type === "prescription") {
+ message.content = JSON.parse(message.content);
+ }
console.log('push', message)
this.messages.push(message);
this.scrollToBottom();
@@ -667,19 +714,9 @@ export default {
// 发送处方
sendPrescription() {
- // 模拟处方数据
- const prescription = {
- id: 'RX20230718001',
- date: new Date().toLocaleDateString(),
- items: [
- { name: '阿司匹林', dosage: '100mg', frequency: '每日一次' },
- { name: '维生素C', dosage: '500mg', frequency: '每日三次' }
- ]
- };
-
this.sendMessage({
type: 'prescription',
- content: JSON.stringify(prescription)
+ content: JSON.stringify(this.prescriptionData)
});
},
@@ -730,6 +767,25 @@ export default {
} finally {
this.loading = false;
}
+ },
+
+ // 获取处方状态文本
+ getStatusText(status) {
+ const statusMap = {
+ 0: '待审核',
+ 1: '已审核',
+ 2: '已发货',
+ 3: '已完成',
+ 4: '已取消'
+ };
+ return statusMap[status] || '未知状态';
+ },
+
+ // 查看处方
+ viewPrescription(id, orderNo) {
+ uni.navigateTo({
+ url: "/subPackages/my/myrecord-detail?id=" + id + '&no=' + orderNo
+ })
}
}
};
@@ -1025,6 +1081,96 @@ $light-bg: #f5f9ff;
overflow: hidden;
}
+/* 处方卡片样式 */
+.prescription-card {
+ background: #fff;
+ border-radius: 12px;
+ padding: 16px;
+ width: 280px;
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
+ border: 1px solid #eaeef5;
+}
+
+.prescription-header {
+ display: flex;
+ align-items: center;
+ margin-bottom: 12px;
+ padding-bottom: 12px;
+ border-bottom: 1px solid #f0f7ff;
+}
+
+.prescription-title {
+ font-size: 16px;
+ font-weight: bold;
+ color: #333;
+ margin-left: 8px;
+}
+
+.prescription-status {
+ margin-left: auto;
+ font-size: 12px;
+ padding: 4px 10px;
+ border-radius: 20px;
+ font-weight: 500;
+
+ &.status-0 { background: #fef3c7; color: #d97706; } /* 待审核 - 黄色 */
+ &.status-1 { background: #d1fae5; color: #059669; } /* 已审核 - 绿色 */
+ &.status-2 { background: #dbeafe; color: #2563eb; } /* 已发货 - 蓝色 */
+ &.status-3 { background: #e5e7eb; color: #4b5563; } /* 已完成 - 灰色 */
+ &.status-4 { background: #fee2e2; color: #dc2626; } /* 已取消 - 红色 */
+}
+
+.prescription-content {
+ margin-bottom: 12px;
+}
+
+.info-item {
+ display: flex;
+ align-items: center;
+ margin-bottom: 8px;
+ font-size: 14px;
+}
+
+.info-text {
+ margin-left: 8px;
+ color: #555;
+}
+
+.prescription-footer {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ padding-top: 12px;
+ border-top: 1px solid #f0f7ff;
+}
+
+.price {
+ font-size: 14px;
+ font-weight: 500;
+ color: #e53e3e;
+}
+
+.view-btn {
+ font-size: 14px;
+ color: #298dff;
+ padding: 6px 12px;
+ border-radius: 16px;
+ background: #f0f7ff;
+ font-weight: 500;
+}
+
+/* 对方消息中的处方卡片 */
+.other-message .prescription-card {
+ background: #e6f2ff;
+ border: 1px solid #cce0ff;
+}
+
+/* 我的消息中的处方卡片 */
+.my-message .prescription-card {
+ background: #e6f9ff;
+ border: 1px solid #cce6ff;
+}
+
.chat-input {
background-color: #fff;
border-top: 1px solid #eaeef5;