场景:Vue 微信商城页面
功能需求:前端请求code前端
微信后台相关设置都是后台同事设置好appid及ip白名单vue
Vue main.js 先设置路由拦截判断,未登陆前往author.vue 页面进行受权微信
router.beforeEach((to, from, next) => { let code = () => { // 获取暂存的code信息 return window.sessionStorage.getItem("weCode") } if(!code){ if (to.path !== '/author') { // 暂存进入连接,以便获取code后返回 window.localStorage.setItem('authUrl', to.fullPath) next("/author") return false } } next() })
author.vuesession
未完待续