更新初级版本

This commit is contained in:
Your Name
2026-03-06 17:30:37 +08:00
parent 52bb80e2f1
commit 7b76671988
19 changed files with 1656 additions and 370 deletions
+218
View File
@@ -0,0 +1,218 @@
# 诊单查看记录功能
## 功能概述
记录用户查看和确认诊单的行为,包括查看次数、查看时间、确认状态等信息。
## 数据库表结构
### la_diagnosis_view_records 表
```sql
CREATE TABLE `la_diagnosis_view_records` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
`user_id` int(11) NOT NULL DEFAULT '0' COMMENT '查看用户ID',
`diagnosis_id` int(11) NOT NULL DEFAULT '0' COMMENT '诊单ID',
`patient_id` int(11) NOT NULL DEFAULT '0' COMMENT '患者ID',
`share_user_id` int(11) NOT NULL DEFAULT '0' COMMENT '分享用户ID',
`view_count` int(11) NOT NULL DEFAULT '1' COMMENT '查看次数',
`first_view_time` int(11) NOT NULL DEFAULT '0' COMMENT '首次查看时间',
`last_view_time` int(11) NOT NULL DEFAULT '0' COMMENT '最后查看时间',
`is_confirmed` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否已确认 0-未确认 1-已确认',
`confirmed_time` int(11) NOT NULL DEFAULT '0' COMMENT '确认时间',
`create_time` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
`update_time` int(11) NOT NULL DEFAULT '0' COMMENT '更新时间',
`delete_time` int(11) DEFAULT NULL COMMENT '删除时间',
PRIMARY KEY (`id`),
KEY `idx_user_diagnosis` (`user_id`, `diagnosis_id`),
KEY `idx_diagnosis` (`diagnosis_id`),
KEY `idx_patient` (`patient_id`),
KEY `idx_share_user` (`share_user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='诊单查看记录表';
```
## 字段说明
| 字段 | 类型 | 说明 |
|------|------|------|
| user_id | int | 查看用户ID(当前登录用户) |
| diagnosis_id | int | 诊单ID |
| patient_id | int | 患者ID(从诊单获取) |
| share_user_id | int | 分享用户ID(生成二维码的用户) |
| view_count | int | 查看次数(每次打开页面+1) |
| first_view_time | int | 首次查看时间戳 |
| last_view_time | int | 最后查看时间戳 |
| is_confirmed | tinyint | 是否已确认(0-未确认 1-已确认) |
| confirmed_time | int | 确认时间戳 |
## 后端实现
### 1. 模型文件
`server/app/common/model/DiagnosisViewRecord.php`
### 2. 控制器方法
`server/app/api/controller/TcmController.php`
#### diagnosisDetail - 获取诊单详情
```php
GET /api/tcm/diagnosisDetail
参数:
- id: 诊单ID(必填)
- user_id: 查看用户ID(选填,默认0
- share_user_id: 分享用户ID(选填,默认0
功能:
1. 获取诊单详情
2. 自动记录查看行为
3. 如果是首次查看,创建新记录
4. 如果已有记录,更新查看次数和最后查看时间
```
#### confirmDiagnosis - 确认诊单
```php
POST /api/tcm/confirmDiagnosis
参数:
- id: 诊单ID(必填)
- user_id: 查看用户ID(选填,默认0
- share_user: 分享用户ID(选填,默认0
功能:
1. 更新查看记录的确认状态
2. 记录确认时间
3. 如果没有查看记录,创建一条已确认的记录
```
### 3. 逻辑层方法
`server/app/adminapi/logic/tcm/DiagnosisLogic.php`
#### diagnosisDetailWithRecord
- 获取诊单详情并记录查看行为
- 调用 `recordDiagnosisView` 记录查看
#### recordDiagnosisView
- 查找是否已有记录
- 首次查看:创建新记录
- 再次查看:更新查看次数和最后查看时间
#### confirmDiagnosisRecord
- 更新确认状态
- 记录确认时间
## 前端实现
### 小程序页面
`TUICallKit-Vue3/pages/order/monad/monad.vue`
#### 参数解析
```javascript
const parsePageParams = (options) => {
// 解析scene参数(扫码进入)
// 解析普通参数(跳转进入)
// 获取当前登录用户ID
return params;
};
```
#### 加载诊单详情
```javascript
const res = await proxy.apiUrl({
url: '/api/tcm/diagnosisDetail',
method: 'GET',
data: {
id: diagnosisId,
user_id: params.user_id || 0,
share_user_id: params.share_user || 0
}
});
```
#### 确认诊单
```javascript
const res = await proxy.apiUrl({
url: '/api/tcm/confirmDiagnosis',
method: 'POST',
data: {
id: params.id,
user_id: params.user_id || 0,
share_user: params.share_user || 0
}
});
```
## 使用流程
### 1. 生成二维码
管理员在后台点击"小程序二维码"按钮
- 传递参数:`diagnosis_id`, `patient_id`, `share_user_id`
- 生成scene: `id=4&share_user=1`
### 2. 用户扫码
用户使用微信扫描二维码
- 小程序接收参数:`scene: "id%3D4%26share_user%3D1"`
- 解析参数:`{ id: "4", share_user: "1" }`
### 3. 查看诊单
小程序加载诊单详情
- 调用 `/api/tcm/diagnosisDetail`
- 传递:`id`, `user_id`, `share_user_id`
- 后端自动记录查看行为
### 4. 确认诊单
用户点击"确认诊单"按钮
- 调用 `/api/tcm/confirmDiagnosis`
- 传递:`id`, `user_id`, `share_user`
- 后端更新确认状态
## 数据统计
### 可统计的数据
1. 每个诊单的查看次数
2. 每个用户查看了哪些诊单
3. 诊单的确认率
4. 分享效果(通过share_user_id统计)
5. 首次查看到确认的时间间隔
### 查询示例
#### 查询某个诊单的查看记录
```php
$records = DiagnosisViewRecord::where('diagnosis_id', $diagnosisId)
->with(['user', 'shareUser'])
->select();
```
#### 查询某个用户的查看记录
```php
$records = DiagnosisViewRecord::where('user_id', $userId)
->with(['diagnosis'])
->select();
```
#### 统计诊单查看次数
```php
$viewCount = DiagnosisViewRecord::where('diagnosis_id', $diagnosisId)
->sum('view_count');
```
#### 统计确认率
```php
$total = DiagnosisViewRecord::where('diagnosis_id', $diagnosisId)->count();
$confirmed = DiagnosisViewRecord::where('diagnosis_id', $diagnosisId)
->where('is_confirmed', 1)
->count();
$rate = $total > 0 ? ($confirmed / $total * 100) : 0;
```
## 注意事项
1. **用户ID获取**: 需要在小程序中实现用户登录,获取当前用户ID
2. **匿名访问**: 如果允许匿名访问,user_id可以为0
3. **数据清理**: 建议定期清理过期的查看记录
4. **性能优化**: 查看记录表可能增长较快,注意添加索引
5. **隐私保护**: 查看记录涉及用户行为,注意数据安全
## TODO
- [ ] 在小程序中实现用户登录功能
- [ ]`parsePageParams` 中添加获取用户ID的逻辑
- [ ] 添加查看记录的管理界面
- [ ] 添加数据统计报表
- [ ] 实现查看记录的导出功能
+223
View File
@@ -0,0 +1,223 @@
# 诊单查看记录功能 - 安装指南
## 安装步骤
### 1. 创建数据库表
执行以下SQL语句创建诊单查看记录表:
```bash
# 方式1: 使用MySQL客户端执行
mysql -u root -p your_database < server/database/diagnosis_view_records.sql
# 方式2: 在phpMyAdmin或其他数据库管理工具中执行
# 打开文件: server/database/diagnosis_view_records.sql
# 复制SQL语句并执行
```
SQL文件位置: `server/database/diagnosis_view_records.sql`
### 2. 验证表创建
登录数据库,检查表是否创建成功:
```sql
SHOW TABLES LIKE 'la_diagnosis_view_records';
DESC la_diagnosis_view_records;
```
### 3. 文件清单
确认以下文件已创建:
#### 后端文件
-`server/database/diagnosis_view_records.sql` - 数据库表结构
-`server/app/common/model/DiagnosisViewRecord.php` - 模型文件
-`server/app/api/controller/TcmController.php` - 控制器(已更新)
-`server/app/adminapi/logic/tcm/DiagnosisLogic.php` - 逻辑层(已更新)
#### 前端文件
-`TUICallKit-Vue3/pages/order/monad/monad.vue` - 小程序页面(已更新)
#### 文档文件
-`DIAGNOSIS_VIEW_RECORD_FEATURE.md` - 功能说明文档
-`DIAGNOSIS_VIEW_RECORD_INSTALL.md` - 安装指南(本文件)
-`MINI_PROGRAM_SCENE_PARAMS.md` - Scene参数说明
### 4. 配置小程序用户ID获取
在小程序中添加用户ID获取逻辑:
```javascript
// TUICallKit-Vue3/pages/order/monad/monad.vue
// 在 parsePageParams 函数中添加
const parsePageParams = (options) => {
const params = {};
// ... 现有的解析逻辑 ...
// 获取当前登录用户ID
try {
// 方式1: 从本地存储获取
const userInfo = uni.getStorageSync('userInfo');
params.user_id = userInfo?.id || 0;
// 方式2: 从全局状态获取
// const app = getApp();
// params.user_id = app.globalData.userId || 0;
// 方式3: 从Vuex获取
// import { useUserStore } from '@/stores/user';
// const userStore = useUserStore();
// params.user_id = userStore.userId || 0;
} catch (error) {
console.error('获取用户ID失败:', error);
params.user_id = 0;
}
return params;
};
```
### 5. 测试功能
#### 5.1 测试查看记录
1. 在管理后台生成小程序二维码
2. 使用微信扫描二维码
3. 小程序打开诊单详情页
4. 检查数据库 `la_diagnosis_view_records` 表,应该有一条新记录
```sql
SELECT * FROM la_diagnosis_view_records ORDER BY id DESC LIMIT 1;
```
#### 5.2 测试重复查看
1. 再次扫描同一个二维码
2. 检查数据库,`view_count` 应该增加,`last_view_time` 应该更新
```sql
SELECT id, user_id, diagnosis_id, view_count,
FROM_UNIXTIME(first_view_time) as first_view,
FROM_UNIXTIME(last_view_time) as last_view
FROM la_diagnosis_view_records
WHERE diagnosis_id = 4;
```
#### 5.3 测试确认功能
1. 在小程序中点击"确认诊单"按钮
2. 检查数据库,`is_confirmed` 应该变为1`confirmed_time` 应该有值
```sql
SELECT id, diagnosis_id, is_confirmed,
FROM_UNIXTIME(confirmed_time) as confirmed_at
FROM la_diagnosis_view_records
WHERE diagnosis_id = 4;
```
### 6. API接口测试
#### 测试 diagnosisDetail 接口
```bash
curl -X GET "http://your-domain/api/tcm/diagnosisDetail?id=4&user_id=1&share_user_id=2"
```
预期响应:
```json
{
"code": 1,
"msg": "success",
"data": {
"id": 4,
"patient_name": "张三",
// ... 其他诊单信息
}
}
```
#### 测试 confirmDiagnosis 接口
```bash
curl -X POST "http://your-domain/api/tcm/confirmDiagnosis" \
-H "Content-Type: application/json" \
-d '{"id": 4, "user_id": 1, "share_user": 2}'
```
预期响应:
```json
{
"code": 1,
"msg": "确认成功",
"data": []
}
```
### 7. 常见问题
#### Q1: 表创建失败
**A:** 检查数据库权限,确保有CREATE TABLE权限
#### Q2: 查看记录没有创建
**A:** 检查以下几点:
- 确认表已创建
- 检查PHP错误日志
- 确认 `DiagnosisViewRecord` 模型文件存在
- 检查数据库连接配置
#### Q3: user_id 总是0
**A:** 需要在小程序中实现用户登录功能,并在 `parsePageParams` 中获取用户ID
#### Q4: 确认功能不工作
**A:** 检查:
- 确认接口已添加到 `$notNeedLogin` 数组
- 检查POST参数是否正确传递
- 查看PHP错误日志
### 8. 数据库索引优化
如果查看记录表数据量较大,建议添加以下索引:
```sql
-- 已在建表语句中包含,如果没有可手动添加
ALTER TABLE la_diagnosis_view_records
ADD INDEX idx_user_diagnosis (user_id, diagnosis_id);
ALTER TABLE la_diagnosis_view_records
ADD INDEX idx_diagnosis (diagnosis_id);
ALTER TABLE la_diagnosis_view_records
ADD INDEX idx_patient (patient_id);
ALTER TABLE la_diagnosis_view_records
ADD INDEX idx_share_user (share_user_id);
```
### 9. 数据清理
定期清理过期的查看记录(可选):
```sql
-- 删除30天前的未确认记录
DELETE FROM la_diagnosis_view_records
WHERE is_confirmed = 0
AND create_time < UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 30 DAY));
-- 或使用软删除
UPDATE la_diagnosis_view_records
SET delete_time = UNIX_TIMESTAMP()
WHERE is_confirmed = 0
AND create_time < UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 30 DAY));
```
### 10. 下一步
功能安装完成后,可以:
1. 实现查看记录的管理界面
2. 添加数据统计报表
3. 实现查看记录的导出功能
4. 添加消息通知(如:诊单被查看时通知医生)
## 相关文档
- [功能说明文档](./DIAGNOSIS_VIEW_RECORD_FEATURE.md)
- [Scene参数说明](./MINI_PROGRAM_SCENE_PARAMS.md)
- [小程序二维码功能](./QRCODE_README.md)
+146
View File
@@ -0,0 +1,146 @@
# 小程序二维码Scene参数说明
## 概述
小程序通过扫描二维码进入时,参数通过 `scene` 字段传递,格式为URL编码的键值对字符串。
## 后端生成
### DiagnosisLogic.php
```php
// 构建scene参数
$scene = "id={$diagnosisId}&share_user={$shareUserId}";
// 调用微信接口
$data = [
'scene' => $scene, // 例如: "id=4&share_user=1"
'page' => 'pages/order/monad/monad',
'check_path' => false,
'env_version' => 'release',
'width' => 280
];
```
### 微信返回的scene格式
微信会自动对scene进行URL编码,小程序接收到的格式为:
```
scene: "id%3D4%26share_user%3D1"
```
## 前端解析
### monad.vue 解析逻辑
```javascript
// 解析页面参数(支持普通参数和scene参数)
const parsePageParams = (options) => {
const params = {};
// 如果有scene参数(扫码进入),解析scene
if (options.scene) {
try {
// URL解码scene参数: "id%3D4%26share_user%3D1" -> "id=4&share_user=1"
const decodedScene = decodeURIComponent(options.scene);
// 解析键值对
decodedScene.split('&').forEach(item => {
const [key, value] = item.split('=');
if (key && value) {
params[key] = value;
}
});
} catch (error) {
console.error('解析scene参数失败:', error);
}
}
// 合并普通参数(普通跳转进入)
Object.keys(options).forEach(key => {
if (key !== 'scene' && options[key]) {
params[key] = options[key];
}
});
return params;
};
```
### 使用示例
```javascript
// 在onMounted或需要的地方调用
const pages = getCurrentPages();
const currentPage = pages[pages.length - 1];
const params = parsePageParams(currentPage.options);
console.log('解析后的参数:', params);
// 输出: { id: "4", share_user: "1" }
// 使用参数
const diagnosisId = params.id;
const shareUserId = params.share_user;
```
## 两种进入方式
### 1. 扫码进入(scene参数)
```javascript
// currentPage.options
{
scene: "id%3D4%26share_user%3D1"
}
// 解析后
{
id: "4",
share_user: "1"
}
```
### 2. 普通跳转进入(直接参数)
```javascript
// currentPage.options
{
id: "4",
share_user: "1"
}
// 解析后
{
id: "4",
share_user: "1"
}
```
## 注意事项
1. **scene长度限制**: 微信小程序scene参数最大长度为32个字符(编码前)
2. **URL编码**: 微信会自动对scene进行URL编码,前端需要使用 `decodeURIComponent` 解码
3. **参数格式**: 使用 `key=value&key2=value2` 格式,不要使用JSON
4. **兼容性**: 解析函数同时支持scene参数和普通参数,确保两种进入方式都能正常工作
## 调试方法
### 查看原始参数
```javascript
const pages = getCurrentPages();
const currentPage = pages[pages.length - 1];
console.log('原始options:', currentPage.options);
```
### 查看解析结果
```javascript
const params = parsePageParams(currentPage.options);
console.log('解析后的参数:', params);
console.log('诊单ID:', params.id);
console.log('分享用户ID:', params.share_user);
```
## 完整流程
1. **管理后台**: 点击"小程序二维码"按钮
2. **后端生成**: 调用 `generateMiniProgramQrcode` 接口
3. **构建scene**: `id=4&share_user=1`
4. **微信编码**: 微信自动编码为 `id%3D4%26share_user%3D1`
5. **用户扫码**: 小程序接收到 `options.scene = "id%3D4%26share_user%3D1"`
6. **前端解析**: 使用 `parsePageParams` 解析为 `{ id: "4", share_user: "1" }`
7. **加载数据**: 使用解析后的参数加载诊单详情
+24 -2
View File
@@ -16,13 +16,16 @@ onLaunch(() => {
success: function (loginRes) {
console.log('xx');
console.log(loginRes.code);
if( uni.getStorageSync('token')){
userinfo(loginRes.code);
}else{
wxcode(loginRes.code)
}
// 获取用户信息
}
});
})
const wxcode = async (code) => {
@@ -41,6 +44,25 @@ const wxcode = async (code) => {
} catch (err) {
}
}
const userinfo = async (code) => {
try {
// 通过 proxy 调用全局的 apiUrl
const res = await proxy.apiUrl({
url: '/api/user/info',
method: 'POST',
}, false) // 不显示加载中
if(res.code==-1){
wxcode(code)
}
uni.setStorageSync('userData', res.data)
} catch (err) {
}
}
+2 -2
View File
@@ -4,7 +4,7 @@ import App from './App'
import Vue from 'vue'
import './uni.promisify.adaptor'
Vue.config.productionTip = false
Vue.prototype.$url = 'http://www.d.com'
Vue.prototype.$url = 'http://api.zzzhengyangtang.cn'
Vue.prototype.apiUrl =function apiurl(promise, Loading = true){
let token=uni.getStorageSync('token')
promise.header={
@@ -55,7 +55,7 @@ app.$mount()
import { createSSRApp } from 'vue'
// 定义全局基础URL
const baseUrl = 'http://www.d.com'
const baseUrl = 'http://api.zzzhengyangtang.cn'
// 封装Vue3版本的apiUrl方法
function apiUrl(promise, Loading = true) {
+5 -3
View File
@@ -1,9 +1,9 @@
{
"pages": [
{
"path": "pages/index/login",
"path": "pages/index/video",
"style": {
"navigationBarTitleText": "uni-app"
"navigationBarTitleText": "甄养堂"
}
},
{
@@ -15,7 +15,9 @@
{
"path": "TUICallKit/src/Components/TUICallKit",
"style": {
"navigationBarTitleText": "视频面诊"
"navigationBarTitleText": "视频面诊",
"navigationBarHidden": true,
"navigationStyle": "custom"
}
},
{
-320
View File
@@ -1,320 +0,0 @@
<template>
<view class="container">
<view class="counter-warp">
<view class="header-content">
<image :src="avatarUrl" class="icon-box" v-if="avatarUrl"/>
<view class="text-header">用户登录</view>
</view>
<view class="box">
<view class="list-item">
<label class="list-item-label">用户ID</label>
<input
class="input-box"
type="text"
v-model="userID"
placeholder="请输入用户ID"
placeholder-style="color:#BBBBBB;"
/>
</view>
<view class="login"
><button class="loginBtn" @click="loginHandler">登录</button></view
>
</view>
</view>
</view>
</template>
<script setup>
import { ref,onMounted,getCurrentInstance } from "vue";
// 2. 获取组件实例,通过 proxy 访问全局属性
const { proxy } = getCurrentInstance()
import * as GenerateTestUserSig from "../../debug/GenerateTestUserSig-es.js";
import { CallManager } from "../../TUICallKit/src/TUICallService/serve/callManager";
let userID = ref("4");
let avatarUrl = ref(""); // 声明为响应式变量
uni.CallManager = new CallManager();
onMounted(() => {
uni.login({
provider: 'weixin',
success: function (loginRes) {
console.log('xx');
console.log(loginRes.code);
wxcode(loginRes.code)
// 获取用户信息
uni.getUserInfo({
provider: 'weixin',
withCredentials:true,
success: function (infoRes) {
avatarUrl.value = infoRes.userInfo.avatarUrl; // 使用 .value 赋值
console.log('头像URL:', avatarUrl.value);
console.log(infoRes.userInfo);
}
});
}
});
console.log('---------进入onMounted')
})
const wxcode = async (code) => {
try {
// 通过 proxy 调用全局的 apiUrl
const res = await proxy.apiUrl({
url: '/api/login/mnpLogin',
method: 'POST',
data: {
code: code
},
}, false) // 不显示加载中
} catch (err) {
uni.showToast({ title: '请求失败', icon: 'none' })
console.error(err)
}
}
const loginHandler = async () => {
// 从后端获取签名
const signatureData = await getSignatureFromServer(patientId.value);
console.log('获取签名成功:', signatureData);
const {userId } = signatureData;
const { userSig, SDKAppID } = GenerateTestUserSig.genTestUserSig({
userID: userId.value,
});
console.warn('--- ', SDKAppID);
getApp().globalData.userID = userId.value;
getApp().globalData.userSig = userSig;
getApp().globalData.SDKAppID = SDKAppID;
await uni.CallManager.init({
sdkAppID: SDKAppID, // 替换为用户自己的 sdkAppID
userID: userId.value, // 替换为用户自己的 userID
userSig: userSig, // 替换为用户自己的 userSig
globalCallPagePath: "TUICallKit/src/Components/TUICallKit", // 替换为步骤一里注册的全局监听页面
});
uni.navigateTo({
url: "./index",
});
};
// 从后端获取签名
const getSignatureFromServer = async (patientId) => {
return new Promise((resolve, reject) => {
uni.request({
url: 'https://api.zzzhengyangtang.cn/api/tcm/getPatientSignature', // 后端接口地址 // 替换为你的后端地址
method: 'GET',
data: {
patient_id: patientId
},
success: (res) => {
if (res.data && res.data.code === 1) {
resolve(res.data.data);
} else {
reject(new Error(res.data.msg || '获取签名失败'));
}
},
fail: (err) => {
reject(err);
}
});
});
};
</script>
<style scoped>
.container {
width: 100vw;
height: 100vh;
background-color: #f4f5f9;
position: fixed;
top: 0;
right: 0;
left: 0;
bottom: 0;
}
.counter-warp {
position: absolute;
top: 0;
right: 0;
left: 0;
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
}
.background-image {
width: 100%;
}
.header-content {
display: flex;
width: 100vw;
padding: 50px 20px 10px;
box-sizing: border-box;
top: 100rpx;
background-color: #000;
align-items: center;
}
.icon-box {
width: 56px;
height: 56px;
}
.text-header {
height: 72rpx;
font-size: 48rpx;
line-height: 72rpx;
color: #ffffff;
margin: 40px auto;
}
.text-content {
height: 36rpx;
font-size: 24rpx;
line-height: 36rpx;
color: #ffffff;
}
.box {
width: 80%;
height: 50vh;
position: relative;
background: #ffffff;
border-radius: 4px;
border-radius: 4px;
display: flex;
flex-direction: column;
justify-content: left;
padding: 30px 20px;
}
.input-box {
flex: 1;
display: flex;
font-family: PingFangSC-Regular;
font-size: 14px;
color: rgba(0, 0, 0, 0.8);
letter-spacing: 0;
}
.login {
display: flex;
box-sizing: border-box;
margin-top: 15px;
width: 100%;
}
.login button {
background: rgba(0, 110, 255, 1);
border-radius: 30px;
font-size: 16px;
color: #ffffff;
letter-spacing: 0;
/* text-align: center; */
font-weight: 500;
}
.loginBtn {
margin-top: 64px;
background-color: white;
border-radius: 24px;
border-radius: 24px;
/* display: flex;
justify-content: center; */
width: 100% !important;
font-family: PingFangSC-Regular;
font-size: 16px;
color: #ffffff;
letter-spacing: 0;
}
.list-item {
display: flex;
flex-direction: column;
font-family: PingFangSC-Medium;
font-size: 14px;
color: #333333;
border-bottom: 1px solid #eef0f3;
}
.input-container {
width: 90%;
margin: 50px auto 0;
display: flex;
flex-direction: column;
font-family: PingFangSC-Medium;
font-size: 14px;
color: #333333;
border-bottom: 1px solid #eef0f3;
}
/* .input-box {
height: 20px;
padding: 5px;
width: 100%;
border: 1px solid #999999;;
} */
.list-item .list-item-label {
font-weight: 500;
padding: 10px 0;
}
.guide-box {
width: 100vw;
box-sizing: border-box;
padding: 16px;
display: flex;
flex-direction: column;
}
.single-box {
flex: 1;
border-radius: 10px;
background-color: #ffffff;
margin-bottom: 16px;
display: flex;
align-items: center;
}
.icon {
display: block;
width: 180px;
height: 144px;
}
.single-content {
padding: 36px 30px 36px 20px;
color: #333333;
}
.label {
display: block;
font-size: 18px;
color: #333333;
letter-spacing: 0;
font-weight: 500;
}
.desc {
display: block;
font-size: 14px;
color: #333333;
letter-spacing: 0;
font-weight: 500;
}
.logo-box {
position: absolute;
width: 100vw;
bottom: 36rpx;
text-align: center;
}
</style>
+578
View File
@@ -0,0 +1,578 @@
<template>
<view class="container">
<!-- 等待视频通话页面 - 老年人友好版 -->
<view class="waiting-container">
<view class="waiting-content">
<!-- 大号医生图标动画 -->
<view class="waiting-animation">
<view class="pulse-ring"></view>
<view class="pulse-ring delay-1"></view>
<view class="pulse-ring delay-2"></view>
<view class="doctor-icon">
<text class="icon-text">👨</text>
</view>
</view>
<!-- 超大标题 -->
<view class="waiting-title">正在等待医生</view>
<view class="waiting-subtitle">视频通话即将开始</view>
<!-- 简化的状态显示 -->
<!-- <view class="status-card">
<view class="status-icon"></view>
<view class="status-main-text">系统已准备好</view>
<view class="status-sub-text">请耐心等待医生接入</view>
</view> -->
<!-- 大字号提示卡片 -->
<view class="tips-card">
<view class="tips-header">
<text class="tips-icon">💡</text>
<text class="tips-header-text">温馨提示</text>
</view>
<view class="tips-list">
<view class="tips-item">
<text class="tips-number">1</text>
<text class="tips-text">请保持手机摄像头清洁</text>
</view>
<view class="tips-item">
<text class="tips-number">2</text>
<text class="tips-text">选择光线明亮的位置</text>
</view>
<view class="tips-item">
<text class="tips-number">3</text>
<text class="tips-text">保持环境安静</text>
</view>
</view>
</view>
<!-- 大号帮助按钮 -->
<view class="help-button">
<text class="help-text">需要帮助点击这里</text>
</view>
</view>
</view>
</view>
</template>
<script setup>
import { ref,onMounted,getCurrentInstance} from "vue";
// 2. 获取组件实例,通过 proxy 访问全局属性
const { proxy } = getCurrentInstance()
import * as GenerateTestUserSig from "@/debug/GenerateTestUserSig-es.js";
import { CallManager } from "@/TUICallKit/src/TUICallService/serve/callManager";
let userID = ref("4");
let avatarUrl = ref(""); // 声明为响应式变量
uni.CallManager = new CallManager();
onMounted(() => {
uni.login({
provider: 'weixin',
success: function (loginRes) {
wxcode(loginRes.code)
// 获取用户信息
}
});
console.log('---------进入onMounted')
})
onShareAppMessage((res) =>{
// res.from 可判断分享触发方式:button(按钮触发)、menu(右上角菜单触发)
const shareSource = res.from;
// 自定义分享内容
return {
title: '视频问诊通话邀请', // 分享标题(必填)
path: '/pages/index/video', // 分享路径(必填,以 / 开头,可带参数)
imageUrl: '/static/share-img.png', // 分享图片(可选,建议尺寸 5:4,支持本地/网络图片)
desc: '自定义分享描述', // 小程序分享描述(仅在某些场景显示)
success() {
// 分享成功回调
uni.showToast({ title: '分享成功', icon: 'success' });
},
fail(err) {
// 分享失败回调
console.log('分享失败:', err);
uni.showToast({ title: '分享失败', icon: 'none' });
}
}
});
const wxcode = async (code) => {
try {
// 通过 proxy 调用全局的 apiUrl
const res = await proxy.apiUrl({
url: '/api/login/mnpLogin',
method: 'POST',
data: {
code: code
},
}, false) // 不显示加载中
loginHandler(res.data.diagnosis.patient_id)
} catch (err) {
uni.showToast({ title: '请求失败', icon: 'none' })
console.error(err)
}
}
const loginHandler = async (patient_id) => {
// 从后端获取签名
//const signatureData = await getSignatureFromServer(patient_id);
const res = await proxy.apiUrl({
url: '/api/tcm/getPatientSignature',
method: 'GET',
data: {
patient_id: patient_id ||patient
},
}, false)
const {userId } = res.data;
const { userSig, SDKAppID } = GenerateTestUserSig.genTestUserSig({
userID:userId,
});
console.log('获取签名成功:',userSig);
getApp().globalData.userID = userId.value;
getApp().globalData.userSig = userSig;
getApp().globalData.SDKAppID = SDKAppID;
await uni.CallManager.init({
sdkAppID: SDKAppID, // 替换为用户自己的 sdkAppID
userID: userId, // 替换为用户自己的 userID
userSig: userSig, // 替换为用户自己的 userSig
globalCallPagePath: "TUICallKit/src/Components/TUICallKit", // 替换为步骤一里注册的全局监听页面
});
// uni.navigateTo({
// url: "./index",
// });
};
</script>
<style scoped>
.container {
width: 100vw;
height: 100vh;
background-color: #f4f5f9;
position: fixed;
top: 0;
right: 0;
left: 0;
bottom: 0;
}
.counter-warp {
position: absolute;
top: 0;
right: 0;
left: 0;
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
}
.background-image {
width: 100%;
}
.header-content {
display: flex;
width: 100vw;
padding: 50px 20px 10px;
box-sizing: border-box;
top: 100rpx;
background-color: #000;
align-items: center;
}
.icon-box {
width: 56px;
height: 56px;
}
.text-header {
height: 72rpx;
font-size: 48rpx;
line-height: 72rpx;
color: #ffffff;
margin: 40px auto;
}
.text-content {
height: 36rpx;
font-size: 24rpx;
line-height: 36rpx;
color: #ffffff;
}
.box {
width: 80%;
height: 50vh;
position: relative;
background: #ffffff;
border-radius: 4px;
border-radius: 4px;
display: flex;
flex-direction: column;
justify-content: left;
padding: 30px 20px;
}
.input-box {
flex: 1;
display: flex;
font-family: PingFangSC-Regular;
font-size: 14px;
color: rgba(0, 0, 0, 0.8);
letter-spacing: 0;
}
.login {
display: flex;
box-sizing: border-box;
margin-top: 15px;
width: 100%;
}
.login button {
background: rgba(0, 110, 255, 1);
border-radius: 30px;
font-size: 16px;
color: #ffffff;
letter-spacing: 0;
/* text-align: center; */
font-weight: 500;
}
.loginBtn {
margin-top: 64px;
background-color: white;
border-radius: 24px;
border-radius: 24px;
/* display: flex;
justify-content: center; */
width: 100% !important;
font-family: PingFangSC-Regular;
font-size: 16px;
color: #ffffff;
letter-spacing: 0;
}
.list-item {
display: flex;
flex-direction: column;
font-family: PingFangSC-Medium;
font-size: 14px;
color: #333333;
border-bottom: 1px solid #eef0f3;
}
.input-container {
width: 90%;
margin: 50px auto 0;
display: flex;
flex-direction: column;
font-family: PingFangSC-Medium;
font-size: 14px;
color: #333333;
border-bottom: 1px solid #eef0f3;
}
/* .input-box {
height: 20px;
padding: 5px;
width: 100%;
border: 1px solid #999999;;
} */
.list-item .list-item-label {
font-weight: 500;
padding: 10px 0;
}
.guide-box {
width: 100vw;
box-sizing: border-box;
padding: 16px;
display: flex;
flex-direction: column;
}
.single-box {
flex: 1;
border-radius: 10px;
background-color: #ffffff;
margin-bottom: 16px;
display: flex;
align-items: center;
}
.icon {
display: block;
width: 180px;
height: 144px;
}
.single-content {
padding: 36px 30px 36px 20px;
color: #333333;
}
.label {
display: block;
font-size: 18px;
color: #333333;
letter-spacing: 0;
font-weight: 500;
}
.desc {
display: block;
font-size: 14px;
color: #333333;
letter-spacing: 0;
font-weight: 500;
}
.logo-box {
position: absolute;
width: 100vw;
bottom: 36rpx;
text-align: center;
}
/* ========== 老年人友好等待界面样式 ========== */
.waiting-container {
width: 100vw;
min-height: 100vh;
background: linear-gradient(180deg, #f0f7ff 0%, #ffffff 100%);
display: flex;
align-items: center;
justify-content: center;
padding: 40rpx;
box-sizing: border-box;
}
.waiting-content {
width: 100%;
max-width: 700rpx;
display: flex;
flex-direction: column;
align-items: center;
}
/* 动画区域 - 更大更明显 */
.waiting-animation {
position: relative;
width: 280rpx;
height: 280rpx;
margin-bottom: 60rpx;
display: flex;
align-items: center;
justify-content: center;
}
.pulse-ring {
position: absolute;
width: 100%;
height: 100%;
border: 6rpx solid #1890ff;
border-radius: 50%;
animation: pulse 2s ease-out infinite;
opacity: 0;
}
.pulse-ring.delay-1 {
animation-delay: 0.6s;
}
.pulse-ring.delay-2 {
animation-delay: 1.2s;
}
@keyframes pulse {
0% {
transform: scale(0.5);
opacity: 1;
}
100% {
transform: scale(1.3);
opacity: 0;
}
}
.doctor-icon {
width: 180rpx;
height: 180rpx;
background: linear-gradient(135deg, #1890ff 0%, #096dd9 100%);
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
box-shadow: 0 8rpx 24rpx rgba(24, 144, 255, 0.3);
z-index: 1;
}
.icon-text {
font-size: 100rpx;
line-height: 1;
}
/* 超大标题 - 老年人易读 */
.waiting-title {
font-size: 56rpx;
font-weight: bold;
color: #1890ff;
margin-bottom: 20rpx;
text-align: center;
line-height: 1.4;
}
.waiting-subtitle {
font-size: 40rpx;
color: #333333;
margin-bottom: 60rpx;
text-align: center;
line-height: 1.5;
}
/* 状态卡片 - 简洁明了 */
.status-card {
width: 100%;
background: #ffffff;
border-radius: 24rpx;
padding: 50rpx 40rpx;
margin-bottom: 40rpx;
box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.08);
display: flex;
flex-direction: column;
align-items: center;
border: 3rpx solid #52c41a;
}
.status-icon {
width: 80rpx;
height: 80rpx;
background: #52c41a;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
font-size: 50rpx;
color: #ffffff;
margin-bottom: 30rpx;
font-weight: bold;
}
.status-main-text {
font-size: 44rpx;
font-weight: bold;
color: #52c41a;
margin-bottom: 20rpx;
text-align: center;
}
.status-sub-text {
font-size: 36rpx;
color: #666666;
text-align: center;
line-height: 1.6;
}
/* 提示卡片 - 大字号清晰 */
.tips-card {
width: 100%;
background: #fffbe6;
border-radius: 24rpx;
padding: 40rpx;
margin-bottom: 40rpx;
border: 3rpx solid #fadb14;
}
.tips-header {
display: flex;
align-items: center;
margin-bottom: 30rpx;
padding-bottom: 20rpx;
border-bottom: 2rpx solid #ffd666;
}
.tips-icon {
font-size: 48rpx;
margin-right: 16rpx;
}
.tips-header-text {
font-size: 40rpx;
font-weight: bold;
color: #d48806;
}
.tips-list {
display: flex;
flex-direction: column;
gap: 30rpx;
}
.tips-item {
display: flex;
align-items: center;
padding: 24rpx;
background: #ffffff;
border-radius: 16rpx;
}
.tips-number {
width: 60rpx;
height: 60rpx;
background: #faad14;
color: #ffffff;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
font-size: 36rpx;
font-weight: bold;
margin-right: 24rpx;
flex-shrink: 0;
}
.tips-text {
font-size: 36rpx;
color: #333333;
line-height: 1.6;
font-weight: 500;
}
/* 帮助按钮 - 大号易点击 */
.help-button {
width: 100%;
height: 100rpx;
background: #ffffff;
border: 3rpx solid #1890ff;
border-radius: 50rpx;
display: flex;
align-items: center;
justify-content: center;
box-shadow: 0 4rpx 12rpx rgba(24, 144, 255, 0.15);
margin-top: 20rpx;
}
.help-text {
font-size: 38rpx;
color: #1890ff;
font-weight: bold;
}
</style>
+180 -35
View File
@@ -1,6 +1,16 @@
<template>
<view class="container">
<view class="form-wrapper">
<view v-if="!dingdan_ok">
<!-- 确认成功页面 -->
<view v-if="showSuccessPage" class="success-page">
<view class="success-icon"></view>
<view class="success-title">确认成功</view>
<view class="success-desc">诊单已确认感谢您的配合</view>
<button class="back-btn" @click="goBack">返回</button>
</view>
<!-- 诊单详情表单 -->
<view v-else class="form-wrapper">
<!-- 基本信息 -->
<view class="section">
<view class="section-title">基本信息</view>
@@ -189,6 +199,21 @@
<button class="confirm-btn" @click="handleConfirm">确认诊单</button>
</view>
</view>
<view v-else class="success-container">
<view class="success-content">
<view class="success-icon-wrapper">
<view class="success-icon-circle">
<text class="success-icon-check"></text>
</view>
</view>
<view class="success-title">确认成功</view>
<view class="success-message">诊单已确认感谢您的配合</view>
</view>
</view>
</view>
</template>
<script setup>
@@ -224,7 +249,7 @@ const formData = ref({
prescription: '',
doctor_advice: ''
});
let dingdan_ok=ref(false)
// 字典选项
const diagnosisTypeOptions = ref([]);
const syndromeTypeOptions = ref([]);
@@ -307,27 +332,52 @@ const getDictData = async (type) => {
}
};
// 解析页面参数(支持普通参数和scene参数)
const parsePageParams = (options) => {
const params = {};
// 如果有scene参数(扫码进入),解析scene
if (options.scene) {
try {
// URL解码scene参数
const decodedScene = decodeURIComponent(options.scene);
// 解析键值对:id=4&share_user=1
decodedScene.split('&').forEach(item => {
const [key, value] = item.split('=');
if (key && value) {
params[key] = value;
}
});
} catch (error) {
console.error('解析scene参数失败:', error);
}
}
// 合并普通参数(普通跳转进入)
Object.keys(options).forEach(key => {
if (key !== 'scene' && options[key]) {
params[key] = options[key];
}
});
// 获取当前登录用户ID(从本地存储或全局状态获取)
// TODO: 根据你的项目实际情况获取用户ID
// 例如: const userInfo = uni.getStorageSync('userInfo');
// params.user_id = userInfo?.id || 0;
return params;
};
// 加载诊单详情
const loadDiagnosisDetail = async () => {
// 从页面参数获取诊单ID
const pages = getCurrentPages();
const currentPage = pages[pages.length - 1];
// 假设你的对象是 ai
const scene = currentPage.options.scene;
const params = parsePageParams(currentPage.options);
dingdan_ok.value=uni.getStorageSync('dingdan_ok');
const diagnosisId = params.id;
console.log('页面参数:', params, '诊单ID:', diagnosisId);
// 1. 先对 scene 进行 URL 解码
const decodedScene = decodeURIComponent(scene) ||currentPage.options;
// 得到 "id=4&share_user=1"
// 2. 解析成键值对对象
const params = {};
decodedScene.split('&').forEach(item => {
const [key, value] = item.split('=');
params[key] = value;
});
const diagnosisId = currentPage.options.id ||params.id|| 4;
console.log('nihhhhhh',pages,params,diagnosisId)
if (!diagnosisId) {
uni.showToast({ title: '缺少诊单ID', icon: 'none' });
return;
@@ -341,7 +391,9 @@ const loadDiagnosisDetail = async () => {
url: '/api/tcm/diagnosisDetail',
method: 'GET',
data: {
id: diagnosisId
id: diagnosisId,
user_id: params.user_id || 0,
share_user_id: params.share_user || 0
},
}, false); // 不显示加载中
@@ -469,25 +521,12 @@ const handleConfirm = () => {
// 提交确认诊单
const confirmDiagnosis = async () => {
const pages = getCurrentPages();
const currentPage = pages[pages.length - 1];
// 假设你的对象是 ai
const scene = currentPage.options.scene;
const params = parsePageParams(currentPage.options);
// 1. 先对 scene 进行 URL 解码
const decodedScene = decodeURIComponent(scene);
// 得到 "id=4&share_user=1"
console.log('确认诊单参数:', params);
// 2. 解析成键值对对象
const params = {};
decodedScene.split('&').forEach(item => {
const [key, value] = item.split('=');
params[key] = value;
});
const diagnosisId = currentPage.options.id ||params.id|| 4;
console.log('nihhhhhh',pages,params,diagnosisId)
if (!params.id) {
uni.showToast({ title: '缺少诊单ID', icon: 'none' });
return;
@@ -503,16 +542,19 @@ const confirmDiagnosis = async () => {
method: 'POST',
data: {
id: params.id,
share_user: params.share_user
user_id: params.user_id || 0,
share_user: params.share_user || 0
}
}, false);
if (res.code === 1) {
uni.showToast({
title: '确认成功',
icon: 'success',
icon: 'none',
duration: 2000
});
uni.setStorageSync('dingdan_ok', true);
dingdan_ok.value=true;
setTimeout(() => {
uni.navigateBack();
}, 2000);
@@ -636,4 +678,107 @@ const confirmDiagnosis = async () => {
border: none;
box-shadow: 0 8rpx 24rpx rgba(102, 126, 234, 0.3);
}
/* 确认成功页面样式 */
.success-container {
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
padding: 40rpx;
}
.success-content {
width: 100%;
max-width: 600rpx;
background: #fff;
border-radius: 32rpx;
padding: 80rpx 40rpx 60rpx;
text-align: center;
box-shadow: 0 20rpx 60rpx rgba(0, 0, 0, 0.15);
animation: successFadeIn 0.5s ease-out;
}
@keyframes successFadeIn {
from {
opacity: 0;
transform: translateY(-40rpx);
}
to {
opacity: 1;
transform: translateY(0);
}
}
.success-icon-wrapper {
margin-bottom: 40rpx;
}
.success-icon-circle {
width: 160rpx;
height: 160rpx;
margin: 0 auto;
background: linear-gradient(135deg, #52c41a 0%, #73d13d 100%);
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
box-shadow: 0 12rpx 40rpx rgba(82, 196, 26, 0.3);
animation: successScale 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
@keyframes successScale {
0% {
transform: scale(0);
opacity: 0;
}
50% {
transform: scale(1.1);
}
100% {
transform: scale(1);
opacity: 1;
}
}
.success-icon-check {
font-size: 100rpx;
color: #fff;
font-weight: bold;
line-height: 1;
}
.success-title {
font-size: 48rpx;
font-weight: bold;
color: #333;
margin-bottom: 24rpx;
animation: successSlideIn 0.6s ease-out 0.2s both;
}
@keyframes successSlideIn {
from {
opacity: 0;
transform: translateY(20rpx);
}
to {
opacity: 1;
transform: translateY(0);
}
}
.success-message {
font-size: 28rpx;
color: #666;
line-height: 1.6;
margin-bottom: 16rpx;
animation: successSlideIn 0.6s ease-out 0.3s both;
}
.success-tips {
font-size: 24rpx;
color: #999;
animation: successSlideIn 0.6s ease-out 0.4s both;
}
</style>
@@ -1048,4 +1048,153 @@ class DiagnosisLogic extends BaseLogic
curl_close($ch);
return $response;
}
/**
* @notes 获取诊单详情并记录查看
* @param array $params
* @return array|false
*/
public static function diagnosisDetailWithRecord(array $params)
{
try {
$diagnosisId = $params['id'];
$userId = $params['user_id'] ?? 0;
$shareUserId = $params['share_user_id'] ?? 0;
// 获取诊单详情
$diagnosis = self::detail(['id' => $diagnosisId]);
if (!$diagnosis) {
throw new \Exception('诊单不存在');
}
// 记录查看行为
self::recordDiagnosisView([
'user_id' => $userId,
'diagnosis_id' => $diagnosisId,
'patient_id' => $diagnosis['patient_id'] ?? 0,
'share_user_id' => $shareUserId
]);
return $diagnosis;
} catch (\Exception $e) {
self::setError($e->getMessage());
return false;
}
}
/**
* @notes 记录诊单查看
* @param array $params
* @return bool
*/
private static function recordDiagnosisView(array $params)
{
try {
$userId = $params['user_id'];
$diagnosisId = $params['diagnosis_id'];
$patientId = $params['patient_id'];
$shareUserId = $params['share_user_id'];
// 查找是否已有记录
$record = \app\common\model\DiagnosisViewRecord::where([
'user_id' => $userId,
'diagnosis_id' => $diagnosisId
])->find();
$now = time();
if ($record) {
// 更新记录
$record->view_count = $record->view_count + 1;
$record->last_view_time = $now;
$record->update_time = $now;
$record->save();
} else {
// 创建新记录
\app\common\model\DiagnosisViewRecord::create([
'user_id' => $userId,
'diagnosis_id' => $diagnosisId,
'patient_id' => $patientId,
'share_user_id' => $shareUserId,
'view_count' => 1,
'first_view_time' => $now,
'last_view_time' => $now,
'is_confirmed' => 0,
'create_time' => $now,
'update_time' => $now
]);
}
return true;
} catch (\Exception $e) {
\think\facade\Log::error('记录诊单查看失败: ' . $e->getMessage());
return false;
}
}
/**
* @notes 确认诊单
* @param array $params
* @return bool
*/
public static function confirmDiagnosisRecord(array $params)
{
try {
$userId = $params['user_id'] ?? 0;
$diagnosisId = $params['id'];
$shareUserId = $params['share_user_id'] ?? 0;
if(!$userId){
throw new \Exception('请重新登录!');
}
// 查找查看记录
$record = \app\common\model\DiagnosisViewRecord::where([
'user_id' => $userId,
'diagnosis_id' => $diagnosisId
])->find();
$now = time();
if ($record) {
// 更新确认状态
$record->is_confirmed = 1;
$record->confirmed_time = $now;
$record->update_time = $now;
$record->save();
} else {
// 如果没有查看记录,创建一条已确认的记录
$diagnosis = Diagnosis::find($diagnosisId);
if (!$diagnosis) {
throw new \Exception('诊单不存在');
}
// 再次检查是否存在记录,防止并发创建重复记录
$existingRecord = \app\common\model\DiagnosisViewRecord::where([
'user_id' => $userId,
'diagnosis_id' => $diagnosisId
])->find();
if (!$existingRecord) {
\app\common\model\DiagnosisViewRecord::create([
'user_id' => $userId,
'diagnosis_id' => $diagnosisId,
'patient_id' => $diagnosis->patient_id ?? 0,
'share_user_id' => $shareUserId,
'view_count' => 1,
'first_view_time' => $now,
'last_view_time' => $now,
'is_confirmed' => 1,
'confirmed_time' => $now,
'create_time' => $now,
'update_time' => $now
]);
}
}
return true;
} catch (\Exception $e) {
self::setError($e->getMessage());
return false;
}
}
}
Binary file not shown.
+42 -4
View File
@@ -28,7 +28,7 @@ class TcmController extends BaseApiController
* @notes 不需要登录的方法
* @var array
*/
public array $notNeedLogin = ['getPatientSignature', 'diagnosisDetail', 'getDict'];
public array $notNeedLogin = ['getPatientSignature', 'diagnosisDetail', 'getDict', 'confirmDiagnosis'];
/**
* @notes 获取患者签名(供小程序调用)
@@ -58,20 +58,58 @@ class TcmController extends BaseApiController
*/
public function diagnosisDetail()
{
$id = $this->request->get('id');
$params = [
'id' => $this->request->get('id'),
'user_id' => $this->request->get('user_id', 0),
'share_user_id' => $this->request->get('share_user_id', 0)
];
if (!$id) {
if (!$params['id']) {
return $this->fail('诊单ID不能为空');
}
try {
$result = DiagnosisLogic::detail(['id' => $id]);
$result = DiagnosisLogic::diagnosisDetailWithRecord($params);
if ($result === false) {
return $this->fail(DiagnosisLogic::getError());
}
return $this->data($result);
} catch (\Exception $e) {
return $this->fail($e->getMessage());
}
}
/**
* @notes 确认诊单(供小程序调用)
* @return \think\response\Json
*/
public function confirmDiagnosis()
{
$params = [
'id' => $this->request->post('id'),
'user_id' => $this->userId,
'share_user_id' => $this->request->post('share_user', 0)
];
if (!$params['id']) {
return $this->fail('诊单ID不能为空');
}
try {
$result = DiagnosisLogic::confirmDiagnosisRecord($params);
if ($result === false) {
return $this->fail(DiagnosisLogic::getError());
}
return $this->success('确认成功');
} catch (\Exception $e) {
return $this->fail($e->getMessage());
}
}
/**
* @notes 获取字典数据(供小程序调用)
* @return \think\response\Json
@@ -53,6 +53,7 @@ class UserController extends BaseApiController
*/
public function info()
{
$result = UserLogic::info($this->userId);
return $this->data($result);
}
+1
View File
@@ -71,6 +71,7 @@ class UserLogic extends BaseLogic
public static function info(int $userId)
{
$user = User::where(['id' => $userId])
->with('diagnosis')
->field('id,sn,sex,account,password,nickname,real_name,avatar,mobile,create_time,user_money')
->findOrEmpty();
$user['has_password'] = !empty($user['password']);
@@ -75,6 +75,7 @@ class WechatUserService
$unionid = $this->unionid;
$user = User::alias('u')
->with('diagnosis')
->field('u.id,u.sn,u.mobile,u.nickname,u.avatar,u.mobile,u.is_disable,u.is_new_user,au.openid')
->join('user_auth au', 'au.user_id = u.id')
->where(function ($query) use ($openid, $unionid) {
@@ -0,0 +1,50 @@
<?php
namespace app\common\model;
use app\common\model\user\User;
use app\common\model\tcm\Diagnosis;
use think\model\concern\SoftDelete;
/**
* 诊单查看记录模型
*/
class DiagnosisViewRecord extends BaseModel
{
use SoftDelete;
protected $name = 'diagnosis_view_records';
protected $deleteTime = 'delete_time';
/**
* @notes 关联用户
*/
public function user()
{
return $this->hasOne(User::class, 'id', 'user_id');
}
/**
* @notes 关联诊单
*/
public function diagnosis()
{
return $this->hasOne(Diagnosis::class, 'id', 'diagnosis_id');
}
/**
* @notes 关联患者
*/
public function patient()
{
return $this->hasOne(User::class, 'id', 'patient_id');
}
/**
* @notes 关联分享用户
*/
public function shareUser()
{
return $this->hasOne(User::class, 'id', 'share_user_id');
}
}
+12 -1
View File
@@ -20,7 +20,7 @@ use app\common\enum\user\UserEnum;
use app\common\model\BaseModel;
use app\common\service\FileService;
use think\model\concern\SoftDelete;
use app\common\model\DiagnosisViewRecord;
/**
* 用户模型
* Class User
@@ -172,5 +172,16 @@ class User extends BaseModel
return $sn;
}
/**
* @notes 关联患者表
* @return \think\model\relation\HasOne
* @author 段誉
* @date 2022/9/22 16:03
*/
public function diagnosis()
{
return $this->belongsTo(DiagnosisViewRecord::class, 'id', 'user_id');
}
}
@@ -0,0 +1,21 @@
-- 诊单查看记录表
CREATE TABLE IF NOT EXISTS `la_diagnosis_view_records` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
`user_id` int(11) NOT NULL DEFAULT '0' COMMENT '查看用户ID',
`diagnosis_id` int(11) NOT NULL DEFAULT '0' COMMENT '诊单ID',
`patient_id` int(11) NOT NULL DEFAULT '0' COMMENT '患者ID',
`share_user_id` int(11) NOT NULL DEFAULT '0' COMMENT '分享用户ID',
`view_count` int(11) NOT NULL DEFAULT '1' COMMENT '查看次数',
`first_view_time` int(11) NOT NULL DEFAULT '0' COMMENT '首次查看时间',
`last_view_time` int(11) NOT NULL DEFAULT '0' COMMENT '最后查看时间',
`is_confirmed` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否已确认 0-未确认 1-已确认',
`confirmed_time` int(11) NOT NULL DEFAULT '0' COMMENT '确认时间',
`create_time` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
`update_time` int(11) NOT NULL DEFAULT '0' COMMENT '更新时间',
`delete_time` int(11) DEFAULT NULL COMMENT '删除时间',
PRIMARY KEY (`id`),
KEY `idx_user_diagnosis` (`user_id`, `diagnosis_id`),
KEY `idx_diagnosis` (`diagnosis_id`),
KEY `idx_patient` (`patient_id`),
KEY `idx_share_user` (`share_user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='诊单查看记录表';
BIN
View File
Binary file not shown.