Authored by 李奇

推荐相关修改

@@ -253,7 +253,6 @@ const component = { @@ -253,7 +253,6 @@ const component = {
253 }; 253 };
254 254
255 model.mightLike(params).then(result => { 255 model.mightLike(params).then(result => {
256 - console.log(result.data.product_list);  
257 if (result && result.code === 200) { 256 if (result && result.code === 200) {
258 res.json({ 257 res.json({
259 code: 200, 258 code: 200,
1 <template> 1 <template>
2 <div class="top-filter clearfix"> 2 <div class="top-filter clearfix">
3 <ul class="filter-type"> 3 <ul class="filter-type">
4 - <li class="type-item" @click="toggleRec">推荐<i class="icon" :class="recClass"></i></li> 4 + <li class="type-item" @click="toggleRec">{{activeSort.text}}<i class="icon" :class="recClass"></i></li>
5 <li class="type-item" @click="toggleFilter">筛选<i class="icon" :class="filterClass"></i></li> 5 <li class="type-item" @click="toggleFilter">筛选<i class="icon" :class="filterClass"></i></li>
6 </ul> 6 </ul>
7 <div class="recommend-detail" v-show="!recDown"> 7 <div class="recommend-detail" v-show="!recDown">
8 <ul class="rec-items"> 8 <ul class="rec-items">
9 - <li class="item active">推荐</li>  
10 - <li class="item">新品</li>  
11 - <li class="item">价格从高到低</li>  
12 - <li class="item">价格从低到高</li> 9 + <li v-for="item in recItems" class="item"
  10 + :class="{active: activeSort.text === item.text}" @click="sortChange(item)">{{item.text}}</li>
13 </ul> 11 </ul>
14 </div> 12 </div>
15 <div class="recommend-detail" v-show="!filterDown"> 13 <div class="recommend-detail" v-show="!filterDown">
@@ -30,12 +28,27 @@ module.exports = { @@ -30,12 +28,27 @@ module.exports = {
30 data(){ 28 data(){
31 return { 29 return {
32 recDown: true, 30 recDown: true,
33 - filterDown: true 31 + filterDown: true,
  32 + recItems: [
  33 + {
  34 + text: '推荐',
  35 + val: ''
  36 + }, {
  37 + text: '新品',
  38 + val: 's_t_desc'
  39 + }, {
  40 + text: '价格从高到低',
  41 + val: 's_p_desc'
  42 + }, {
  43 + text: '价格从低到高',
  44 + val: 's_p_asc'
  45 + }
  46 + ],
  47 + activeSort: {
  48 + text: '推荐',
  49 + order: ''
  50 + }
34 } 51 }
35 - },  
36 - components: {  
37 - simple,  
38 - updown  
39 }, 52 },
40 computed: { 53 computed: {
41 recClass(){ 54 recClass(){
@@ -62,16 +75,26 @@ module.exports = { @@ -62,16 +75,26 @@ module.exports = {
62 toggleFilter(){ 75 toggleFilter(){
63 this.recDown = true; 76 this.recDown = true;
64 this.filterDown = !this.filterDown; 77 this.filterDown = !this.filterDown;
65 - }  
66 }, 78 },
67 - watch: {  
68 - val: function(newVal) { 79 + sortChange(item) {
  80 + const text = this.activeSort.text;
  81 +
  82 + if (item.text === text) {
  83 + this.recDown = true;
  84 + return;
  85 + }
  86 +
  87 + this.activeSort = item;
69 bus.$emit('order.change', { 88 bus.$emit('order.change', {
70 - val: newVal, 89 + val: item.val,
71 ref: this._uid 90 ref: this._uid
72 }); 91 });
  92 + this.recDown = true;
73 } 93 }
74 - } 94 + },
  95 + watch: {
  96 + },
  97 + components: {}
75 }; 98 };
76 </script> 99 </script>
77 <style> 100 <style>