参考

uniapp接入企业微信客服 – 月半猪博客 (fatterpig.com)

步骤

  1. 打开企业微信-应用管理-微信客服

    企业微信 (qq.com)

  2. 启用微信客服

  3. 客服账号-创建账号,选择公司

  4. 人工接待配置,添加人员

  5. 选择接入场景

  6. 代码示例

    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
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    //界面代码
    <u-tag :text="$t('联系客服')" shape="circle" class="u-m-r-30" @click="chat" type="info" />

    //方法
    chat() {
    //WORKWXCORPID 企业ID
    //WORKWXURL 企业客服链接

    // #ifdef H5
    // 触发跳转外链
    // 此处参考:
    // https://blog.fatterpig.com/uniapp跳转到外部链接/
    uni.navigateTo({
    url: '/pagesC/webview/webview?url='+WORKWXURL
    });
    // #endif

    // #ifdef MP-WEIXIN
    wx.openCustomerServiceChat({
    extInfo: {url: WORKWXURL},
    corpId: WORKWXCORPID,
    success(res) {}
    })
    // #endif

    // #ifdef APP-PLUS
    let sweixin = null
    plus.share.getServices(res => {
    sweixin = res.find(i => i.id === 'weixin')
    if (sweixin) {
    sweixin?sweixin.openCustomerServiceChat({
    corpid: WORKWXCORPID,
    url:WORKWXURL
    }, res => {
    console.log(res)
    }, error=>{
    console.log(error)
    }):plus.nativeUI.alert('当前环境不支持微信操作!');
    } else {
    uni.showToast({
    title: "当前环境不支持微信操作",
    icon: 'error'
    })
    }
    }, function() {
    uni.showToast({
    title: "获取服务失败,不支持该操作。" + JSON.stringify(e),
    icon: 'error'
    })
    })

    // #endif
    }