ShareExercise.vue 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <template>
  2. <h1></h1>
  3. </template>
  4. <script>
  5. import { GetShareRecordInfo } from '@/api/exercise';
  6. export default {
  7. name: 'ShareExercise',
  8. data() {
  9. let { share_record_id } = this.$route.query;
  10. return {
  11. share_record_id,
  12. };
  13. },
  14. created() {
  15. let info = navigator.userAgent;
  16. // 通过正则表达式的test方法判断是否包含“Mobile”字符串
  17. let isPhone = /mobile|iPad/i.test(info);
  18. // 如果包含“Mobile”(是手机设备)则返回true
  19. if (isPhone) {
  20. window.location.href = `${window.location.origin}/GCLS-Mobile/#/open/share/exercise?share_record_id=${this.share_record_id}`;
  21. } else {
  22. this.getShareRecordInfo();
  23. }
  24. },
  25. methods: {
  26. getShareRecordInfo() {
  27. GetShareRecordInfo({
  28. share_record_id: this.share_record_id,
  29. }).then(({ share_record }) => {
  30. if (share_record.access_popedom === 1) {
  31. this.$router.push({ path: '/exercise', query: { id: share_record.exercise_id } });
  32. }
  33. if (share_record.access_popedom === 2) {
  34. this.$router.push({ path: '/answer', query: { share_record_id: this.share_record_id } });
  35. }
  36. });
  37. },
  38. },
  39. };
  40. </script>