123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- <template>
- <view class="section-wrapper">
- <view class="section-header">
- <view class="left">
- {{ title }}
- </view>
- <view
- v-if="options.length > 0"
- class="right">
- <wk-drop
- v-model="option"
- :list="options" />
- </view>
- </view>
- <slot />
- </view>
- </template>
- <script>
- export default {
- name: 'HomeSection',
- props: {
- title: {
- type: String,
- default: ''
- },
- options: {
- type: Array,
- default: () => []
- },
- defaultVal: {
- type: [String, Number],
- default: null
- }
- },
- data() {
- return {
- option: ''
- }
- },
- watch: {
- options: {
- handler(val) {
- if (val.length > 0) {
- this.option = val[0].value
- }
- },
- immediate: true,
- deep: true
- },
- option: {
- handler(val) {
- console.log('change---------')
- this.$emit('status', val)
- }
- }
- },
- mounted() {
- if (this.option) {
- this.$emit('status', this.option)
- }
- }
- }
- </script>
- <style scoped lang="scss">
- .section-wrapper {
- background-color: white;
- border-top: 1rpx solid #e5e5e5;
- border-bottom: 1rpx solid #e5e5e5;
- margin-top: 20rpx;
- margin-bottom: 20rpx;
- padding: 0 32rpx;
-
- .section-header {
- padding: 25rpx 0;
- border-bottom: 1rpx solid $border-color;
- @include left;
- .left {
- flex: 1;
- font-size: 28rpx;
- color: $dark;
- font-weight: 500;
- }
- .right {
- @include left;
- .select {
- height: 40rpx;
- margin-right: 60rpx;
- @include left;
- &:last-child {
- margin-right: 0;
- }
- &-label {
- font-size: 26rpx;
- color: $gray;
- margin-right: 20rpx;
- }
- &-icon {
- width: 20rpx;
- }
- }
- }
- }
- .section-body {
- padding: 40rpx 30rpx;
- }
- }
- </style>
|