Authored by 陈轩

brand-coupon save

@@ -12,6 +12,7 @@ const detailModel = require(`${mRoot}/detail`); // 商品详情 model @@ -12,6 +12,7 @@ const detailModel = require(`${mRoot}/detail`); // 商品详情 model
12 const introModel = require(`${mRoot}/intro`); // 商品尺码信息 model 12 const introModel = require(`${mRoot}/intro`); // 商品尺码信息 model
13 const preferenceModel = require(`${mRoot}/preference`); // 商品偏好 model 13 const preferenceModel = require(`${mRoot}/preference`); // 商品偏好 model
14 const detailRelated = require(`${mRoot}/consult-comment`); // 商品评论咨询 model 14 const detailRelated = require(`${mRoot}/consult-comment`); // 商品评论咨询 model
  15 +const couponModel = require(`${mRoot}/coupon`); // 商品 优惠券 modal
15 const _ = require('lodash'); 16 const _ = require('lodash');
16 17
17 const helpers = global.yoho.helpers; 18 const helpers = global.yoho.helpers;
@@ -368,3 +369,28 @@ exports.indexData = (req, res, next)=> { @@ -368,3 +369,28 @@ exports.indexData = (req, res, next)=> {
368 }).catch(next); 369 }).catch(next);
369 370
370 }; 371 };
  372 +
  373 +
  374 +/**
  375 + * [查询商品 品牌券]
  376 + */
  377 +exports.brandCoupon = (req, res) => {
  378 + const uid = req.user.uid;
  379 + const skn = +req.query.skn;
  380 + const brandId = +req.query.brandId;
  381 +
  382 + if (!(skn && brandId)) {
  383 + return res.json([]);
  384 + }
  385 +
  386 + couponModel.queryProdPageCoupons(uid, skn, brandId)
  387 + .then(
  388 + result => {
  389 + return result.data || [];
  390 + }, () => {
  391 + return [];
  392 + })
  393 + .then(coupons => {
  394 + return res.json(coupons);
  395 + });
  396 +};
  1 +'use strict';
  2 +
  3 +const api = global.yoho.API;
  4 +
  5 +/**
  6 + * [查询商品详情页优惠券]
  7 + * doc: http://git.yoho.cn/yoho-documents/api-interfaces/blob/master/促销/product_detail_page_coupon.md
  8 + */
  9 +exports.queryProdPageCoupons = (uid, skn, brandId) => {
  10 + const param = {
  11 + method: 'app.coupons.queryProdPageCoupons',
  12 + uid,
  13 + skn,
  14 + brandId
  15 + };
  16 +
  17 + return api.get('', param, {cache: true});
  18 +};
@@ -1250,6 +1250,7 @@ const _detailDataPkg = (origin, ua) => { @@ -1250,6 +1250,7 @@ const _detailDataPkg = (origin, ua) => {
1250 let extra = `?productSkn=${origin.product_skn}&brandId=${origin.brand_info.brand_id}`; 1250 let extra = `?productSkn=${origin.product_skn}&brandId=${origin.brand_info.brand_id}`;
1251 1251
1252 dest.preferenceUrl = `/product/detail/preference${extra}`; 1252 dest.preferenceUrl = `/product/detail/preference${extra}`;
  1253 + dest.brandId = origin.brand_info.brand_id;
1253 } 1254 }
1254 1255
1255 dest.productSkn = origin.product_skn; 1256 dest.productSkn = origin.product_skn;
@@ -1251,6 +1251,7 @@ const _detailDataPkg = (origin, ua) => { @@ -1251,6 +1251,7 @@ const _detailDataPkg = (origin, ua) => {
1251 let extra = `?productSkn=${origin.product_skn}&brandId=${origin.brand_info.brand_id}`; 1251 let extra = `?productSkn=${origin.product_skn}&brandId=${origin.brand_info.brand_id}`;
1252 1252
1253 dest.preferenceUrl = `/product/detail/preference${extra}`; 1253 dest.preferenceUrl = `/product/detail/preference${extra}`;
  1254 + dest.brandId = origin.brand_info.brand_id;
1254 } 1255 }
1255 1256
1256 dest.productSkn = origin.product_skn; 1257 dest.productSkn = origin.product_skn;
@@ -65,6 +65,8 @@ router.get('/detail/comments', detail.comments); // 商品评价 @@ -65,6 +65,8 @@ router.get('/detail/comments', detail.comments); // 商品评价
65 router.post('/detail/info', detail.getUser, detail.indexData); // 商品详情页-异步数据 65 router.post('/detail/info', detail.getUser, detail.indexData); // 商品详情页-异步数据
66 router.post('/detail/consultsubmit', auth, detail.consultsubmit); // 商品咨询提交接口 66 router.post('/detail/consultsubmit', auth, detail.consultsubmit); // 商品咨询提交接口
67 67
  68 +router.get('/detail/coupon.json', detail.brandCoupon); // 品牌券
  69 +
