Authored by 沈志敏

增加跳转地址

... ... @@ -4,21 +4,18 @@
*/
'use strict';
const favModel = require('../models/favorite');
const helpers = global.yoho.helpers;
const fav = {
favorite: (req, res) => {
if (req.query.tab === 'brand') {
res.render('favorite-brand', {
module: 'home',
page: 'favorite-brand',
brandUrl: helpers.urlFormat('/product/new')
page: 'favorite-brand'
});
} else {
res.render('favorite', {
module: 'home',
page: 'favorite',
productUrl: helpers.urlFormat('/product/new')
page: 'favorite'
});
}
},
... ...
... ... @@ -19,47 +19,7 @@ exports.getFavProductData = (uid, page, limit) => {
}, {
code: 200
}).then(result => {
var isend = true,
list = [],
data = result.data;
if (data && page <= data.page_total) {
data.product_list.forEach(function(d) {
if (!d.product_skn) {
return;
}
let link = '';
let discountPrice = false;
if (d.goodsId && d.cnAlphabet) {
link = helpers.urlFormat(`/product/pro_${d.product_id}_${d.goodsId}/${d.cnAlphabet}.html`);
}
if (Number(d.market_price) - Number(d.sales_price) > 0) {
discountPrice = '¥' + Number(Math.max(d.sales_price, 0)).toFixed(2);
}
list.push({
fav_id: d.product_id,
link: link,
imgUrl: d.image ? helpers.image(d.image) : '',
title: d.product_name,
price: '¥' + Number(Math.max(d.market_price, 0)).toFixed(2),
discountPrice: discountPrice,
sellOut: d.storage <= 0,
invalidGoods: d.status === 0
});
});
if (page < data.page_total) {
isend = false;
}
}
return {
isend: isend,
list: list
};
return result.data ? global.yoho.camelCase(result.data) : {};
});
};
... ... @@ -82,30 +42,7 @@ exports.getFavBrandData = (uid, gender, page, limit) => {
}, {
code: 200
}).then(result => {
var isend = true,
list = [],
data = result.data;
if (data && page <= data.page_total) {
data.brand_list.forEach(function(d) {
list.push({
fav_id: d.brand_id,
link: '', // todo
imgUrl: d.brand_ico ? helpers.image(d.brand_ico, 160, 125) : '',
brandName: d.brand_name,
down: d.status === 0
});
});
if (page < data.page_total) {
isend = false;
}
}
return {
isend: isend,
list: list
};
return result.data ? global.yoho.camelCase(result.data) : {};
});
};
... ...
... ... @@ -59,7 +59,7 @@ const _getInfoNumData = (uid) => {
}
return Object.assign(res, {
address_num: data[1].data.length ? data[1].data.length : ''
address_num: data[1].data && data[1].data.length ? data[1].data.length : ''
});
});
};
... ...
<div class="yoho-favorite-brand-page">
<div class="fav-content" id="fav-content">
<fav-brand-list brand-url='{{brandUrl}}'></fav-brand-list>
<fav-brand-list></fav-brand-list>
</div>
</div>
\ No newline at end of file
</div>
... ...
<div class="yoho-favorite-page">
<div class="fav-content" id="fav-content">
<fav-product-list product-url='{{productUrl}}'></fav-product-list>
<fav-product-list></fav-product-list>
</div>
</div>
\ No newline at end of file
</div>
... ...
... ... @@ -8,7 +8,7 @@ let Vue = require('yoho-vue');
*
* {value | resize 100 200 2} ==> /100/200/2
*/
Vue.filter('resize', (value, width, height, mode)=> {
Vue.filter('resize', (value, width, height, mode) => {
return value ? value.replace(/(\{width}|\{height}|\{mode})/g, function($0) {
const dict = {
'{width}': width,
... ... @@ -27,7 +27,7 @@ Vue.filter('resize', (value, width, height, mode)=> {
*
* {value | gender}
*/
Vue.filter('clothingGenderIdentity', (value)=> {
Vue.filter('clothingGenderIdentity', (value) => {
let ret = null;
switch (value) {
... ... @@ -49,7 +49,7 @@ Vue.filter('clothingGenderIdentity', (value)=> {
*
* @param value brand domain
*/
Vue.filter('brandUrl', (value)=> {
Vue.filter('brandUrl', (value) => {
return `/product/shop?domain=${value}`;
});
... ... @@ -57,6 +57,7 @@ Vue.filter('brandUrl', (value)=> {
* 产品 URL
*/
Vue.filter('goodsUrl', productId => {
if (!productId) return '';
return `/product/${productId}`;
});
... ...
const Vue = require('yoho-vue');
const infiniteScroll = require('yoho-vue-infinite-scroll');
const favBrandList = require('home/fav-brand-list.vue');
const VueTouch = require('vue-touch');
Vue.use(VueTouch)
require('common/vue-filter');
Vue.use(VueTouch)
Vue.use(infiniteScroll);
new Vue({
... ...
const Vue = require('yoho-vue');
const infiniteScroll = require('yoho-vue-infinite-scroll');
const favProductList = require('home/fav-product-list.vue');
const VueTouch = require('vue-touch');
Vue.use(VueTouch)
require('common/vue-filter');
Vue.use(VueTouch)
Vue.use(infiniteScroll);
new Vue({
... ...
... ... @@ -8,9 +8,9 @@
<div class="fav-del-left {{editmodel ? 'delshow': ''}}" @click="showDelBtn(item.fav_id)">
<span class="fav-del-span"><span class="icon icon-edit-del"></span></span>
</div>
<a :href="item.link">
<a :href="item.link | brandUrl">
<div class="fav-img-box">
<img :src="item.imgUrl" alt=""/>
<img :src="item.imgUrl | resize 160 125" alt=""/>
</div>
<div class="fav-info-list">
<span class="title">{{item.brandName}}</span>
... ... @@ -29,7 +29,7 @@
<div class="fav-null-box {{ nullbox }}">
<span class="fav-null">您暂无收藏任何品牌</span>
<a slot="go-shopping" class="go-shopping" :href="brandUrl">随便逛逛</a>
<a slot="go-shopping" class="go-shopping" href="/product/new">随便逛逛</a>
</div>
</div>
</template>
... ... @@ -40,7 +40,6 @@
const yoho = require('yoho');
module.exports = {
props: ['brandUrl'],
data() {
return {
nullbox: 'hide',
... ... @@ -65,21 +64,26 @@
page: ++_this.page,
tab: 'brand'
}
}).then(result => {
if (result.isend) {
}).then(data => {
if (_this.page === data.pageTotal) {
_this.busy = true;
} else {
_this.busy = false;
}
if (result.list.length) {
result.list.forEach(function(o) {
if (!_this.keys[o.fav_id]) {
_this.keys[o.fav_id] = true;
_this.brandData.push(o);
data.brandList.forEach(function(o){
if (!_this.keys[o.brandId]) {
_this.keys[o.brandId] = true;
_this.brandData.push({
fav_id: o.brandId,
link: o.brandDomain,
imgUrl: o.brandIco,
brandName: o.brandName,
down: o.status === 0
});
}
});
}
})
_this.nullbox = _this.brandData.length ? 'hide' : '';
}).fail(() => {
... ...
... ... @@ -8,9 +8,9 @@
<div class="fav-del-left {{editmodel ? 'delshow': ''}}" @click="showDelBtn(item.fav_id)">
<span class="fav-del-span"><span class="icon icon-edit-del"></span></span>
</div>
<a :href="item.link">
<a :href="item.link | goodsUrl">
<div class="fav-img-box">
<img :src="item.imgUrl" alt=""/>
<img :src="item.imgUrl | resize 152 203" alt=""/>
</div>
<div class="fav-info-list">
<span class="title">{{item.title}}</span>
... ... @@ -34,7 +34,7 @@
</ul>
<div class="fav-null-box {{ nullbox }}">
<span class="fav-null">您暂无收藏任何商品</span>
<a slot="go-shopping" class="go-shopping" :href="productUrl">随便逛逛</a>
<a slot="go-shopping" class="go-shopping" href='/product/new'>随便逛逛</a>
</div>
</div>
</template>
... ... @@ -45,7 +45,6 @@
const yoho = require('yoho');
module.exports = {
props: ['productUrl'],
data() {
return {
nullbox: 'hide',
... ... @@ -69,21 +68,39 @@
data: {
page: ++_this.page
}
}).then(result => {
if (result.isend) {
}).then(data => {
if (_this.page === data.pageTotal) {
_this.busy = true;
} else {
_this.busy = false;
}
if (result.list.length) {
result.list.forEach(function(o) {
if (!_this.keys[o.fav_id]) {
_this.keys[o.fav_id] = true;
_this.productData.push(o);
data.productList.forEach(function(o){
if (!o.productSkn) {
return;
}
if (!_this.keys[o.productId]) {
_this.keys[o.productId] = true;
let discountPrice = false;
if (Number(o.marketPrice) - Number(o.salesPrice) > 0) {
discountPrice = '¥' + Number(Math.max(o.salesPrice, 0)).toFixed(2);
}
});
}
_this.productData.push({
fav_id: o.productId,
link: o.goodsId && o.cnAlphabet ? o.productId : '',
imgUrl: o.image,
title: o.productName,
price: '¥' + Number(Math.max(o.marketPrice, 0)).toFixed(2),
discountPrice: discountPrice,
sellOut: o.storage <= 0,
invalidGoods: o.status === 0
});
}
})
_this.nullbox = _this.productData.length ? 'hide' : '';
}).fail(() => {
... ...