index.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. <template>
  2. <view class="">
  3. <view class="u-m-p-50">
  4. <view class="u-demo-area u-flex u-row-center">
  5. <u-dropdown :close-on-click-mask="mask" ref="uDropdown" :activeColor="activeColor" :borderBottom="borderBottom">
  6. <u-dropdown-item @change="change" v-model="value1" title="距离" :options="options1"></u-dropdown-item>
  7. <u-dropdown-item @change="change" v-model="value2" title="温度" :options="options2"></u-dropdown-item>
  8. <u-dropdown-item title="属性">
  9. <view class="slot-content">
  10. <view class="item-box">
  11. <view class="item" :class="[item.active ? 'active' : '']" @tap="tagClick(index)" v-for="(item, index) in list" :key="index">
  12. {{item.label}}
  13. </view>
  14. </view>
  15. <u-button type="primary" @click="closeDropdown">确定</u-button>
  16. </view>
  17. </u-dropdown-item>
  18. </u-dropdown>
  19. </view>
  20. </view>
  21. <view class="u-config-wrap">
  22. <view class="u-config-title u-border-bottom">
  23. 参数配置
  24. </view>
  25. <view class="u-config-item">
  26. <view class="u-item-title">下边框</view>
  27. <u-subsection current="1" :list="['有', '无']" @change="borderChange"></u-subsection>
  28. </view>
  29. <view class="u-config-item">
  30. <view class="u-item-title">激活颜色</view>
  31. <u-subsection :list="['#2979ff', '#ff9900', '#19be6b']" @change="activeColorChange"></u-subsection>
  32. </view>
  33. <view class="u-config-item">
  34. <view class="u-item-title">遮罩是否可点击</view>
  35. <u-subsection :list="['是', '否']" @change="maskChange"></u-subsection>
  36. </view>
  37. </view>
  38. </view>
  39. </template>
  40. <script>
  41. export default {
  42. data() {
  43. return {
  44. value1: '',
  45. value2: '2',
  46. mask: true,
  47. options1: [{
  48. label: '默认排序',
  49. value: 1,
  50. },
  51. {
  52. label: '距离优先',
  53. value: 2,
  54. },
  55. {
  56. label: '价格优先',
  57. value: 3,
  58. }
  59. ],
  60. options2: [{
  61. label: '去冰',
  62. value: 1,
  63. },
  64. {
  65. label: '加冰',
  66. value: 2,
  67. },
  68. {
  69. label: '正常温',
  70. value: 3,
  71. },
  72. {
  73. label: '加热',
  74. value: 4,
  75. },
  76. {
  77. label: '极寒风暴',
  78. value: 5,
  79. }
  80. ],
  81. list: [{
  82. label: '琪花瑶草',
  83. active: true,
  84. },
  85. {
  86. label: '清词丽句',
  87. active: false,
  88. },
  89. {
  90. label: '宛转蛾眉',
  91. active: false,
  92. },
  93. {
  94. label: '煦色韶光',
  95. active: false,
  96. },
  97. {
  98. label: '鱼沉雁落',
  99. active: false,
  100. },
  101. {
  102. label: '章台杨柳',
  103. active: false,
  104. },
  105. {
  106. label: '霞光万道',
  107. active: false,
  108. }
  109. ],
  110. borderBottom: false,
  111. activeColor: '#2979ff'
  112. }
  113. },
  114. methods: {
  115. borderChange(index) {
  116. this.borderBottom = !index;
  117. },
  118. activeColorChange(index) {
  119. this.activeColor = ['#2979ff', '#ff9900', '#19be6b'][index];
  120. },
  121. change(index) {
  122. this.$u.toast(`点击了第${index}项`);
  123. },
  124. closeDropdown() {
  125. this.$refs.uDropdown.close();
  126. },
  127. tagClick(index) {
  128. this.list[index].active = !this.list[index].active;
  129. },
  130. maskChange(index) {
  131. this.mask = !index;
  132. }
  133. }
  134. }
  135. </script>
  136. <style scoped lang="scss">
  137. .u-config-wrap {
  138. padding: 40rpx;
  139. }
  140. .slot-content {
  141. background-color: #FFFFFF;
  142. padding: 24rpx;
  143. .item-box {
  144. margin-bottom: 50rpx;
  145. display: flex;
  146. flex-wrap: wrap;
  147. justify-content: space-between;
  148. .item {
  149. border: 1px solid $u-type-primary;
  150. color: $u-type-primary;
  151. padding: 8rpx 40rpx;
  152. border-radius: 100rpx;
  153. margin-top: 30rpx;
  154. }
  155. .active {
  156. color: #FFFFFF;
  157. background-color: $u-type-primary;
  158. }
  159. }
  160. }
  161. </style>