Authored by yyq

店铺优惠券

@@ -6,11 +6,13 @@ @@ -6,11 +6,13 @@
6 'use strict'; 6 'use strict';
7 const utils = '../../../utils'; 7 const utils = '../../../utils';
8 const searchApi = require('./search-api'); 8 const searchApi = require('./search-api');
  9 +const shopApi = require('./shop-api');
9 const headerModel = require('../../../doraemon/models/header'); 10 const headerModel = require('../../../doraemon/models/header');
10 const productProcess = require(`${utils}/product-process`); 11 const productProcess = require(`${utils}/product-process`);
11 const searchHandler = require('./search-handler'); 12 const searchHandler = require('./search-handler');
12 const shopHandler = require('./shop-handler'); 13 const shopHandler = require('./shop-handler');
13 const helpers = global.yoho.helpers; 14 const helpers = global.yoho.helpers;
  15 +const crypto = global.yoho.crypto;
14 const _ = require('lodash'); 16 const _ = require('lodash');
15 17
16 const limitNum = 60; // 商品每页显示数目 18 const limitNum = 60; // 商品每页显示数目
@@ -544,7 +546,8 @@ const getShopData = (shopId, channel, params, shopInfo) => { @@ -544,7 +546,8 @@ const getShopData = (shopId, channel, params, shopInfo) => {
544 searchApi.getProductList(Object.assign({ 546 searchApi.getProductList(Object.assign({
545 shop_id: shopId 547 shop_id: shopId
546 }, params)), // 搜索店铺商品 548 }, params)), // 搜索店铺商品
547 - searchApi.getShopBrands(shopId) // 店铺品牌数据 549 + searchApi.getShopBrands(shopId), // 店铺品牌数据
  550 + shopApi.shopCouponListAsync(792) // 店铺优惠券数据
548 ]).then(result => { 551 ]).then(result => {
549 let finalResult = {}; 552 let finalResult = {};
550 553
@@ -614,6 +617,29 @@ const getShopData = (shopId, channel, params, shopInfo) => { @@ -614,6 +617,29 @@ const getShopData = (shopId, channel, params, shopInfo) => {
614 }); 617 });
615 } 618 }
616 619
  620 + if (result[4].data && !_.isEmpty(result[4].data)) {
  621 + let data = result[4].data,
  622 + length = data.length || 0;
  623 +
  624 + if (length) {
  625 + _.forEach(data, value => {
  626 + Object.assign(value, {
  627 + coupon_id: crypto.encryption('', `${value.coupon_id}`),
  628 + money: +value.money
  629 + });
  630 + });
  631 +
  632 + if (length === 1) {
  633 + data[0].showUnit = true;
  634 + }
  635 + finalResult.coupon = {
  636 + list: data,
  637 + length: data.length,
  638 + showNextBtn: length > 3
  639 + };
  640 + }
  641 + }
  642 +
617 // 根据品牌获取分类 (腾讯云测试没有该接口,暂时不调用分类) 643 // 根据品牌获取分类 (腾讯云测试没有该接口,暂时不调用分类)
618 apiMethod.push(searchApi.getSortList({brand: shopBrandIds})); 644 apiMethod.push(searchApi.getSortList({brand: shopBrandIds}));
619 apiMethod = _.concat(apiMethod, articleApiMethod); 645 apiMethod = _.concat(apiMethod, articleApiMethod);
@@ -14,3 +14,22 @@ exports.shopsDecoratorListAsync = shopId => { @@ -14,3 +14,22 @@ exports.shopsDecoratorListAsync = shopId => {
14 shop_id: shopId 14 shop_id: shopId
15 }); 15 });
16 }; 16 };
  17 +
  18 +/**
  19 + * 获取店铺优惠券接口
  20 + */
  21 +exports.shopCouponListAsync = (shopId, uid) => {
  22 + let extra = {
  23 + code: 200
  24 + };
  25 +
  26 + if (!uid) {
  27 + extra.cache = true;
  28 + }
  29 +
  30 + return api.get('', {
  31 + method: 'shop.coupons.list',
  32 + shop_id: shopId,
  33 + uid: uid
  34 + }, extra);
  35 +};
