| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- <template>
- <div></div>
- </template>
- <script>
- import { CheckBookPreviewIdentityCode } from '@/api/app';
- import { setToken, setLocalStore } from '@/utils/auth';
- export default {
- name: 'EnterPage',
- data() {
- return {
- identityCode: this.$route.query.identity_code || '',
- data: {
- book_id: null,
- access_token: null,
- gcls_sys_session_info: null,
- },
- };
- },
- created() {
- this.checkIdentityCode();
- },
- methods: {
- checkIdentityCode() {
- if (!this.identityCode) {
- this.$message.error('缺少身份码参数');
- return;
- }
- CheckBookPreviewIdentityCode({ identity_code: this.identityCode })
- .then((response) => {
- this.data = response;
- setToken(response);
- setLocalStore('book_id', this.data.book_id);
- if (this.isMobile()) {
- this.$router.replace({ name: 'MobileBookPreview' });
- } else {
- this.$router.replace({ name: 'BookPreview' });
- }
- })
- .catch(() => {});
- },
- // 判断当前是web端还是手机端
- isMobile() {
- const userAgent = navigator.userAgent || navigator.vendor || window.opera;
- return /android|iphone|ipad|ipod/i.test(userAgent);
- },
- },
- };
- </script>
- <style lang="scss" scoped></style>
|