me.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. <template>
  2. <view class="content">
  3. <view class="text-area">
  4. <text class="title">{{title}}</text>
  5. </view>
  6. <u-dropdown ref="uDropdown" @open="open" @close="close">
  7. <u-dropdown-item v-model="value1" title="距离" :options="options1"></u-dropdown-item>
  8. <u-dropdown-item v-model="value2" title="温度" :options="options2"></u-dropdown-item>
  9. <u-dropdown-item title="属性">
  10. <view class="slot-content" style="background-color: #FFFFFF;">
  11. <!-- <u-checkbox-group>
  12. <u-checkbox class="item.checked?'checkboxbox':''" v-model="item.checked" v-for="(item, index) in list" :key="index"
  13. :name="item.name">{{item.name}}</u-checkbox>
  14. </u-checkbox-group> -->
  15. <!-- <uni-view class="item-box">
  16. <uni-view class="item">琪花瑶草</uni-view>
  17. <uni-view class="item">琪花瑶草</uni-view>
  18. <uni-view class="item">琪花瑶草</uni-view>
  19. <uni-view class="item">琪花瑶草</uni-view>
  20. <uni-view class="item">琪花瑶草</uni-view>
  21. <uni-view class="item">琪花瑶草</uni-view>
  22. <uni-view class="item">琪花瑶草</uni-view>
  23. </uni-view> -->
  24. <view class="item-box">
  25. <view class="item" :class="{'active': rSelect.indexOf(index)!=-1}" v-for="(value,index) in infoArr" :key="index"
  26. @tap="tapInfo(index,value)">
  27. {{value.name}}
  28. </view>
  29. </view>
  30. <u-button type="primary" @click="closeDropdown">确定</u-button>
  31. </view>
  32. </u-dropdown-item>
  33. </u-dropdown>
  34. </view>
  35. </template>
  36. <script>
  37. // import uActionSheet from "../../uview-ui/components/u-action-sheet/u-action-sheet.vue";
  38. // import uSelection from '../../uview-ui/components/u-select/u-select.vue';
  39. export default {
  40. data() {
  41. return {
  42. title: 'Hello',
  43. list: [{
  44. text: '点赞',
  45. color: 'blue',
  46. fontSize: 28,
  47. name: '点赞'
  48. }, {
  49. text: '分享',
  50. name: '分享'
  51. }, {
  52. text: '评论',
  53. name: '评论'
  54. }],
  55. // show: true
  56. lists: [
  57. '寒雨连江夜入吴',
  58. '平明送客楚山孤',
  59. '洛阳亲友如相问',
  60. '一片冰心在玉壶'
  61. ],
  62. value1: 1,
  63. value2: 2,
  64. options1: [{
  65. label: '默认排序',
  66. value: 1,
  67. },
  68. {
  69. label: '距离优先',
  70. value: 2,
  71. },
  72. {
  73. label: '价格优先',
  74. value: 3,
  75. }
  76. ],
  77. options2: [{
  78. label: '去冰',
  79. value: 1,
  80. },
  81. {
  82. label: '加冰',
  83. value: 2,
  84. },
  85. ],
  86. infoArr: [{
  87. name: "直播",
  88. id: '12',
  89. }, {
  90. name: "视频",
  91. id: '13',
  92. }, {
  93. name: "手游",
  94. id: '14',
  95. }],
  96. rSelect: [],
  97. }
  98. },
  99. onLoad() {
  100. },
  101. methods: {
  102. goPricate() {
  103. console.log("aa")
  104. uni.navigateTo({
  105. url: '/pages/pricate/pricate'
  106. })
  107. },
  108. open(index) {
  109. // 展开某个下来菜单时,先关闭原来的其他菜单的高亮
  110. // 同时内部会自动给当前展开项进行高亮
  111. this.$refs.uDropdown.highlight();
  112. },
  113. closeDropdown() {
  114. console.log(this.rSelect)
  115. let arr = [];
  116. this.infoArr.forEach((item,index) => {
  117. this.rSelect.forEach(items => {
  118. if(index == items){
  119. arr.push(item.id)
  120. }
  121. })
  122. })
  123. console.log(arr ,"删除的锕")
  124. this.$refs.uDropdown.close();
  125. },
  126. close(index) {
  127. // 关闭的时候,给当前项加上高亮
  128. // 当然,您也可以通过监听dropdown-item的@change事件进行处理
  129. this.$refs.uDropdown.highlight(index);
  130. },
  131. tapInfo(e) {
  132. console.log(this.rSelect) //是数组,数组也有indexOf
  133. if (this.rSelect.indexOf(e) == -1) {
  134. console.log(e) //打印下标
  135. this.rSelect.push(e); //选中添加到数组里
  136. } else {
  137. this.rSelect.splice(this.rSelect.indexOf(e), 1); //取消
  138. }
  139. },
  140. }
  141. }
  142. </script>
  143. <style scoped>
  144. .item {
  145. border: 1px solid #2979ff;
  146. color: #2979ff;
  147. padding: 3px 15px;
  148. -webkit-border-radius: 38px;
  149. border-radius: 38px;
  150. margin-top: 11px;
  151. }
  152. .item-box {
  153. margin-bottom: 19px;
  154. display: flex;
  155. flex-wrap: wrap;
  156. -webkit-box-pack: justify;
  157. justify-content: space-around;
  158. }
  159. .slot-content {
  160. padding: 9px;
  161. }
  162. .active {
  163. color: #fff;
  164. background-color: #2979ff;
  165. }
  166. /deep/.u-checkbox__icon-wrap {
  167. display: none;
  168. }
  169. .checkboxbox {
  170. background: #EB3F33;
  171. color: white;
  172. }
  173. .active {
  174. color: white;
  175. border: 1px solid #2979ff;
  176. background-color: #2979ff;
  177. }
  178. </style>