首页 > 编程语言 >链接进入小程序后接口token失败,返回登录页授权后返回当前页面

链接进入小程序后接口token失败,返回登录页授权后返回当前页面

时间:2023-01-10 10:25:37浏览次数:54  
标签:返回 lastpage token suburl before login 页面 pages wx

                        case 401:
                            let pages = getCurrentPages()
                            wx.setStorageSync('before_login_page', pages[0].route)
                            wx.setStorageSync('before_login_page_options', pages[0].options)
                            wx.reLaunch({
                                url: '/pages/login/login',
                            })
                            break;
        let lastpage = wx.getStorageSync('before_login_page')
        let lastpageoption = wx.getStorageSync('before_login_page_options')
        if (lastpage) {
            lastpage = '/' + lastpage
            wx.setStorageSync('before_login_page', undefined)
            wx.setStorageSync('before_login_page_options', undefined)
            let tabarr = ['/pages/index/index', '/pages/mine/mine']
            let suburl = ''
            for (const key in lastpageoption) {
                if (key) {
                    suburl += `&${key}=${lastpageoption[key]}`
                }
            }
            if (suburl) {
                suburl = suburl.replace('&', '?')
            }
            let jumppage = lastpage + suburl
            if (tabarr.indexOf(lastpage) == -1) {
                wx.navigateTo({
                    url: jumppage,
                })
            } else {
                wx.switchTab({
                    url: jumppage,
                })
            }
        } else {
            wx.switchTab({
                url: '/pages/index/index',
            })
        }

 

标签:返回,lastpage,token,suburl,before,login,页面,pages,wx
From: https://www.cnblogs.com/jqynr/p/17039312.html

相关文章