1 -  
2 -<div class="top-coupon-wrap num1"> 1 +{{# coupon}}
  2 +<div class="top-coupon-wrap num{{length}}">
3 <div class="coupon-title"></div> 3 <div class="coupon-title"></div>
4 <ul class="coupon-list clearfix"> 4 <ul class="coupon-list clearfix">
5 - <li class="coupon-item">  
6 - <div class="cp-info">  
7 - <em class="price">¥ 1000</em>  
8 - <p class="limit-text">满 ¥ 5999使用</p>  
9 - <p class="term">有效日期:2016.11.11 ~ 2016.11.11</p>  
10 - </div>  
11 - <div class="pick-btn">点击领取</div>  
12 - </li>  
13 - <li class="coupon-item">  
14 - <div class="cp-info">  
15 - <em class="price">¥ 1000</em>  
16 - <p class="limit-text">满 ¥ 5999使用</p>  
17 - <p class="term">有效日期:2016.11.11 ~ 2016.11.11</p>  
18 - </div>  
19 - <div class="pick-btn">点击领取</div>  
20 - </li>  
21 - <li class="coupon-item">  
22 - <div class="cp-info">  
23 - <em class="price">¥ 1000</em>  
24 - <p class="limit-text">满 ¥ 5999使用</p>  
25 - <p class="term">有效日期:2016.11.11 ~ 2016.11.11</p>  
26 - </div>  
27 - <div class="pick-btn">点击领取</div>  
28 - </li>  
29 - <li class="coupon-item"></li> 5 + {{# list}}
  6 + <li class="coupon-item">
  7 + <div class="cp-info">
  8 + <em class="price">¥ {{money}}{{#if showUnit}}优惠券{{/if}}</em>
  9 + <p class="limit-text">{{coupon_name}}</p>
  10 + <p class="term">有效日期:{{couponValidity}}</p>
  11 + </div>
  12 + <div class="pick-btn" data-id={{coupon_id}}>点击领取</div>
  13 + </li>
  14 + {{/ list}}
30 </ul> 15 </ul>
31 - <div class="coupon-next-btn">  
32 - </div>  
33 -</div>  
  16 + {{#if showNextBtn}}
  17 + <div class="coupon-next-btn">
  18 + <i class="iconfont">&#xe608;</i>
  19 + </div>
  20 + {{/if}}
  21 +</div>
  22 +{{/ coupon}}
@@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
3 height: 80px; 3 height: 80px;
4 margin-bottom: 20px; 4 margin-bottom: 20px;
5 font-size: 0; 5 font-size: 0;
  6 + position: relative;
6 7
7 .coupon-title { 8 .coupon-title {
8 width: 164px; 9 width: 164px;
@@ -59,6 +60,12 @@ @@ -59,6 +60,12 @@
59 padding: 16px 0 0 16px; 60 padding: 16px 0 0 16px;
60 float: left; 61 float: left;
61 62
  63 + > p {
  64 + text-overflow: ellipsis;
  65 + white-space: nowrap;
  66 + overflow: hidden;
  67 + }
  68 +
62 .price { 69 .price {
63 font-size: 38px; 70 font-size: 38px;
64 font-weight: 500; 71 font-weight: 500;
@@ -158,4 +165,24 @@ @@ -158,4 +165,24 @@
158 white-space: nowrap; 165 white-space: nowrap;
159 } 166 }
160 } 167 }
  168 +
  169 + &.num3 .coupon-item {
  170 + width: 244px;
  171 + }
  172 +
  173 + .coupon-next-btn {
  174 + width: 34px;
  175 + height: 80px;
  176 + line-height: 80px;
  177 + background: #d0021b;
  178 + text-align: center;
  179 + position: absolute;
  180 + right: 0;
  181 + cursor: pointer;
  182 +
  183 + .iconfont {
  184 + font-size: 24px;
  185 + color: #fff;
  186 + }
  187 + }
161 } 188 }