Authored by htoooth

change

... ... @@ -8,7 +8,7 @@ const mRoot = '../models';
const service = require(`${mRoot}/coupon-service`);
const acquire = (req, res, next) => {
let uid = req.yoho.user.uid;
let uid = req.user.uid;
let cid = req.query.couponId || 0;
if (!cid) {
... ... @@ -18,7 +18,10 @@ const acquire = (req, res, next) => {
});
}
service.acquire(cid, uid).then((result) => {
service.acquireAsync(cid, uid).then((result) => {
return res.json({
code: 200
});
}).catch(next);
};
... ...
... ... @@ -5,5 +5,44 @@
'use strict';
const api = require('./coupon-api');
const _ = require('lodash');
const decrypt = _.partial(global.yoho.crypto.decrypt, null);
module.exports = api;
const _acquireAsync = _.overArgs(api.acquireAsync, [decrypt, _.constant]);
const acquireAsync = (cid, uid) => {
return _acquireAsync(cid, uid).then(result => {
switch (result.code) {
case 200:
return {
code: 200,
message: '恭喜您,成功领取优惠券'
};
case 401:
return {
code: 401,
message: '您已领取过优惠券'
};
case 315:
return {
code: 315,
message: '优惠券已过期'
};
case 300:
return {
code: 300,
message: '请求参数错误'
};
default:
return {
code: 500,
message: '领券失败!'
};
}
});
};
module.exports = {
acquireAsync,
listAsync: api.listAsync
};
... ...
... ... @@ -20,6 +20,7 @@ const detailHelper = require('./detail-helper');
const consultService = require('./detail-consult-service');
const commentService = require('./detail-comment-service');
const hotAreaService = require('./detail-hotarea-service');
const couponService = require('./coupon-service');
const brandService = require('./brand-service');
const favoriteProductService = require('./favorite-product-service');
const shopService = require('./shop-service');
... ... @@ -1040,8 +1041,6 @@ const _getCoupon = (coupons) => {
let replace = Fn.update('rule4ShortName', (r)=> r.replace(/¥/g, '¥'));
return Fn.map(Fn.pipe(pickProp, encodeId, replace))(couponList);
return coupons.data;
};
/**
... ... @@ -1085,7 +1084,7 @@ const _detailDataPkg = (origin, uid, vipLevel, cookies) => {
addition: _getProductAdditionInfoAsync(origin), // 预处理所有的数据
fav: _getProductFavoriteDataAsync(uid, result.productId), // 处理收藏喜欢数据
promotion: productAPI.getPromotionAsync(result.skn), // 打折信息
coupon: productAPI.getCouponAsync(propOrigin('brand_info.brand_id'), result.skn, uid) // 优惠券
coupon: couponService.listAsync(propOrigin('brand_info.brand_id'), result.skn, uid) // 优惠券
};
if (propOrigin('isLimitBuy', false) && propOrigin('limitProductCode', '')) {
... ...
... ... @@ -17,7 +17,7 @@ const detail = require(`${cRoot}/detail`);
const favorite = require(`${cRoot}/favorite`);
// 优惠券
const coupon = require('${cRoot}/coupon');
const coupon = require(`${cRoot}/coupon`);
// 商品促销controller
const sale = require(`${cRoot}/sale`);
... ...
... ... @@ -22,334 +22,12 @@
<div class="center-content">
{{> common/path-nav}}
{{# goodsInfo}}
<div class="main clearfix" data-skn="{{skn}}" data-id="{{productId}}" data-md5="{{md5}}"
data-skn="{{skn}}">
<div class="pull-left imgs clearfix">
<div class="pull-left img">
<div class="tags clearfix">
{{# tags}}
{{# isNew}}
<span class="good-tag new-tag">NEW</span>
{{/ isNew}}
{{# isReNew}}
<span class="good-tag renew-tag">再到着</span>
{{/ isReNew}}
{{# isSale}}
<span class="good-tag sale-tag">SALE</span>
{{/ isSale}}
{{# isNewFestival}}
<span class="good-tag new-festival-tag">新品节</span>
{{/ isNewFestival}}
{{# isLimit}}
<span class="good-tag limit-tag">限量商品</span>
{{/ isLimit}}
{{# isYearEndPromotion}}
<span class="good-tag yep-tag">年终大促</span>
{{/ isYearEndPromotion}}
{{# isYearMidPromotion}}
<span class="good-tag ymp-tag">年中热促</span>
{{/ isYearMidPromotion}}
{{/ tags}}
</div>
<img id="img-show" class="img-show" src="{{img}}">
</div>
<div id="thumbs" class="pull-right thumbs">
{{# colors}}
<div class="thumb-wrap{{#unless focus}} hide{{/unless}}">
{{#if focus}}
{{# thumbs}}
<img class="thumb" src="{{img}}" data-shower="{{shower}}">
{{/ thumbs}}
{{^}}
{{# thumbs}}
<img class="thumb lazy" data-original="{{img}}" data-shower="{{shower}}">
{{/ thumbs}}
{{/if}}
</div>
{{/ colors}}
</div>
</div>
<div class="pull-right infos">
<p class="name">
{{name}}
{{#if saleTip}}
<span class="sale-tip">{{saleTip}}</span>
{{/if}}
</p>
<a class="brand-name" href="{{brandUrl}}">{{brandName}}</a>
<p class="market-price">
<span class="title">市场价:</span>
<span class="price{{#if hasOtherPrice}} has-other-price{{/if}}">{{marketPrice}}</span>
</p>
{{#if salePrice}}
<p class="sale-price">
<span class="title">促销价:</span>
<span class="price">{{salePrice}}</span>
</p>
{{/if}}
{{#if presalePrice}}
<p class="presale-price">
<span class="title">预售价:</span>
<span class="price">{{presalePrice}}</span>
<span class="arrival-date">上市期:{{arrivalDate}}</span>
</p>
{{/if}}
{{#if advancePrice}}
<p class="advance-price">
<span class="title">先行价:</span>
<span class="price">{{advancePrice}}</span>
</p>
{{/if}}
{{# vipPrice}}
<p class="vip-price">
{{#if unLogin}}
登录后即可查看vip价格
<a class="login-url" href="{{unLogin}}">立即登录</a>
{{/if}}
{{#if normalUser}}
<span class="vip-price-item">您当前是普通会员,成为VIP享受更多优惠!</span>
{{/if}}
{{# prices}}
<span class="vip-price-item{{#if cur}} cur{{/if}}">
{{name}}
<em>
{{price}}
</em>
</span>
{{/ prices}}
{{#unless unLogin}}
<a class="vip-schedual" href="{{vipSchedualUrl}}">查看我的VIP进度</a>
{{/unless}}
</p>
{{/ vipPrice}}
{{#if studentsPrice}}
<p class="students-price">
<span class="title">学生价</span>
<span class="price">{{studentsPrice}}</span>
</p>
{{/if}}
{{#if activity}}
<ul class="activity">
{{#each activity}}
<li>
{{#if activityImg}}
<a class="img-link" href="{{url}}">
<img src="{{activityImg}}">
</a>
{{^}}
<span class="ac-type">{{type}}</span>
<span class="ac-des">{{des}}</span>
{{/if}}
</li>
{{/each}}
</ul>
{{/if}}
{{> product/coupon-list}}
<div class="trade-content">
<div id="type-chose" class="type-chose">
{{#if virtualGoods}}
<div class="chose-ticket chose-color row clearfix">
<span class="title pull-left">选日期:</span>
<ul class="colors pull-left clearfix">
{{#each colors}}
<li class="{{#if focus}}focus{{/if}} {{#if disable}}disable{{/if}} pull-left"
title="{{title}}" data-color="{{name}}" data-total="{{total}}">
{{name}}
</li>
{{/each}}
</ul>
</div>
<div class="chose-size row clearfix {{#if isTicket}} hide {{/if}}">
<input type="hidden" name="isTicket" value="{{isTicket}}"/>
<span class="title pull-left">
选区域:
</span>
<div id="sizes" class="size-wrapper pull-left">
{{#each colors}}
<ul class="size{{#unless focus}} hide{{/unless}}">
{{#each size}}
<li {{#unless num}}class="disable"{{/unless}} data-sku="{{sku}}"
data-num="{{num}}" data-name="{{name}}">{{name}}</li>
{{/each}}
<span class="size-warn warn-tip hide">
<i class="iconfont">&#xe62c;</i>
请选择区域
</span>
</ul>
{{/each}}
</div>
</div>
{{else}}
<div class="chose-color row clearfix">
<span class="title pull-left">选颜色:</span>
<ul class="colors pull-left clearfix">
{{#each colors}}
<li class="{{#if focus}}focus{{/if}} {{#if disable}}disable{{/if}} pull-left"
title="{{title}}" data-color="{{name}}" data-total="{{total}}">
<img src="{{src}}">
</li>
{{/each}}
</ul>
</div>
<div class="chose-size row clearfix">
<span class="title pull-left">
选尺码:
</span>
<div id="sizes" class="size-wrapper pull-left">
{{#each colors}}
<ul class="size{{#unless focus}} hide{{/unless}}">
{{#each size}}
<li {{#unless num}}class="disable"{{/unless}} data-sku="{{sku}}"
data-num="{{num}}" data-name="{{name}}">{{name}}</li>
{{/each}}
{{#unless virtualGoods}}
<span class="size-ruler"></span>
{{/unless}}
<span class="size-warn warn-tip hide">
<i class="iconfont">&#xe61f;</i>
请选择尺码
</span>
</ul>
{{/each}}
{{#unless virtualGoods}}
<p class="color-size-tip hide"></p>
{{/unless}}
</div>
</div>
{{/if}}
<div class="chose-count row clearfix">
<span class="title pull-left">选数量:</span>
<div class="num-wraper pull-left clearfix">
<span id="num" class="num pull-left">1</span>
<span class="minus-plus pull-left">
<i id="plus-num" class="plus iconfont">&#xe607;</i>
<i id="minus-num" class="minus dis iconfont">&#xe60b;</i>
</span>
{{#each tags}}
{{#if isFew}}
<span class="warn-tip">即将售罄</span>
{{/if}}
{{/each}}
{{# fashionTopGoods}}
{{#if getLimitedCode}}
<span class="lc-btn get-lc{{#if getLimitedCodeDis}} dis{{/if}}">获取限购码</span>
<div class="lc-container hide">
<span class="lc-arrow"></span>
<div class="lc-content">
<div class="qr-code"></div>
<p class="title">打开APP扫描二维码获取限购码</p>
<p class="sub-title">商品开售后即可购买</p>
</div>
</div>
{{/if}}
{{#if hadLimitedCode}}
<span class="lc-btn had-lc">已获取限购码</span>
{{/if}}
{{#if limitedCodeSoldOut}}
<span class="lc-btn lc-sold-out">限购码已抢光</span>
{{/if}}
{{/ fashionTopGoods}}
</div>
</div>
<p class="row">
{{#if virtualGoods}}
{{!-- 电子门票按钮 --}}
{{#if isVirtualBtn}}
<form name="ticket-form" action="//www.yohobuy.com/cart/index/ticketEnsure"
method="POST"
class="hide"></form>
<span id="buy-ticket" class="buy-ticket buy-now item-buy{{#if dis}} dis{{/if}}">立即购买</span>
{{/if}}
{{else}}
{{!-- 各颜色下所有尺码均售罄则只显示售罄按钮 --}}
{{#unless soldOut}}
{{# buyNow}}
<span id="buy-now" class="buy-btn buy-now item-buy{{#if dis}} dis{{/if}}"
data-base="{{buyNowBase}}">立即购买</span>
{{/ buyNow}}
{{# openSoon}}
<span id="open-soon" class="buy-btn item-buy dis">即将开售</span>
{{/ openSoon}}
{{#if notForSale}}
<span class="buy-btn dis">
<i class="iconfont">&#xe61c;</i>
非买品
</span>
{{/if}}
{{#if addToCart}}
<span id="add-to-cart" class="buy-btn item-buy add-to-cart">
<i class="iconfont">&#xe61b;</i>
添加到购物车
</span>
{{/if}}
{{/unless}}
{{/if}}
<span id="sold-out" class="buy-btn dis{{#unless soldOut}} hide{{/unless}}">
<i class="iconfont">&#xe61c;</i>
已售罄
</span>
<span id="collect-product" class="{{#if isCollect}}coled {{/if}}collect-product">
<i class="iconfont">&#xe611;</i>
{{#if isCollect}}
<em>已收藏</em>
{{^}}
<em>收藏商品</em>
{{/if}}
</span>
</p>
<div class="share-row">
<span class="title pull-left">分享商品:</span>
{{> common/share }}
</div>
</div>
<div id="balance" class="balance">
<p class="success-tip">商品已成功添加到购物车!</p>
<p class="cart-total">购物车一共有<span id="cart-num">0</span>件商品</p>
<p class="balance-btns">
<a class="go-cart buy-btn" href="{{goCartUrl}}">
去购物车结算
<i class="iconfont">&#xe60c;</i>
</a>
<span id="keep-shopping" class="keep-shopping">
继续购物
</span>
</p>
</div>
</div>
</div>
{{#if goodsInfo}}
<div class="main clearfix" data-skn="{{goodsInfo.skn}}" data-id="{{goodsInfo.productId}}"
data-md5="{{goodsInfo.md5}}">
{{> product/detail-header}}
</div>
{{/ goodsInfo}}
{{/if}}
{{!-- 因接口原因,暂存size的title的值 --}}
<div id="size-title-json" style="display: none;">{{sizeTitleJson}}</div>
... ...
... ... @@ -130,7 +130,6 @@
</ul>
{{/if}}
{{> product/coupon-list}}
<div class="trade-content">
... ... @@ -256,9 +255,11 @@
{{#if virtualGoods}}
{{!-- 电子门票按钮 --}}
{{#if isVirtualBtn}}
<form name="ticket-form" action="//www.yohobuy.com/cart/index/ticketEnsure" method="POST"
<form name="ticket-form" action="//www.yohobuy.com/cart/index/ticketEnsure"
method="POST"
class="hide"></form>
<span id="buy-ticket" class="buy-ticket buy-now item-buy{{#if dis}} dis{{/if}}">立即购买</span>
<span id="buy-ticket"
class="buy-ticket buy-now item-buy{{#if dis}} dis{{/if}}">立即购买</span>
{{/if}}
{{else}}
{{!-- 各颜色下所有尺码均售罄则只显示售罄按钮 --}}
... ... @@ -322,4 +323,5 @@
</div>
</div>
</div>
{{/ goodsInfo}}
{{/goodsInfo}}
... ...
... ... @@ -587,6 +587,7 @@ bindEvent.add(function() {
var i = $this.data('i');
var $item = $($couponItem.get(i));
console.log(status);
switch (status) {
case 1:
getCouponAsync(couponId).then(function() {
... ... @@ -909,7 +910,7 @@ window.fetchReturn = fetchReturn;
md5: md5
}
}).then(function(result) {
$('.main').html(result);
//$('.main').html(result);
bindEvent.fire();
});
... ...