Authored by ccbikai

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

@@ -23,7 +23,7 @@ const model = { @@ -23,7 +23,7 @@ const model = {
23 const content = yield serviceAPI.get(URI_PACKAGE_ARTICLE + 'getArticleContent', params); 23 const content = yield serviceAPI.get(URI_PACKAGE_ARTICLE + 'getArticleContent', params);
24 const brands = yield serviceAPI.get(URI_PACKAGE_ARTICLE + 'getBrand', params); 24 const brands = yield serviceAPI.get(URI_PACKAGE_ARTICLE + 'getBrand', params);
25 const other = yield serviceAPI.get(URI_PACKAGE_ARTICLE + 'getOtherArticle', Object.assign({ 25 const other = yield serviceAPI.get(URI_PACKAGE_ARTICLE + 'getOtherArticle', Object.assign({
26 - tags: article.data.tag, 26 + tags: article.data ? article.data.tag : {},
27 offset: 0, 27 offset: 0,
28 limit: 3 28 limit: 3
29 }, params)); 29 }, params));
@@ -104,6 +104,13 @@ Vue.filter('convertOrderState', (value) => { @@ -104,6 +104,13 @@ Vue.filter('convertOrderState', (value) => {
104 return stateTxt; 104 return stateTxt;
105 }); 105 });
106 106
  107 +Vue.filter('toFixed', (value, num) => {
  108 + if (typeof value === 'undefined') {
  109 + return;
  110 + }
  111 + return Number(value).toFixed(num || 2);
  112 +});
  113 +
107 /** 114 /**
108 * 转换时间 115 * 转换时间
109 * yyyy-MM-dd hh:mm:ss 116 * yyyy-MM-dd hh:mm:ss
1 const Vue = require('vue'); 1 const Vue = require('vue');
2 const lazyload = require('vue-lazyload'); 2 const lazyload = require('vue-lazyload');
3 const directive = require('common/vue-directive'); 3 const directive = require('common/vue-directive');
4 -const app = require('product/detail/index.vue'); 4 +const app = require('editorial/detail.vue');
5 5
6 require('common/vue-filter'); 6 require('common/vue-filter');
7 Vue.use(lazyload); 7 Vue.use(lazyload);
@@ -202,8 +202,6 @@ @@ -202,8 +202,6 @@
202 } 202 }
203 </style> 203 </style>
204 <script> 204 <script>
205 - const bus = require('common/vue-bus');  
206 -  
207 module.exports = { 205 module.exports = {
208 props: { 206 props: {
209 category: { 207 category: {
@@ -226,13 +224,7 @@ @@ -226,13 +224,7 @@
226 }, 224 },
227 watch: { 225 watch: {
228 category() { 226 category() {
229 - this.$set('cateNavLeftData', this.category);  
230 - this.$set('cateNavRightData', this.cateNavLeftData ? this.cateNavLeftData[0].sub : []);  
231 -  
232 - this.$set('rightAll', this.cateNavLeftData ? {  
233 - sortId: this.cateNavLeftData[0].relationParameter.sort,  
234 - categoryName: this.cateNavLeftData[0].categoryName  
235 - } : {}); 227 + this.categoryChangeHandler();
236 } 228 }
237 }, 229 },
238 methods: { 230 methods: {
@@ -247,11 +239,28 @@ @@ -247,11 +239,28 @@
247 239
248 /* 筛选列表使用返回值 */ 240 /* 筛选列表使用返回值 */
249 noJumpReturn(categoryId, categoryName) { 241 noJumpReturn(categoryId, categoryName) {
250 - bus.$emit('category.result', { 242 + this.$dispatch('select', {
251 id: categoryId, 243 id: categoryId,
252 name: categoryName 244 name: categoryName
253 }); 245 });
  246 + },
  247 +
  248 + categoryChangeHandler() {
  249 + if (!this.category.length) {
  250 + return;
  251 + }
  252 +
  253 + this.$set('cateNavLeftData', this.category);
  254 + this.$set('cateNavRightData', this.cateNavLeftData ? this.cateNavLeftData[0].sub : []);
  255 +
  256 + this.$set('rightAll', this.cateNavLeftData ? {
  257 + sortId: this.cateNavLeftData[0].relationParameter.sort,
  258 + categoryName: this.cateNavLeftData[0].categoryName
  259 + } : {});
254 } 260 }
  261 + },
  262 + created() {
  263 + this.categoryChangeHandler();
255 } 264 }
256 }; 265 };
257 </script> 266 </script>
@@ -23,12 +23,19 @@ @@ -23,12 +23,19 @@
23 const bus = require('common/vue-bus'); 23 const bus = require('common/vue-bus');
24 const Overlay = require('common/overlay'); 24 const Overlay = require('common/overlay');
25 const filterSub = require('./filter/filter-sub.vue'); 25 const filterSub = require('./filter/filter-sub.vue');
  26 + const qs = require('yoho-qs/parse');
  27 + let locationQuery = qs(decodeURIComponent(location.search.replace(/^\?/, '')));
  28 + let hasSort = !!locationQuery.sort;
  29 +
  30 + const aliasMap = {
  31 + groupSort: 'sort'
  32 + };
