dmPopView.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. <template>
  2. <view class="pop-view" v-if='visible'>
  3. <view class="pop-maskView" :style="{
  4. 'background-color': maskBgColor,
  5. zIndex: zIndex - 1
  6. }" @tap.stop="handleMaskTap"
  7. @touchmove.stop.prevent="moveHandle">
  8. </view>
  9. <view v-if="isScannerOption" :class="['pop-contentView',containerVisible ? 'pop-contentView-show' : '']" :style="{zIndex: zIndex}" >
  10. <text class="pop-title" v-if="isShowTitle">{{title}}</text>
  11. <image class="pop-close" src="../../static/icons/icon_close@2x.png" v-if="isShowClose" mode="" @click="handleCancel"></image>
  12. <slot></slot>
  13. <text class="pop-commit" :style="{'background-color':color2}" v-if="isShowConfirm" @click="handleConfirm">确定</text>
  14. </view>
  15. <view v-else :class="['pop-contentView',containerVisible ? 'pop-contentView-show' : '']" :style="{zIndex: zIndex}"
  16. @touchmove.stop.prevent="moveHandle">
  17. <text class="pop-title" v-if="isShowTitle">{{title}}</text>
  18. <image class="pop-close" src="../../static/icons/icon_close@2x.png" v-if="isShowClose" mode="" @click="handleCancel"></image>
  19. <slot></slot>
  20. <text class="pop-commit" :style="{'background-color':color2}" v-if="isShowConfirm" @click="handleConfirm">确定</text>
  21. </view>
  22. </view>
  23. </template>
  24. <script>
  25. export default {
  26. props: {
  27. title: String,
  28. maskColor: {
  29. type: String,
  30. default: 'rgba(0, 0, 0, 0.3)'
  31. },
  32. zIndex: {
  33. type: Number,
  34. default: 999
  35. },
  36. maskTapHide: {
  37. type: Boolean,
  38. default: true
  39. },
  40. isShowTitle: {
  41. type: Boolean,
  42. default: true
  43. },
  44. isShowClose: {
  45. type: Boolean,
  46. default: true
  47. },
  48. isShowConfirm: {
  49. type: Boolean,
  50. default: true
  51. },
  52. isScannerOption:{
  53. type:Boolean,
  54. default:false
  55. }
  56. },
  57. data() {
  58. return {
  59. visible: false,
  60. containerVisible: false,
  61. maskBgColor: '',
  62. selectValue: [0],
  63. selIdx: 0,
  64. color2:''
  65. }
  66. },
  67. mounted() {
  68. let app = getApp();
  69. this.globalData = app.globalData;
  70. this.color2 = this.globalData.color2;
  71. },
  72. methods: {
  73. show() {
  74. this.visible = true
  75. setTimeout(() => {
  76. this.maskBgColor = this.maskColor
  77. this.containerVisible = true
  78. }, 20)
  79. },
  80. hide() {
  81. this.maskBgColor = ''
  82. this.containerVisible = false
  83. setTimeout(() => {
  84. this.visible = false
  85. }, 200)
  86. this.$emit('close')
  87. },
  88. handleCancel() {
  89. this.hide()
  90. },
  91. handleConfirm() {
  92. this.hide()
  93. this.$emit('confirm')
  94. },
  95. handleMaskTap() {
  96. if (this.maskTapHide) {
  97. this.hide()
  98. }
  99. },
  100. moveHandle() {},
  101. }
  102. }
  103. </script>
  104. <style scoped lang="scss">
  105. .pop-view {
  106. position: relative;
  107. .pop-maskView {
  108. position: fixed;
  109. top: 0;
  110. right: 0;
  111. left: 0;
  112. bottom: 0;
  113. transition-property: background-color;
  114. transition-duration: 0.3s;
  115. }
  116. .pop-contentView {
  117. position: fixed;
  118. right: 0;
  119. left: 0;
  120. bottom: 0;
  121. overflow-y: scroll;
  122. background-color: #fff;
  123. border-radius: 40rpx 40rpx 0rpx 0rpx;
  124. box-shadow: 0rpx 8rpx 12rpx 0rpx;
  125. display: flex;
  126. flex-direction: column;
  127. align-items: center;
  128. transform: translateY(100%);
  129. transition-property: transform;
  130. transition-duration: 0.3s;
  131. .pop-title {
  132. margin-top: 60rpx;
  133. font-size: 32rpx;
  134. font-family: Verdana, Verdana-Bold;
  135. font-weight: 700;
  136. text-align: center;
  137. color: #333333;
  138. }
  139. .pop-close {
  140. position: absolute;
  141. top: 64rpx;
  142. right: 30rpx;
  143. width: 40rpx;
  144. height: 40rpx;
  145. }
  146. .pop-commit {
  147. margin-bottom: 54rpx;
  148. width: 260rpx;
  149. height: 84rpx;
  150. line-height: 84rpx;
  151. border-radius: 42rpx;
  152. font-size: 32rpx;
  153. font-family: Verdana, Verdana-Regular;
  154. font-weight: 400;
  155. text-align: center;
  156. color: #ffffff;
  157. }
  158. }
  159. .pop-contentView-show {
  160. transform: translateY(0);
  161. }
  162. }
  163. </style>