index.vue 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <template>
  2. <div class="map-home">
  3. <space-box :spaceData="spaceData" @changeSpace="changeSpace"></space-box>
  4. </div>
  5. </template>
  6. <script lang="ts">
  7. import {
  8. defineComponent,
  9. reactive,
  10. toRefs,
  11. onBeforeMount,
  12. onMounted,
  13. ref,
  14. watch,
  15. } from "vue";
  16. import SpaceBox from "./SpaceBox.vue";
  17. import MapBox from "./MapBox.vue";
  18. import { useRouter } from "vue-router";
  19. import { newNumber, parseImgUrl } from "@/utils";
  20. import { UserActionTypes } from "@/store/modules/user/action-types";
  21. import { useStore } from "@/store";
  22. import { login } from "@/apis/user";
  23. import { Form, Field, CellGroup, Button, Toast } from "vant";
  24. import { setToken } from "@/utils/cookies";
  25. export default defineComponent({
  26. props: {
  27. spaceData: {
  28. type: Array,
  29. default: () => [],
  30. },
  31. },
  32. components: {
  33. vanForm: Form,
  34. vanField: Field,
  35. CellGroup,
  36. vanButton: Button,
  37. SpaceBox,
  38. MapBox,
  39. },
  40. setup(props, contex) {
  41. let router: any = useRouter();
  42. const store = useStore();
  43. const proxyData = reactive({
  44. spaceData: props.spaceData,
  45. changeSpace(item: any) {
  46. contex.emit("changeSpace", item, 1);
  47. },
  48. });
  49. onMounted(() => {});
  50. watch(
  51. props,
  52. (newProps: any) => {
  53. proxyData.spaceData = newProps.spaceData;
  54. },
  55. {
  56. deep: false,
  57. immediate: true,
  58. }
  59. );
  60. return {
  61. ...toRefs(proxyData),
  62. };
  63. },
  64. });
  65. </script>
  66. <style lang="scss" scoped>
  67. .map-home {
  68. width: 100%;
  69. height: 100%;
  70. }
  71. </style>