新增功能
This commit is contained in:
@@ -0,0 +1,198 @@
|
||||
"use strict";
|
||||
const common_vendor = require("../../common/vendor.js");
|
||||
const TUICallKit_src_TUICallService_index = require("../src/TUICallService/index.js");
|
||||
const TUICallKit_src_TUICallService_CallService_index = require("../src/TUICallService/CallService/index.js");
|
||||
const TUICallKit_src_TUICallService_const_index = require("../src/TUICallService/const/index.js");
|
||||
const TUICallKit_src_TUICallService_const_call = require("../src/TUICallService/const/call.js");
|
||||
if (!Math) {
|
||||
common_vendor.unref(TUICallKit)();
|
||||
}
|
||||
const TUICallKit = () => "../src/Components/TUICallKit.js";
|
||||
const _sfc_main = {
|
||||
__name: "call",
|
||||
setup(__props) {
|
||||
let patientId = common_vendor.ref("2");
|
||||
let currentUserId = common_vendor.ref("");
|
||||
let isLogin = common_vendor.ref(false);
|
||||
let loading = common_vendor.ref(false);
|
||||
const callStatus = common_vendor.computed(() => {
|
||||
const status = TUICallKit_src_TUICallService_CallService_index.TUIStore.getData(TUICallKit_src_TUICallService_const_call.StoreName.CALL, TUICallKit_src_TUICallService_const_index.NAME.CALL_STATUS);
|
||||
return status || "IDLE";
|
||||
});
|
||||
common_vendor.onMounted(() => {
|
||||
common_vendor.index.__f__("log", "at TUICallKit/pages/call.vue:52", "=== 页面已挂载 ===");
|
||||
try {
|
||||
TUICallKit_src_TUICallService_index.TUICallKitAPI.setLogLevel(1);
|
||||
common_vendor.index.__f__("log", "at TUICallKit/pages/call.vue:57", "=== 已设置详细日志级别 ===");
|
||||
} catch (error) {
|
||||
common_vendor.index.__f__("log", "at TUICallKit/pages/call.vue:59", "设置日志级别失败:", error);
|
||||
}
|
||||
TUICallKit_src_TUICallService_CallService_index.TUIStore.watch(TUICallKit_src_TUICallService_const_call.StoreName.CALL, {
|
||||
[TUICallKit_src_TUICallService_const_index.NAME.CALL_STATUS]: (newStatus) => {
|
||||
common_vendor.index.__f__("log", "at TUICallKit/pages/call.vue:64", "=== 通话状态变化 ===", newStatus);
|
||||
common_vendor.index.__f__("log", "at TUICallKit/pages/call.vue:65", "可能的状态值: idle, calling, connected");
|
||||
},
|
||||
[TUICallKit_src_TUICallService_const_index.NAME.IS_GROUP]: (isGroup) => {
|
||||
common_vendor.index.__f__("log", "at TUICallKit/pages/call.vue:68", "=== 是否群组通话 ===", isGroup);
|
||||
},
|
||||
[TUICallKit_src_TUICallService_const_index.NAME.CALL_ROLE]: (role) => {
|
||||
common_vendor.index.__f__("log", "at TUICallKit/pages/call.vue:71", "=== 通话角色 ===", role);
|
||||
},
|
||||
[TUICallKit_src_TUICallService_const_index.NAME.CALL_MEDIA_TYPE]: (type) => {
|
||||
common_vendor.index.__f__("log", "at TUICallKit/pages/call.vue:74", "=== 通话类型 ===", type);
|
||||
}
|
||||
});
|
||||
});
|
||||
common_vendor.onUnmounted(() => {
|
||||
TUICallKit_src_TUICallService_CallService_index.TUIStore.unwatch(TUICallKit_src_TUICallService_const_call.StoreName.CALL, {
|
||||
[TUICallKit_src_TUICallService_const_index.NAME.CALL_STATUS]: () => {
|
||||
},
|
||||
[TUICallKit_src_TUICallService_const_index.NAME.IS_GROUP]: () => {
|
||||
},
|
||||
[TUICallKit_src_TUICallService_const_index.NAME.CALL_ROLE]: () => {
|
||||
},
|
||||
[TUICallKit_src_TUICallService_const_index.NAME.CALL_MEDIA_TYPE]: () => {
|
||||
}
|
||||
});
|
||||
});
|
||||
const getSignatureFromServer = async (patientId2) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
common_vendor.index.request({
|
||||
url: "https://api.zzzhengyangtang.cn/api/tcm/getPatientSignature",
|
||||
// 后端接口地址 // 替换为你的后端地址
|
||||
method: "GET",
|
||||
data: {
|
||||
patient_id: patientId2
|
||||
},
|
||||
success: (res) => {
|
||||
if (res.data && res.data.code === 1) {
|
||||
resolve(res.data.data);
|
||||
} else {
|
||||
reject(new Error(res.data.msg || "获取签名失败"));
|
||||
}
|
||||
},
|
||||
fail: (err) => {
|
||||
reject(err);
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
const loginHandler = async () => {
|
||||
if (!patientId.value) {
|
||||
common_vendor.index.showToast({
|
||||
title: "请输入患者ID",
|
||||
icon: "none"
|
||||
});
|
||||
return;
|
||||
}
|
||||
try {
|
||||
loading.value = true;
|
||||
common_vendor.index.showLoading({
|
||||
title: "正在获取签名..."
|
||||
});
|
||||
const signatureData = await getSignatureFromServer(patientId.value);
|
||||
common_vendor.index.__f__("log", "at TUICallKit/pages/call.vue:130", "获取签名成功:", signatureData);
|
||||
const { sdkAppId, userId, userSig } = signatureData;
|
||||
currentUserId.value = userId;
|
||||
common_vendor.index.__f__("log", "at TUICallKit/pages/call.vue:135", "=== 小程序端登录信息 ===");
|
||||
common_vendor.index.__f__("log", "at TUICallKit/pages/call.vue:136", "sdkAppId:", sdkAppId);
|
||||
common_vendor.index.__f__("log", "at TUICallKit/pages/call.vue:137", "userId:", userId);
|
||||
common_vendor.index.__f__("log", "at TUICallKit/pages/call.vue:138", "userSig 长度:", userSig == null ? void 0 : userSig.length);
|
||||
common_vendor.index.showLoading({
|
||||
title: "正在初始化..."
|
||||
});
|
||||
await TUICallKit_src_TUICallService_index.TUICallKitAPI.init({
|
||||
sdkAppID: Number(sdkAppId),
|
||||
// 确保是数字类型
|
||||
userID: userId,
|
||||
// 应该是 patient_2 格式
|
||||
userSig
|
||||
});
|
||||
common_vendor.index.__f__("log", "at TUICallKit/pages/call.vue:151", "TUICallKit 初始化成功, userId:", userId);
|
||||
await new Promise((resolve) => setTimeout(resolve, 1e3));
|
||||
common_vendor.index.__f__("log", "at TUICallKit/pages/call.vue:158", "=== TUICallKit 初始化完成,等待来电 ===");
|
||||
isLogin.value = true;
|
||||
await common_vendor.nextTick$1();
|
||||
common_vendor.index.__f__("log", "at TUICallKit/pages/call.vue:165", "=== TUICallKit 组件已挂载 ===");
|
||||
common_vendor.index.__f__("log", "at TUICallKit/pages/call.vue:166", "当前通话状态:", callStatus.value);
|
||||
common_vendor.index.__f__("log", "at TUICallKit/pages/call.vue:167", "完整状态信息:", {
|
||||
callStatus: TUICallKit_src_TUICallService_CallService_index.TUIStore.getData(TUICallKit_src_TUICallService_const_call.StoreName.CALL, TUICallKit_src_TUICallService_const_index.NAME.CALL_STATUS),
|
||||
isGroup: TUICallKit_src_TUICallService_CallService_index.TUIStore.getData(TUICallKit_src_TUICallService_const_call.StoreName.CALL, TUICallKit_src_TUICallService_const_index.NAME.IS_GROUP),
|
||||
callRole: TUICallKit_src_TUICallService_CallService_index.TUIStore.getData(TUICallKit_src_TUICallService_const_call.StoreName.CALL, TUICallKit_src_TUICallService_const_index.NAME.CALL_ROLE),
|
||||
callMediaType: TUICallKit_src_TUICallService_CallService_index.TUIStore.getData(TUICallKit_src_TUICallService_const_call.StoreName.CALL, TUICallKit_src_TUICallService_const_index.NAME.CALL_MEDIA_TYPE),
|
||||
localUserInfo: TUICallKit_src_TUICallService_CallService_index.TUIStore.getData(TUICallKit_src_TUICallService_const_call.StoreName.CALL, TUICallKit_src_TUICallService_const_index.NAME.LOCAL_USER_INFO)
|
||||
});
|
||||
common_vendor.index.hideLoading();
|
||||
common_vendor.index.showToast({
|
||||
title: "登录成功",
|
||||
icon: "success"
|
||||
});
|
||||
patientId.value = "";
|
||||
} catch (error) {
|
||||
common_vendor.index.__f__("error", "at TUICallKit/pages/call.vue:185", "登录失败:", error);
|
||||
common_vendor.index.hideLoading();
|
||||
common_vendor.index.showToast({
|
||||
title: "登录失败: " + (error.message || "未知错误"),
|
||||
icon: "none",
|
||||
duration: 3e3
|
||||
});
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
const callHandler = async () => {
|
||||
if (!patientId.value) {
|
||||
common_vendor.index.showToast({
|
||||
title: "请输入要呼叫的用户ID",
|
||||
icon: "none"
|
||||
});
|
||||
return;
|
||||
}
|
||||
try {
|
||||
loading.value = true;
|
||||
let targetUserId = patientId.value;
|
||||
if (/^\d+$/.test(patientId.value)) {
|
||||
targetUserId = `doctor_${patientId.value}`;
|
||||
}
|
||||
common_vendor.index.__f__("log", "at TUICallKit/pages/call.vue:218", "准备呼叫用户:", targetUserId);
|
||||
await TUICallKit_src_TUICallService_index.TUICallKitAPI.calls({
|
||||
userIDList: [targetUserId],
|
||||
type: 2
|
||||
// 2 表示视频通话
|
||||
});
|
||||
common_vendor.index.__f__("log", "at TUICallKit/pages/call.vue:226", "发起通话成功, 目标用户:", targetUserId);
|
||||
common_vendor.index.showToast({
|
||||
title: "正在呼叫...",
|
||||
icon: "none"
|
||||
});
|
||||
} catch (error) {
|
||||
common_vendor.index.__f__("error", "at TUICallKit/pages/call.vue:234", "发起通话失败:", error);
|
||||
common_vendor.index.showToast({
|
||||
title: "发起通话失败: " + (error.message || "未知错误"),
|
||||
icon: "none",
|
||||
duration: 3e3
|
||||
});
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
return (_ctx, _cache) => {
|
||||
return common_vendor.e({
|
||||
a: common_vendor.unref(isLogin)
|
||||
}, common_vendor.unref(isLogin) ? {} : {}, {
|
||||
b: !common_vendor.unref(isLogin) ? "请输入患者ID(数字)" : "输入医生ID或完整userId(如:doctor_1)",
|
||||
c: common_vendor.unref(patientId),
|
||||
d: common_vendor.o(($event) => common_vendor.isRef(patientId) ? patientId.value = $event.detail.value : patientId = $event.detail.value),
|
||||
e: common_vendor.t(common_vendor.unref(loading) ? "加载中..." : !common_vendor.unref(isLogin) ? "登录" : "呼叫"),
|
||||
f: common_vendor.o(($event) => !common_vendor.unref(isLogin) ? loginHandler() : callHandler()),
|
||||
g: common_vendor.unref(loading),
|
||||
h: common_vendor.unref(isLogin)
|
||||
}, common_vendor.unref(isLogin) ? {
|
||||
i: common_vendor.t(common_vendor.unref(currentUserId)),
|
||||
j: common_vendor.t(callStatus.value)
|
||||
} : {});
|
||||
};
|
||||
}
|
||||
};
|
||||
wx.createPage(_sfc_main);
|
||||
//# sourceMappingURL=../../../.sourcemap/mp-weixin/TUICallKit/pages/call.js.map
|
||||
Reference in New Issue
Block a user