Heim  >  Artikel  >  Backend-Entwicklung  >  javascript - 微信卡券领取后无法关闭页面

javascript - 微信卡券领取后无法关闭页面

WBOY
WBOYOriginal
2016-07-06 13:54:07957Durchsuche

<code>wx.config({
                debug: false,
                appId: '<?php echo $sign['appId']; ?>',
                timestamp: <?php echo $sign['timestamp']; ?>,
                nonceStr: '<?php echo $sign['nonceStr']; ?>',
                signature: '<?php echo $sign['signature']; ?>',
                jsApiList: [
                    'checkJsApi',
                    'addCard',
                    'chooseCard',
                    'openCard',
                    'hideMenuItems',
                    'showMenuItems',
                    'closeWindow'
                ]
            });

            wx.ready(function () {
                var json = <?php echo $cardExt?>;
                setTimeout(function() {
                    wx.closeWindow();
                    //window.location.href = url;
                }, 5000);
                var url = '<?php echo url('Index', 'closeWindow', array(), 'index.php'); ?>';
                wx.addCard({
                    cardList: json.card_list,
                    success: function (res) {
                        alert('领取成功,进入微信>我>卡包查看');
                        wx.closeWindow();
                        window.location.href = url;
                    },
                    cancel: function (res) {
                        wx.closeWindow();
                        window.location.href = url;
                    },
                    fail: function (res) {
                        wx.closeWindow();
                        window.location.href = url;
                    }
                });
            });</code>

config是ok
无论是直接wx.closeWindow还是跳转到关闭页面都会出现closeWindow:error
在android里是正常的,IOS下面才有这问题

回复内容:

<code>wx.config({
                debug: false,
                appId: '<?php echo $sign['appId']; ?>',
                timestamp: <?php echo $sign['timestamp']; ?>,
                nonceStr: '<?php echo $sign['nonceStr']; ?>',
                signature: '<?php echo $sign['signature']; ?>',
                jsApiList: [
                    'checkJsApi',
                    'addCard',
                    'chooseCard',
                    'openCard',
                    'hideMenuItems',
                    'showMenuItems',
                    'closeWindow'
                ]
            });

            wx.ready(function () {
                var json = <?php echo $cardExt?>;
                setTimeout(function() {
                    wx.closeWindow();
                    //window.location.href = url;
                }, 5000);
                var url = '<?php echo url('Index', 'closeWindow', array(), 'index.php'); ?>';
                wx.addCard({
                    cardList: json.card_list,
                    success: function (res) {
                        alert('领取成功,进入微信>我>卡包查看');
                        wx.closeWindow();
                        window.location.href = url;
                    },
                    cancel: function (res) {
                        wx.closeWindow();
                        window.location.href = url;
                    },
                    fail: function (res) {
                        wx.closeWindow();
                        window.location.href = url;
                    }
                });
            });</code>

config是ok
无论是直接wx.closeWindow还是跳转到关闭页面都会出现closeWindow:error
在android里是正常的,IOS下面才有这问题

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn