homeSection.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <template>
  2. <view class="section-wrapper">
  3. <view class="section-header">
  4. <view class="left">
  5. {{ title }}
  6. </view>
  7. <view
  8. v-if="options.length > 0"
  9. class="right">
  10. <wk-drop
  11. v-model="option"
  12. :list="options" />
  13. </view>
  14. </view>
  15. <slot />
  16. </view>
  17. </template>
  18. <script>
  19. export default {
  20. name: 'HomeSection',
  21. props: {
  22. title: {
  23. type: String,
  24. default: ''
  25. },
  26. options: {
  27. type: Array,
  28. default: () => []
  29. },
  30. defaultVal: {
  31. type: [String, Number],
  32. default: null
  33. }
  34. },
  35. data() {
  36. return {
  37. option: ''
  38. }
  39. },
  40. watch: {
  41. options: {
  42. handler(val) {
  43. if (val.length > 0) {
  44. this.option = val[0].value
  45. }
  46. },
  47. immediate: true,
  48. deep: true
  49. },
  50. option: {
  51. handler(val) {
  52. console.log('change---------')
  53. this.$emit('status', val)
  54. }
  55. }
  56. },
  57. mounted() {
  58. if (this.option) {
  59. this.$emit('status', this.option)
  60. }
  61. }
  62. }
  63. </script>
  64. <style scoped lang="scss">
  65. .section-wrapper {
  66. background-color: white;
  67. border-top: 1rpx solid #e5e5e5;
  68. border-bottom: 1rpx solid #e5e5e5;
  69. margin-top: 20rpx;
  70. margin-bottom: 20rpx;
  71. padding: 0 32rpx;
  72. .section-header {
  73. padding: 25rpx 0;
  74. border-bottom: 1rpx solid $border-color;
  75. @include left;
  76. .left {
  77. flex: 1;
  78. font-size: 28rpx;
  79. color: $dark;
  80. font-weight: 500;
  81. }
  82. .right {
  83. @include left;
  84. .select {
  85. height: 40rpx;
  86. margin-right: 60rpx;
  87. @include left;
  88. &:last-child {
  89. margin-right: 0;
  90. }
  91. &-label {
  92. font-size: 26rpx;
  93. color: $gray;
  94. margin-right: 20rpx;
  95. }
  96. &-icon {
  97. width: 20rpx;
  98. }
  99. }
  100. }
  101. }
  102. .section-body {
  103. padding: 40rpx 30rpx;
  104. }
  105. }
  106. </style>