javascript - The page cannot be closed after receiving WeChat coupons

WBOY
Release: 2016-07-06 13:54:07
Original
957 people have browsed it

<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>
Copy after login
Copy after login

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>
Copy after login
Copy after login

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

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!