modal-img.vue 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <template>
  2. <view class="zaiui-modal-box" :class="show?'show':''">
  3. <view class="dialog">
  4. <image class="img" :src="src" lazy-load mode="widthFix" @tap="imgEvent"></image>
  5. <text class="cuIcon-roundclose close" @tap="closeEvent"></text>
  6. </view>
  7. </view>
  8. </template>
  9. <script>
  10. export default {
  11. name: 'modal-img',
  12. props: {
  13. src: {
  14. type: String,
  15. default: ""
  16. },
  17. show: {
  18. type: Boolean,
  19. default: false
  20. }
  21. },
  22. methods: {
  23. imgEvent() {
  24. this.$emit('imgTap');
  25. },
  26. closeEvent() {
  27. this.$emit('closeTap');
  28. }
  29. }
  30. }
  31. </script>
  32. <style lang="scss" scoped>
  33. .zaiui-modal-box {
  34. position: fixed;
  35. opacity: 0;
  36. top: inherit;
  37. left: inherit;
  38. right: inherit;
  39. bottom: inherit;
  40. z-index: 999;
  41. text-align: center;
  42. background: rgba(0, 0, 0, 0.6);
  43. transition: all 0.3s;
  44. pointer-events: none;
  45. &::before {
  46. content: "\200B";
  47. display: inline-block;
  48. height: 100%;
  49. vertical-align: middle;
  50. }
  51. .dialog {
  52. position: relative;
  53. display: inline-block;
  54. vertical-align: middle;
  55. width: 618.18upx;
  56. .img {
  57. width: 100%;
  58. border-radius: 3%;
  59. }
  60. .close {
  61. color: #dadada;
  62. top: 18.18upx;
  63. position: relative;
  64. font-size: 54.54upx;
  65. }
  66. }
  67. }
  68. .zaiui-modal-box.show {
  69. top: 0;
  70. left: 0;
  71. right: 0;
  72. bottom: 0;
  73. opacity: 1;
  74. pointer-events: auto;
  75. }
  76. </style>