en-select.vue 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <template>
  2. <view class="select">
  3. <view class="title p-30 row-justify-sb">
  4. <view class="icon"></view>
  5. <text class="size-30 sys-weight-600">{{title}}</text>
  6. <view class="icon">
  7. <uni-icons :animation="animationData" class="dropdown-icon" type="closeempty" size="16"
  8. color="#666"></uni-icons>
  9. </view>
  10. </view>
  11. <view class="select">
  12. <scroll-view scroll-y="true" class="scroll-Y select">
  13. <view id="demo1" class="scroll-view-item" :class="item.id === current?'':'active'"
  14. v-for="(item,index) in localData" @click="onSelect(index)">
  15. <text class="size-28">{{item[itemText]}}</text>
  16. </view>
  17. </scroll-view>
  18. </view>
  19. <EnButton :is_fixed="false"></EnButton>
  20. </view>
  21. </template>
  22. <script>
  23. import EnButton from "@/components/en-utils/en-button/en-button.vue";
  24. export default {
  25. name: 'peak_chart',
  26. props: {
  27. title: {
  28. type: String,
  29. default: '选择'
  30. },
  31. localData: {
  32. default: []
  33. },
  34. itemKey: {
  35. type: String,
  36. default: 'id'
  37. },
  38. itemText: {
  39. type: String,
  40. default: 'name'
  41. },
  42. value: {
  43. default: ''
  44. }
  45. },
  46. components: {
  47. EnButton
  48. },
  49. data() {
  50. return {
  51. current: 3,
  52. };
  53. },
  54. watch: {
  55. 'value': function() {
  56. if (this.current !== this.value) {
  57. this.current = this.value
  58. }
  59. }
  60. },
  61. methods: {
  62. onSelect(index) {
  63. this.$emit('onChange', index)
  64. this.$emit('input', this.localData[index][this.itemKey])
  65. }
  66. }
  67. }
  68. </script>
  69. <style lang="scss">
  70. .select {
  71. height: 800rpx;
  72. }
  73. .icon {
  74. width: 40rpx;
  75. text-align: right;
  76. }
  77. .scroll-view-item {
  78. height: 90rpx;
  79. line-height: 90rpx;
  80. text-align: center;
  81. background: rgba(15, 177, 96, 0.1);
  82. border-radius: 10rpx;
  83. color: #0FB160;
  84. border: 1rpx solid #0FB160;
  85. margin: 16rpx 30rpx;
  86. }
  87. .active {
  88. border: none;
  89. color: #333333;
  90. background: #F7F9FE;
  91. }
  92. </style>