choiceProject.vue 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <template>
  2. <div class="choice-project com-search">
  3. <van-search placeholder="请输入搜索关键词" />
  4. <div class="choice-content">
  5. <div
  6. class="choice-item"
  7. :key="index"
  8. @click="goCheckSpace(item)"
  9. v-for="(item, index) in projects"
  10. >
  11. {{ item.localName }}
  12. </div>
  13. </div>
  14. </div>
  15. </template>
  16. <script lang="ts">
  17. import { defineComponent, nextTick, onMounted, reactive, toRefs } from "vue";
  18. import { useRoute, onBeforeRouteUpdate } from "vue-router";
  19. import { Search } from "vant";
  20. import router from "@/router";
  21. import { getUsersInfo } from "@/apis/user";
  22. import { store } from "@/store";
  23. import { UserMutationTypes } from "@/store/modules/user/mutation-types";
  24. export default defineComponent({
  25. components: {
  26. vanSearch: Search,
  27. },
  28. setup() {
  29. const route: any = useRoute();
  30. const projects: any = [];
  31. const proxyData = reactive({
  32. route: route,
  33. transitionName: "slide-right",
  34. showHeader: false,
  35. // 去选择空间
  36. goCheckSpace(item: any) {
  37. store.commit(UserMutationTypes.SET_PROJECT_ID, item.id);
  38. router.push({ path: "/choice-space", query: { id: item.id } });
  39. },
  40. projects: projects,
  41. getUsersInfo() {
  42. getUsersInfo().then((res) => {
  43. let resData: any = res;
  44. let projects: any = resData?.projects ?? [];
  45. proxyData.projects = projects;
  46. });
  47. },
  48. });
  49. onMounted(() => {
  50. proxyData.getUsersInfo();
  51. });
  52. return {
  53. ...toRefs(proxyData),
  54. };
  55. },
  56. });
  57. </script>
  58. <style lang="scss" scoped>
  59. .choice-project {
  60. width: 100%;
  61. // height: 100%;
  62. background: #fff;
  63. padding: 5px 20px;
  64. }
  65. </style>
  66. <style lang="scss">
  67. .choice-project {
  68. .choice-content {
  69. padding-top: 10px;
  70. .choice-item {
  71. padding: 20px 10px;
  72. font-family: "Noto Sans SC";
  73. font-style: normal;
  74. font-weight: 400;
  75. font-size: 16px;
  76. line-height: 26px;
  77. color: #1f2429;
  78. border-bottom: 1px solid #e4e6e7;
  79. }
  80. }
  81. }
  82. </style>