Authored by yyq

套餐结算页

... ... @@ -16,7 +16,14 @@ const getProductInfo = (req, res, next) => {
}).catch(next);
};
// 获取优惠券列表
const getCoupons = (req, res, next) => {
service.getCoupons(req.user.uid).then(data => {
res.send(data);
}).catch(next);
};
module.exports = {
getProductInfo
getProductInfo,
getCoupons
};
... ...
... ... @@ -17,13 +17,15 @@ const index = (req, res, next) => {
let uid = req.user.uid;
let params = req.query;
// params = {bundle: 1124, sku: '809291,789238'};
easypay.getEasypayOrderData(params, uid).then(result => {
let header = headerModel.setSimpleHeaderData() || {};
Object.assign(result, {
stepper: stepper,
couponUnsupport: true // 限定发售不支持优惠券
});
result.stepper = stepper;
if (params.limitcode) { // 限定发售不支持优惠券
result.couponUnsupport = true;
}
res.render('order-ensure', {
page: 'easypay',
... ...
... ... @@ -9,6 +9,7 @@
const Promise = require('bluebird');
const co = Promise.coroutine;
const _ = require('lodash');
const api = global.yoho.API;
const helpers = global.yoho.helpers;
const productAPI = require('./product-api');
... ... @@ -375,6 +376,39 @@ const getProductInfoAsync = (pid) => {
})();
};
// 获取优惠券列表
const getCoupons = (uid) => api.get('', {
method: 'app.Shopping.listCoupon',
uid: uid
}).then(result => {
if (result.code === 200) {
let unuse = [];
let use = [];
_.forEach(result.data.unusable_coupons, i => {
unuse.push({
code: i.coupon_code,
name: i.coupon_name,
value: i.coupon_value,
canuse: false
});
});
_.forEach(result.data.usable_coupons, i => {
use.push({
code: i.coupon_code,
name: i.coupon_name,
value: i.coupon_value
});
});
result.data = _.concat(use, unuse);
}
return result;
});
module.exports = {
getProductInfoAsync // 获取某一个商品详情主页面
getProductInfoAsync, // 获取某一个商品详情主页面
getCoupons // 获取优惠券列表
};
... ...
... ... @@ -7,15 +7,21 @@
const api = global.yoho.API;
const getEasyPaymentAsync = (goods, uid) => {
return api.get('', {
const getEasyPaymentAsync = (uid, goods, activity) => {
let param = {
method: 'app.Shopping.easyPayment',
uid: uid,
cart_type: 'ordinary',
product_sku_list: goods,
yoho_coin_mode: 0,
is_support_apple_pay: 'N'
}, {code: 200});
};
if (activity) {
param.activity_id = activity;
}
return api.get('', param, {code: 200});
};
... ... @@ -71,7 +77,14 @@ const getEasypayComputeAsync = (uid, cartType, paymentType, deliveryWay, other)
Object.assign(param, {
product_sku_list: other.productSkuList
});
if (other.bundle) {
Object.assign(param, {
activity_id: other.bundle
});
}
}
}
return api.get('', param);
... ... @@ -151,6 +164,12 @@ const easypayOrderSubmitAsync = (uid, cartType, addressId, deliveryTime, deliver
Object.assign(param, {
product_sku_list: other.productSkuList
});
if (other.bundle) {
Object.assign(param, {
activity_id: other.bundle
});
}
}
return api.get('', param);
... ...
... ... @@ -126,29 +126,37 @@ const _handelPaymentInfo = (d) => {
};
const _getLimitProductData = (params) => {
let info = {
type: 'limitcode',
buy_number: 1
};
let resList = [];
if (params.sku && params.skn && params.limitcode) {
Object.assign(info, {
if (params.limitcode && params.sku && params.skn) {
resList.push({
type: 'limitcode',
buy_number: 1,
sku: params.sku,
skn: params.skn,
limitproductcode: params.limitcode
});
} else if (params.bundle && params.sku) {
resList = [];
return JSON.stringify([info]);
_.forEach(_.split(params.sku, ',', 10), val => {
resList.push({
type: 'bundle',
sku: parseInt(val, 10),
buy_number: 1
});
});
}
return false;
return resList.length ? JSON.stringify(resList) : false;
};
const getEasypayOrderData = (params, uid) => {
let resData = {};
let strInfo = _getLimitProductData(params);
let bundle = params.bundle ? parseInt(params.bundle, 10) : false;
return easypayApi.getEasyPaymentAsync(strInfo, uid).then(result => {
return easypayApi.getEasyPaymentAsync(uid, strInfo, bundle).then(result => {
let d = _.get(result, 'data', false);
if (d) {
... ...
... ... @@ -15,6 +15,8 @@ const easypay = require(`${cRoot}/easypay`);
router.get('/index/getProductInfo', cart.getProductInfo);
router.get('/coupon/list', cart.getCoupons); // 优惠券列表
router.get('/address/list', address.getList); // 省市区列表信息
router.get('/address/area', address.getArea); // 省市区列表信息
router.post('/address/delete', address.delAddress); // 删除地址
... ...
... ... @@ -158,6 +158,37 @@
</div>
</div>
{{#with shopping_cart_data}}
{{#isY is_multi_package}}
<div class="multi-package-row">
温馨提示:您购买的商品<em class="red">分属不同仓库</em>,需要调拨,将被拆分成多个包裹送达
<span class="iconfont show-package">&#xe628;</span>
<div class="package-list hide">
<div class="package-up-icon"></div>
{{#each ../package_list}}
<div class="package-item">
<p class="package-title bold">包裹{{math @index '+' 1}}:{{#if @first}}总仓发货{{^}}异地调拨{{/if}}</p>
{{#if showToggle}}
<span class="iconfont toggle-icon left-icon">&#xe609;</span>
<span class="iconfont toggle-icon right-icon">&#xe608;</span>
{{/if}}
<div class="package-goods-wrap">
<ul class="package-goods clearfix">
{{#each goods_list}}
<li class="left">
<img class="lazy package-goods-img" data-original="{{image goods_images 90 90}}">
</li>
{{/each}}
</ul>
</div>
<p class="package-shipping">运费:¥{{shopping_cost}}</p>
</div>
{{/each}}
</div>
</div>
{{/isY}}
{{/with}}
<table class="goods-table">
<thead>
<tr>
... ...
... ... @@ -87,6 +87,10 @@ function compute(coin) {
if (queryInfo.limitcode) {
d.limitcode = queryInfo.limitcode;
}
if (queryInfo.bundle) {
d.bundle = queryInfo.bundle;
}
}
$.ajax({
... ... @@ -147,7 +151,7 @@ if ($('#use-coupons').length) {
// 优惠券
$.ajax({
type: 'GET',
url: '/cart/easypay/coupons'
url: '/cart/coupon/list'
}).then(function(data) {
if (data.code === 200) {
$('#coupon-list').prepend(couponsTpl({
... ... @@ -263,6 +267,10 @@ $('#go-pay').click(function() {
if (queryInfo.limitcode) {
d.limitcode = queryInfo.limitcode;
}
if (queryInfo.bundle) {
d.bundle = queryInfo.bundle;
}
}
$.ajax({
... ...