更新
This commit is contained in:
@@ -13,34 +13,30 @@
|
||||
class="mb-4"
|
||||
>
|
||||
<p>此页面用于测试音视频通话功能</p>
|
||||
<p>使用方法:</p>
|
||||
<ol>
|
||||
<li>在此页面初始化患者端</li>
|
||||
<li>在另一个浏览器窗口登录医生端</li>
|
||||
<li>医生端发起通话</li>
|
||||
<li>此页面会收到来电提示</li>
|
||||
</ol>
|
||||
<p>页面打开后会自动初始化患者端,等待医生端发起通话</p>
|
||||
</el-alert>
|
||||
|
||||
<el-form :model="form" label-width="100px" v-if="!initialized">
|
||||
<el-form-item label="患者ID">
|
||||
<el-input
|
||||
v-model="form.patientId"
|
||||
placeholder="输入患者ID,如:1"
|
||||
style="width: 300px;"
|
||||
/>
|
||||
</el-form-item>
|
||||
<div v-if="!initialized" class="init-section">
|
||||
<el-alert
|
||||
type="info"
|
||||
:closable="false"
|
||||
class="mb-4"
|
||||
>
|
||||
<p><strong>当前登录用户:</strong> {{ currentUser.nickname || currentUser.name || '未知' }}</p>
|
||||
<p><strong>用户ID:</strong> {{ currentUser.id || '未获取' }}</p>
|
||||
<p><strong>状态:</strong> 正在初始化...</p>
|
||||
</el-alert>
|
||||
|
||||
<el-form-item>
|
||||
<el-button
|
||||
type="primary"
|
||||
@click="initPatient"
|
||||
:loading="loading"
|
||||
>
|
||||
初始化患者端
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<el-button
|
||||
type="primary"
|
||||
@click="initPatient"
|
||||
:loading="loading"
|
||||
size="large"
|
||||
v-if="!loading"
|
||||
>
|
||||
重新初始化
|
||||
</el-button>
|
||||
</div>
|
||||
|
||||
<div v-if="initialized" class="status">
|
||||
<el-alert
|
||||
@@ -101,14 +97,18 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, onUnmounted } from 'vue'
|
||||
import { ref, onUnmounted, computed, onMounted } from 'vue'
|
||||
import { Phone } from '@element-plus/icons-vue'
|
||||
import { TUICallKitAPI, TUICallKit, STATUS } from '@trtc/calls-uikit-vue'
|
||||
import { ElMessage, ElNotification } from 'element-plus'
|
||||
import request from '@/utils/request'
|
||||
import useUserStore from '@/stores/modules/user'
|
||||
|
||||
const userStore = useUserStore()
|
||||
const currentUser = computed(() => userStore.userInfo)
|
||||
|
||||
const form = ref({
|
||||
patientId: '1'
|
||||
patientId: computed(() => currentUser.value.id?.toString() || '1')
|
||||
})
|
||||
|
||||
const loading = ref(false)
|
||||
@@ -117,6 +117,11 @@ const currentUserId = ref('')
|
||||
const hasIncomingCall = ref(false)
|
||||
const incomingCallInfo = ref<any>(null)
|
||||
|
||||
// 页面加载时自动初始化
|
||||
onMounted(() => {
|
||||
initPatient()
|
||||
})
|
||||
|
||||
// 监听状态变化
|
||||
const handleStatusChange = ({ oldStatus, newStatus }: any) => {
|
||||
console.log('通话状态变化:', { oldStatus, newStatus })
|
||||
@@ -150,13 +155,18 @@ const initPatient = async () => {
|
||||
try {
|
||||
loading.value = true
|
||||
|
||||
const patientId = currentUser.value.id
|
||||
if (!patientId) {
|
||||
throw new Error('未获取到当前用户ID,请重新登录')
|
||||
}
|
||||
|
||||
ElMessage.info('正在获取签名...')
|
||||
|
||||
// 获取患者签名
|
||||
const result = await request.get({
|
||||
url: '/tcm.diagnosis/getPatientSignature',
|
||||
url: '/tcm.diagnosis/getDoctorSignature',
|
||||
params: {
|
||||
patient_id: form.value.patientId
|
||||
patient_id: patientId
|
||||
}
|
||||
})
|
||||
|
||||
@@ -234,7 +244,6 @@ const reset = () => {
|
||||
currentUserId.value = ''
|
||||
hasIncomingCall.value = false
|
||||
incomingCallInfo.value = null
|
||||
form.value.patientId = '1'
|
||||
}
|
||||
|
||||
// 组件卸载时清理
|
||||
@@ -262,6 +271,11 @@ onUnmounted(() => {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.init-section {
|
||||
text-align: center;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.status {
|
||||
margin: 20px 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user