index.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. <!--选择弹窗操作组件-->
  2. <template>
  3. <view>
  4. <!--START 选择弹窗-->
  5. <view class="cu-modal bottom-modal" :class="isShow ? 'show' : ''" @touchmove.stop.prevent @click="clickMast">
  6. <view class="cu-dialog items-popup" @click.stop="">
  7. <view class="title bold" v-if="title">{{title}}</view>
  8. <view class="items">
  9. <view class="border-bottom" v-for="(v,i) in list" :key="i" @click="confirm(i,v)">{{v.name}}</view>
  10. <view style="height: 100rpx;"></view>
  11. <view class="cancel text-red" @click="cancel">取消</view>
  12. </view>
  13. </view>
  14. </view>
  15. <!--END 选择弹窗-->
  16. </view>
  17. </template>
  18. <script>
  19. /*
  20. <hs-picker ref="picker" @onCancel="$refs['picker'].hide()" @onConfirm="confirm" />
  21. this.$refs['picker'].show();
  22. */
  23. export default {
  24. name: "lin-picker",
  25. props: {
  26. //标题
  27. title: {
  28. type: String,
  29. default: ''
  30. },
  31. // 选项数据
  32. list: {
  33. type: Array,
  34. default: () => {
  35. return [];
  36. }
  37. },
  38. //是否点击遮罩层关闭
  39. maskClosable: {
  40. type: Boolean,
  41. default: true
  42. }
  43. },
  44. data() {
  45. return {
  46. isShow: false
  47. };
  48. },
  49. methods: {
  50. cancel() {
  51. this.$emit('onCancel');
  52. this.isShow = false;
  53. },
  54. confirm(index, item) {
  55. this.$emit('onConfirm', index, item);
  56. this.isShow = false;
  57. },
  58. show() {
  59. this.isShow = true;
  60. },
  61. hide() {
  62. this.isShow = false;
  63. },
  64. clickMast() {
  65. if (!this.maskClosable) return false;
  66. this.isShow = false;
  67. }
  68. }
  69. }
  70. </script>
  71. <style lang="scss">
  72. .cu-modal {
  73. position: fixed;
  74. top: 0;
  75. right: 0;
  76. bottom: 0;
  77. left: 0;
  78. z-index: 1600;
  79. opacity: 0;
  80. outline: 0;
  81. text-align: center;
  82. -ms-transform: scale(1.185);
  83. transform: scale(1.185);
  84. backface-visibility: hidden;
  85. perspective: 2000upx;
  86. background: rgba(0, 0, 0, 0.6);
  87. transition: all 0.3s ease-in-out 0s;
  88. pointer-events: none;
  89. &::before {
  90. content: "\200B";
  91. display: inline-block;
  92. height: 100%;
  93. vertical-align: middle;
  94. }
  95. &.show {
  96. opacity: 1;
  97. transition-duration: 0.3s;
  98. -ms-transform: scale(1);
  99. transform: scale(1);
  100. overflow-x: hidden;
  101. overflow-y: auto;
  102. pointer-events: auto;
  103. }
  104. &.bottom-modal::before {
  105. vertical-align: bottom;
  106. }
  107. &.bottom-modal .cu-dialog {
  108. width: 100%;
  109. border-radius: 0;
  110. }
  111. &.bottom-modal {
  112. margin-bottom: -1000upx;
  113. }
  114. &.bottom-modal.show {
  115. margin-bottom: 0;
  116. }
  117. .cu-dialog {
  118. position: relative;
  119. display: inline-block;
  120. vertical-align: middle;
  121. margin-left: auto;
  122. margin-right: auto;
  123. width: 80%;
  124. box-sizing: border-box;
  125. background-color: #fff;
  126. border-radius: 12rpx;
  127. overflow: hidden;
  128. }
  129. }
  130. .items-popup {
  131. padding: 30rpx 0;
  132. border-radius: 30rpx 30rpx 0 0 !important;
  133. .title {
  134. font-size: 32rpx;
  135. margin-bottom: 20rpx;
  136. }
  137. .items {
  138. max-height: 600rpx;
  139. overflow: auto;
  140. line-height: 90rpx;
  141. position: relative;
  142. &::-webkit-scrollbar {
  143. display: none;
  144. }
  145. view {
  146. &:last-child {
  147. border: none;
  148. }
  149. &.cancel {
  150. width: 100%;
  151. height: 90rpx;
  152. background: #fff;
  153. text-align: center;
  154. position: fixed;
  155. bottom: 20rpx;
  156. left: 0;
  157. border-top: 10rpx solid #F5F6FA;
  158. }
  159. }
  160. }
  161. }
  162. .border-bottom:hover {
  163. background-color: #f9f9f9;
  164. }
  165. </style>