dmPopScrollView.vue 3.6 KB

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