Popup.vue 7.8KB

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