DialogEmail.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <template>
  2. <view class="dialog-email-layer flexcc" :class="{show: show}" @click="onHide" v-if="visible">
  3. <view class="dialog-email-view" :class="{show: show}" @click.stop="">
  4. <view class="dialog-email-title">Receive Receipt</view>
  5. <input class="dialog-email-input" v-model="email" placeholder="Please input your email address"/>
  6. <button :disabled="loading" class="ui-button" type="primary" style="font-size: 28rpx;" @click="sendEmail">SEND</button>
  7. </view>
  8. </view>
  9. </template>
  10. <script>
  11. import validate from "/utils/validate.js";
  12. export default {
  13. name: "DialogEmail",
  14. props: {
  15. visible: {
  16. type: Boolean,
  17. default: false
  18. },
  19. loading: {
  20. type: Boolean,
  21. default: false
  22. }
  23. },
  24. data() {
  25. return {
  26. email: "",
  27. show: false
  28. };
  29. },
  30. watch: {
  31. visible(n, o) {
  32. if (n) {
  33. setTimeout(() => {
  34. this.show = true;
  35. }, 10)
  36. } else {
  37. this.email = "";
  38. this.ready = false;
  39. }
  40. }
  41. },
  42. mounted() {
  43. },
  44. methods: {
  45. onHide() {
  46. this.show = false;
  47. setTimeout(() => {
  48. this.$emit("close");
  49. }, 200)
  50. },
  51. sendEmail() {
  52. if (this.email) {
  53. if (validate.validEmail(this.email)) {
  54. this.$emit("send", this.email)
  55. } else {
  56. uni.showToast({
  57. title: "Email format incorrect",
  58. icon: "none"
  59. })
  60. }
  61. } else {
  62. uni.showToast({
  63. title: "Please input your email address",
  64. icon: "none"
  65. })
  66. }
  67. }
  68. }
  69. }
  70. </script>
  71. <style scoped>
  72. .dialog-email-layer {
  73. top: 0;
  74. left: 0;
  75. right: 0;
  76. bottom: 0;
  77. opacity: 0;
  78. z-index: 5;
  79. position: fixed;
  80. transition: all 0.3s;
  81. background-color: rgba(28, 29, 29, 0.7);
  82. }
  83. .dialog-email-layer.show {
  84. opacity: 1;
  85. }
  86. .dialog-email-view {
  87. transform: scale(0);
  88. border-radius: 32rpx;
  89. background-color: white;
  90. }
  91. .dialog-email-view.show {
  92. width: 74vw;
  93. padding: 32rpx;
  94. transform: scale(1);
  95. transition: all 0.05s;
  96. }
  97. .dialog-email-title {
  98. color: #000;
  99. font-size: 32rpx;
  100. padding-top: 28rpx;
  101. font-weight: bold;
  102. text-align: center;
  103. word-wrap: break-word;
  104. word-break: break-all;
  105. white-space: pre-wrap;
  106. overflow: hidden;
  107. text-overflow: ellipsis;
  108. display: -webkit-box;
  109. -webkit-line-clamp: 2;
  110. -webkit-box-orient: vertical;
  111. }
  112. .dialog-email-input {
  113. color: #333;
  114. margin: 42rpx 0;
  115. font-size: 28rpx;
  116. border-radius: 24rpx;
  117. padding: 20rpx 28rpx;
  118. border: 1px solid #ddd;
  119. background-color: #f0f0f0;
  120. }
  121. </style>