c-pop-gift.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <template>
  2. <view class="mask" :class="maskState===0 ? 'none' : maskState===1 ? 'show' : ''" >
  3. <view class="mask-content" @click.stop.prevent="stopPrevent">
  4. <view class="icon-wrap" @click.stop="toggleMask('none')">
  5. <u-icon name="/static/app/close.png" size="60rpx"></u-icon>
  6. </view>
  7. <!-- <view class="title">
  8. <image style="width: 262rpx;height: 52rpx" src="@/static/app/activity_title.png" mode="aspectFit"></image>
  9. </view>
  10. <view class="desc">
  11. <image style="width: 632rpx;height: 598rpx;" src="@/static/app/activity_content.png" mode="aspectFit"></image>
  12. </view> -->
  13. <view class="action-content">
  14. <u-button type="primary"
  15. style="margin-bottom: 30rpx;"
  16. shape="circle"
  17. class="c-button"
  18. :text="defautlOptions.confirmText"
  19. @click="confirm">
  20. </u-button>
  21. </view>
  22. </view>
  23. </view>
  24. </template>
  25. <script>
  26. export default {
  27. name:"c-pop-gift",
  28. data() {
  29. return {
  30. maskState: 0,
  31. defautlOptions: {
  32. title: '',
  33. content: '',
  34. confirmText: '我知道啦!',
  35. confirmClass: 'text-red',
  36. cancelText: '我在想想',
  37. cancelClass: 'text-black'
  38. }
  39. };
  40. },
  41. methods: {
  42. stopPrevent(){
  43. },
  44. toggleMask(type){
  45. let timer = type === 'show' ? 10 : 30;
  46. let state = type === 'show' ? 1 : 0;
  47. this.maskState = 2;
  48. setTimeout(()=>{
  49. this.maskState = state;
  50. }, timer)
  51. },
  52. /**
  53. * @description 确认
  54. * @param {Object} title: String desc: String
  55. */
  56. $confirm(options = {}){
  57. // 继承原来的
  58. this.defautlOptions = Object.assign(this.defautlOptions, options);
  59. return new Promise((resolve,reject)=> {
  60. this.toggleMask('show')
  61. this._confirm = () => {
  62. resolve(1)
  63. this._confirm = null;
  64. }
  65. this._cancel = () => {
  66. resolve(0)
  67. this._cancel = null;
  68. }
  69. })
  70. },
  71. confirm() {
  72. if(this._confirm){
  73. this._confirm()
  74. this.toggleMask();
  75. }
  76. },
  77. cancel() {
  78. if(this._cancel){
  79. this._cancel()
  80. this.toggleMask();
  81. }
  82. }
  83. },
  84. }
  85. </script>
  86. <style lang="scss" scoped>
  87. .mask{
  88. display: flex;
  89. align-items: center;
  90. justify-content: center;
  91. position: fixed;
  92. left: 0;
  93. top: var(--window-top);
  94. bottom: 0;
  95. width: 100vw;
  96. background: rgba(0,0,0,0);
  97. z-index: 10001;
  98. transition: .6s;
  99. .mask-content{
  100. padding-top: 0rpx;
  101. display: flex;
  102. flex-direction: column;
  103. width: 720rpx;
  104. min-height: 586rpx;
  105. // background: #fff;
  106. background: url(@/static/app/gift_bg.png) no-repeat center center/ 720rpx 576rpx;
  107. border-radius: 15px;
  108. transition: transform .1s opacity 0.1s;
  109. transform: scale(1.2);
  110. transition-timing-function: ease-out;
  111. opacity: 0.3;
  112. }
  113. &.none{
  114. display: none;
  115. }
  116. &.show{
  117. background: rgba(0,0,0,.4);
  118. .mask-content{
  119. transition: transform .3s;
  120. opacity: 1;
  121. transform: scale(1);
  122. }
  123. }
  124. .title{
  125. padding-top: 20rpx;
  126. display: flex;
  127. justify-content: center;
  128. align-items: center;
  129. }
  130. .desc {
  131. margin-top: 55rpx;
  132. display: flex;
  133. justify-content: center;
  134. align-items: center;
  135. }
  136. .action-content{
  137. padding-top: 40rpx;
  138. padding-left: 15rpx;
  139. padding-right: 15rpx;
  140. position: absolute;
  141. bottom: -130rpx;
  142. left: 0;
  143. right: 0;
  144. }
  145. }
  146. .icon-wrap{
  147. position: absolute;
  148. top: -40rpx;
  149. right: 20rpx;
  150. }
  151. </style>