dmDialog.vue 3.1 KB

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