Authored by 沈志敏

收藏品牌

... ... @@ -65,32 +65,42 @@ const component = {
brandUrl: helpers.urlFormat('/product/new'),
productUrl: helpers.urlFormat('/product/new')
}
res.render('favorite', _.merge({
module: 'home',
page: 'favorite',
}, testData));
if (tab === 'brand') {
res.render('favorite-brand', _.merge({
module: 'home',
page: 'favorite-brand',
}, testData));
} else {
res.render('favorite', _.merge({
module: 'home',
page: 'favorite',
}, testData));
}
},
favpaging: (req, res, next) => {
let tab = req.query.tab;
let page = req.query.page;
console.log("page: " + page);
if (tab === 'brand') {
}
if (page > 3) return res.json([]);
if (page > 2) return res.json([]);
let testData = []
for (var i = 1; i <= 9; i++) {
testData.push({
fav_id: Number(page + i),
title: "商品名测试测试测试测试测试测试测试测试" + Number(page + i),
invalidGoods: true,
discountPrice: '¥' + 900,
price: '¥' + 990
})
if (tab === 'brand') {
testData.push({
fav_id: Number(page + i),
brandName: "品牌名测试" + Number(page + i),
invalidGoods: true
})
} else {
testData.push({
fav_id: Number(page + i),
title: "商品名测试测试测试测试测试测试测试测试" + Number(page + i),
invalidGoods: true,
discountPrice: '¥' + 900,
price: '¥' + 990
})
}
}
return res.json(testData);
... ...
<div class="yoho-favorite-brand-page">
<div class="fav-content" id="fav-content">
<fav-brand-list brand-url={{brandUrl}}></fav-brand-list>
</div>
</div>
\ No newline at end of file
... ...
<div class="yoho-favorite-page yoho-page">
<div class="yoho-favorite-page">
<div class="fav-content" id="fav-content">
<fav-product-list product-url={{productUrl}}></fav-product-list>
</div>
... ...
<div class="my-page yoho-page">
<div class="my-page">
<div class="my-header">
<a class="user-info" href={{userinfourl}}>
<span class="user-avatar" data-avatar="{{head_ico}}"></span>
... ...
const Vue = require('yoho-vue');
const infiniteScroll = require('yoho-vue-infinite-scroll');
const BrandList = require('home/fav-brand-list.vue');
Vue.use(infiniteScroll)
new Vue({
el: '#fav-content',
components: {
'fav-brand-list': BrandList
}
});
\ No newline at end of file
... ...
... ... @@ -4,43 +4,9 @@
.fav-content {
.fav-type {
display: none;
}
.show {
display: block;
}
.fav-null {
font-size: 22px;
color: #444;
display: block;
margin-top: 100px;
text-align: center;
&:before {
content: '';
display: block;
width: 188px;
height: 171px;
background: resolve("home/fav/fav-null.png");
background-size: 100% 100%;
margin: 0 auto 45px auto;
}
}
.go-shopping {
width: 472px;
height: 88px;
line-height: 88px;
margin: 80px auto 0 auto;
background: #444;
text-align: center;
color: #fff;
display: block;
font-size: 26px;
border-radius:.2rem;
}
.fav-product-list {
padding-left: 20px;
list-style: none;
... ... @@ -137,5 +103,154 @@
}
}
}
.fav-null {
font-size: 22px;
color: #444;
display: block;
margin-top: 100px;
text-align: center;
&:before {
content: '';
display: block;
width: 188px;
height: 171px;
background: resolve("home/fav/fav-null.png");
background-size: 100% 100%;
margin: 0 auto 45px auto;
}
}
.go-shopping {
width: 472px;
height: 88px;
line-height: 88px;
margin: 80px auto 0 auto;
background: #444;
text-align: center;
color: #fff;
display: block;
font-size: 26px;
border-radius:.2rem;
}
}
}
.yoho-favorite-brand-page {
width: 100%;
height: auto;
.fav-content {
.fav-type {
display: block;
}
.fav-brand-list {
padding-left: 20px;
list-style: none;
li {
height: 130px;
overflow: hidden;
margin-top: 20px;
}
.fav-del {
display: none;
float: left;
width: 50px;
height: 100%;
.fav-del-span {
display: inline-block;
width: 35px;
height: 35px;
margin-right: 15px;
margin-top: 35px;
background: resolve("home/fav/fav-del.png");
}
}
.delshow {
display: block;
}
.fav-img-box {
width: 160px;
height: 125px;
float: left;
margin-right: 24px;
img {
display: block;
overflow: hidden;
width: 100%;
height: 100%;
}
}
.fav-info-list {
color: #444;
font-size: 24px;
border-bottom: 1px solid #e0e0e0;
padding-bottom: 20px;
margin-right: 10px;
margin-top: 35px;
height: 125px;
overflow: hidden;
position: relative;
.title {
width: 430px;
color: #b0b0b0;
text-overflow: ellipsis;
font-size: 34px;
margin: 0;
}
}
span {
&.down {
float: right;
padding: 5px 18px;
color: #fffefe;
background: #b0b0b0;
border-radius: 20px;
font-size: 22px;
}
}
}
.fav-null {
font-size: 22px;
color: #444;
display: block;
margin-top: 100px;
text-align: center;
&:before {
content: '';
display: block;
width: 188px;
height: 171px;
background: resolve("home/fav/fav-null.png");
background-size: 100% 100%;
margin: 0 auto 45px auto;
}
}
.go-shopping {
width: 472px;
height: 88px;
line-height: 88px;
margin: 80px auto 0 auto;
background: #444;
text-align: center;
color: #fff;
display: block;
font-size: 26px;
border-radius:.2rem;
}
}
}
\ No newline at end of file
... ...
<template>
<div class="fav-type" v-infinite-scroll="loadMore()" infinite-scroll-disabled="busy" infinite-scroll-distance="10">
<ul class="fav-brand-list">
<li v-for="item in brandData" track-by="fav_id">
<div class="fav-del {{editmodel ? 'delshow': ''}}" @click="delItem($index, item.fav_id)">
<span class="fav-del-span"></span>
</div>
<a :href="item.link">
<div class="fav-img-box">
<img :src="item.imgUrl" alt=""/>
</div>
<div class="fav-info-list">
<span class="title">{{item.brandName}}</span>
<span class="down" v-if="item.invalidGoods">品牌已下架</span>
</div>
</a>
</li>
</ul>
<div class="fav-null-box {{ nullbox }}">
<span class="fav-null">您暂无收藏任何品牌</span>
<a slot="go-shopping" class="go-shopping" :href="brandUrl">随便逛逛</a>
</div>
</div>
</template>
<script>
const $ = require('yoho-jquery');
const tip = require('common/tip');
const modal = require('common/modal');
const loading = require('common/loading');
module.exports = {
props: ['brandUrl'],
data() {
return {
nullbox : 'hide',
busy: false,
editmodel: false,
page: 0,
brandData: []
};
},
methods: {
loadMore: function() {
let _this = this;
this.busy = true;
$.ajax({
url: '/home/favorite/favpaging',
data: {
page : ++_this.page,
tab : "brand"
}
}).then(result => {
if (result.length) {
result.forEach(function(o){
_this.brandData.push(o);
});
_this.busy = false;
} else {
_this.busy = true;
}
_this.nullbox = _this.brandData.length ? "hide" : "";
}).fail(() => {
tip('网络错误');
});
},
editModel(action) {
this.editmodel = action;
},
delItem(index, id) {
let _this = this;
$.modal.confirm('', '确定刪除该收藏吗?', function() {
this.hide();
$.ajax({
method: 'post',
url: '/home/favorite/favdel',
data: {
id: id
}
}).then(function(data) {
if (data.code === 200) {
_this.brandData.splice(index, 1);
} else if (data.code === 400) {
$.modal.alert(data.message, '出错了!');
} else {
$.modal.alert('', '刪除收藏失败');
}
}).fail(function() {
$.modal.alert('', '网络错误');
});
});
}
}
};
</script>
... ...
<template>
<div class="fav-type show" v-infinite-scroll="loadMore()" infinite-scroll-disabled="busy" infinite-scroll-distance="10">
<div class="fav-type" v-infinite-scroll="loadMore()" infinite-scroll-disabled="busy" infinite-scroll-distance="10">
<ul class="fav-product-list">
<li v-for="item in productData" track-by="fav_id">
<div class="fav-del {{editmodel ? 'delshow': ''}}" @click="delProduct($index, item.fav_id)">
<div class="fav-del {{editmodel ? 'delshow': ''}}" @click="delItem($index, item.fav_id)">
<span class="fav-del-span"></span>
</div>
<a :href="item.link">
... ... @@ -25,7 +25,7 @@
</li>
</ul>
<div class="fav-null-box {{ nullbox }}">
<span class="fav-null">您暂无收藏任何商品}}</span>
<span class="fav-null">您暂无收藏任何商品</span>
<a slot="go-shopping" class="go-shopping" :href="productUrl">随便逛逛</a>
</div>
</div>
... ... @@ -73,10 +73,10 @@
tip('网络错误');
});
},
editProduct(action) {
editModel(action) {
this.editmodel = action;
},
delProduct(index, id) {
delItem(index, id) {
let _this = this;
$.modal.confirm('', '确定刪除该收藏吗?', function() {
this.hide();
... ... @@ -92,7 +92,7 @@
} else if (data.code === 400) {
$.modal.alert(data.message, '出错了!');
} else {
$.modal.alert('', '取消收藏失败');
$.modal.alert('', '刪除收藏失败');
}
}).fail(function() {
$.modal.alert('', '网络错误');
... ...