Authored by yyq

店铺优惠券

... ... @@ -6,11 +6,13 @@
'use strict';
const utils = '../../../utils';
const searchApi = require('./search-api');
const shopApi = require('./shop-api');
const headerModel = require('../../../doraemon/models/header');
const productProcess = require(`${utils}/product-process`);
const searchHandler = require('./search-handler');
const shopHandler = require('./shop-handler');
const helpers = global.yoho.helpers;
const crypto = global.yoho.crypto;
const _ = require('lodash');
const limitNum = 60; // 商品每页显示数目
... ... @@ -544,7 +546,8 @@ const getShopData = (shopId, channel, params, shopInfo) => {
searchApi.getProductList(Object.assign({
shop_id: shopId
}, params)), // 搜索店铺商品
searchApi.getShopBrands(shopId) // 店铺品牌数据
searchApi.getShopBrands(shopId), // 店铺品牌数据
shopApi.shopCouponListAsync(792) // 店铺优惠券数据
]).then(result => {
let finalResult = {};
... ... @@ -614,6 +617,29 @@ const getShopData = (shopId, channel, params, shopInfo) => {
});
}
if (result[4].data && !_.isEmpty(result[4].data)) {
let data = result[4].data,
length = data.length || 0;
if (length) {
_.forEach(data, value => {
Object.assign(value, {
coupon_id: crypto.encryption('', `${value.coupon_id}`),
money: +value.money
});
});
if (length === 1) {
data[0].showUnit = true;
}
finalResult.coupon = {
list: data,
length: data.length,
showNextBtn: length > 3
};
}
}
// 根据品牌获取分类 (腾讯云测试没有该接口,暂时不调用分类)
apiMethod.push(searchApi.getSortList({brand: shopBrandIds}));
apiMethod = _.concat(apiMethod, articleApiMethod);
... ...
... ... @@ -14,3 +14,22 @@ exports.shopsDecoratorListAsync = shopId => {
shop_id: shopId
});
};
/**
* 获取店铺优惠券接口
*/
exports.shopCouponListAsync = (shopId, uid) => {
let extra = {
code: 200
};
if (!uid) {
extra.cache = true;
}
return api.get('', {
method: 'shop.coupons.list',
shop_id: shopId,
uid: uid
}, extra);
};
... ...
<div class="top-coupon-wrap num1">
{{# coupon}}
<div class="top-coupon-wrap num{{length}}">
<div class="coupon-title"></div>
<ul class="coupon-list clearfix">
<li class="coupon-item">
<div class="cp-info">
<em class="price">¥ 1000</em>
<p class="limit-text">满 ¥ 5999使用</p>
<p class="term">有效日期:2016.11.11 ~ 2016.11.11</p>
</div>
<div class="pick-btn">点击领取</div>
</li>
<li class="coupon-item">
<div class="cp-info">
<em class="price">¥ 1000</em>
<p class="limit-text">满 ¥ 5999使用</p>
<p class="term">有效日期:2016.11.11 ~ 2016.11.11</p>
</div>
<div class="pick-btn">点击领取</div>
</li>
<li class="coupon-item">
<div class="cp-info">
<em class="price">¥ 1000</em>
<p class="limit-text">满 ¥ 5999使用</p>
<p class="term">有效日期:2016.11.11 ~ 2016.11.11</p>
</div>
<div class="pick-btn">点击领取</div>
</li>
<li class="coupon-item"></li>
{{# list}}
<li class="coupon-item">
<div class="cp-info">
<em class="price">¥ {{money}}{{#if showUnit}}优惠券{{/if}}</em>
<p class="limit-text">{{coupon_name}}</p>
<p class="term">有效日期:{{couponValidity}}</p>
</div>
<div class="pick-btn" data-id={{coupon_id}}>点击领取</div>
</li>
{{/ list}}
</ul>
<div class="coupon-next-btn">
</div>
</div>
\ No newline at end of file
{{#if showNextBtn}}
<div class="coupon-next-btn">
<i class="iconfont">&#xe608;</i>
</div>
{{/if}}
</div>
{{/ coupon}}
... ...
... ... @@ -3,6 +3,7 @@
height: 80px;
margin-bottom: 20px;
font-size: 0;
position: relative;
.coupon-title {
width: 164px;
... ... @@ -59,6 +60,12 @@
padding: 16px 0 0 16px;
float: left;
> p {
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
}
.price {
font-size: 38px;
font-weight: 500;
... ... @@ -158,4 +165,24 @@
white-space: nowrap;
}
}
&.num3 .coupon-item {
width: 244px;
}
.coupon-next-btn {
width: 34px;
height: 80px;
line-height: 80px;
background: #d0021b;
text-align: center;
position: absolute;
right: 0;
cursor: pointer;
.iconfont {
font-size: 24px;
color: #fff;
}
}
}
... ...