收藏
回答

企业微信在H5页面引入weixin-js-sdk . wx.agentConfig 方法不存在。

问题类型 API/组件名称 终端类型 微信版本 基础库版本
Bug wx.agentConfig 微信安卓客户端 3.0.0 weixin-js-sdk@1.4.0-test

importwxfrom'weixin-js-sdk'

    exportdefault {

        data(){

          return {

            

          }

        },

        created(){

            consolelogwx);

            thisinit();

        },

        methods: {

          init(){

            letself = this;  

            self$apiget({

                sc:"member2"

                url:`h5/wechat/qy/config/get?url=${windowlocationhref

                success=> {

                    letresult = result || {};

                    letappId = resultappId

                    letagentid = resultagentid

                    lettimestamp = resulttimestamp

                    letnonceStr = resultnonceStr

                    letsignature = resultsignature

                    letagentSignature = resultagentSignature

                    wxconfig({

                        beta:true

                        debug:true

                        appId:appId

                        timestamp:timestamp

                        nonceStr:nonceStr

                        signature:signature

                        jsApiList: [

                            'agentConfig'

                            'getCurExternalContact'

                        ]

                    })

                    wxreadyfunction () {

                        wxagentConfig({

                            corpid:appId// 必填,企业微信的corpid,必须与当前登录的企业一致

                            agentid:agentid// 必填,企业微信的应用id

                            timestamp:timestamp// 必填,生成签名的时间戳

                            nonceStr:nonceStr// 必填,生成签名的随机串

                            signature:agentSignature// 必填,签名,见附录1

                            jsApiList: ['agentConfig''getCurExternalContact'], //必填

                            successfunctionres) {

                                // 回调

                                consolelog'success');

                                wxinvoke'getCurExternalContact', {

                                    

                                    }, functionres){

                                        consolelog'res');

                                        consolelogres);

                                        ifreserr_msg == "getCurExternalContact:ok"){

                                            letuserId  = resuserId ; //返回当前外部联系人userId

                                        }else {

                                            //错误处理

                                            consolelog'error');

                                        }

                                })

                            },

                            failfunctionres) {

                                consolelog'fail');

                                ifreserrMsgindexOf'function not exist') > -){

                                    alert'版本过低请升级'

                                }

                            }

                        })

                    })

                }

            })  

          }

        }

    }

最后一次编辑于  2019-12-25
回答关注问题邀请回答
收藏

4 个回答

登录 后发表内容
问题标签