cwg-global-popup.vue 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <template>
  2. <cwg-popup v-model:visible="popupState.visible" type="center" :mask-click="false" :show-footers="true" width="400px">
  3. <view class="popup-content">
  4. <view class="confirm-title">{{ popupState.title }}</view>
  5. <view class="confirm-content">{{ popupState.content }}</view>
  6. </view>
  7. <template #footer>
  8. <button v-if="popupState.showCancel" @click="close">{{ popupState.cancelText }}</button>
  9. <button class="btn btn-secondary btn-shadow waves-effect" @click="handleConfirm">{{ popupState.confirmText }}</button>
  10. </template>
  11. </cwg-popup>
  12. </template>
  13. <script setup>
  14. import { watch, ref } from 'vue'
  15. import { usePopup } from '@/hooks/usePopup'
  16. const { popupState, close, handleConfirm } = usePopup()
  17. const popupRef = ref(null)
  18. watch(() => popupState.value.visible, (val) => {
  19. if (val) {
  20. popupRef.value?.open()
  21. } else {
  22. popupRef.value?.close()
  23. }
  24. }, { immediate: true })
  25. </script>
  26. <style scoped lang="scss">
  27. @import "@/uni.scss";
  28. :deep(.cwg-dialog) {
  29. width: px2rpx(500);
  30. background-color: rgba(var(--bs-body-bg-rgb), var(--bs-bg-opacity)) !important;
  31. border-radius: px2rpx(16);
  32. text-align: center;
  33. box-shadow: 0 px2rpx(10) px2rpx(20) rgba(0, 0, 0, 0.1);
  34. }
  35. .confirm-title {
  36. font-size: px2rpx(24);
  37. font-weight: 600;
  38. color: var(--bs-heading-color);
  39. margin-bottom: px2rpx(30);
  40. }
  41. .confirm-content {
  42. font-size: px2rpx(20);
  43. color: var(--bs-heading-color);
  44. margin-bottom: px2rpx(30);
  45. line-height: 1.5;
  46. word-break: break-word;
  47. }
  48. </style>