ShaerPopup.vue 6.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  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="width:100%; height:100%; z-index:46" src="../assets/popupImg/myShare.png" alt />
  6. </div>
  7. <transition name="dialog">
  8. <div class="dialog-sprite">
  9. <div class="dialog-body">
  10. <div class="bd2 flex-col">
  11. <img class="pic1" src="../assets/ShaerPopupImg/popuBgc.jpg" alt />
  12. </div>
  13. <div class="bd1 flex-col">
  14. <span class="btn" :style="`background-image: url(${popuSave});`"></span>
  15. </div>
  16. </div>
  17. <!-- 右侧 -->
  18. <!-- <div class="section-box">
  19. <div class="section-box-share" @click="()=>{this.myShareShow=true}">
  20. <img src="../assets/popupImg/shareImage.png" alt />
  21. </div>
  22. <div class="section-box-receive">
  23. <router-link :to="{path:'SaveShare',query: { states: 0 }}">
  24. <img src="../assets/popupImg/receiveImage.png" alt />
  25. </router-link>
  26. </div>
  27. <div class="section-box-save">
  28. <router-link :to="{path:'SaveShare',query: { states: 1 }}">
  29. <img src="../assets/popupImg/saveImage.png" alt />
  30. </router-link>
  31. </div>
  32. </div>-->
  33. </div>
  34. </transition>
  35. </div>
  36. </div>
  37. </template>
  38. <script>
  39. export default {
  40. name: 'ShaerPopup',
  41. props: {
  42. show: {
  43. type: Boolean,
  44. default: false,
  45. required: true
  46. },
  47. cancelText: {
  48. type: String,
  49. default: '取消',
  50. required: false
  51. }
  52. },
  53. data() {
  54. return {
  55. name: 'dialog',
  56. showSelf: false,
  57. zIndex: this.getZIndex(),
  58. bodyOverflow: '',
  59. popuSave: require('../assets/ShaerPopupImg/popuSave.png'),
  60. myShareShow: true
  61. }
  62. },
  63. watch: {
  64. show(val) {
  65. console.log('🚀 ~ file: Popup.vue ~ line 78 ~ show ~ val', val)
  66. this.showSelf = val
  67. // this.closeMyself()
  68. // if (!val) {
  69. // this.closeMyself()
  70. // } else {
  71. // this.showSelf = val
  72. // }
  73. }
  74. },
  75. created() {
  76. this.showSelf = this.show
  77. },
  78. mounted() {
  79. this.forbidScroll()
  80. },
  81. methods: {
  82. /** 禁止页面滚动 */
  83. forbidScroll() {
  84. this.bodyOverflow = document.body.style.overflow
  85. document.body.style.overflow = 'hidden'
  86. },
  87. /** 每次获取之后 zindex 自动增加 */
  88. getZIndex() {
  89. let zIndexInit = 2022112
  90. return zIndexInit++
  91. },
  92. /** 取消按钮操作 */
  93. cancel() {
  94. // this.$emit('cancel', true)
  95. },
  96. /** 确认按钮操作 */
  97. confirm() {
  98. this.$emit('confirm', true)
  99. },
  100. /** 点击遮罩关闭弹窗 */
  101. closeMyself(event) {
  102. // this.sloveBodyOverflow()
  103. this.$emit('closeMyself', true)
  104. },
  105. /** 恢复页面的滚动 */
  106. sloveBodyOverflow() {
  107. this.showSelf = false
  108. document.body.style.overflow = this.bodyOverflow
  109. }
  110. }
  111. }
  112. </script>
  113. <style lang="less" scoped>
  114. // 弹窗动画
  115. // 最外层 设置position定位
  116. // 遮罩 设置背景层,z-index值要足够大确保能覆盖,高度 宽度设置满 做到全屏遮罩
  117. .flex-col {
  118. display: flex;
  119. flex-direction: column;
  120. }
  121. .dialog {
  122. position: fixed;
  123. top: 0;
  124. right: 0;
  125. width: 100%;
  126. height: 100%;
  127. transition: opacity 1s;
  128. // 内容层 z-index要比遮罩大,否则会被遮盖
  129. .dialog-mark {
  130. position: absolute;
  131. top: 0;
  132. height: 0;
  133. width: 100%;
  134. height: 100%;
  135. background: rgba(0, 0, 0, 0.9);
  136. left: 0;
  137. top: 0;
  138. z-index: 99;
  139. display: flex;
  140. align-items: center;
  141. justify-content: center;
  142. .sharetiptxt {
  143. background-size: 100% auto;
  144. background-repeat: no-repeat;
  145. z-index: 55;
  146. width: 20px;
  147. height: 320px;
  148. display: block;
  149. position: absolute;
  150. right: 1rem;
  151. top: 0.5em;
  152. animation: tipup 1s ease infinite;
  153. }
  154. }
  155. }
  156. @keyframes tipup {
  157. 0% {
  158. transform: translateY(0%);
  159. }
  160. 50% {
  161. transform: translateY(5%);
  162. }
  163. 100% {
  164. transform: translateY(0%);
  165. }
  166. }
  167. .dialog-sprite {
  168. width: 100vw;
  169. display: flex;
  170. justify-content: center;
  171. position: relative;
  172. .header {
  173. padding: 15px;
  174. text-align: center;
  175. font-size: 18px;
  176. font-weight: 700;
  177. color: #333;
  178. }
  179. .dialog-body {
  180. flex: 1;
  181. overflow-x: hidden;
  182. overflow-y: scroll;
  183. padding: 0 15px 20px 15px;
  184. //中间卡片
  185. .bd2 {
  186. z-index: 33;
  187. width: 100%;
  188. justify-content: flex-start;
  189. align-items: center;
  190. margin-top: 20px;
  191. .pic1 {
  192. z-index: 45;
  193. width: 280px;
  194. height: 464px;
  195. // div {
  196. // // position: relative;
  197. // position: absolute;
  198. // width: 100%;
  199. // height: 100%;
  200. // /* 背面不显示 */
  201. // // backface-visibility: hidden;
  202. // }
  203. img {
  204. width: 48vw;
  205. }
  206. }
  207. .flipped {
  208. animation: change 0.8s linear forwards;
  209. }
  210. }
  211. @keyframes change {
  212. from {
  213. top: -20vh;
  214. left: -20vw;
  215. opacity: 0;
  216. transform: scale(0.5);
  217. }
  218. to {
  219. top: -0;
  220. left: -0;
  221. opacity: 2;
  222. transform: scale(1);
  223. transform: rotateY(180deg);
  224. }
  225. }
  226. //底部按钮
  227. .bd1 {
  228. width: 100%;
  229. background-size: 100% auto;
  230. margin: 10px auto 0;
  231. .btn {
  232. z-index: 42;
  233. width: 152px;
  234. height: 50px;
  235. display: block;
  236. text-align: center;
  237. align-self: center;
  238. margin-top: 12px;
  239. background-size: 100% auto;
  240. background-repeat: no-repeat;
  241. }
  242. }
  243. }
  244. .section-box {
  245. position: absolute;
  246. right: 15vw;
  247. top: 98px;
  248. height: 394px;
  249. display: flex;
  250. flex-direction: column;
  251. width: 36px;
  252. justify-content: space-between;
  253. img {
  254. width: 36px;
  255. background-size: 100% auto;
  256. margin-top: 0;
  257. border-radius: 18px;
  258. }
  259. &-receive {
  260. width: 36px;
  261. background-size: 100% auto;
  262. margin-top: 0;
  263. }
  264. &-save {
  265. width: 36px;
  266. border-radius: 18px;
  267. background-size: 100% auto;
  268. width: 36px;
  269. margin-top: 0;
  270. // background: url('../assets/popupImg/receiveImage.png') no-repeat;
  271. }
  272. }
  273. }
  274. </style>