Popup.vue 7.3KB

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