eight
2024-10-15 1d08de208c93dba281f39cbbc59bdc336841a3e4
src/views/ecg/callingscreen/roomscreen.vue
@@ -4,11 +4,14 @@
import {RoomApi} from "@/api/ecg/room";
import {ScreenQueueVO, ScreenApi} from "@/api/ecg/screen";
import {DICT_TYPE} from "@/utils/dict";
import {CallApi, CallVO} from "@/api/ecg/call";
defineOptions({ name: 'roomscreen' })
const list = ref<ScreenQueueVO[]>([]) // 列表的数据
const listPassed = ref<ScreenQueueVO[]>([]) // 过号列表的数据
let curSpeakPat : CallVO | null = null;
const roomBed = ref<RoomBedVO>({
  roomId : null,
@@ -31,6 +34,9 @@
  setInterval(() => {
    // console.info("...")
    getList()
    if ( curSpeakPat === null ) {
      initiateSpeak()
    }
  }, 3000); // 每两秒滚动一次
}
@@ -49,6 +55,34 @@
  }
}
const onSpeachEndEvent = async (event) => {
  console.log("Speech ended... " + event.currentTarget.text);
  curSpeakPat!.called = 1
  await CallApi.updateCall(curSpeakPat!)
  initiateSpeak()
}
const initiateSpeak = async () => {
  curSpeakPat = await CallApi.getNextInstallCall()
  console.info( curSpeakPat )
  if (curSpeakPat !== null) {
    speak("请、" + curSpeakPat.patName + "到" + curSpeakPat.roomName + "装机");
  }
}
const speak = (msg) => {
  console.info("speak " + msg);
  var speech = new SpeechSynthesisUtterance()
  speech.text = msg + "。。。" + msg + "。。。" + msg  + "。。。"
  speech.pitch = 1 // 获取并设置话语的音调(0-2 默认1,值越大越尖锐,越低越低沉)
  speech.rate = 0.9 // 获取并设置说话的速度(0.1-10 默认1,值越大语速越快,越小语速越慢)
  speech.volume = 100 // 获取并设置说话的音量
  speech.lang = 'zh-CN' // 设置播放语言
  speech.onend = onSpeachEndEvent
  speechSynthesis.speak(speech)
}
onMounted( () => {
  getRoomByIp()
  startScrolling()