delivery-partners.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <script setup lang="ts">
  2. import { computed, ref, watch } from 'vue';
  3. import { useRouter } from 'vue-router';
  4. import { useUserStore } from '@vben/stores';
  5. import { $t } from '@/locales';
  6. import { getDeliveryPartnersApi, type UserApi } from '#/api';
  7. import { useLoginModalStore } from '#/store';
  8. interface Props {
  9. jurisdiction: boolean;
  10. }
  11. const props = defineProps<Props>();
  12. const router = useRouter();
  13. const loginModalStore = useLoginModalStore();
  14. const userStore = useUserStore();
  15. const isLogin = computed(() => !!userStore.userInfo);
  16. function handleNavigate() {
  17. if (!isLogin.value) {
  18. loginModalStore.open();
  19. return;
  20. }
  21. router.push('/delivery-partners');
  22. }
  23. const deliveryPartnersList = ref<UserApi.DeliveryPartnerModel[]>([]);
  24. const loading = ref(false);
  25. async function fetchDeliveryPartnersList() {
  26. if (!isLogin.value) {
  27. return;
  28. }
  29. try {
  30. loading.value = true;
  31. const result = await getDeliveryPartnersApi({
  32. currentPage: 1,
  33. pageSize: 12,
  34. orderByProperty: 'name',
  35. Ascending: true,
  36. totalPage: 1,
  37. totalCount: 2,
  38. filters: [
  39. { name: 'name' },
  40. { name: 'account' },
  41. { name: 'status', value: 1 },
  42. ],
  43. });
  44. if (result?.result?.model) {
  45. deliveryPartnersList.value = result.result.model;
  46. }
  47. } catch {}
  48. }
  49. watch(
  50. () => isLogin.value,
  51. (newValue) => {
  52. if (newValue) {
  53. fetchDeliveryPartnersList();
  54. }
  55. },
  56. { immediate: true },
  57. );
  58. </script>
  59. <template>
  60. <div class="info-card border-box h-[217px] w-full rounded-lg p-5 shadow-md">
  61. <div class="items-flex-start flex justify-between">
  62. <div>
  63. <h2 class="text-lg font-bold">
  64. {{ $t('homeModule.deliveryPartners') }}
  65. </h2>
  66. <div class="text-xs text-[#9A9BA3]">Delivery Partners</div>
  67. </div>
  68. <img
  69. v-if="props.jurisdiction"
  70. alt="more"
  71. class="h-[29px] w-[29px] cursor-pointer"
  72. src="@/assets/image/home-more.png"
  73. @click="handleNavigate"
  74. />
  75. </div>
  76. <p
  77. v-if="!isLogin"
  78. class="mt-4 w-[174px] text-sm text-xs leading-relaxed text-[#9A9BA3]"
  79. >
  80. {{ $t('homeModule.deliveryPartnersIntroduction') }}
  81. </p>
  82. <div v-if="props.jurisdiction && isLogin" class="mt-[63px]">
  83. <div v-if="deliveryPartnersList.length > 0" class="flex gap-[18px]">
  84. <img
  85. v-for="index in 4"
  86. :key="index"
  87. :src="`/src/assets/image/user${index}.png`"
  88. :style="{ marginLeft: index !== 1 ? '-35px' : '0' }"
  89. :text="index"
  90. alt=""
  91. class="h-[46px] w-[46px]"
  92. />
  93. </div>
  94. <div
  95. v-else
  96. class="mx-auto mt-[-40px] flex flex-col items-center justify-center text-center"
  97. >
  98. <img
  99. alt=""
  100. class="block h-[80px] w-[85px]"
  101. src="@/assets/image/jurisdiction.png"
  102. />
  103. {{ $t('auth.emptyContent') }}
  104. </div>
  105. </div>
  106. <div
  107. v-else
  108. class="mt-[10px] flex flex-col items-center justify-center text-center"
  109. >
  110. <img
  111. alt=""
  112. class="block h-[80px] w-[85px]"
  113. src="@/assets/image/empty.png"
  114. />
  115. {{ $t('auth.noPermission') }}
  116. </div>
  117. </div>
  118. </template>
  119. <style scoped>
  120. .info-card {
  121. overflow: hidden;
  122. background: url('@/assets/image/DeliveryPartners.png') no-repeat center center;
  123. background-size: cover;
  124. border-radius: 27px;
  125. }
  126. </style>