@tencentcloud/ai-desk-customer-wechat
Version:
AI Desk customer UIKit for wechat mini program
157 lines (156 loc) • 7.33 kB
JavaScript
;
const common_vendor = require("../../../../../common/vendor.js");
const aiDeskCustomerUniapp_adapterVue = require("../../../../adapter-vue.js");
const common_assets = require("../../../../../common/assets.js");
const aiDeskCustomerUniapp_utils_utils = require("../../../../utils/utils.js");
if (!Math) {
(MessageQuote + Icon + ReadStatus)();
}
const Icon = () => "../../../common/Icon.js";
const ReadStatus = () => "./read-status/index.js";
const MessageQuote = () => "./message-quote/index-uniapp.js";
const riskImageReplaceUrl = "https://web.sdk.qcloud.com/component/TUIKit/assets/has_risk_default.png";
const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
__name: "message-bubble-uniapp",
props: {
messageItem: { default: () => ({}) },
content: { default: () => ({}) },
classNameList: { default: () => [] },
blinkMessageIDList: { default: () => [] },
isAudioPlayed: { type: Boolean, default: false }
},
emits: ["resendMessage", "blinkMessage", "scrollTo", "handleTouchStart", "handleTouchEnd", "handleToggleMessageItem"],
setup(__props, { emit: __emit }) {
const { computed, toRefs } = aiDeskCustomerUniapp_adapterVue.vue;
const emits = __emit;
const props = __props;
const TYPES = common_vendor.qt.TYPES;
const needLoadingIconMessageType = [
TYPES.MSG_LOCATION,
TYPES.MSG_TEXT,
TYPES.MSG_CUSTOM,
TYPES.MSG_MERGER,
TYPES.MSG_FACE
];
const { blinkMessageIDList, messageItem: message } = toRefs(props);
const isDisplayUnplayMark = computed(() => {
return message.value.flow === "in" && message.value.status === "success" && message.value.type === TYPES.MSG_AUDIO && !props.isAudioPlayed;
});
const isMultiBranchMsg = computed(() => {
var _a;
if (((_a = message.value) == null ? void 0 : _a.type) == "TIMCustomElem") {
console.log(`src ${JSON.parse(message.value.payload.data).src}`);
if (JSON.parse(message.value.payload.data).src == "32") {
return true;
}
}
return false;
});
const containerClassNameList = computed(() => {
return ["message-bubble", ...props.classNameList];
});
const isNoPadding = computed(() => {
return [TYPES.MSG_IMAGE, TYPES.MSG_VIDEO, TYPES.MSG_MERGER].includes(
message.value.type
);
});
const riskContentText = computed(() => {
let content = common_vendor.Wt.t("TUIChat.涉及敏感内容") + ", ";
if (message.value.flow === "out") {
content += common_vendor.Wt.t("TUIChat.发送失败");
} else {
content += common_vendor.Wt.t(
message.value.type === TYPES.MSG_AUDIO ? "TUIChat.无法收听" : "TUIChat.无法查看"
);
}
return content;
});
const isBlink = computed(() => {
var _a, _b;
if ((_a = message.value) == null ? void 0 : _a.ID) {
return (_b = blinkMessageIDList == null ? void 0 : blinkMessageIDList.value) == null ? void 0 : _b.includes(message.value.ID);
}
return false;
});
function resendMessage() {
var _a;
if (!((_a = message.value) == null ? void 0 : _a.hasRiskContent)) {
emits("resendMessage");
}
}
function blinkMessage(messageID) {
emits("blinkMessage", messageID);
}
function scrollTo(scrollHeight) {
emits("scrollTo", scrollHeight);
}
function handleToggle() {
console.log("handleToggle");
emits("handleToggleMessageItem");
}
function handleTouchStart() {
console.log("handleTouchStart");
emits("handleTouchStart");
}
function handleTouchEnd() {
emits("handleTouchEnd");
}
return (_ctx, _cache) => {
return common_vendor.e({
a: common_vendor.unref(message).flow === "in" && common_vendor.unref(message).conversationType === "GROUP"
}, common_vendor.unref(message).flow === "in" && common_vendor.unref(message).conversationType === "GROUP" ? {
b: common_vendor.t(props.content.showName)
} : {}, {
c: common_vendor.n(common_vendor.unref(message).flow === "out" ? "reverse" : "flex-row"),
d: common_vendor.o(blinkMessage),
e: common_vendor.o(scrollTo),
f: common_vendor.p({
message: common_vendor.unref(message)
}),
g: (common_vendor.unref(message).type === common_vendor.unref(TYPES).MSG_IMAGE || common_vendor.unref(message).type === common_vendor.unref(TYPES).MSG_VIDEO) && common_vendor.unref(message).hasRiskContent
}, (common_vendor.unref(message).type === common_vendor.unref(TYPES).MSG_IMAGE || common_vendor.unref(message).type === common_vendor.unref(TYPES).MSG_VIDEO) && common_vendor.unref(message).hasRiskContent ? {
h: riskImageReplaceUrl
} : {}, {
i: common_vendor.unref(message).hasRiskContent
}, common_vendor.unref(message).hasRiskContent ? {
j: common_vendor.t(common_vendor.unref(riskContentText))
} : {}, {
k: common_vendor.n(common_vendor.unref(message).flow === "out" ? "content-out" : "content-in"),
l: common_vendor.n(common_vendor.unref(message).hasRiskContent && "content-has-risk"),
m: common_vendor.n(common_vendor.unref(isNoPadding) ? "content-no-padding" : ""),
n: common_vendor.n(common_vendor.unref(isNoPadding) && common_vendor.unref(isBlink) ? "blink-shadow" : ""),
o: common_vendor.n(!common_vendor.unref(isNoPadding) && common_vendor.unref(isBlink) ? "blink-content" : ""),
p: common_vendor.n(common_vendor.unref(isMultiBranchMsg) ? "multi-branch-message" : ""),
q: common_vendor.unref(isDisplayUnplayMark)
}, common_vendor.unref(isDisplayUnplayMark) ? {} : {}, {
r: common_vendor.unref(message).status === "fail" || common_vendor.unref(message).hasRiskContent
}, common_vendor.unref(message).status === "fail" || common_vendor.unref(message).hasRiskContent ? {
s: common_vendor.o(($event) => resendMessage())
} : {}, {
t: common_vendor.unref(message).status === "unSend" && needLoadingIconMessageType.includes(common_vendor.unref(message).type)
}, common_vendor.unref(message).status === "unSend" && needLoadingIconMessageType.includes(common_vendor.unref(message).type) ? {
v: common_vendor.p({
file: common_vendor.unref(common_assets.loadingIcon),
width: "15px",
height: "15px"
})
} : {}, {
w: common_vendor.p({
message: common_vendor.unref(aiDeskCustomerUniapp_utils_utils.shallowCopyMessage)(common_vendor.unref(message))
}),
x: common_vendor.n(common_vendor.unref(message).flow === "out" && "message-body-main-reverse"),
y: common_vendor.o(() => {
}),
z: common_vendor.n(common_vendor.unref(message).flow === "in" ? "" : "reverse"),
A: common_vendor.o(handleToggle),
B: common_vendor.o(handleTouchStart),
C: common_vendor.o(handleTouchEnd),
D: common_vendor.o(handleTouchEnd),
E: common_vendor.unref(message).flow === "out" ? 1 : "",
F: common_vendor.n(common_vendor.unref(containerClassNameList))
});
};
}
});
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-84aed101"]]);
wx.createComponent(Component);