26 33
27 module.exports = { 34 module.exports = {
28 props: { 35 props: {
29 config: Object, 36 config: Object,
30 isVisible: Boolean, 37 isVisible: Boolean,
31 - action: '', 38 + action: ''
32 }, 39 },
33 data: function() { 40 data: function() {
34 return { 41 return {
@@ -60,8 +67,8 @@ @@ -60,8 +67,8 @@
60 showCate: function(cateName, cateVals) { 67 showCate: function(cateName, cateVals) {
61 if (toString.call(cateVals) === '[object Array]') { 68 if (toString.call(cateVals) === '[object Array]') {
62 if (cateName === 'groupSort') { 69 if (cateName === 'groupSort') {
63 - // TODO  
64 - } else if (cateVals.length > 1) { 70 + return !hasSort;
  71 + } else if (cateVals.length >= 1) {
65 return true; 72 return true;
66 } 73 }
67 } 74 }
@@ -92,10 +99,16 @@ @@ -92,10 +99,16 @@
92 * @param {[type]} val [description] 99 * @param {[type]} val [description]
93 */ 100 */
94 setParams: function(item) { 101 setParams: function(item) {
95 - this.$set(`params.${this.subType}`, item); 102 + let sortType = this.subType;
  103 +
  104 + aliasMap[this.subType] && (sortType = aliasMap[this.subType]);
  105 +
  106 + this.$set(`params.${sortType}`, item);
96 }, 107 },
97 108
98 showLabel: function(key) { 109 showLabel: function(key) {
  110 + aliasMap[key] && (key = aliasMap[key]);
  111 +
99 const newSelected = this.params[key]; 112 const newSelected = this.params[key];
100 const oldSelected = this.selected[key]; 113 const oldSelected = this.selected[key];
101 114
@@ -106,24 +119,6 @@ @@ -106,24 +119,6 @@
106 } 119 }
107 } 120 }
108 }, 121 },
109 - filters: {  
110 - unifyTxt: function(val, category) {  
111 - let txt = '';  
112 - let arr = [];  
113 - let foo = $.noop;  
114 -  
115 -  
116 - if ($.isArray(val)) { // [{categoryName,..},{}..]  
117 - foo = (index, obj) => {  
118 - arr.push(obj[category + 'Name']);  
119 - };  
120 - }  
121 -  
122 - $.each(val, foo);  
123 - txt = arr.join(',');  
124 - return txt;  
125 - }  
126 - },  
127 created() { 122 created() {
128 const self = this; 123 const self = this;
129 124
@@ -3,19 +3,21 @@ @@ -3,19 +3,21 @@
3 <c-header class="filter-sub-header" :title="type | filter-cn '选择'"> 3 <c-header class="filter-sub-header" :title="type | filter-cn '选择'">
4 <i class="icon icon-left" slot="left" @click="hide"></i> 4 <i class="icon icon-left" slot="left" @click="hide"></i>
5 </c-header> 5 </c-header>
6 - <div>  
7 - <brand-filter v-if="type === 'brand'" :data="data" :val.sync="val" @select="selectItem"></brand-filter>  
8 - <normal-filter v-else :data="data" :type="type" :val.sync="val" @select="selectItem"></normal-filter>  
9 - </div> 6 + <div class="filter-sub-select">
  7 + <brand-filter v-if="type === 'brand'" :data="data" @select="selectItem"></brand-filter>
  8 + <normal-filter v-if="type !== 'brand' && type !== 'groupSort'" :data="data" :type="type" @select="selectItem"></normal-filter>
  9 + <sort-filter class="filter-detail filter-sort" v-if="type === 'groupSort'" :category="data" @select="selectItem"></sort-filter>
  10 + </div>
10 </div> 11 </div>
11 </template> 12 </template>
12 <script> 13 <script>
13 const cHeader = require('component/header.vue'); 14 const cHeader = require('component/header.vue');
14 const brandFilter = require('./brand.vue'); 15 const brandFilter = require('./brand.vue');
15 const normalFilter = require('./normal.vue'); 16 const normalFilter = require('./normal.vue');
  17 + const sortFilter = require('channel/brand-cate.vue');
16 18
17 module.exports = { 19 module.exports = {
18 - components: {cHeader, brandFilter, normalFilter}, 20 + components: {cHeader, brandFilter, normalFilter, sortFilter},
19 props: ['type', 'data'], 21 props: ['type', 'data'],
20 data() { 22 data() {
21 return { 23 return {
@@ -47,7 +49,6 @@ @@ -47,7 +49,6 @@
47 transform: translate3d(100%, 0, 0); 49 transform: translate3d(100%, 0, 0);
48 background-color: $white; 50 background-color: $white;
49 z-index: 2010; 51 z-index: 2010;
50 - overflow: auto;  
51 52
52 &.filter-sub-open { 53 &.filter-sub-open {
53 transform: translate3d(0, 0, 0); 54 transform: translate3d(0, 0, 0);
@@ -90,4 +91,30 @@ @@ -90,4 +91,30 @@
90 91
91 } 92 }
92 } 93 }
  94 +
  95 +.filter-sub-select {
  96 + position: absolute;
  97 + top: 90px;
  98 + left: 0;
  99 + right: 0;
  100 + bottom: 0;
  101 +}
  102 +
  103 +.filter-detail {
  104 + height: 100%;
  105 + overflow: auto;
  106 +}
  107 +
  108 +.filter-sort {
  109 + .cate-container {
  110 + margin-top: 0;
  111 + height: 100%;
  112 + }
  113 + .content {
  114 + height: 100% !important;
  115 + }
  116 + .sub-level-container {
  117 + overflow: auto;
  118 + }
  119 +}
93 </style> 120 </style>
@@ -4,15 +4,15 @@ @@ -4,15 +4,15 @@
4 <li class="card" v-for="item in data"> 4 <li class="card" v-for="item in data">
5 <div class="card-pic"> 5 <div class="card-pic">
6 <a href="{{item.productId | goodsUrl}}"> 6 <a href="{{item.productId | goodsUrl}}">
7 - <img v-lazy="item.goodsList[0].imagesUrl | resize 372 499" alt="{{item.productName}}"> 7 + <img v-lazy="item.defaultImages | resize 372 499" alt="{{item.productName}}">
8 </a> 8 </a>
9 </div> 9 </div>
10 <div class="card-bd"> 10 <div class="card-bd">
11 <h2 class="card-label"> 11 <h2 class="card-label">
12 <a href="{{item.productId | goodsUrl}}" class="line-clamp-2">{{item.productName}}</a> 12 <a href="{{item.productId | goodsUrl}}" class="line-clamp-2">{{item.productName}}</a>
13 </h2> 13 </h2>
14 - <span class="good-price" :class="{'old-price': item.marketPrice}" v-if="item.marketPrice">¥ {{item.marketPrice}}</span>  
15 - <span class="good-price" :class="{'sale-price': item.marketPrice}">¥ {{item.salesPrice}}</span> 14 + <span class="good-price" :class="{'old-price': item.marketPrice}" v-if="item.marketPrice">¥ {{item.marketPrice | toFixed}}</span>
  15 + <span class="good-price" :class="{'sale-price': item.marketPrice}">¥ {{item.salesPrice | toFixed}}</span>
16 </div> 16 </div>
17 </li> 17 </li>
18 </ul> 18 </ul>
@@ -60,11 +60,11 @@ @@ -60,11 +60,11 @@
60 }, (results)=> { 60 }, (results)=> {
61 const result = results[0], misc = results[1]; 61 const result = results[0], misc = results[1];
62 62
63 - if (result.code === 200) { 63 + if (result && result.code === 200) {
64 this.likeCount = result.data; 64 this.likeCount = result.data;
65 } 65 }
66 66
67 - if (misc.code === 200) { 67 + if (misc && misc.code === 200) {
68 this.isLiked = misc.data.isPraise === 'Y'; 68 this.isLiked = misc.data.isPraise === 'Y';
69 } 69 }
70 }); 70 });
@@ -75,9 +75,9 @@ @@ -75,9 +75,9 @@
75 }, (results)=> { 75 }, (results)=> {
76 const result = results[0], misc = results[1]; 76 const result = results[0], misc = results[1];
77 77
78 - if (result.code === 200) { 78 + if (result && result.code === 200) {
79 // TODO: 79 // TODO:
80 - } if (result.code === 403) { 80 + } if (result && result.code === 403) {
81 // 未登录 81 // 未登录
82 yoho.goLogin('', function() { 82 yoho.goLogin('', function() {
83 this.toggleFavorite(); 83 this.toggleFavorite();
@@ -86,7 +86,7 @@ @@ -86,7 +86,7 @@
86 }); 86 });
87 } 87 }
88 88
89 - if (misc.code === 200) { 89 + if (misc && misc.code === 200) {
90 this.isFavorite = misc.data.isFavor === 'Y'; 90 this.isFavorite = misc.data.isFavor === 'Y';
91 } 91 }
92 }); 92 });
@@ -109,7 +109,7 @@ @@ -109,7 +109,7 @@
109 }, 109 },
110 created() { 110 created() {
111 $.get(`/editorial/misc_${this.id}.json`).then(result => { 111 $.get(`/editorial/misc_${this.id}.json`).then(result => {
112 - if (result.code === 200) { 112 + if (result && result.code === 200) {
113 this.isFavorite = result.data.isFavor === 'Y'; 113 this.isFavorite = result.data.isFavor === 'Y';
114 this.isLiked = result.data.isPraise === 'Y'; 114 this.isLiked = result.data.isPraise === 'Y';
115 } 115 }
1 <template> 1 <template>
2 <shop-top v-bind:shop-info="shopInfo"></shop-top> 2 <shop-top v-bind:shop-info="shopInfo"></shop-top>
3 <div v-bind:class='{"shop-goods-top": !shopInfo.isBlkShop}'> 3 <div v-bind:class='{"shop-goods-top": !shopInfo.isBlkShop}'>
4 - <goods-list v-bind:data="productList"></goods-list> 4 + <goods-list v-bind:data="productList" :empty="empty"></goods-list>
5 </div> 5 </div>
6 <filter :config="filterConfig" v-ref:filter></filter> 6 <filter :config="filterConfig" v-ref:filter></filter>
7 <top-bar v-bind:share-data="shareData"></top-bar> 7 <top-bar v-bind:share-data="shareData"></top-bar>
8 </template> 8 </template>
9 <style> 9 <style>
  10 + #shop {
  11 + .empty-tip {
  12 + margin-top: 40px;
  13 + }
  14 + }
10 .shop-goods-top { 15 .shop-goods-top {
11 margin-top: 140px; 16 margin-top: 140px;
12 } 17 }
@@ -53,6 +58,11 @@ @@ -53,6 +58,11 @@
53 inSearching: false 58 inSearching: false
54 }; 59 };
55 }, 60 },
  61 + computed: {
  62 + empty: function() {
  63 + return this.page !== 0 && !this.productList.length;
  64 + }
  65 + },
56 watch: { 66 watch: {
57 67
58 /* order 和 filter 改变 都会触发 重新搜索 (想象成清空所有分页) */ 68 /* order 和 filter 改变 都会触发 重新搜索 (想象成清空所有分页) */
1 <template> 1 <template>
2 <div v-if="shopInfo.isBlkShop" class="brand-top-box" v-lazy:background-image="shopInfo.shopBg | resize 750 478"> 2 <div v-if="shopInfo.isBlkShop" class="brand-top-box" v-lazy:background-image="shopInfo.shopBg | resize 750 478">
3 <div class="brand-bottom"> 3 <div class="brand-bottom">
4 - <img v-if="shopInfo.brandLogo" v-lazy="shopInfo.brandLogo | resize 80 80" alt="{{ shopInfo.shopName }}"> 4 + <img v-if="shopInfo.shopLogo" v-lazy="shopInfo.shopLogo | resize 80 80" alt="{{ shopInfo.shopName }}">
5 <div v-else class="brand-title">{{ shopInfo.shopName }}</div> 5 <div v-else class="brand-title">{{ shopInfo.shopName }}</div>
6 <hr> 6 <hr>
7 <div v-show="showMore" transition="brand-intro" v-bind:class="{ 'brand-short': !showMore }">{{ shopInfo.shopIntro }}</div> 7 <div v-show="showMore" transition="brand-intro" v-bind:class="{ 'brand-short': !showMore }">{{ shopInfo.shopIntro }}</div>