Authored by htoooth

add

/**
* Created by TaoHuang on 2016/10/26.
*/
'use strict';
exports.if_cond = (left, operator, right, options) => {
switch (operator) {
case '==':
return (left == right) ? options.fn(this) : options.inverse(this); // eslint-disable-line
case '===':
return (left === right) ? options.fn(this) : options.inverse(this);
case '<':
return (left < right) ? options.fn(this) : options.inverse(this);
case '<=':
return (left <= right) ? options.fn(this) : options.inverse(this);
case '>':
return (left > right) ? options.fn(this) : options.inverse(this);
case '>=':
return (left >= right) ? options.fn(this) : options.inverse(this);
case '&&':
return (left && right) ? options.fn(this) : options.inverse(this);
case '||':
return (left || right) ? options.fn(this) : options.inverse(this);
default:
return options.inverse(this);
}
};
... ...
... ... @@ -24,7 +24,7 @@ app.engine('.hbs', hbs({
defaultLayout: 'layout',
layoutsDir: doraemon,
partialsDir: [path.join(__dirname, 'views/partial'), `${doraemon}/partial`],
helpers: global.yoho.helpers
helpers: Object.assign(require('./helper'), global.yoho.helpers)
}));
// router
... ...
... ... @@ -104,17 +104,87 @@ const getLimitedProductStatusAsync = (code, uid, skn) => {
};
const getCouponAsync = (bid, skn, uid) => {
let params = {
method: 'app.coupons.queryProdPageCoupons',
brandId: bid,
skn: skn
};
if (uid) {
params.uid = uid;
}
return api.get('', params);
//let params = {
// method: 'app.coupons.queryProdPageCoupons',
// brandId: bid,
// skn: skn
//};
//
//if (uid) {
// params.uid = uid;
//}
//
//return api.get('', params);
return Promise.resolve({
"alg": "SALT_MD5",
"code": 200,
"data": [
{
"couponName": "满¥199减10",
"amount": 10,
"acquireStatus": 3,
"createTime": 1476358043,
"startTime": 1476633600,
"lifeTime": "2016.10.17-2016.10.28",
"endTime": 1477584000,
"couponId": 14200
},
{
"couponName": "满¥199减10",
"amount": 22,
"acquireStatus": 3,
"createTime": 1475152374,
"startTime": 1474992000,
"lifeTime": "2016.09.28-2016.11.17",
"endTime": 1479312000,
"couponId": 14144
},
{
"couponName": "满¥199减10",
"amount": 15,
"acquireStatus": 3,
"createTime": 1476358258,
"startTime": 1476115200,
"lifeTime": "2016.10.11-2016.11.18",
"endTime": 1479398400,
"couponId": 14202
},
{
"couponName": "满¥199减10",
"amount": 10,
"acquireStatus": 3,
"createTime": 1476358043,
"startTime": 1476633600,
"lifeTime": "2016.10.17-2016.10.28",
"endTime": 1477584000,
"couponId": 14200
},
{
"couponName": "满¥199减10",
"amount": 22,
"acquireStatus": 3,
"createTime": 1475152374,
"startTime": 1474992000,
"lifeTime": "2016.09.28-2016.11.17",
"endTime": 1479312000,
"couponId": 14144
},
{
"couponName": "满¥199减10",
"amount": 15,
"acquireStatus": 3,
"createTime": 1476358258,
"startTime": 1476115200,
"lifeTime": "2016.10.11-2016.11.18",
"endTime": 1479398400,
"couponId": 14202
}
],
"md5": "fe8f6e48b14c8f0b5044cb73d7c79900",
"message": "操作成功"
}
);
};
module.exports = {
... ...
... ... @@ -12,6 +12,7 @@ const _ = require('lodash');
const Fn = require('lodash/fp');
const url = require('url');
const helpers = global.yoho.helpers;
const crypto = global.yoho.crypto;
const productAPI = require('./detail-product-api');
const detailHelper = require('./detail-helper');
... ... @@ -1033,9 +1034,11 @@ const _getCoupon = (coupons) => {
}
let couponList = _.get(coupons, 'data', []);
let getProp = Fn.map(Fn.pick(['couponName', 'amount', 'couponId']));
return getProp(couponList);
let pickProp = Fn.pick(['couponName', 'amount', 'couponId', 'acquireStatus']);
let encodeId = Fn.update('couponId', (cid) => crypto.encryption(null, cid + ''));
return Fn.map(Fn.pipe(pickProp, encodeId))(couponList);
};
/**
... ... @@ -1100,7 +1103,7 @@ const _detailDataPkg = (origin, uid, vipLevel, cookies) => {
let additionalData = requestData.addition;
let favoriteData = requestData.fav;
let promotionData = requestData.promotion;
let coupoon = requestData.coupon;
let coupon = requestData.coupon;
let limitedInfo = requestData.limited;
let domainBrand = requestData.brand;
... ... @@ -1137,7 +1140,7 @@ const _detailDataPkg = (origin, uid, vipLevel, cookies) => {
}
// 优惠券
result.coupon = _getCoupon(coupoon);
result.coupon = _getCoupon(coupon);
// 有货币
if (!_.includes(['', '0'], propOrigin('yohoCoinNum'))) {
... ...
... ... @@ -156,7 +156,7 @@
</ul>
{{/if}}
{{> product/coupon}}
{{> product/coupon-list}}
<div class="trade-content">
<div id="type-chose" class="type-chose">
... ...
<div class="coupon-list">
<ul>
{{#each coupon}}
{{#if @first}}
<li>
<a class="left">领券:</a>
</li>
{{/if}}
{{!大于三条记录}}
{{#if_cond @index '==' 3}}
<li>
<a class="left more-coupon more-desc">更多</a>
</li>
{{/if_cond}}
{{!大于三条记录不显示}}
<li class="{{#if_cond @index '>=' 3}}hide{{/if_cond}}">
<div class="small"
data-id="{{couponId}}"
data-name="{{couponName}}"
data-amount="{{amount}}"
data-status="{{acquireStatus}}">
<a class="more-coupon small-desc">{{couponName}}</a>
</div>
</li>
{{/each}}
</ul>
</div>
... ...
... ... @@ -130,6 +130,9 @@
</ul>
{{/if}}
{{> product/coupon-list}}
<div class="trade-content">
<div id="type-chose" class="type-chose">
{{#if virtualGoods}}
... ... @@ -319,4 +322,4 @@
</div>
</div>
</div>
{{/ goodsInfo}}
\ No newline at end of file
{{/ goodsInfo}}
... ...
... ... @@ -16,8 +16,10 @@ module.exports = {
siteUrl: 'http://www.yohobuy.com',
domains: {
favApi: 'http://192.168.102.31:8092/brower',
api: 'http://api-test3.yohops.com:9999/',
service: 'http://service-test3.yohops.com:9999/',
//api: 'http://api-test3.yohops.com:9999/',
//service: 'http://service-test3.yohops.com:9999/',
api: 'http://api.yoho.cn/',
service: 'http://service.yoho.cn/',
search: 'http://192.168.102.216:8080/yohosearch/'
},
subDomains: {
... ...
... ... @@ -229,6 +229,17 @@
}
}
.coupon-list {
.small {
float: left;
color: white !important;
width: 86px;
height: 18px;
font-size: 12px;
background: resolve("product/coupon-small.png") no-repeat;
}
}
.ac-type {
display: inline-block;
width: 60px;
... ...