<template> <div v-if="showSelf" class="dialog"> <div class="dialog-mark" @click.self="closeMyself"> <div class="sharetiptxt" style> <img style=" height:100%;" src="../assets/buttonImg/shareText.png" alt /> </div> <transition name="dialog"> <div class="dialog-sprite"> <div class="dialog-body"> <div class="card-wrapper"> <div :class="`dialog-popuImag ${classDivAA?'flipped':''}`"> <!-- <img src="../assets/popupImg/popuBody.jpg" alt /> --> <div class="back" :style="`background-image: url(${backimg});`"> <img style="width: 180px; height:492px" src="../assets/prizeImg/HappyWnning.jpg" alt /> </div> <div class="front"> <img style="width: 180px; height:492px " src="../assets/prizeImg/HappyWnning.jpg" alt /> </div> </div> </div> <div @click="cancel" class="dialog-footer"> <img @click="cancel" class="btn" src="../assets/buttonImg/happyAccept.png" alt /> </div> </div> <!-- 右侧 --> </div> </transition> </div> </div> </template> <script> export default { name: 'Popup', components: {}, props: { show: { type: Boolean, default: false, required: true }, cancelText: { type: String, default: '取消', required: false }, currentMonth: { type: Object } }, data() { return { name: 'dialog', showSelf: false, zIndex: this.getZIndex(), bodyOverflow: '', classDivAA: false, myShareShow: false, backimg: require('../assets/luckyImg/2.jpg'), stater: null } }, watch: { show(val) { console.log('🚀 ~ file: Popup.vue ~ line 78 ~ show ~ val', val) this.showSelf = val if (this.show === false) { this.myShareShow = false } this.transform() // if (!val) { // this.closeMyself() // } else { // this.showSelf = val // } } }, created() { this.showSelf = this.show }, mounted() { this.forbidScroll() if (this.show === true) { this.transform() } }, methods: { canckle() { // this.showPopupCalendarPoster = false }, shareClick() { this.$router.replace({ path: 'SaveShare', query: { states: 0 } }) }, saveClick() { this.$router.replace({ path: 'SaveShare', query: { states: 1 } }) }, transform() { setTimeout(() => { this.classDivAA = this.show }, 0) }, /** 禁止页面滚动 */ forbidScroll() { this.bodyOverflow = document.body.style.overflow document.body.style.overflow = 'hidden' }, /** 每次获取之后 zindex 自动增加 */ getZIndex() { let zIndexInit = 2022112 return zIndexInit++ }, /** 取消按钮操作 */ cancel() { this.$emit('cancel', true) }, /** 确认按钮操作 */ confirm() { this.$emit('confirm', true) }, /** 点击遮罩关闭弹窗 */ closeMyself(event) { // this.sloveBodyOverflow() }, /** 恢复页面的滚动 */ sloveBodyOverflow() { document.body.style.overflow = this.bodyOverflow } } } </script> <style lang="less" scoped> // 弹窗动画 // 最外层 设置position定位 // 遮罩 设置背景层,z-index值要足够大确保能覆盖,高度 宽度设置满 做到全屏遮罩 .dialog { position: fixed; top: 0; right: 0; width: 100%; height: 100%; transition: opacity 1s; // 内容层 z-index要比遮罩大,否则会被遮盖 .dialog-mark { position: relative; top: 0; height: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.6); left: 0; top: 0; z-index: 99; display: flex; align-items: center; justify-content: center; .sharetiptxt { background-size: 100% auto; background-repeat: no-repeat; z-index: 55; width: 20px; height: 320px; display: block; position: absolute; right: 1rem; top: 0.5em; animation: tipup 1s ease infinite; } } } @keyframes tipup { 0% { transform: translateY(0%); } 50% { transform: translateY(5%); } 100% { transform: translateY(0%); } } .dialog-sprite { width: 100vw; display: flex; justify-content: center; position: relative; .header { padding: 15px; text-align: center; font-size: 18px; font-weight: 700; color: #333; } .dialog-body { flex: 1; overflow-x: hidden; overflow-y: scroll; padding: 0 15px 20px 15px; //中间卡片 .card-wrapper { perspective: 600px; margin-top: 2em; .dialog-popuImag { position: relative; display: flex; justify-content: center; transform-style: preserve-3d; transition: all 1.2s ease; // div { // // position: relative; // position: absolute; // width: 100%; // height: 100%; // /* 背面不显示 */ // // backface-visibility: hidden; // } .front { } .back { position: absolute; transform: rotateY(180deg); width: 180px; height: 492px; background-size: 100% auto; background-repeat: no-repeat; // animation: change 0.8s linear forwards; } img { width: 48vw; } } .flipped { animation: change 0.8s linear forwards; } } @keyframes change { from { top: -20vh; left: -20vw; opacity: 0; transform: scale(0.5); } to { top: -0; left: -0; opacity: 2; transform: scale(1); transform: rotateY(180deg); } } //底部按钮 .dialog-footer { width: 140px; margin: 10px auto 0; .btn { background-position: 50% 50%; background-repeat: no-repeat; padding-top: 0; width: 100%; } } } .section-box { position: absolute; right: 15vw; top: 98px; height: 394px; display: flex; flex-direction: column; width: 36px; justify-content: space-between; margin-top: 2em; img { width: 36px; background-size: 100% auto; margin-top: 0; border-radius: 18px; } &-receive { width: 36px; background-size: 100% auto; margin-top: 0; } &-save { width: 36px; border-radius: 18px; background-size: 100% auto; width: 36px; margin-top: 0; // background: url('../assets/popupImg/receiveImage.png') no-repeat; } } } </style>