uniapp小程序有接入客服自带的方法,将button设置属性open-type='contact',就可以接入,但是只支持接入小程序客服,并不支持企业微信客服

<button open-type='contact' session-from='' class="contact">联系我们</button>

原生微信小程序方法,可以使用wx.openCustomerServiceChat()去调用企业微信客服,去uniapp官方文档搜索并不支持,其实是可以直接使用的

一、去微信公众平台客服接入微信客服(详情见官方文档)

二、在代码中加上条件编译直接使用微信原生的wx.openCustomerServiceChat()方法

  <button @click="openChat" style='font-size: 20px;background-color: white'>专家咨询</button>
<script setup>
const openChat=()=>{
  wx.openCustomerServiceChat({
    extInfo: {
      url: 'https://work.weixin.qq.com/xxxxxxxxx' //客服地址链接
    },
    corpId: 'xxxxxxxxxxxx', //必须和你小程序上的一致
    success(res) {
      console.log(res, 1)
    },
    fail(res) {
      console.log(res, 2)
    },
  })
}
</script>