综合、销量、价格对商品进行排序

1、orderField,order为传给后台的参数2个参数进行综合、销量、价格对商品进行排序综合、销量、价格对商品进行排序_第1张图片
2、2.1:html


    
综合
销量
价格

2.2定义变量

 sort: '',
        synthesize: '', // 综合
        sales: '',    // 销量
        priceing: '',   // 价钱
        selectIndex: 0,
        orderField: '', // 销售、价格排序
        order: '', // 升序降序

2.3js

selectedFn(e) {
        let target = e.target
        this.selectIndex = target.getAttribute('data-index')
        if (this.selectIndex === '1' && this.sort !== 'top') {
          this.orderField = 'salesVolume_i'
          this.order = 'asc'
          this.sort = 'top'
        } else if (this.selectIndex === '1' && this.sort !== 'bottom') {
          this.orderField = 'salesVolume_i'
          this.order = 'desc'
          this.sort = 'bottom'
        } else if (this.selectIndex === '2' && this.sort !== 'top2') {
          this.orderField = 'price'
          this.order = 'asc'
          this.sort = 'top2'
        } else if (this.selectIndex === '2' && this.sort !== 'bottom2') {
          this.orderField = 'price'
          this.order = 'desc'
          this.sort = 'bottom2'
        } else if (this.selectIndex === '0') {
          this.orderField = ''
          this.order = ''
          this.sort = ''
        }
        this.getList()
      }

你可能感兴趣的:(js)