相关文章推荐
咆哮的青蛙  ·  五大唱片·  1 月前    · 
耍酷的抽屉  ·  Suppression of ...·  1 月前    · 
有爱心的松鼠  ·  【歌剧】| ...·  1 年前    · 

如果企业id、应用id等都配置正确,
如果你是java项目
用的 RestTemplate

替换为HttpClient!

RestTemplate真坑,估计是urlconnection问题

2.企业自建应用默认打开系统浏览器

1.引入企业微信jssdk
2.应用配置回调域名LOGIN_URL
3.验证完用户信息后,跳转到jssdk嵌入页并在路径上拼写token
4.截取路径token在下方url中拼写自建应用地址,js自动打开系统默认浏览器

整体流程:

  1. 用户访问企业微信应用 企业微信打开应用首页(在企业微信管理平台进行配置的地址)
  2. 打开应用首页的同时拼接code,建议直接拼接https://open.weixin.qq.com/connect/oauth2/authorize微信认证地址
  3. 根据配置的redirect_uri参数,跳转到目标地址URL&code=XXXX 根据code请求企业微信解析该用户
  4. 解析成功,后端重定向跳转到嵌入企业微信的jssdk地址,这里页面可以写上即将打开默认浏览器,并拼接应用系统token
  5. sdk.openDefaultBrowser方法执行打开系统默认浏览器并打开配置的url,然后截取地址栏上的token=,完成应用系统认证。
    如果在openDefaultBrowser中直接拼接认证,该地址将不是在企业微信浏览器中打开,认证地址回提示请在微信中打开。
<!DOCTYPE html>
    <title>跳转等待页面</title>
    <style>
        body {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            height: 100vh;
            margin: 0;
            background-color: #f5f5f5;
            font-family: Arial, sans-serif;
        .message {
            font-size: 24px;
            margin-bottom: 20px;
        .spinner {
            width: 60px;
            height: 60px;
            border: 6px solid #333;
            border-top-color: transparent;
            border-radius: 50%;
            animation: spin 1s linear infinite;
        @keyframes spin {
            100% {
                transform: rotate(360deg);
    </style>
</head>
    <h1 class="message">即将在系统浏览器打开XXXXX</h1>
    <div class="spinner"></div>
</body>
</html>
<script>
	function getJumpUrl(url){
		return url.split('jumpUrl=')[1];
    console.log(getJumpUrl(window.location.href));
    fetch('http://zxsj.fdine.net/yhy/api/v1/openBrow')
        .then(response => response.json())
        .then(data => {
            wx.config({
                beta: true,// 调用wx.invoke形式的接口值时,该值必须为true。
                debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
                appId: data.appId, // 必填,交建通的cropID
                timestamp: data.timestamp, // 必填,生成签名的时间戳
                nonceStr: data.randomStr, // 必填,生成签名的随机串
                signature: data.sign,// 必填,签名,见附录1
                jsApiList: ['openUrl','openDefaultBrowser'] // 必填,需要使用的JS接口列表,所有JS接口列表见附录2
            console.log('wx.config配置完成')
            wx.ready(function () {
		console.log('wx.ready执行')
                wx.invoke('openUrl', {
                    "type": 1, //0或不填表示使用内部浏览器新窗口打开,1表示用系统浏览器打开
                    "url": getJumpUrl(window.location.href) //url地址
                }, function (res) {
			console.log(res)
                    if (res.err_msg != "openUrl:ok") {
                        //错误处理
                        console.log(res)
            wx.error(function (res) {
                // config信息验证失败会执行error函数,如签名过期导致验证失败,具体错误信息可以打开config的debug模式查看,也可以在返回的res参数中查看,对于SPA可以在这里更新签名。
                console.log(res);
        .catch(error => {
            // 处理请求错误
            console.log(error);
</script>
agentid: that.agentid+’’, // 加一个‘’ 表示字符串
//判断返回时候获取res.errMsg 判断
if (res.errMsg != “agentConfig:ok”) {
//错误处理
console.log(“pppp======”);
return;
...
<!-- config -->
<script src="//res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<!-- agentConfig -->
<script type="text/javascript" src="https://open.work.weixin.qq.com/wwopen/js/jwxwork-1.0.0.js"></script&g
				
微信公众号支付,支付凭证(微信端统一预下订单)数据返回正常,然后页面js也到了执行WeixinJSBridge.invoke的地方,发现页面一闪而过,页面传入的参数都没了,由于第一次调支付接口,各种找问题,最后发现
函数的调用方式如下6种: 1、构造函数 function star() {}; new Star(); 2、对象方法函数 var o = { sayHi:function(){ console.log(123)} } o.sayHi() 3、绑定事件函数 btn.onclick=function() {} //点击了按钮就可以调用函...