index.vue 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <template>
  2. <!-- <nuxt-link to="/user">首页</nuxt-link> -->
  3. <!-- <nuxt-link to="/m_user">首页</nuxt-link> -->
  4. <div>
  5. <h1>惠融易客</h1>
  6. <nuxt-child />
  7. </div>
  8. </template>
  9. <script>
  10. import {postListData} from '../api/index'
  11. export default {
  12. middleware({ store, route, redirect, params, query }) {
  13. console.log('middleware layouts inside')
  14. // store状态树信息
  15. // route 一条目标路由信息
  16. //redirect 路由的强制跳转
  17. // params query 校验参数的合理性
  18. // console.log('layouts守卫前置守卫')
  19. // redirect('/reg')
  20. },
  21. data() {
  22. return {
  23. }
  24. },
  25. mounted() {
  26. this.goto()
  27. },
  28. methods: {
  29. async goto() {
  30. let z = postListData({
  31. "categoryId": 1
  32. })
  33. console.log('zzzzzzz',z)
  34. var system = {};
  35. system.pingtai = /(Win32|Win16|WinCE|Mac68K|MacIntel|MacIntel|MacPPC|Linux mips64)/i.test(navigator.platform);
  36. if (system.pingtai) {
  37. //电脑
  38. console.log('电脑')
  39. this.$router.push('/user')
  40. } else {
  41. //手机
  42. console.log('手机')
  43. this.$router.push('/user/m_user')
  44. }
  45. }
  46. }
  47. }
  48. </script>