引入企业微信中的「联系我」插件
一、企业微信中客户联系-互动服务-「联系我」中设置联系方式
二、新建联系方式
1. 通过二维码联系
- 创建
- 下载、配置
- 在公众号中联系我
2. 在小程序中联系
- 创建
- 配置
三、将“联系我”按钮添加到需要使用的小程序中
在小程序后台 - 设置 - 第三方服务 - 添加插件 搜索ID
四、前端配置-小程序插件接入步骤
-
开发者在小程序管理后台申请使用插件,添加路径:设置 ->第三方服务 -> 插件管理 -> 添加插件,搜索并添加插件ID: wx104a1a2xxxxxxxxx,无需审核确认。
-
开发者在小程序app.json 文件中添加对插件的引用
"plugins": {
"contactPlugin": {
"version": "1.3.0",
"provider": "wx104a1a2xxxxxx"
}
}
- 开发者在具体引用插件的页面文件json文件中,添加对组件的引用,例如:
"usingComponents": {
"cell": "plugin://contactPlugin/cell"
}
- 开发者在引用插件的wxml文件中添加组件的具体代码,其中plugid为在企业微信管理后台配置的客服ID,将该ID作为参数传入组件,例如:
<cell bind:startmessage='startmessage' bind:completemessage="completemessage" plugid='plugid' />
注意点:因为是uni-app开发,所以配置有所不同
- 使用插件之前开发者需要在
manifest.json
中的各平台对应的字段内声明使用的插件,具体配置参照所用插件的开发文档
// 微信小程序
"mp-weixin": {
"usingComponents":true, //必须加 不然编译会报错
"plugins": {
"myPlugin": {
"version": "1.3.0",
"provider": "wxidxxxxxxxxxxxxxxxx"
}
}
}
- 在页面内使用插件需要在
pages.json
内对应页面的style节点下配置对应平台的usingComponents,示例如下。
// 微信小程序
{
"path": "pages/index/index",
"style": {
"mp-weixin": {
"usingComponents": {
"hello-component": "plugin://myPlugin/hello-component"
}
}
}
}
- 页面引入
<hello-component></hello-component>