uni-popup_moments.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. <template>
  2. <view v-if="showPopup" class="uni-popup" @touchmove.stop.prevent="clear">
  3. <uni-transition :mode-class="['fade']" :styles="maskClass" :show="showTrans" @click="onTap" />
  4. <uni-transition :mode-class="ani" :styles="transClass" :show="showTrans" @click="onTap">
  5. <view class="uni-popup__wrapper-box" @click.stop="clear">
  6. <view class="uni-popup_mask">
  7. <view class="popup_text" @click="onTap">
  8. <image src="/static/img/img31.jpg"></image>
  9. <view class="text">{{illustrate}}</view>
  10. </view>
  11. </view>
  12. </view>
  13. </uni-transition>
  14. </view>
  15. </template>
  16. <script>
  17. import uniTransition from '../uni-transition/uni-transition.vue'
  18. export default {
  19. name: 'Popup',
  20. components: {
  21. uniTransition
  22. },
  23. props: {
  24. // 开启动画
  25. animation: {
  26. type: Boolean,
  27. default: true
  28. },
  29. // 弹出层类型,可选值,top: 顶部弹出层;bottom:底部弹出层;center:全屏弹出层
  30. type: {
  31. type: String,
  32. default: 'center'
  33. },
  34. // maskClick
  35. maskClick: {
  36. type: Boolean,
  37. default: true
  38. },
  39. },
  40. data() {
  41. return {
  42. ani: [],
  43. showPopup: false,
  44. illustrate:'',
  45. showTrans: false,
  46. maskClass: {
  47. 'position': 'fixed',
  48. 'bottom': 0,
  49. 'top': 0,
  50. 'left': 0,
  51. 'right': 0,
  52. 'backgroundColor': 'rgba(0, 0, 0, 0.4)'
  53. },
  54. transClass: {
  55. 'position': 'fixed',
  56. 'left': 0,
  57. 'right': 0,
  58. }
  59. }
  60. },
  61. watch: {
  62. type: {
  63. handler: function(newVal) {
  64. switch (this.type) {
  65. case 'top':
  66. this.ani = ['slide-top']
  67. this.transClass = {
  68. 'position': 'fixed',
  69. 'left': 0,
  70. 'right': 0,
  71. }
  72. break
  73. case 'bottom':
  74. this.ani = ['slide-bottom']
  75. this.transClass = {
  76. 'position': 'fixed',
  77. 'left': 0,
  78. 'right': 0,
  79. 'bottom': 0
  80. }
  81. break
  82. case 'center':
  83. this.ani = ['zoom-out', 'fade']
  84. this.transClass = {
  85. 'position': 'fixed',
  86. /* #ifndef APP-NVUE */
  87. 'display': 'flex',
  88. 'flexDirection': 'column',
  89. /* #endif */
  90. 'bottom': 0,
  91. 'left': 0,
  92. 'right': 0,
  93. 'top': 0,
  94. 'justifyContent': 'center',
  95. 'alignItems': 'center'
  96. }
  97. break
  98. }
  99. },
  100. immediate: true
  101. }
  102. },
  103. created() {},
  104. methods: {
  105. clear(e) {
  106. // TODO nvue 取消冒泡
  107. // console.log("取消冒泡")
  108. e.stopPropagation()
  109. },
  110. open(item) {
  111. console.log(item,55)
  112. this.illustrate = item;
  113. this.showPopup = true
  114. this.$nextTick(() => {
  115. setTimeout(() => {
  116. this.showTrans = true
  117. }, 50);
  118. })
  119. this.$emit('change', {
  120. show: true
  121. })
  122. },
  123. close(type) {
  124. // console.log("取消冒泡111")
  125. this.showTrans = false
  126. this.$nextTick(() => {
  127. clearTimeout(this.timer)
  128. this.timer = setTimeout(() => {
  129. this.$emit('change', {
  130. show: false
  131. })
  132. this.showPopup = false
  133. }, 300)
  134. })
  135. },
  136. onTap() {
  137. if (!this.maskClick) return
  138. this.close()
  139. }
  140. }
  141. }
  142. </script>
  143. <style lang="scss" scoped>
  144. .uni-popup {
  145. position: fixed;
  146. /* #ifdef H5 */
  147. top: var(--window-top);
  148. /* #endif */
  149. /* #ifndef H5 */
  150. top: 0;
  151. /* #endif */
  152. bottom: 0;
  153. left: 0;
  154. right: 0;
  155. /* #ifndef APP-NVUE */
  156. z-index: 99;
  157. /* #endif */
  158. }
  159. .uni-popup__mask {
  160. position: absolute;
  161. top: 0;
  162. bottom: 0;
  163. left: 0;
  164. right: 0;
  165. background-color: $uni-bg-color-mask;
  166. opacity: 0;
  167. }
  168. .mask-ani {
  169. transition-property: opacity;
  170. transition-duration: 0.2s;
  171. }
  172. .uni-top-mask {
  173. opacity: 1;
  174. }
  175. .uni-bottom-mask {
  176. opacity: 1;
  177. }
  178. .uni-center-mask {
  179. opacity: 1;
  180. }
  181. .uni-popup__wrapper {
  182. /* #ifndef APP-NVUE */
  183. display: block;
  184. /* #endif */
  185. position: absolute;
  186. }
  187. .top {
  188. top: 0;
  189. left: 0;
  190. right: 0;
  191. transform: translateY(-500px);
  192. }
  193. .bottom {
  194. bottom: 0;
  195. left: 0;
  196. right: 0;
  197. transform: translateY(500px);
  198. }
  199. .center {
  200. /* #ifndef APP-NVUE */
  201. display: flex;
  202. flex-direction: column;
  203. /* #endif */
  204. bottom: 0;
  205. left: 0;
  206. right: 0;
  207. top: 0;
  208. justify-content: center;
  209. align-items: center;
  210. transform: scale(1.2);
  211. opacity: 0;
  212. }
  213. .uni-popup__wrapper-box {
  214. /* #ifndef APP-NVUE */
  215. display: block;
  216. /* #endif */
  217. position: relative;
  218. }
  219. .content-ani {
  220. // transition: transform 0.3s;
  221. transition-property: transform, opacity;
  222. transition-duration: 0.2s;
  223. }
  224. .uni-top-content {
  225. transform: translateY(0);
  226. }
  227. .uni-bottom-content {
  228. transform: translateY(0);
  229. }
  230. .uni-center-content {
  231. transform: scale(1);
  232. opacity: 1;
  233. }
  234. .uni-popup_mask{
  235. padding: 55rpx 35rpx;
  236. // background: #FFFFFF;
  237. width: 100%;
  238. // border-radius: 15rpx;
  239. .popup_list{
  240. font-size: 45rpx;
  241. text-align: center;
  242. color: #2D2D2D;
  243. padding-bottom: 55rpx;
  244. // font-weight: 800;
  245. }
  246. .popup_text{
  247. font-size: 45rpx !important;
  248. color: #FFFFFF;
  249. background: #FFFFFF;
  250. padding-bottom: 25rpx;
  251. text-align: left;
  252. border-radius: 15rpx;
  253. width: 600rpx;
  254. .text{
  255. padding: 0rpx 45rpx;
  256. font-size: 28rpx;
  257. overflow: auto;
  258. color: #333;
  259. margin-top: .58rem;
  260. line-height: 1.5;
  261. height: 500rpx;
  262. }
  263. image{
  264. width: 100%;
  265. height: 300rpx;
  266. border-radius: 15rpx;
  267. }
  268. .popup_image{
  269. width: 40rpx;
  270. height: 40rpx;
  271. margin-right: 25rpx;
  272. image{
  273. width: 100%;
  274. height: 100%;
  275. }
  276. }
  277. }
  278. .popup_button{
  279. margin-top: 35rpx;
  280. .button_action{
  281. color: #BC253A;
  282. border: 2rpx solid #BC253A;
  283. width: 250rpx;
  284. text-align: center;
  285. margin-right: 25rpx;
  286. padding: 15rpx 0rpx;
  287. border-radius: 15rpx;
  288. }
  289. .submit{
  290. background: #BC253A !important;
  291. color: #FFFFFF !important;
  292. }
  293. }
  294. }
  295. </style>