_.vue 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <template>
  2. <div></div>
  3. </template>
  4. <script>
  5. import oldRoutes from '@/utils/old-routes'
  6. import { getQueryObject } from '@/utils/index'
  7. export default {
  8. data() {
  9. return {
  10. appId: '',
  11. redirectInfo: null,
  12. }
  13. },
  14. mounted() {
  15. this.initData()
  16. },
  17. methods: {
  18. initData() {
  19. // 获取页面hash值 因为老页面基于vue-router hash模式进行路由跳转
  20. let hash = this.$route.hash
  21. const query = getQueryObject(hash)
  22. this.appId = query.appId
  23. const index = hash.indexOf('?')
  24. hash = hash.slice(1, index)
  25. this.redirectInfo = oldRoutes.find((route) => hash === route.path)
  26. if (this.redirectInfo) {
  27. this.fetchSupplierInfo()
  28. }
  29. },
  30. // 获取供应商信息
  31. async fetchSupplierInfo() {
  32. try {
  33. const { data } = await this.$http.api.fetchSupplierInfo({
  34. appId: this.appId,
  35. })
  36. const path = `/${data.authUserId}` + this.redirectInfo.redirect
  37. this.$router.push(path)
  38. } catch (error) {
  39. console.log(error)
  40. }
  41. },
  42. },
  43. }
  44. </script>
  45. <style scoped></style>