How to use the vux.base64.encode function in vux

To help you get started, we’ve selected a few vux examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github huahua0406 / pretty-vendor / src / pages / login / login.vue View on Github external
.then(res => {
                    // 登录成功
                    if (res.data.data.code === 0) {
                        this.$vux.toast.show({
                            text: '登录成功'
                        })
                        // 本地保存 token 和 userInfo
                        // vux 中提供的base64方法
                        // base64.encode('VUX')
                        // base64.decode('VlVY')
                        window.localStorage.setItem('token', base64.encode(res.data.data.token))
                        window.localStorage.setItem('userInfo', JSON.stringify(
                            res.data.data.userInfo
                        ))
                        this.UPDATE_USERINFO({
                            userInfo: res.data.data.userInfo
                        })
                        // 重定向到首页或者登录前的页面
                        let redirect = decodeURIComponent(
                            this.$route.query.redirect || '/'
                        )
                        setTimeout(() => {
                            this.$router.push({
                                path: redirect
                            })
                        }, 2000)
                    }