Home >Backend Development >PHP Tutorial >javascript - The page cannot be closed after receiving WeChat coupons

javascript - The page cannot be closed after receiving WeChat coupons

WBOY
WBOYOriginal
2016-07-06 13:54:07999browse

<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>

The config is ok
Whether it is directly wx.closeWindow or jumps to the close page, it will appearcloseWindow:error
It is normal in Android, but this problem only occurs under IOS

Reply content:

<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>

The config is ok
Whether it is directly wx.closeWindow or jumps to the close page, it will appearcloseWindow:error
It is normal in Android, but this problem only occurs under IOS

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn