1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- <template>
- <h1></h1>
- </template>
- <script>
- import { GetShareRecordInfo } from '@/api/exercise';
- export default {
- name: 'ShareExercise',
- data() {
- let { share_record_id } = this.$route.query;
- return {
- share_record_id,
- };
- },
- created() {
- let info = navigator.userAgent;
- // 通过正则表达式的test方法判断是否包含“Mobile”字符串
- let isPhone = /mobile|iPad/i.test(info);
- // 如果包含“Mobile”(是手机设备)则返回true
- if (isPhone) {
- window.location.href = `${window.location.origin}/GCLS-Mobile/#/open/share/exercise?share_record_id=${this.share_record_id}`;
- } else {
- this.getShareRecordInfo();
- }
- },
- methods: {
- getShareRecordInfo() {
- GetShareRecordInfo({
- share_record_id: this.share_record_id,
- }).then(({ share_record }) => {
- if (share_record.access_popedom === 1) {
- this.$router.push({ path: '/exercise', query: { id: share_record.exercise_id } });
- }
- if (share_record.access_popedom === 2) {
- this.$router.push({ path: '/answer', query: { share_record_id: this.share_record_id } });
- }
- });
- },
- },
- };
- </script>
|