ShaerPopup.vue 4.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. <template>
  2. <div v-if="showSelf" class="dialog" :style="{'z-index': zIndex}">
  3. <div class="dialog-mark" @click="closeMyself" :style="{'z-index': zIndex + 1}">
  4. <div v-show="myShareShow" class="sharetiptxt" style>
  5. <img style=" height:90%; z-index:46" src="../assets/buttonImg/shareText.png" alt />
  6. </div>
  7. <fire-flies></fire-flies>
  8. <transition name="dialog">
  9. <div class="dialog-sprite">
  10. <div class="dialog-body">
  11. <div class="bd2 flex-col">
  12. <img class="pic1" :src="currentMonth.shareImg" alt />
  13. </div>
  14. <div class="bd1 flex-col">
  15. <span class="btn" :style="`background-image: url(${popuSave});`"></span>
  16. </div>
  17. </div>
  18. <!-- 右侧 -->
  19. </div>
  20. </transition>
  21. </div>
  22. </div>
  23. </template>
  24. <script>
  25. export default {
  26. name: 'ShaerPopup',
  27. components: {
  28. FireFlies: () => import('@/components/FireFlies')
  29. },
  30. props: {
  31. show: {
  32. type: Boolean,
  33. default: false,
  34. required: true
  35. },
  36. cancelText: {
  37. type: String,
  38. default: '取消',
  39. required: false
  40. },
  41. currentMonth: {
  42. type: Object
  43. }
  44. },
  45. data() {
  46. return {
  47. showSelf: false,
  48. zIndex: this.getZIndex(),
  49. bodyOverflow: '',
  50. popuSave: require('../assets/buttonImg/pressSave.png'),
  51. myShareShow: true
  52. };
  53. },
  54. watch: {
  55. show(val) {
  56. console.log('🚀 ~ file: Popup.vue ~ line 78 ~ show ~ val', val);
  57. this.showSelf = val;
  58. }
  59. },
  60. created() {
  61. this.showSelf = this.show;
  62. },
  63. mounted() {
  64. this.forbidScroll();
  65. },
  66. methods: {
  67. /** 禁止页面滚动 */
  68. forbidScroll() {
  69. this.bodyOverflow = document.body.style.overflow;
  70. document.body.style.overflow = 'hidden';
  71. },
  72. /** 每次获取之后 zindex 自动增加 */
  73. getZIndex() {
  74. let zIndexInit = 2022112;
  75. return zIndexInit++;
  76. },
  77. /** 取消按钮操作 */
  78. cancel() {
  79. // this.$emit('cancel', true)
  80. },
  81. /** 确认按钮操作 */
  82. confirm() {
  83. this.$emit('confirm', true);
  84. },
  85. /** 点击遮罩关闭弹窗 */
  86. closeMyself(event) {
  87. // this.sloveBodyOverflow()
  88. this.$emit('closeMyself', true);
  89. },
  90. /** 恢复页面的滚动 */
  91. sloveBodyOverflow() {
  92. this.showSelf = false;
  93. document.body.style.overflow = this.bodyOverflow;
  94. }
  95. }
  96. };
  97. </script>
  98. <style lang="less" scoped>
  99. // 弹窗动画
  100. // 最外层 设置position定位
  101. // 遮罩 设置背景层,z-index值要足够大确保能覆盖,高度 宽度设置满 做到全屏遮罩
  102. .flex-col {
  103. display: flex;
  104. flex-direction: column;
  105. }
  106. .dialog {
  107. position: fixed;
  108. top: 0;
  109. right: 0;
  110. width: 100%;
  111. height: 100%;
  112. transition: opacity 1s;
  113. // 内容层 z-index要比遮罩大,否则会被遮盖
  114. .dialog-mark {
  115. position: absolute;
  116. top: 0;
  117. height: 0;
  118. width: 100%;
  119. height: 100%;
  120. background: rgba(0, 0, 0, 0.9);
  121. left: 0;
  122. top: 0;
  123. z-index: 99;
  124. display: flex;
  125. align-items: center;
  126. justify-content: center;
  127. .sharetiptxt {
  128. background-size: 100% auto;
  129. background-repeat: no-repeat;
  130. z-index: 55;
  131. width: 20px;
  132. height: 320px;
  133. display: block;
  134. position: absolute;
  135. right: 1rem;
  136. top: 0.5em;
  137. animation: tipup 1s ease infinite;
  138. }
  139. }
  140. .dialog-sprite {
  141. width: 100vw;
  142. display: flex;
  143. justify-content: center;
  144. position: relative;
  145. .dialog-body {
  146. flex: 1;
  147. overflow-x: hidden;
  148. overflow-y: scroll;
  149. padding: 0 15px 20px 15px;
  150. //中间卡片
  151. .bd2 {
  152. z-index: 33;
  153. width: 100%;
  154. justify-content: flex-start;
  155. align-items: center;
  156. margin-top: 20px;
  157. .pic1 {
  158. z-index: 45;
  159. width: 280px;
  160. height: 464px;
  161. }
  162. }
  163. //底部按钮
  164. .bd1 {
  165. width: 100%;
  166. background-size: 100% auto;
  167. margin: 10px auto 0;
  168. .btn {
  169. z-index: 42;
  170. width: 162px;
  171. height: 46.8px;
  172. display: block;
  173. text-align: center;
  174. align-self: center;
  175. margin-top: 12px;
  176. background-size: 100% auto;
  177. background-repeat: no-repeat;
  178. }
  179. }
  180. }
  181. }
  182. }
  183. @keyframes tipup {
  184. 0% {
  185. transform: translateY(0%);
  186. }
  187. 50% {
  188. transform: translateY(5%);
  189. }
  190. 100% {
  191. transform: translateY(0%);
  192. }
  193. }
  194. </style>