-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
31 lines (26 loc) · 1.09 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
export default {
install(Vue, options) {
const defaultOptions = {
welcomeMessage: "Rất vui khi được hỗ trợ bạn!",
autopopup: "0",
width: "300",
height: "300",
};
const mergedOptions = { ...defaultOptions, ...options };
const { oaid, welcomeMessage, autopopup, width, height } = mergedOptions;
// Tạo một div element cho Zalo Chat Widget
const zaloChatDiv = document.createElement("div");
zaloChatDiv.className = "zalo-chat-widget";
zaloChatDiv.setAttribute("data-oaid", oaid);
zaloChatDiv.setAttribute("data-welcome-message", welcomeMessage);
zaloChatDiv.setAttribute("data-autopopup", autopopup);
zaloChatDiv.setAttribute("data-width", width);
zaloChatDiv.setAttribute("data-height", height);
// Tạo một script element để tải Zalo Chat SDK
const zaloChatScript = document.createElement("script");
zaloChatScript.src = "https://sp.zalo.me/plugins/sdk.js";
// Thêm div và script vào body của trang
document.body.appendChild(zaloChatDiv);
document.body.appendChild(zaloChatScript);
},
};