Authored by 沈志敏

Merge branch 'develop' of git.yoho.cn:fe/yohoblk-wap into develop

1 -<div id="brand-cate">  
2 - <brand-cate></brand-cate>  
3 -</div>  
  1 +<div id="brand-cate-box">
  2 + <brand-cate-box></brand-cate-box>
  3 +</div>
1 const Vue = require('vue'); 1 const Vue = require('vue');
2 -const brandCate = require('channel/brand-cate.vue'); 2 +const brandCateBox = require('channel/brand-cate-box.vue');
3 3
4 new Vue({ 4 new Vue({
5 - el: '#brand-cate', 5 + el: '#brand-cate-box',
6 components: { 6 components: {
7 - 'brand-cate': brandCate 7 + 'brand-cate-box': brandCateBox
8 } 8 }
9 }); 9 });
  1 +<template>
  2 + <tab v-bind:page="'cate'"></tab>
  3 + <brand-cate v-bind:category="category" v-bind:jump="true" v-bind:gender="gender"></brand-cate>
  4 +</template>
  5 +<script>
  6 + const tip = require('common/tip');
  7 + const brandCate = require('channel/brand-cate.vue');
  8 + const tab = require('channel/tab.vue');
  9 + const $ = require('jquery');
  10 + const bus = require('common/vue-bus');
  11 +
  12 + const channelTrans = {
  13 + men: {
  14 + key: 'MEN男士',
  15 + code: '1,3'
  16 + },
  17 + women: {
  18 + key: 'WOMEN女士',
  19 + code: '2,3'
  20 + },
  21 + lifestyle: {
  22 + key: 'LIFESTYLE生活',
  23 + code: '1,2,3'
  24 + }
  25 + };
  26 +
  27 + module.exports = {
  28 + data() {
  29 + return {
  30 + category: [],
  31 + categoryResult: {},
  32 + gender: '1,3'
  33 + };
  34 + },
  35 + components: {
  36 + tab,
  37 + brandCate
  38 + },
  39 + methods: {
  40 + getCateList() {
  41 +
  42 + $.ajax({
  43 + url: '/cate/list.json'
  44 + }).then(result => {
  45 + if (result.code === 200 && result.data) {
  46 + this.$set('categoryResult', result.data);
  47 + this.$set('category', this.categoryResult['MEN男士']);
  48 + }
  49 + }).fail(() => {
  50 + tip('网络错误');
  51 + });
  52 + }
  53 + },
  54 + created() {
  55 + this.getCateList();
  56 +
  57 + bus.$on('channel.change', (page, channel) => {
  58 + this.$set('gender', channelTrans[channel].code);
  59 + this.$set('category', this.categoryResult[channelTrans[channel].key]);
  60 + });
  61 + }
  62 + };
  63 +</script>
1 <template> 1 <template>
2 - <tab v-bind:page="'cate'"></tab>  
3 <div class="cate-page" id='cate-page'> 2 <div class="cate-page" id='cate-page'>
4 <div class="cate-container clearfix"> 3 <div class="cate-container clearfix">
5 <div class="content" style="height: 522px;"> 4 <div class="content" style="height: 522px;">
@@ -10,11 +9,15 @@ @@ -10,11 +9,15 @@
10 </ul> 9 </ul>
11 <div class="sub-level-container"> 10 <div class="sub-level-container">
12 <ul class="sub-level"> 11 <ul class="sub-level">
13 - <li><a href="/list?sort={{rightAll.sortId}}&sort_name=全部{{rightAll.categoryName}}&gender={{gender}}">全部{{rightAll.categoryName}}</a></li> 12 + <li >
  13 + <a v-if="jump" href="/list?sort={{rightAll.sortId}}&sort_name=全部{{rightAll.categoryName}}&gender={{gender}}">全部{{rightAll.categoryName}}</a>
  14 + <a v-else @click="noJumpReturn(rightAll.sortId, '全部' + rightAll.categoryName)">全部{{rightAll.categoryName}}</a>
  15 + </li>
14 </ul> 16 </ul>
15 <ul class="sub-level"> 17 <ul class="sub-level">
16 <li v-for="sub in cateNavRightData"> 18 <li v-for="sub in cateNavRightData">
17 - <a href="/list?sort={{sub.relationParameter.sort}}&sort_name={{sub.categoryName}}&gender={{gender}}">{{sub.categoryName}}</a> 19 + <a v-if="jump" href="/list?sort={{sub.relationParameter.sort}}&sort_name={{sub.categoryName}}&gender={{gender}}">{{sub.categoryName}}</a>
  20 + <a v-else @click="noJumpReturn(sub.relationParameter.sort, sub.categoryName)">{{sub.categoryName}}</a>
