欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

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

程序员文章站 2022-05-19 20:57:54
...
wx.config({
                debug: false,
                appId: '',
                timestamp: ,
                nonceStr: '',
                signature: '',
                jsApiList: [
                    'checkJsApi',
                    'addCard',
                    'chooseCard',
                    'openCard',
                    'hideMenuItems',
                    'showMenuItems',
                    'closeWindow'
                ]
            });

            wx.ready(function () {
                var json = ;
                setTimeout(function() {
                    wx.closeWindow();
                    //window.location.href = url;
                }, 5000);
                var url = '';
                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;
                    }
                });
            });

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

回复内容:

wx.config({
                debug: false,
                appId: '',
                timestamp: ,
                nonceStr: '',
                signature: '',
                jsApiList: [
                    'checkJsApi',
                    'addCard',
                    'chooseCard',
                    'openCard',
                    'hideMenuItems',
                    'showMenuItems',
                    'closeWindow'
                ]
            });

            wx.ready(function () {
                var json = ;
                setTimeout(function() {
                    wx.closeWindow();
                    //window.location.href = url;
                }, 5000);
                var url = '';
                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;
                    }
                });
            });

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