popup.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <template>
  2. <transition name='fade'>
  3. <!-- 蒙版 -->
  4. <div class="mask" v-if="show" @touchmove.prevent>
  5. <div class="wrapper">
  6. <img :src="info.popup_image_url" class="ad-image" alt="" @click="toAdPay">
  7. <!-- <img src="../../api/adtest.png" class="ad-image" alt="" @click="toAdPay"> -->
  8. <div class="text-wrapper" @click="toAdPay">
  9. <div class="title">充<span>{{ info.product_info.price }}</span>元 <span v-if="isShowGive">,送{{
  10. info.product_info.given }}书币</span>
  11. </div>
  12. <div class="title" v-if="isShowGive">立得<span>{{ standCoin }}</span>书币</div>
  13. <div class="title" v-else>得<span>{{ coin }}</span>书币</div>
  14. <!-- <div class="sub-title">立省M元</div> -->
  15. </div>
  16. <div class="close-wrapper">
  17. <img @click="close" class="close" src="../../assets/close_icon.png" alt="">
  18. </div>
  19. </div>
  20. </div>
  21. </transition>
  22. </template>
  23. <script>
  24. import { advertisementPopupInfo } from '../../api/index'
  25. import {
  26. adPay,
  27. } from "../../view/namespace";
  28. export default {
  29. name: 'adPay',
  30. props: {
  31. popup_position: {
  32. type: String,
  33. default: 'homePage'
  34. },
  35. from: {
  36. type: String,
  37. default: ''
  38. }
  39. },
  40. data () {
  41. return {
  42. info: {
  43. "popup_image_url": "https://zhuishuyun.oss-cn-hangzhou.aliyuncs.com/wap/popup_adv_images/popup3%402x.png", // 弹窗图片地址
  44. "product_id": null, // 充值档位id
  45. // 充值档位信息
  46. "product_info": {
  47. "price": 555, // 充值金额
  48. "given": 666, //赠送金币
  49. },
  50. "id": null, // 弹窗广告id
  51. },
  52. show: false,
  53. title: '',
  54. content: '',
  55. btnText: '',
  56. click: ''
  57. }
  58. },
  59. computed: {
  60. isShowGive () {
  61. return Number(this.info.product_info.given) > 0
  62. },
  63. standCoin () {
  64. return Number(this.info.product_info.price) * 100 + Number(this.info.product_info.given)
  65. },
  66. coin () {
  67. return Number(this.info.product_info.price) * 100
  68. }
  69. // show () {
  70. // return Boolean(this.info.id)
  71. // }
  72. },
  73. created () {
  74. console.log(adPay);
  75. this.init()
  76. },
  77. methods: {
  78. init () {
  79. advertisementPopupInfo({ popup_position: this.popup_position })
  80. .then(res => {
  81. console.log(res);
  82. this.info = res
  83. if (this.info.id) {
  84. this.show = true
  85. }
  86. }).catch(err => {
  87. console.log(err);
  88. if (this.popup_position == 'returnNotRecharge') {
  89. if (this.from == 'reader') {
  90. console.log('readerreaderreader');
  91. this.$router.go(-2)
  92. } else {
  93. console.log('chongzchongzchongzchongz');
  94. this.$router.go(-1)
  95. }
  96. }
  97. })
  98. },
  99. close () {
  100. this.show = false
  101. this.info.id = null
  102. },
  103. toAdPay () {
  104. this.$router.push({ path: 'ad_pay', query: { product_id: this.info.product_id, id: this.info.id } })
  105. this.show = false
  106. }
  107. }
  108. }
  109. </script>
  110. <style lang="scss" scoped>
  111. // 渐变过渡
  112. .fade-enter,
  113. .fade-leave-active {
  114. opacity: 0;
  115. }
  116. .fade-enter-active,
  117. .fade-leave-active {
  118. transition: opacity 0.35s;
  119. }
  120. .text-wrapper {
  121. width: 70%;
  122. position: absolute;
  123. top: 48%;
  124. left: 50%;
  125. transform: translate(-50%, -48%);
  126. .title {
  127. font-size: 0.36rem;
  128. font-family: MicrosoftYaHei-Bold, MicrosoftYaHei;
  129. font-weight: bold;
  130. color: #d65142;
  131. }
  132. .sub-title {
  133. font-size: 0.45rem;
  134. font-family: MicrosoftYaHei;
  135. color: #5e5a60;
  136. margin-bottom: 0.5rem;
  137. }
  138. }
  139. .mask {
  140. width: 100vw;
  141. height: 100vh;
  142. position: fixed;
  143. z-index: 1000;
  144. background: rgba(0, 0, 0, 0.65);
  145. display: flex;
  146. flex-direction: column;
  147. justify-content: center;
  148. align-items: center;
  149. padding: 75/75rem;
  150. .wrapper {
  151. width: 95%;
  152. border-radius: 8px;
  153. text-align: center;
  154. .ad-image {
  155. width: 100%;
  156. object-fit: contain;
  157. }
  158. .close-wrapper {
  159. .close {
  160. width: 42px;
  161. height: 42px;
  162. margin-top: 2em;
  163. }
  164. }
  165. }
  166. }
  167. @media screen and (max-width: 321px) and (max-width: 375px) {}
  168. </style>