rightSlider.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. <template>
  2. <view class="right-wrapper" @touchmove.stop.prevent="moveStop">
  3. <view class="control-wrapper animated" :class="showBox?'slideInRight':''">
  4. <view class="header">
  5. <view class="title">价格区间</view>
  6. <view class="input-wrapper">
  7. <input placeholder="最低价" v-model="min" type="number"/>
  8. <view class="line"></view>
  9. <input placeholder="最高价" v-model="max" type="number"/>
  10. </view>
  11. </view>
  12. <view class="content-box">
  13. <view class="title">品牌</view>
  14. <view class="brand-wrapper">
  15. <scroll-view :style="{'height':isShow?'90%':'250rpx'}" :scroll-y="isShow">
  16. <view class="wrapper">
  17. <view class="item line1" v-for="(item,index) in list" :key="index" :class="item.check?'on':''" @tap="bindChenck(item)">
  18. {{item.brand_name}}
  19. </view>
  20. </view>
  21. </scroll-view>
  22. <view class="btns" v-if="!isShow && list.length>9" @click="isShow = true">展开全部<text class="iconfont icon-xiangxia"></text></view>
  23. <view class="btns" v-if="isShow && list.length>9" @click="isShow = false">收起<text class="iconfont icon-xiangshang"></text></view>
  24. </view>
  25. <view class="foot-btn">
  26. <view class="btn-item" @click="reset">重置</view>
  27. <view class="btn-item confirm" @click="confirm">确定</view>
  28. </view>
  29. </view>
  30. </view>
  31. <view class="right-bg" @click="close"></view>
  32. </view>
  33. </template>
  34. <script>
  35. export default{
  36. props: {
  37. brandList: {
  38. type: Array,
  39. },
  40. status:{
  41. type:Boolean,
  42. default:false
  43. },
  44. price_on:{
  45. type:String,
  46. default:''
  47. },
  48. price_off:{
  49. type:String,
  50. default:''
  51. }
  52. },
  53. data(){
  54. return {
  55. min: '',
  56. max:'',
  57. isShow:false,
  58. list:[],
  59. activeList:[],
  60. showBox:false
  61. }
  62. },
  63. mounted() {
  64. // 重要组件挂载后
  65. this.list = this.brandList
  66. this.showBox = this.status
  67. this.min = this.price_on
  68. this.max = this.price_off
  69. },
  70. methods:{
  71. bindChenck(item){
  72. item.check = !item.check
  73. this.arrFilter()
  74. },
  75. arrFilter(){
  76. this.activeList = this.list.filter(item=>{
  77. return item.check == true
  78. })
  79. },
  80. reset(){
  81. this.list.forEach((el,index)=>{
  82. el.check = false
  83. })
  84. this.min = this.max = ''
  85. this.arrFilter()
  86. },
  87. confirm(){
  88. this.arrFilter()
  89. console.log(this.activeList)
  90. let obj = {
  91. brandList:this.activeList,
  92. price_on:this.min,
  93. price_off:this.max,
  94. status:false
  95. }
  96. this.showBox = false
  97. this.$emit('confirm',obj)
  98. },
  99. close(){
  100. // this.list.forEach((el,index)=>{
  101. // el.check = false
  102. // })
  103. // this.arrFilter()
  104. this.showBox = false
  105. this.$emit('close')
  106. },
  107. moveStop(){}
  108. }
  109. }
  110. </script>
  111. <style lang="scss">
  112. .slideInRight{
  113. animation-duration:.5s
  114. }
  115. .right-wrapper{
  116. z-index: 99;
  117. position: fixed;
  118. left: 0;
  119. top: 0;
  120. width: 100%;
  121. height: 100%;
  122. .control-wrapper{
  123. z-index: 90;
  124. position: absolute;
  125. right: 0;
  126. top: 0;
  127. display: flex;
  128. flex-direction: column;
  129. width: 635rpx;
  130. height: 100%;
  131. background-color: #F5F5F5;
  132. .header{
  133. padding: 50rpx 26rpx 40rpx;
  134. background-color: #fff;
  135. .title{
  136. font-size: 26rpx;
  137. font-weight: bold;
  138. color: #282828;
  139. }
  140. .input-wrapper{
  141. display: flex;
  142. align-items: center;
  143. justify-content: space-between;
  144. margin-top: 28rpx;
  145. input{
  146. width:260rpx;
  147. height:56rpx;
  148. padding: 0 10rpx;
  149. background:rgba(242,242,242,1);
  150. border-radius:28rpx;
  151. font-size: 22rpx;
  152. text-align: center;
  153. }
  154. .line{
  155. width:15rpx;
  156. height:2rpx;
  157. background:#7D7D7D;
  158. }
  159. }
  160. }
  161. .content-box{
  162. position: relative;
  163. flex: 1;
  164. display: flex;
  165. flex-direction: column;
  166. margin-top: 20rpx;
  167. padding: 0 26rpx;
  168. background-color: #fff;
  169. overflow: hidden;
  170. .title{
  171. padding: 40rpx 0 20rpx;
  172. font-size: 26rpx;
  173. font-weight: bold;
  174. color: #282828;
  175. }
  176. .brand-wrapper{
  177. flex: 1;
  178. overflow: hidden;
  179. .wrapper{
  180. display: flex;
  181. flex-wrap: wrap;
  182. padding-bottom: 20rpx;
  183. }
  184. .item{
  185. display: block;
  186. width:186rpx;
  187. height:56rpx;
  188. line-height: 56rpx;
  189. text-align: center;
  190. background:rgba(242,242,242,1);
  191. border-radius:28rpx;
  192. margin-top: 25rpx;
  193. padding: 0 10rpx;
  194. margin-right: 12rpx;
  195. &:nth-child(3n){
  196. margin-right: 0;
  197. }
  198. &.on{
  199. background:rgba(255,244,243,1);
  200. border:1px solid rgba(233,51,35,1);
  201. color: rgba(233,51,35,1);
  202. }
  203. }
  204. .btns{
  205. display: flex;
  206. align-items: center;
  207. justify-content: center;
  208. padding-top: 10rpx;
  209. font-size: 22rpx;
  210. color: #999;
  211. .iconfont{
  212. margin-left: 10rpx;
  213. margin-top: 5rpx;
  214. font-size: 20rpx;
  215. }
  216. }
  217. }
  218. .foot-btn{
  219. display: flex;
  220. align-items: center;
  221. justify-content: space-between;
  222. padding-bottom: 30rpx;
  223. .btn-item{
  224. display: flex;
  225. align-items: center;
  226. justify-content: center;
  227. width:286rpx;
  228. height:68rpx;
  229. background:rgba(255,255,255,1);
  230. border:1px solid rgba(170,170,170,1);
  231. border-radius:34rpx;
  232. font-size: 26rpx;
  233. color: #282828;
  234. &.confirm{
  235. background: $theme-color;
  236. border-color: $theme-color;
  237. color: #fff;
  238. }
  239. }
  240. }
  241. }
  242. }
  243. .right-bg{
  244. position: absolute;
  245. left: 0;
  246. top: 0;
  247. width: 100%;
  248. height: 100%;
  249. background-color: rgba(0,0,0,.5);
  250. }
  251. }
  252. </style>