Authored by 陈轩

brand-coupon save

... ... @@ -12,6 +12,7 @@ const detailModel = require(`${mRoot}/detail`); // 商品详情 model
const introModel = require(`${mRoot}/intro`); // 商品尺码信息 model
const preferenceModel = require(`${mRoot}/preference`); // 商品偏好 model
const detailRelated = require(`${mRoot}/consult-comment`); // 商品评论咨询 model
const couponModel = require(`${mRoot}/coupon`); // 商品 优惠券 modal
const _ = require('lodash');
const helpers = global.yoho.helpers;
... ... @@ -368,3 +369,28 @@ exports.indexData = (req, res, next)=> {
}).catch(next);
};
/**
* [查询商品 品牌券]
*/
exports.brandCoupon = (req, res) => {
const uid = req.user.uid;
const skn = +req.query.skn;
const brandId = +req.query.brandId;
if (!(skn && brandId)) {
return res.json([]);
}
couponModel.queryProdPageCoupons(uid, skn, brandId)
.then(
result => {
return result.data || [];
}, () => {
return [];
})
.then(coupons => {
return res.json(coupons);
});
};
... ...
'use strict';
const api = global.yoho.API;
/**
* [查询商品详情页优惠券]
* doc: http://git.yoho.cn/yoho-documents/api-interfaces/blob/master/促销/product_detail_page_coupon.md
*/
exports.queryProdPageCoupons = (uid, skn, brandId) => {
const param = {
method: 'app.coupons.queryProdPageCoupons',
uid,
skn,
brandId
};
return api.get('', param, {cache: true});
};
... ...
... ... @@ -1250,6 +1250,7 @@ const _detailDataPkg = (origin, ua) => {
let extra = `?productSkn=${origin.product_skn}&brandId=${origin.brand_info.brand_id}`;
dest.preferenceUrl = `/product/detail/preference${extra}`;
dest.brandId = origin.brand_info.brand_id;
}
dest.productSkn = origin.product_skn;
... ...
... ... @@ -1251,6 +1251,7 @@ const _detailDataPkg = (origin, ua) => {
let extra = `?productSkn=${origin.product_skn}&brandId=${origin.brand_info.brand_id}`;
dest.preferenceUrl = `/product/detail/preference${extra}`;
dest.brandId = origin.brand_info.brand_id;
}
dest.productSkn = origin.product_skn;
... ...
... ... @@ -65,6 +65,8 @@ router.get('/detail/comments', detail.comments); // 商品评价
router.post('/detail/info', detail.getUser, detail.indexData); // 商品详情页-异步数据
router.post('/detail/consultsubmit', auth, detail.consultsubmit); // 商品咨询提交接口
router.get('/detail/coupon.json', detail.brandCoupon); // 品牌券
router.get('/recom/maylike', recom.mayLike);// 你可能喜欢
router.get('/recom/maylikekids', recom.mayLikeKids); // 潮童你可能喜欢
... ...
... ... @@ -82,6 +82,11 @@
</li>
</ul>
{{! 品牌优惠券}}
<div class="brand-coupon">
<i class="iconfont font-right pull-right">&#xe614;</i>
<i class="iconfont font-quan">&#xe900;</i><span>领取优惠券</span>
</div>
... ... @@ -151,6 +156,7 @@
{{/if}}
<input id="productSkn" type="hidden" value="{{productSkn}}">
<input id="brand-id" type="hidden" value="{{brandId}}">
<input type="hidden" class="data-bind" name="loginUrl" id="loginUrl" value="">
... ...
{{ 商品详情--品牌券 抽屉dom}}
<div class="coupon-drawer">
<div class="title">领取优惠券</div>
<div class="body">
<ul class="coupon-list">
{{#each coupons}}
<li class="coupon">
<div class="pull-right">
<button type="button">立刻领取</button>
</div>
<div class="coupon-intro">
<div class="coupon-price">¥ 200</div>
<div class="coupon-desc">issz品牌优惠券满499减120</div>
<div class="coupon-time">使用期限: 2016.10.21 ~ 2016.10.22</div>
</div>
</li>
{{/each}}
</ul>
</div>
</div>
\ No newline at end of file
... ...
... ... @@ -8,7 +8,6 @@ var $ = require('yoho-jquery'),
Hammer = require('yoho-hammer'),
lazyLoad = require('yoho-jquery-lazyload');
require('./detail/page-render')(function() {
var $discountFolder = $('.goods-discount .discount-folder'),
$discountArrow = $('.goods-discount .first-item span');
... ... @@ -150,6 +149,7 @@ require('./detail/page-render')(function() {
$('#yoho-footer').css('border-top', '1px solid #e0e0e0');
}
});
require('./detail/brand-coupon');
... ...
'use strict';
/**
* 商品详情: 品牌券
*/
/* eslint-disable */
var mock_data = [{
"couponName": "有效期20161017未到,10*2",
"amount": 10,
"acquireStatus": 3,
"createTime": 1476358043,
"startTime": 1476633600,
"lifeTime": "2016.10.17-2016.10.28",
"endTime": 1477584000,
"couponId": 14200
}, {
"couponName": "有效的nike券",
"amount": 22,
"acquireStatus": 3,
"createTime": 1475152374,
"startTime": 1474992000,
"lifeTime": "2016.09.28-2016.11.17",
"endTime": 1479312000,
"couponId": 14144
}, {
"couponName": "有效期内优惠券15*3倍",
"amount": 15,
"acquireStatus": 3,
"createTime": 1476358258,
"startTime": 1476115200,
"lifeTime": "2016.10.11-2016.11.18",
"endTime": 1479398400,
"couponId": 14202
}];
/* eslint-enable */
var tip = require('plugin/tip');
var $ = require('yoho-jquery');
var brandCoupon = {
skn: null,
brandId: null,
$entry: null,
$couponDrawer: null,
template: require('product/detail/coupon-list.hbs'),
init: function(skn, brandId) {
var self = this;
this.skn = skn;
this.brandId = brandId;
if (!(skn && brandId)) {
return;
}
this.fetchCoupons(this.skn, this.brandId)
.done(function(data) {
data = mock_data;
if (data.length) {
self.domInit();
self.render(data);
self.bindEvents();
}
})
.fail();
},
domInit: function() {
this.$entry = $('.brand-coupon');
this.$entry.removeClass('hide');
},
bindEvents: function() {
var self = this;
this.$entry.on('click', function() {
self.$couponDrawer.addClass('open');
});
},
render: function(data) {
this.$couponDrawer = $(this.template(data));
this.$couponDrawer.appendTo('body');
return this;
},
// 获取 品牌券
fetchCoupons: function(skn, brandId) {
return $.get('/product/detail/coupon.json', {
skn: skn,
brandId: brandId
});
},
// 收藏 品牌券
saveCoupons: function() {
}
};
$(function() {
brandCoupon.init(
$('#productSkn').val(),
$('#brand-id').val()
);
});
... ...
/*
商品品牌券 CSS
*/
.good-detail-page {
.coupon-drawer {
}
.coupon-list {
}
}
\ No newline at end of file
... ...
... ... @@ -282,7 +282,8 @@ $basicBtnC: #eb0313;
}
}
.price-date {
.price-date,
.brand-coupon {
position: relative;
padding-right: 28px;
padding-left: 28px;
... ... @@ -293,6 +294,28 @@ $basicBtnC: #eb0313;
color: $subFontC;
}
.brand-coupon {
font-size: 28px;
line-height: 88px;
span {
color: $mainFontC;
}
.iconfont {
font-size: inherit;
}
.font-right{
color: $subFontC;
}
.font-quan {
color: $basicBtnC;
margin-right: 15px;
}
}
.limit-sale {
position: absolute;
top: 50%;
... ...
... ... @@ -2,3 +2,4 @@
@import "comments-consults";
@import "product-description";
@import "recommend-for-you";
@import "brand-coupon";
... ...