18 </li> 21 </li>
19 </ul> 22 </ul>
20 </div> 23 </div>
@@ -199,68 +202,40 @@ @@ -199,68 +202,40 @@
199 } 202 }
200 </style> 203 </style>
201 <script> 204 <script>
202 - const $ = require('jquery');  
203 - const tip = require('common/tip');  
204 - const tab = require('channel/tab.vue');  
205 - const contentCode = require('content-code');  
206 - const qs = require('yoho-qs');  
207 const bus = require('common/vue-bus'); 205 const bus = require('common/vue-bus');
208 206
209 - const channelTrans = {  
210 - men: {  
211 - key: 'MEN男士',  
212 - code: '1,3'  
213 - },  
214 - women: {  
215 - key: 'WOMEN女士',  
216 - code: '2,3'  
217 - },  
218 - lifestyle: {  
219 - key: 'LIFESTYLE生活',  
220 - code: '1,2,3'  
221 - }  
222 - };  
223 -  
224 module.exports = { 207 module.exports = {
225 - props: [], 208 + props: {
  209 + category: {
  210 + type: Array
  211 + },
  212 + jump: {
  213 + type: Boolean
  214 + },
  215 + gender: {
  216 + type: String
  217 + }
  218 + },
226 data() { 219 data() {
227 return { 220 return {
228 - brandCate: [],  
229 - cateNavLeftData: [],  
230 - cateNavRightData: [],  
231 - topcurrent: 0,  
232 - widthli: 33.33,  
233 - leftcurrent: 0,  
234 - page: 'cate',  
235 - gender: '1,2,3',  
236 - rightAll: {},  
237 - contentCode: contentCode.brand[qs.channel || 'men'] 221 + cateNavLeftData: [], // 左侧分类数据
  222 + cateNavRightData: [], // 右侧分类数据
  223 + leftcurrent: 0, // 标记当前左侧选中条目
  224 + rightAll: {} // 全部XX
238 }; 225 };
239 }, 226 },
240 - methods: {  
241 - getCateList() {  
242 - let data = {  
243 - channel: ''  
244 - }; 227 + watch: {
  228 + category() {
  229 + this.$set('cateNavLeftData', this.category);
  230 + this.$set('cateNavRightData', this.cateNavLeftData ? this.cateNavLeftData[0].sub : []);
245 231
246 - $.ajax({  
247 - url: '/cate/list.json',  
248 - data: data  
249 - }).then(result => {  
250 - if (result.code === 200 && result.data) {  
251 - this.$set('brandCate', result.data);  
252 - this.$set('cateNavLeftData', result.data['MEN男士']);  
253 - this.$set('cateNavRightData', result.data['MEN男士'] ? result.data['MEN男士'][0].sub : []);  
254 -  
255 - this.$set('rightAll', result.data['MEN男士'] ? {  
256 - sortId: result.data['MEN男士'][0].relationParameter.sort,  
257 - categoryName: result.data['MEN男士'][0].categoryName  
258 - } : {});  
259 - }  
260 - }).fail(() => {  
261 - tip('网络错误');  
262 - });  
263 - }, 232 + this.$set('rightAll', this.cateNavLeftData ? {
  233 + sortId: this.cateNavLeftData[0].relationParameter.sort,
  234 + categoryName: this.cateNavLeftData[0].categoryName
  235 + } : {});
  236 + }
  237 + },
  238 + methods: {
264 cateNavLeftFun(index, categoryId, categoryName) { 239 cateNavLeftFun(index, categoryId, categoryName) {
265 this.leftcurrent = index; 240 this.leftcurrent = index;
266 this.cateNavRightData = this.cateNavLeftData[index].sub; 241 this.cateNavRightData = this.cateNavLeftData[index].sub;
@@ -268,23 +243,15 @@ @@ -268,23 +243,15 @@
268 sortId: categoryId, 243 sortId: categoryId,
269 categoryName: categoryName 244 categoryName: categoryName
270 }; 245 };
271 - }  
272 - },  
273 - components: {  
274 - tab  
275 - },  
276 - created() {  
277 - this.getCateList(); 246 + },
278 247
279 - bus.$on('channel.change', (page, channel) => {  
280 - this.gender = channelTrans[channel].code;  
281 - this.cateNavLeftData = this.brandCate[channelTrans[channel].key];  
282 - this.cateNavRightData = this.cateNavLeftData ? this.cateNavLeftData[0].sub : [];  
283 - this.rightAll = {  
284 - sortId: this.cateNavLeftData[0].relationParameter.sort,  
285 - categoryName: this.cateNavLeftData[0].categoryName  
286 - };  
287 - }); 248 + /* 筛选列表使用返回值 */
  249 + noJumpReturn(categoryId, categoryName) {
  250 + bus.$emit('category.result', {
  251 + id: categoryId,
  252 + name: categoryName
  253 + });
  254 + }
288 } 255 }
289 }; 256 };
290 </script> 257 </script>