AdwebLogistics.vue 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <template>
  2. <div class="container">
  3. <iframe :src="iframeSrc" class="full-iframe"></iframe>
  4. </div>
  5. </template>
  6. <script lang="ts" setup>
  7. import { ref, onMounted } from 'vue';
  8. import { useUserStore } from '@/store/modules/user';
  9. import { getAction } from '@/api/manage/manage';
  10. // 使用 setup
  11. const { userInfo } = useUserStore();
  12. const iframeSrc = ref('');
  13. onMounted(() => {
  14. getUrl();
  15. });
  16. // 获取 动态url
  17. function getUrl() {
  18. getAction('/adweb/logistics/getMeiri56Token', null).then((res) => {
  19. if (res.success) {
  20. const siteCode = localStorage.getItem('siteCode') || '';
  21. const realName = userInfo?.realname || '';
  22. const userId = userInfo?.id || '';
  23. // 获取 字典中存放的token
  24. const token = res.result || '';
  25. // 动态生成 URL
  26. iframeSrc.value = `https://meiri56.cn?company=${encodeURIComponent(siteCode)}&companyName=${encodeURIComponent(realName)}&userId=${encodeURIComponent(userId)}&token=${encodeURIComponent(token)}`;
  27. } else {
  28. console.error('未获取到 token!');
  29. }
  30. });
  31. }
  32. </script>
  33. <style scoped>
  34. .container {
  35. width: 100%;
  36. height: 100vh;
  37. margin: 0;
  38. padding: 0;
  39. overflow: hidden;
  40. display: flex;
  41. }
  42. .full-iframe {
  43. width: 100%;
  44. height: 100%;
  45. border: none;
  46. display: block;
  47. }
  48. </style>