68 router.get('/recom/maylike', recom.mayLike);// 你可能喜欢 70 router.get('/recom/maylike', recom.mayLike);// 你可能喜欢
69 router.get('/recom/maylikekids', recom.mayLikeKids); // 潮童你可能喜欢 71 router.get('/recom/maylikekids', recom.mayLikeKids); // 潮童你可能喜欢
70 72
@@ -82,6 +82,11 @@ @@ -82,6 +82,11 @@
82 </li> 82 </li>
83 </ul> 83 </ul>
84 84
  85 + {{! 品牌优惠券}}
  86 + <div class="brand-coupon">
  87 + <i class="iconfont font-right pull-right">&#xe614;</i>
  88 + <i class="iconfont font-quan">&#xe900;</i><span>领取优惠券</span>
  89 + </div>
85 90
86 91
87 92
@@ -151,6 +156,7 @@ @@ -151,6 +156,7 @@
151 {{/if}} 156 {{/if}}
152 157
153 <input id="productSkn" type="hidden" value="{{productSkn}}"> 158 <input id="productSkn" type="hidden" value="{{productSkn}}">
  159 + <input id="brand-id" type="hidden" value="{{brandId}}">
154 160
155 <input type="hidden" class="data-bind" name="loginUrl" id="loginUrl" value=""> 161 <input type="hidden" class="data-bind" name="loginUrl" id="loginUrl" value="">
156 162
  1 +{{ 商品详情--品牌券 抽屉dom}}
  2 +<div class="coupon-drawer">
  3 + <div class="title">领取优惠券</div>
  4 + <div class="body">
  5 + <ul class="coupon-list">
  6 + {{#each coupons}}
  7 + <li class="coupon">
  8 + <div class="pull-right">
  9 + <button type="button">立刻领取</button>
  10 + </div>
  11 + <div class="coupon-intro">
  12 + <div class="coupon-price">¥ 200</div>
  13 + <div class="coupon-desc">issz品牌优惠券满499减120</div>
  14 + <div class="coupon-time">使用期限: 2016.10.21 ~ 2016.10.22</div>
  15 + </div>
  16 + </li>
  17 + {{/each}}
  18 + </ul>
  19 + </div>
  20 +</div>
@@ -8,7 +8,6 @@ var $ = require('yoho-jquery'), @@ -8,7 +8,6 @@ var $ = require('yoho-jquery'),
8 Hammer = require('yoho-hammer'), 8 Hammer = require('yoho-hammer'),
9 lazyLoad = require('yoho-jquery-lazyload'); 9 lazyLoad = require('yoho-jquery-lazyload');
10 10
11 -  
12 require('./detail/page-render')(function() { 11 require('./detail/page-render')(function() {
13 var $discountFolder = $('.goods-discount .discount-folder'), 12 var $discountFolder = $('.goods-discount .discount-folder'),
14 $discountArrow = $('.goods-discount .first-item span'); 13 $discountArrow = $('.goods-discount .first-item span');
@@ -150,6 +149,7 @@ require('./detail/page-render')(function() { @@ -150,6 +149,7 @@ require('./detail/page-render')(function() {
150 $('#yoho-footer').css('border-top', '1px solid #e0e0e0'); 149 $('#yoho-footer').css('border-top', '1px solid #e0e0e0');
151 } 150 }
152 }); 151 });
  152 +require('./detail/brand-coupon');
153 153
154 154
155 155
  1 +'use strict';
  2 +
  3 +/**
  4 + * 商品详情: 品牌券
  5 + */
  6 +/* eslint-disable */
  7 +var mock_data = [{
  8 + "couponName": "有效期20161017未到,10*2",
  9 + "amount": 10,
  10 + "acquireStatus": 3,
  11 + "createTime": 1476358043,
  12 + "startTime": 1476633600,
  13 + "lifeTime": "2016.10.17-2016.10.28",
  14 + "endTime": 1477584000,
  15 + "couponId": 14200
  16 +}, {
  17 + "couponName": "有效的nike券",
  18 + "amount": 22,
  19 + "acquireStatus": 3,
  20 + "createTime": 1475152374,
  21 + "startTime": 1474992000,
  22 + "lifeTime": "2016.09.28-2016.11.17",
  23 + "endTime": 1479312000,
  24 + "couponId": 14144
  25 +}, {
  26 + "couponName": "有效期内优惠券15*3倍",
  27 + "amount": 15,
  28 + "acquireStatus": 3,
  29 + "createTime": 1476358258,
  30 + "startTime": 1476115200,
  31 + "lifeTime": "2016.10.11-2016.11.18",
  32 + "endTime": 1479398400,
  33 + "couponId": 14202
  34 +}];
  35 +/* eslint-enable */
  36 +
  37 +var tip = require('plugin/tip');
  38 +var $ = require('yoho-jquery');
  39 +
  40 +var brandCoupon = {
  41 + skn: null,
  42 + brandId: null,
  43 + $entry: null,
  44 + $couponDrawer: null,
  45 +
  46 + template: require('product/detail/coupon-list.hbs'),
  47 +
  48 + init: function(skn, brandId) {
  49 + var self = this;
  50 +
  51 + this.skn = skn;
  52 + this.brandId = brandId;
  53 +
  54 + if (!(skn && brandId)) {
  55 + return;
  56 + }
  57 +
  58 + this.fetchCoupons(this.skn, this.brandId)
  59 + .done(function(data) {
  60 + data = mock_data;
  61 +
  62 + if (data.length) {
  63 + self.domInit();
  64 + self.render(data);
  65 + self.bindEvents();
  66 + }
  67 + })
  68 + .fail();
  69 + },
  70 +
  71 + domInit: function() {
  72 + this.$entry = $('.brand-coupon');
  73 +
  74 + this.$entry.removeClass('hide');
  75 + },
  76 +
  77 + bindEvents: function() {
  78 + var self = this;
  79 +
  80 + this.$entry.on('click', function() {
  81 + self.$couponDrawer.addClass('open');
  82 + });
  83 + },
  84 +
  85 + render: function(data) {
  86 + this.$couponDrawer = $(this.template(data));
  87 + this.$couponDrawer.appendTo('body');
  88 +
  89 + return this;
  90 + },
  91 +
  92 + // 获取 品牌券
  93 + fetchCoupons: function(skn, brandId) {
  94 + return $.get('/product/detail/coupon.json', {
  95 + skn: skn,
  96 + brandId: brandId
  97 + });
  98 + },
  99 +
  100 + // 收藏 品牌券
  101 + saveCoupons: function() {
  102 +
  103 + }
  104 +};
  105 +
  106 +
  107 +$(function() {
  108 + brandCoupon.init(
  109 + $('#productSkn').val(),
  110 + $('#brand-id').val()
  111 + );
  112 +});
  1 +/*
  2 + 商品品牌券 CSS
  3 +*/
  4 +
  5 +.good-detail-page {
  6 + .coupon-drawer {
  7 +
  8 + }
  9 +
  10 + .coupon-list {
  11 +
  12 + }
  13 +}
@@ -282,7 +282,8 @@ $basicBtnC: #eb0313; @@ -282,7 +282,8 @@ $basicBtnC: #eb0313;
282 } 282 }
283 } 283 }
284 284
285 - .price-date { 285 + .price-date,
  286 + .brand-coupon {
286 position: relative; 287 position: relative;
287 padding-right: 28px; 288 padding-right: 28px;
288 padding-left: 28px; 289 padding-left: 28px;
@@ -293,6 +294,28 @@ $basicBtnC: #eb0313; @@ -293,6 +294,28 @@ $basicBtnC: #eb0313;
293 color: $subFontC; 294 color: $subFontC;
294 } 295 }
295 296
  297 + .brand-coupon {
  298 + font-size: 28px;
  299 + line-height: 88px;
  300 +
  301 + span {
  302 + color: $mainFontC;
  303 + }
  304 +
  305 + .iconfont {
  306 + font-size: inherit;
  307 + }
  308 +
  309 + .font-right{
  310 + color: $subFontC;
  311 + }
  312 +
  313 + .font-quan {
  314 + color: $basicBtnC;
  315 + margin-right: 15px;
  316 + }
  317 + }
  318 +
296 .limit-sale { 319 .limit-sale {
297 position: absolute; 320 position: absolute;
298 top: 50%; 321 top: 50%;
@@ -2,3 +2,4 @@ @@ -2,3 +2,4 @@
2 @import "comments-consults"; 2 @import "comments-consults";
3 @import "product-description"; 3 @import "product-description";
4 @import "recommend-for-you"; 4 @import "recommend-for-you";
  5 +@import "brand-coupon";