34
chenyincheng
2023-04-12 a814f6eb98bb1f38a80415abefd61df71a579a8a
src/stores/sockteInfo.ts
@@ -7,74 +7,110 @@
    deviceName:string;
    result:string;
    resultTime:string;
    state:boolean;
    state:number;
}
let weightInfo:info={
    type:"体重秤",
    state:false,
    state:2,
    deviceName:"",
    result:"",
    result:"0",
    resultTime:""
let xyjInfo:info={
    type:"血压计",
    state:false,
    state:2,
    deviceName:"",
    result:"",
    resultTime:""
let dkqInfo:info={
    type:"读卡器",
    state:false,
    state:2,
    deviceName:"",
    result:"",
    resultTime:""
}
let faceInfo:info={
    type:"人脸识别",
    state:2,
    deviceName:"",
    result:"",
    resultTime:""
}
export const sockteStore =defineStore('sockteInfo',()=>{
    const isLink=ref(false) // sockte 链接状态
    const netLink=ref(false) // 网络链接状态
    const weightSockte=weightInfo // 体重秤sockte结果
    const xyjSockte=xyjInfo // 血压计sockte结果
    const dkqSockte=dkqInfo // 读卡器sockte结果
    const netLink=ref(true) // 网络链接状态
    const pcName=ref('')
    const weightSockte=ref(weightInfo) // 体重秤sockte结果
    const xyjSockte=ref(xyjInfo) // 血压计sockte结果
    const dkqSockte=ref(dkqInfo) // 读卡器sockte结果
    const faceInfoSockte=ref(faceInfo)
    // 更新连接状态
    function setsockteIsLink(Link:boolean){
        isLink.value=Link
    }
    // 更新连接状态
    // 更新网络连接状态
    function setnetLink(Link:boolean){
        netLink.value=Link
    }
    /**
     * 更新体重秤结果
     * @param roleText 体重结果
     * @param infoObj 体重结果
     */
    function setweightSockte(info:info){
        weightSockte.deviceName=info.deviceName
        weightSockte.result=info.result
        weightSockte.resultTime=info.resultTime
        weightSockte.state=info.state
    function setweightSockte(infoObj:info){
        console.log(infoObj,'入参')
        if(Number(infoObj.result)>10||Number(infoObj.result)===0){
            weightSockte.value.deviceName=infoObj.deviceName
            weightSockte.value.result=infoObj.result
            weightSockte.value.resultTime=infoObj.resultTime
            weightSockte.value.state=infoObj.state
            console.log('体重秤更新')
        }else{
            console.log('体重不足10gk')
        }
    }
     /**
     * 更新体重秤工作状态
     * @param state 体重秤运行状态
     */
      function setweightState(state:any){
        weightSockte.value.state=state
    }
      /**
     * 更新血压计结果
     * @param roleText 体重结果
     * @param info 体重结果
     */
    function setxyjSockte(info:info){
        xyjSockte.deviceName=info.deviceName
        xyjSockte.result=info.result
        xyjSockte.resultTime=info.resultTime
        xyjSockte.state=info.state
        xyjSockte.value.deviceName=info.deviceName
        xyjSockte.value.result=info.result
        xyjSockte.value.resultTime=info.resultTime
        weightSockte.value.state=info.state
    }
    function setXtjState(state:any){
        xyjSockte.value.state=state
    }
      /**
     * 更新血压计结果
     * @param roleText 体重结果
     * 更新读卡器结果
     * @param info 读卡器结果
     */
    function setdkqSockte(info:info){
        dkqSockte.deviceName=info.deviceName
        dkqSockte.result=info.result
        dkqSockte.resultTime=info.resultTime
        dkqSockte.state=info.state
        dkqSockte.value.deviceName=info.deviceName
        dkqSockte.value.result=info.result
        dkqSockte.value.resultTime=info.resultTime
    }
    function setfaceSockte(info:info){
        faceInfoSockte.value.deviceName=info.deviceName
        faceInfoSockte.value.result=info.result
        faceInfoSockte.value.resultTime=info.resultTime
    }
    function setPcName(name:any){
        pcName.value=name
    }
    return {isLink,netLink,weightSockte,xyjSockte,dkqSockte,setsockteIsLink,setnetLink,setweightSockte,setxyjSockte,setdkqSockte}
    return {isLink,netLink,weightSockte,xyjSockte,dkqSockte,faceInfoSockte,pcName,setsockteIsLink,setnetLink,setweightSockte,
        setweightState,setPcName,setXtjState,setfaceSockte,
        setxyjSockte,setdkqSockte}
})