1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- <template>
- <div id="login">
- <van-button type="primary" @click="toIndex" v-if="is_dev">去首页(开发用)</van-button>
- </div>
- </template>
- <script>
- const jwt = require('jsonwebtoken');
- export default {
- metaInfo: { title: '正在登陆...' },
- name: 'login',
- props: {},
- components: {},
- data: () => ({
- is_dev: process.env.NODE_ENV === 'development',
- }),
- created() {
- this.$toast.loading({
- message: '登陆中...',
- duration: 0,
- });
- let token = this.$route.query.token;
- let user = jwt.decode(token);
- console.log(user);
- localStorage.setItem('user', JSON.stringify(user));
- this.$toast.clear();
- if (this.redirect_uri) this.$router.push('this.redirect_uri');
- else if (!this.is_dev) this.toIndex();
- },
- computed: {
- redirect_uri() {
- return this.$route.query.redirect_uri;
- },
- },
- methods: {
- toIndex() {
- this.$router.push({ path: '/' });
- },
- },
- };
- </script>
- <style lang="less" scoped></style>
|