index.vue 3.3 KB

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