UserQRCode.vue 1019 B

12345678910111213141516171819202122232425262728293031323334
  1. <script setup lang="ts">
  2. import type { UserModel } from '@/model/system.model';
  3. const props = defineProps<{ dataset: UserModel }>();
  4. const loading = ref(false);
  5. async function handle() {
  6. loading.value = true;
  7. try {
  8. const response = await fetch(props.dataset.appletImg);
  9. const blob = await response.blob();
  10. const url = window.URL.createObjectURL(blob);
  11. const link = document.createElement('a');
  12. link.href = url;
  13. link.download = `${ props.dataset.nickName }专属小程序码.png`;
  14. link.click();
  15. setTimeout(() => window.URL.revokeObjectURL(url), 20);
  16. } catch ( e ) {}
  17. loading.value = false;
  18. }
  19. </script>
  20. <template>
  21. <div class="text-center" style="padding: 12px">
  22. <a-image
  23. :src="props.dataset?.appletImg" :width="256" :height="256" :preview="false"
  24. style="object-fit: scale-down;"
  25. />
  26. <a-button type="primary" block style="margin-top: 12px;" :loading="loading" @click="handle()">下载</a-button>
  27. </div>
  28. </template>
  29. <style scoped lang="scss"></style>