Showing
3 changed files
with
59 additions
and
41 deletions
@@ -3,7 +3,7 @@ | @@ -3,7 +3,7 @@ | ||
3 | <cheader :title="sortName" class="list-header"> | 3 | <cheader :title="sortName" class="list-header"> |
4 | <i class="icon icon-filter" slot="right" @click="openFilter"></i> | 4 | <i class="icon icon-filter" slot="right" @click="openFilter"></i> |
5 | </cheader> | 5 | </cheader> |
6 | - <order :config="orderConfig" :val="order" V-if="!empty"></order> | 6 | + <order :config="orderConfig" :val="order" v-if="enableOrder"></order> |
7 | <List :data="productList" :empty="empty"></List> | 7 | <List :data="productList" :empty="empty"></List> |
8 | <Filter :config="filterConfig" v-ref:filter></Filter> | 8 | <Filter :config="filterConfig" v-ref:filter></Filter> |
9 | </div> | 9 | </div> |
@@ -46,7 +46,8 @@ | @@ -46,7 +46,8 @@ | ||
46 | productList: [], | 46 | productList: [], |
47 | 47 | ||
48 | // state | 48 | // state |
49 | - inSearching: false // 请求中 | 49 | + inSearching: false, // 请求中 |
50 | + enableOrder: false | ||
50 | }; | 51 | }; |
51 | }, | 52 | }, |
52 | computed: { | 53 | computed: { |
@@ -75,7 +76,7 @@ | @@ -75,7 +76,7 @@ | ||
75 | } | 76 | } |
76 | 77 | ||
77 | this.inSearching = true; | 78 | this.inSearching = true; |
78 | - $.get(this.url, Object.assign({ | 79 | + return $.get(this.url, Object.assign({ |
79 | order: this.order, | 80 | order: this.order, |
80 | page: nextPage | 81 | page: nextPage |
81 | }, this.filter, locationQuery)) | 82 | }, this.filter, locationQuery)) |
@@ -152,7 +153,12 @@ | @@ -152,7 +153,12 @@ | ||
152 | self.$refs.filter.isVisible = false; | 153 | self.$refs.filter.isVisible = false; |
153 | }); | 154 | }); |
154 | 155 | ||
155 | - this.search(); | 156 | + this.search() |
157 | + .then(()=>{ | ||
158 | + if (self.productList.length) { | ||
159 | + self.enableOrder = true; | ||
160 | + } | ||
161 | + }); | ||
156 | } | 162 | } |
157 | }; | 163 | }; |
158 | 164 |
@@ -3,7 +3,7 @@ | @@ -3,7 +3,7 @@ | ||
3 | <cheader title="新品抢先看"> | 3 | <cheader title="新品抢先看"> |
4 | <i class="icon icon-filter" slot="right" @click="openFilter"></i> | 4 | <i class="icon icon-filter" slot="right" @click="openFilter"></i> |
5 | </cheader> | 5 | </cheader> |
6 | - <order :config="orderConfig" :val="order" v-if="!empty"></order> | 6 | + <order :config="orderConfig" :val="order" v-if="enableOrder"></order> |
7 | <List :data="productList" :empty="empty"></List> | 7 | <List :data="productList" :empty="empty"></List> |
8 | <Filter :config="filterConfig" action="/product/list.json" v-ref:filter></Filter> | 8 | <Filter :config="filterConfig" action="/product/list.json" v-ref:filter></Filter> |
9 | </div> | 9 | </div> |
@@ -46,7 +46,8 @@ | @@ -46,7 +46,8 @@ | ||
46 | productList: [], | 46 | productList: [], |
47 | 47 | ||
48 | // state | 48 | // state |
49 | - inSearching: false // 请求中 | 49 | + inSearching: false, // 请求中 |
50 | + enableOrder: false | ||
50 | }; | 51 | }; |
51 | }, | 52 | }, |
52 | computed: { | 53 | computed: { |
@@ -76,27 +77,27 @@ | @@ -76,27 +77,27 @@ | ||
76 | } | 77 | } |
77 | 78 | ||
78 | this.inSearching = true; | 79 | this.inSearching = true; |
79 | - $.get(this.url, Object.assign({ | 80 | + return $.get(this.url, Object.assign({ |
80 | order: this.order, | 81 | order: this.order, |
81 | page: nextPage | 82 | page: nextPage |
82 | }, this.filter, locationQuery)) | 83 | }, this.filter, locationQuery)) |
83 | - .done(res => { | ||
84 | - if (res.code === 200) { | ||
85 | - self.page = res.data.page; | ||
86 | - self.totalPage = res.data.pageTotal; | ||
87 | - self.$set('productList', self.productList.concat(res.data.productList)); | ||
88 | - | ||
89 | - if (!self.filterConfig) { | ||
90 | - self.$set('filterConfig', res.data.filter); | 84 | + .done(res => { |
85 | + if (res.code === 200) { | ||
86 | + self.page = res.data.page; | ||
87 | + self.totalPage = res.data.pageTotal; | ||
88 | + self.$set('productList', self.productList.concat(res.data.productList)); | ||
89 | + | ||
90 | + if (!self.filterConfig) { | ||
91 | + self.$set('filterConfig', res.data.filter); | ||
92 | + } | ||
91 | } | 93 | } |
92 | - } | ||
93 | - }) | ||
94 | - .fail(error => { | ||
95 | - tip('网络出错~'); | ||
96 | - }) | ||
97 | - .always(() => { | ||
98 | - self.inSearching = false; | ||
99 | - }); | 94 | + }) |
95 | + .fail(error => { | ||
96 | + tip('网络出错~'); | ||
97 | + }) | ||
98 | + .always(() => { | ||
99 | + self.inSearching = false; | ||
100 | + }); | ||
100 | }, | 101 | }, |
101 | 102 | ||
102 | openFilter() { | 103 | openFilter() { |
@@ -157,7 +158,12 @@ | @@ -157,7 +158,12 @@ | ||
157 | self.$refs.filter.isVisible = false; | 158 | self.$refs.filter.isVisible = false; |
158 | }); | 159 | }); |
159 | 160 | ||
160 | - this.search(); | 161 | + this.search() |
162 | + .then(()=>{ | ||
163 | + if (self.productList.length) { | ||
164 | + self.enableOrder = true; | ||
165 | + } | ||
166 | + }); | ||
161 | } | 167 | } |
162 | }; | 168 | }; |
163 | 169 |
1 | <template> | 1 | <template> |
2 | <div> | 2 | <div> |
3 | - <Order :config="orderConfig" :val="order" v-if="!empty"> | 3 | + <Order :config="orderConfig" :val="order" v-if="enableOrder"> |
4 | </Order> | 4 | </Order> |
5 | <List :data="productList" :empty="empty"></List> | 5 | <List :data="productList" :empty="empty"></List> |
6 | </div> | 6 | </div> |
@@ -40,7 +40,8 @@ | @@ -40,7 +40,8 @@ | ||
40 | productList: [], | 40 | productList: [], |
41 | 41 | ||
42 | // state | 42 | // state |
43 | - inSearching: false // 请求中 | 43 | + inSearching: false, // 请求中 |
44 | + enableOrder: false | ||
44 | }; | 45 | }; |
45 | }, | 46 | }, |
46 | computed: { | 47 | computed: { |
@@ -69,24 +70,24 @@ | @@ -69,24 +70,24 @@ | ||
69 | 70 | ||
70 | this.inSearching = true; | 71 | this.inSearching = true; |
71 | console.log(nextPage); | 72 | console.log(nextPage); |
72 | - $.get(this.url, { | 73 | + return $.get(this.url, { |
73 | order: this.order, // 排序 信息 | 74 | order: this.order, // 排序 信息 |
74 | query: this.query, | 75 | query: this.query, |
75 | page: nextPage | 76 | page: nextPage |
76 | }) | 77 | }) |
77 | - .done(res => { | ||
78 | - if (res.code === 200) { | ||
79 | - self.page = res.data.page; | ||
80 | - self.totalPage = res.data.pageTotal; | ||
81 | - self.$set('productList', self.productList.concat(res.data.productList)); | ||
82 | - } | ||
83 | - }) | ||
84 | - .fail(error => { | ||
85 | - tip('网络出错~'); | ||
86 | - }) | ||
87 | - .always(() => { | ||
88 | - self.inSearching = false; | ||
89 | - }); | 78 | + .done(res => { |
79 | + if (res.code === 200) { | ||
80 | + self.page = res.data.page; | ||
81 | + self.totalPage = res.data.pageTotal; | ||
82 | + self.$set('productList', self.productList.concat(res.data.productList)); | ||
83 | + } | ||
84 | + }) | ||
85 | + .fail(error => { | ||
86 | + tip('网络出错~'); | ||
87 | + }) | ||
88 | + .always(() => { | ||
89 | + self.inSearching = false; | ||
90 | + }); | ||
90 | }, | 91 | }, |
91 | 92 | ||
92 | /** | 93 | /** |
@@ -119,7 +120,12 @@ | @@ -119,7 +120,12 @@ | ||
119 | self.order = val; | 120 | self.order = val; |
120 | }); | 121 | }); |
121 | 122 | ||
122 | - this.search(); | 123 | + this.search() |
124 | + .then(()=>{ | ||
125 | + if (self.productList.length) { | ||
126 | + self.enableOrder = true; | ||
127 | + } | ||
128 | + }); | ||
123 | } | 129 | } |
124 | }; | 130 | }; |
125 | 131 |
-
Please register or login to post a comment