Newer
Older
Nanping_sponge_SJJC / src / hooks / rongyunhooks.js
@liyingjing liyingjing on 25 Oct 2023 1 KB 数据检测
import { ref, watch } from "vue"
import useUserStore from '@/store/modules/user'
const appStore = useUserStore()

import bus from "@/utils";
const { proxy } = getCurrentInstance();

export default function () {
  const rongYunCall = async (item) => {
    let formData1 = new FormData();
    formData1.append("userId", appStore.userInfo.phonenumber);
    let res1 = await getUserStatus(formData1);
    let flag1 = null;
    console.log(res1, "111");
    if (res1.code == 200) {
      let data = JSON.parse(res1.msg);
      flag1 = data.status;
    }
    if (flag1 != 1) {
      ElMessageBox.confirm(
        `${appStore.userInfo.userName}用户视频会商不在线,是否重新连接?, "提示"`,
        {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        }
      )
        .then(() => {
          bus.emit("rystatus");
          setTimeout(() => {
            getCallStatus(item);
          }, 1100);
        })
        .catch(() => { });
    } else {
      setTimeout(() => {
        getCallStatus(item);
      }, 1100);
    }
  };

  const getCallStatus = async (item) => {
    let formData = new FormData();
    formData.append("userId", item.phone);
    formData.append("userName", item.userName);
    let res = await getUserStatus(formData);
    let flag = null;
    if (res.code == 200) {
      let data = JSON.parse(res.msg);
      flag = data.status;
    }
    if (flag != 1) {
      return proxy.$modal.msgWarning(`${item.userName}用户视频会商不在线!`);
    } else {
      bus.emit("OffRongYun", { ...item, type: 1 });
    }
  };

  return {
    rongYunCall,
    getCallStatus
  }
}