是不是模块化引入的,换成<script src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js">引入试试?
求救!!企业微信jssdk 调用wx.invoke 显示未定义[图片][图片][图片][图片] JSSDK是cdn引入的,具体代码如下,父类里面定义,子类调用 async __initJsSdk(jsApiList:Array<string>,wxReady?:()=>void){ if(wx){ const config = await fetchJssdkConfig({h5url:window.location.href}).then(res=>{ let { data, sc } = res.data; if(sc==='0') return data; return undefined; }); if(!config) return window.Toast.info('fetch jssdk config fail'); wx.config({ beta: true, debug: true, appId: config.appId, // 必填,企业微信的corpID timestamp: config.timestamp, // 必填,生成签名的时间戳 nonceStr: config.nonceStr, // 必填,生成签名的随机串 signature: config.signature, jsApiList }) wx.ready(()=>{ wxReady&&wxReady(); }) wx.error(function(res:any){ console.log(`jssdk`,res) }); } } async __initJsSdkAgent(jsApiAgentList:Array<string>,agentSuccess?:()=>void){ if(wx){ const agentConfig = await fetchJssdkAgentConfig({h5url:window.location.href}).then(res=>{ let { data, sc } = res.data; if(sc==='0') return data; return undefined; }); if(!agentConfig) return window.Toast.info('fetch jssdkAgent config fail'); wx.agentConfig({ corpid:agentConfig.appId, agentid:agentConfig.agentId, timestamp:agentConfig.timestamp, nonceStr: agentConfig.nonceStr, // 必填,生成签名的随机串 signature: agentConfig.signature, jsApiList: jsApiAgentList, debug: true, success(res:any){ console.log(res) agentSuccess&&agentSuccess(); }, fail(res:any) { if(res.errMsg.indexOf('function not exist') > -1){ window.Toast.info('企业微信版本过低请升级') } } }); } } __jsSdkInvoke(type:string,options:{[key:string]:any},callback:(res:any)=>void){ if(wx){ wx.invoke(type, options, callback); } } //调用 super.__initJsSdk(['invoke','agentConfig'],()=>{ super.__initJsSdkAgent(['getCurExternalContact'],()=>{ super.__jsSdkInvoke('getCurExternalContact',{}, (res)=>{ console.log(res) // if(res.err_msg === "getCurExternalContact:ok"){ // window.Toast.info(res.userId) // }else { // window.Toast.info(JSON.stringify(res)) // } }) }) });
2020-01-19