小程序引入「联系我」插件

5,581 阅读2分钟

引入企业微信中的「联系我」插件

一、企业微信中客户联系-互动服务-「联系我」中设置联系方式

企业微信登录

二、新建联系方式

1. 通过二维码联系

2. 在小程序中联系

  • 创建
  • 配置

三、将“联系我”按钮添加到需要使用的小程序中

在小程序后台 - 设置 - 第三方服务 - 添加插件 搜索ID

四、前端配置-小程序插件接入步骤

  1. 开发者在小程序管理后台申请使用插件,添加路径:设置 ->第三方服务 -> 插件管理 -> 添加插件,搜索并添加插件ID: wx104a1a2xxxxxxxxx,无需审核确认。

  2. 开发者在小程序app.json 文件中添加对插件的引用

"plugins": {
 "contactPlugin": {
     "version": "1.3.0",
     "provider": "wx104a1a2xxxxxx"
 }
}
  1. 开发者在具体引用插件的页面文件json文件中,添加对组件的引用,例如:
"usingComponents": {
 "cell": "plugin://contactPlugin/cell"
}
  1. 开发者在引用插件的wxml文件中添加组件的具体代码,其中plugid为在企业微信管理后台配置的客服ID,将该ID作为参数传入组件,例如:
<cell bind:startmessage='startmessage' bind:completemessage="completemessage" plugid='plugid' />

注意点:因为是uni-app开发,所以配置有所不同

  1. 使用插件之前开发者需要在manifest.json中的各平台对应的字段内声明使用的插件,具体配置参照所用插件的开发文档
// 微信小程序
"mp-weixin": {
	"usingComponents":true, //必须加 不然编译会报错
    "plugins": {
      "myPlugin": {
        "version": "1.3.0",
        "provider": "wxidxxxxxxxxxxxxxxxx"
      }
    }
}
  1. 在页面内使用插件需要在pages.json内对应页面的style节点下配置对应平台的usingComponents,示例如下。
// 微信小程序
{
  "path": "pages/index/index",
  "style": {
    "mp-weixin": {
      "usingComponents": {
        "hello-component": "plugin://myPlugin/hello-component"
      }
    }
  }
}
  1. 页面引入
<hello-component></hello-component>