cwg-pay-webview-popup.vue 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <template>
  2. <cwg-popup
  3. :visible="visible"
  4. :title="displayTitle"
  5. width="min(920px, 94vw)"
  6. :show-footers="false"
  7. footer-type="none"
  8. :mask-click="true"
  9. @update:visible="onVisibleChange"
  10. @close="handleClose"
  11. >
  12. <view class="pay-webview-body">
  13. <!-- #ifdef H5 -->
  14. <iframe v-if="payUrl" :src="payUrl" class="pay-webview-frame" frameborder="0" />
  15. <!-- #endif -->
  16. </view>
  17. </cwg-popup>
  18. </template>
  19. <script setup>
  20. import { computed } from 'vue'
  21. import { useI18n } from 'vue-i18n'
  22. import { payWebviewState, closePayWebview } from '@/hooks/usePayWebview'
  23. const { t } = useI18n()
  24. const visible = computed({
  25. get: () => payWebviewState.value.visible,
  26. set: (val) => {
  27. if (!val) closePayWebview()
  28. },
  29. })
  30. const payUrl = computed(() => payWebviewState.value.url)
  31. const displayTitle = computed(() => {
  32. return t('Shop.Order.OrderDetails')
  33. })
  34. function onVisibleChange(val) {
  35. if (!val) closePayWebview()
  36. }
  37. function handleClose() {
  38. closePayWebview()
  39. }
  40. </script>
  41. <style scoped lang="scss">
  42. @import "@/uni.scss";
  43. .pay-webview-body {
  44. width: 100%;
  45. height: 70vh;
  46. min-height: px2rpx(360);
  47. max-height: 80vh;
  48. overflow: hidden;
  49. border-radius: px2rpx(8);
  50. background: var(--bs-body-bg, #fff);
  51. }
  52. .pay-webview-frame {
  53. width: 100%;
  54. height: 100%;
  55. border: none;
  56. display: block;
  57. }
  58. </style>