使用NuxtJS为Zoho CRM小工具



Zoho CRM有一个名为Widgets的东西来扩展它的功能。使用小部件功能,您可以直接在CRM中嵌入UI组件,并使用来自第三方应用程序的数据根据要求执行操作。

小部件基本上是一个HTML文件,一旦触发自定义按钮,就会加载到弹出窗口中。要从Zoho CRM存储/检索数据,您需要在HTML文件中加载jQuery及其JS SDK。

最基本的HTML文件如下所示:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js"></script>
<script src="https://live.zwidgets.com/js-sdk/1.0.5/ZohoEmbededAppSDK.min.js"></script>
<title>Document</title>
</head>
<body>
<script>
ZOHO.embeddedApp.on("PageLoad",function(data) {
console.log(data);
//Custom Business logic goes here
});
ZOHO.embeddedApp.init();
</script>
</body>
</html>

在这个文件中,console.log(data)将记录关于小部件被启动的页面的信息。在一个潜在客户页面上,它会记录有关该潜在客户的信息,比如id。

存储/检索数据的函数需要在它表示//Custom Business logic goes here的地方使用。

在这个小部件中获取所有Lead的代码如下所示:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js"></script>
<script src="https://live.zwidgets.com/js-sdk/1.0.5/ZohoEmbededAppSDK.min.js"></script>
<title>Document</title>
</head>
<body>
<script>
ZOHO.embeddedApp.on("PageLoad",function(data) {
ZOHO.CRM.API.getAllRecords({Entity:"Leads"})
.then(function(data){
console.log(data)
})
});
ZOHO.embeddedApp.init();
</script>
</body>
</html>

因为我需要创建多个Zoho小部件,并在我想到使用NuxtJS的每个小部件上使用相同的Vue组件。我成功地创建了Vue组件,但我不知道如何合并Zoho的JS SDK。

有谁能给我一些如何使这项工作发挥作用的建议吗?谢谢

为什么不在html的外部文件中使用SDK函数,在那里您可以从SDK api调用所有方法?

只需将您的SDK导入到html的头部即可。

嘿,我在github问题页面上找到了这个解决方案,它确实有效。但愿它能帮助你。

在数据下,您可以将脚本定义为字符串,例如:

<template>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div v-html="scripts"></div>
</template>
<script>
export default {
data: () => ({
scripts: "<script src='https://www.google.com/recaptcha/api.js'></script>"
})
}
</script>

然后只需在您的页面中添加一个div标记,并使用v-html="脚本";

我试过了,效果很好。但我觉得这不是最好的做法。但愿这对你有帮助。

github的来源和所有讨论:https://github.com/nuxt/nuxt.js/issues/2000

最新更新