app-select.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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" :indicator-style="indicatorStyle" :style="{'height': height}" @change="change">
  11. <picker-view-column style="text-align: center;">
  12. <view v-if="list" :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. props: {
  23. list: {
  24. type: Array,
  25. default: function() {
  26. return [];
  27. }
  28. },
  29. isShow: {
  30. type: Boolean,
  31. default: false,
  32. },
  33. title: {
  34. type: String,
  35. default: ''
  36. },
  37. height: {
  38. type: String,
  39. default: '440rpx',
  40. },
  41. index: {
  42. type: Number,
  43. default: 0
  44. }
  45. },
  46. watch: {
  47. isShow(newVal, oldVal) {
  48. if (newVal) {
  49. this.newValue = this.index;
  50. }
  51. }
  52. },
  53. data() {
  54. return {
  55. newValue: 0,
  56. value: [0],
  57. indicatorStyle: `height: ${Math.round(uni.getSystemInfoSync().screenWidth/(750/88))}px;`
  58. }
  59. },
  60. methods: {
  61. confirm(type) {
  62. this.$emit('confirm', { index: this.newValue, is_modal_confirm: type === 'close' });
  63. },
  64. change(e) {
  65. this.newValue = e.detail.value[0];
  66. }
  67. }
  68. }
  69. </script>
  70. <style scoped lang="scss">
  71. .modal-box {
  72. position: fixed;
  73. top: 0;
  74. left: 0;
  75. width: 100%;
  76. height: 100%;
  77. background-color: rgba(0, 0, 0, 0.4);
  78. z-index: 9998;
  79. .modal-item {
  80. background: #ffffff;
  81. border-top-left-radius: 16#{rpx};
  82. border-top-right-radius: 16#{rpx};
  83. overflow: hidden;
  84. position: absolute;
  85. width: 100%;
  86. bottom: 0;
  87. z-index: 9999;
  88. .title-box {
  89. height: 100#{rpx};
  90. width: 100%;
  91. position: relative;
  92. display: flex;
  93. align-items: center;
  94. justify-content: center;
  95. border-bottom: 1#{rpx} solid #e2e2e2;
  96. .title {
  97. font-size: 32#{rpx};
  98. color: #353535;
  99. }
  100. .confirm {
  101. position: absolute;
  102. color: #ff4544;
  103. font-size: 32#{rpx};
  104. right: 24#{rpx}
  105. }
  106. }
  107. }
  108. .picker-box {
  109. padding: 48#{rpx} 0;
  110. .picker-item {
  111. border: 1#{rpx} solid red;
  112. }
  113. .line {
  114. line-height: 88rpx;
  115. font-size: 36#{rpx};
  116. color: #353535;
  117. }
  118. .line-2 {
  119. line-height: 88rpx;
  120. font-size: 32#{rpx};
  121. color: #353535;
  122. }
  123. }
  124. }
  125. </style>