Home >Backend Development >PHP Tutorial >javascript - The page cannot be closed after receiving WeChat coupons
<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
<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