123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212 |
- <template>
- <div v-if="showSelf" class="dialog" :style="{'z-index': zIndex}">
- <div class="dialog-mark" @click="closeMyself" :style="{'z-index': zIndex + 1}">
- <div v-show="myShareShow" class="sharetiptxt" style>
- <img style=" height:90%; z-index:46" src="../assets/buttonImg/shareText.png" alt />
- </div>
- <fire-flies></fire-flies>
-
- <transition name="dialog">
- <div class="dialog-sprite">
- <div class="dialog-body">
- <div class="bd2 flex-col">
- <img class="pic1" :src="currentMonth.shareImg" alt />
- </div>
-
- <div class="bd1 flex-col">
- <span class="btn" :style="`background-image: url(${popuSave});`"></span>
- </div>
- </div>
- <!-- 右侧 -->
- </div>
- </transition>
- </div>
- </div>
- </template>
-
- <script>
- export default {
- name: 'ShaerPopup',
- components: {
- FireFlies: () => import('@/components/FireFlies')
- },
- props: {
- show: {
- type: Boolean,
- default: false,
- required: true
- },
- cancelText: {
- type: String,
- default: '取消',
- required: false
- },
- currentMonth: {
- type: Object
- }
- },
-
- data() {
- return {
- showSelf: false,
- zIndex: this.getZIndex(),
- bodyOverflow: '',
- popuSave: require('../assets/buttonImg/pressSave.png'),
-
- myShareShow: true
- };
- },
- watch: {
- show(val) {
- console.log('🚀 ~ file: Popup.vue ~ line 78 ~ show ~ val', val);
- this.showSelf = val;
- }
- },
- created() {
- this.showSelf = this.show;
- },
- mounted() {
- this.forbidScroll();
- },
- methods: {
- /** 禁止页面滚动 */
- 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()
- this.$emit('closeMyself', true);
- },
-
- /** 恢复页面的滚动 */
- sloveBodyOverflow() {
- this.showSelf = false;
-
- document.body.style.overflow = this.bodyOverflow;
- }
- }
- };
- </script>
-
- <style lang="less" scoped>
- // 弹窗动画
-
- // 最外层 设置position定位
- // 遮罩 设置背景层,z-index值要足够大确保能覆盖,高度 宽度设置满 做到全屏遮罩
-
- .flex-col {
- display: flex;
- flex-direction: column;
- }
- .dialog {
- position: fixed;
- top: 0;
- right: 0;
- width: 100%;
- height: 100%;
- transition: opacity 1s;
-
- // 内容层 z-index要比遮罩大,否则会被遮盖
- .dialog-mark {
- position: absolute;
- top: 0;
- height: 0;
- width: 100%;
- height: 100%;
- background: rgba(0, 0, 0, 0.9);
- 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;
- }
- }
-
- .dialog-sprite {
- width: 100vw;
- display: flex;
- justify-content: center;
- position: relative;
- .dialog-body {
- flex: 1;
- overflow-x: hidden;
- overflow-y: scroll;
- padding: 0 15px 20px 15px;
- //中间卡片
- .bd2 {
- z-index: 33;
- width: 100%;
- justify-content: flex-start;
- align-items: center;
- margin-top: 20px;
-
- .pic1 {
- z-index: 45;
- width: 280px;
- height: 464px;
- }
- }
- //底部按钮
- .bd1 {
- width: 100%;
- background-size: 100% auto;
- margin: 10px auto 0;
- .btn {
- z-index: 42;
- width: 162px;
- height: 46.8px;
- display: block;
- text-align: center;
- align-self: center;
- margin-top: 12px;
- background-size: 100% auto;
- background-repeat: no-repeat;
- }
- }
- }
- }
- }
- @keyframes tipup {
- 0% {
- transform: translateY(0%);
- }
- 50% {
- transform: translateY(5%);
- }
- 100% {
- transform: translateY(0%);
- }
- }
- </style>
|