app-select.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <template>
  2. <!-- 弹框 -->
  3. <view class="modal-box" v-if="isShow" @click="confirm('close')">
  4. <view class="modal-item" @click.stop.prevent="">
  5. <view class="title-box">
  6. <view class="title">{{title}}</view>
  7. <view class="confirm" @click.stop="confirm('confirm')">确定</view>
  8. </view>
  9. <view class="picker-box">
  10. <picker-view indicator-class="picker-item" :value="value" :indicator-style="indicatorStyle" :style="{'height': height}" @change="change">
  11. <picker-view-column style="text-align: center;">
  12. <view :class="{'line': newValue == index, 'line-2': newValue != index}" v-for="(item, index) in list" :key="index">{{item}}</view>
  13. </picker-view-column>
  14. </picker-view>
  15. </view>
  16. </view>
  17. </view>
  18. </template>
  19. <script>
  20. export default {
  21. name: 'app-select',
  22. components: {},
  23. props: {
  24. list: {
  25. type: Array,
  26. default: function() {
  27. return [];
  28. }
  29. },
  30. isShow: {
  31. type: Boolean,
  32. default: false,
  33. },
  34. title: {
  35. type: String,
  36. default: ''
  37. },
  38. height: {
  39. type: String,
  40. default: '440rpx',
  41. }
  42. },
  43. data() {
  44. return {
  45. newValue: 0,
  46. value: 0,
  47. indicatorStyle: `height: ${Math.round(uni.getSystemInfoSync().screenWidth/(750/88))}px;`
  48. }
  49. },
  50. methods: {
  51. confirm(type) {
  52. this.$emit('confirm', { index: this.newValue, is_modal_confirm: type == 'close' ? true : false });
  53. },
  54. change(e) {
  55. this.newValue = e.detail.value[0];
  56. }
  57. }
  58. }
  59. </script>
  60. <style scoped lang="scss">
  61. .modal-box {
  62. position: fixed;
  63. top: 0;
  64. left: 0;
  65. width: 100%;
  66. height: 100%;
  67. background-color: rgba(0, 0, 0, 0.4);
  68. z-index: 9998;
  69. .modal-item {
  70. background: #ffffff;
  71. border-top-left-radius: 16#{rpx};
  72. border-top-right-radius: 16#{rpx};
  73. overflow: hidden;
  74. position: absolute;
  75. width: 100%;
  76. bottom: 0;
  77. z-index: 9999;
  78. .title-box {
  79. height: 100#{rpx};
  80. width: 100%;
  81. position: relative;
  82. display: flex;
  83. align-items: center;
  84. justify-content: center;
  85. border-bottom: 1#{rpx} solid #e2e2e2;
  86. .title {
  87. font-size: 32#{rpx};
  88. color: #353535;
  89. }
  90. .confirm {
  91. position: absolute;
  92. color: #ff4544;
  93. font-size: 32#{rpx};
  94. right: 24#{rpx}
  95. }
  96. }
  97. }
  98. .picker-box {
  99. padding: 48#{rpx} 0;
  100. .picker-item {
  101. border: 1#{rpx} solid red;
  102. }
  103. .line {
  104. line-height: 88rpx;
  105. font-size: 36#{rpx};
  106. color: #353535;
  107. }
  108. .line-2 {
  109. line-height: 88rpx;
  110. font-size: 32#{rpx};
  111. color: #353535;
  112. }
  113. }
  114. }
  115. </style>