Popup.vue 7.8KB

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