|
| 1 | +<template> |
| 2 | + <view class=""> |
| 3 | + <view class=""> |
| 4 | + <view class="u-demo-title">演示效果</view> |
| 5 | + |
| 6 | + <view class="u-demo-area u-flex u-row-center"> |
| 7 | + <u-dropdown ref="uDropdown"> |
| 8 | + <u-dropdown-item v-model="value1" title="距离" :options="options1"></u-dropdown-item> |
| 9 | + <u-dropdown-item v-model="value2" title="温度" :options="options2"></u-dropdown-item> |
| 10 | + <u-dropdown-item title="属性"> |
| 11 | + <view class="slot-content"> |
| 12 | + <view class="item-box"> |
| 13 | + <view class="item" :class="[item.active ? 'active' : '']" @tap="tagClick(index)" v-for="(item, index) in list" :key="index"> |
| 14 | + {{item.text}} |
| 15 | + </view> |
| 16 | + </view> |
| 17 | + <u-button type="primary" @click="closeDropdown">确定</u-button> |
| 18 | + </view> |
| 19 | + </u-dropdown-item> |
| 20 | + </u-dropdown> |
| 21 | + </view> |
| 22 | + </view> |
| 23 | + <view class="u-config-wrap"> |
| 24 | + <view class="u-config-title u-border-bottom"> |
| 25 | + 参数配置时 |
| 26 | + </view> |
| 27 | + <!-- <view class="u-config-item"> |
| 28 | + <view class="u-item-title">颜色</view> |
| 29 | + <u-subsection vibrateShort :list="['primary', 'success', 'warning', 'error', 'info']" @change="colorChange"></u-subsection> |
| 30 | + </view> |
| 31 | + <view class="u-config-item"> |
| 32 | + <view class="u-item-title">线条类型</view> |
| 33 | + <u-subsection vibrateShort :list="['实线', '方形虚线', '圆点虚线']" @change="borderStyleChange"></u-subsection> |
| 34 | + </view> |
| 35 | + <view class="u-config-item"> |
| 36 | + <view class="u-item-title">细边</view> |
| 37 | + <u-subsection vibrateShort :list="['是', '否']" @change="hairLineChange"></u-subsection> |
| 38 | + </view> |
| 39 | + <view class="u-config-item"> |
| 40 | + <view class="u-item-title">方向</view> |
| 41 | + <u-subsection vibrateShort :list="['水平', '垂直']" @change="directionChange"></u-subsection> |
| 42 | + </view> --> |
| 43 | + </view> |
| 44 | + </view> |
| 45 | +</template> |
| 46 | + |
| 47 | +<script> |
| 48 | + export default { |
| 49 | + data() { |
| 50 | + return { |
| 51 | + value1: '', |
| 52 | + value2: '2', |
| 53 | + value3: '', |
| 54 | + options1: [{ |
| 55 | + text: '默认排序', |
| 56 | + value: 1, |
| 57 | + icon: 'map' |
| 58 | + }, |
| 59 | + { |
| 60 | + text: '距离优先', |
| 61 | + value: 2, |
| 62 | + icon: 'map' |
| 63 | + }, |
| 64 | + { |
| 65 | + text: '价格优先', |
| 66 | + value: 3, |
| 67 | + icon: 'map' |
| 68 | + } |
| 69 | + ], |
| 70 | + options2: [{ |
| 71 | + text: '去冰', |
| 72 | + value: 1, |
| 73 | + icon: 'map' |
| 74 | + }, |
| 75 | + { |
| 76 | + text: '加冰', |
| 77 | + value: 2, |
| 78 | + icon: 'map' |
| 79 | + }, |
| 80 | + { |
| 81 | + text: '正常温', |
| 82 | + value: 3, |
| 83 | + icon: 'map' |
| 84 | + }, |
| 85 | + { |
| 86 | + text: '加热', |
| 87 | + value: 4, |
| 88 | + icon: 'map' |
| 89 | + }, |
| 90 | + { |
| 91 | + text: '极寒风暴', |
| 92 | + value: 5, |
| 93 | + icon: 'map' |
| 94 | + } |
| 95 | + ], |
| 96 | + list: [{ |
| 97 | + text: '琪花瑶草', |
| 98 | + active: true, |
| 99 | + }, |
| 100 | + { |
| 101 | + text: '清词丽句', |
| 102 | + active: false, |
| 103 | + }, |
| 104 | + { |
| 105 | + text: '宛转蛾眉', |
| 106 | + active: false, |
| 107 | + }, |
| 108 | + { |
| 109 | + text: '煦色韶光', |
| 110 | + active: false, |
| 111 | + }, |
| 112 | + { |
| 113 | + text: '鱼沉雁落', |
| 114 | + active: false, |
| 115 | + }, |
| 116 | + { |
| 117 | + text: '章台杨柳', |
| 118 | + active: false, |
| 119 | + }, |
| 120 | + { |
| 121 | + text: '霞光万道', |
| 122 | + active: false, |
| 123 | + } |
| 124 | + ], |
| 125 | + direction: 'row', |
| 126 | + hairLine: true, |
| 127 | + length: '100%', |
| 128 | + color: this.$u.color['primary'], |
| 129 | + borderStyle: 'solid' |
| 130 | + } |
| 131 | + }, |
| 132 | + methods: { |
| 133 | + colorChange(index) { |
| 134 | + this.color = this.$u.color[['primary', 'success', 'warning', 'error', 'info'][index]]; |
| 135 | + }, |
| 136 | + hairLineChange(index) { |
| 137 | + this.hairLine = !index; |
| 138 | + }, |
| 139 | + directionChange(index) { |
| 140 | + this.direction = index == 0 ? 'row' : 'col'; |
| 141 | + if (index == 0) this.length = '100%'; |
| 142 | + else this.length = '50rpx'; |
| 143 | + }, |
| 144 | + borderStyleChange(index) { |
| 145 | + this.borderStyle = ['solid', 'dashed', 'dotted'][index]; |
| 146 | + }, |
| 147 | + tagClick(index) { |
| 148 | + this.list[index].active = !this.list[index].active; |
| 149 | + }, |
| 150 | + closeDropdown() { |
| 151 | + this.$refs.uDropdown.close(); |
| 152 | + } |
| 153 | + } |
| 154 | + } |
| 155 | +</script> |
| 156 | + |
| 157 | +<style scoped lang="scss"> |
| 158 | + .u-config-wrap { |
| 159 | + padding: 40rpx; |
| 160 | + } |
| 161 | + |
| 162 | + .slot-content { |
| 163 | + background-color: #FFFFFF; |
| 164 | + padding: 24rpx; |
| 165 | + |
| 166 | + .item-box { |
| 167 | + margin-bottom: 50rpx; |
| 168 | + display: flex; |
| 169 | + flex-wrap: wrap; |
| 170 | + justify-content: space-between; |
| 171 | + |
| 172 | + .item { |
| 173 | + border: 1px solid $u-type-primary; |
| 174 | + color: $u-type-primary; |
| 175 | + padding: 8rpx 40rpx; |
| 176 | + border-radius: 100rpx; |
| 177 | + margin-top: 30rpx; |
| 178 | + } |
| 179 | + |
| 180 | + .active { |
| 181 | + color: #FFFFFF; |
| 182 | + background-color: $u-type-primary; |
| 183 | + } |
| 184 | + } |
| 185 | + } |
| 186 | +</style> |
0 commit comments