Authored by lijing

支付成功页

/**
* 支付成功页
* @author: jing.li<jing.li@yoho.cn>
* @date: 2016/10/25
*/
'use strict';
const mRoot = '../models';
const payModel = require(`${mRoot}/pay`);
const headerModel = require('../../../doraemon/models/header'); // 头部model
// 货到付款
const payCod = (req, res, next) => {
let headerData = headerModel.setNav({
navTitle: '支付完成'
});
let responseData = {
pageHeader: headerData,
module: 'cart',
page: 'pay',
title: '支付中心 | Yoho!Buy有货 | 潮流购物逛不停'
};
let param = {
uid: req.user.uid,
udid: req.sessionID || require('md5')(req.ip) || 'yoho',
orderCode: req.query.order_code,
contentCode: '05afedf76886d732573f10f7451a1703'
};
// 如果没有uid,跳转到首页
if (!param.uid) {
res.redirect('/');
return;
}
payModel.getPayCod(param).then(result => {
if (result.match === true) {
res.render('pay/pay-cod', Object.assign(responseData, result));
} else {
res.redirect('/');
}
}).catch(next);
};
// 支付宝支付
const payAli = (req, res, next) => {
let headerData = headerModel.setNav({
navTitle: '支付完成'
});
let responseData = {
pageHeader: headerData,
module: 'cart',
page: 'pay',
title: '支付中心 | Yoho!Buy有货 | 潮流购物逛不停'
};
let param = {
uid: req.user.uid,
udid: req.sessionID || require('md5')(req.ip) || 'yoho',
orderCode: req.query.out_trade_no,
contentCode: '05afedf76886d732573f10f7451a1703'
};
// 如果没有uid,跳转到首页
if (!param.uid) {
res.redirect('/');
return;
}
payModel.getPayAli(param).then(result => {
if (result.match === true) {
res.render('pay/pay-ali', Object.assign(responseData, result));
} else {
res.redirect('/');
}
}).catch(next);
};
module.exports = {
payCod,
payAli
};
... ...
/**
<<<<<<< HEAD
* sub app cart
* @author: xuan.chen@yoho.cn<xuan.chen@yoho.cn>
* @date: 2016/09/26
=======
* sub app guang
* @author: Bi Kai<kai.bi@yoho.cn>
* @date: 2016/05/09
>>>>>>> feature/payment
*/
var express = require('express'),
... ... @@ -21,11 +27,18 @@ app.use(global.yoho.hbs({
extname: '.hbs',
defaultLayout: 'layout',
layoutsDir: doraemon,
partialsDir: path.join(__dirname, 'views/partial'),
partialsDir: path.join(__dirname, './views/partial'),
views: path.join(__dirname, 'views/action'),
helpers: global.yoho.helpers
}));
// for zookeeper, inject locals
app.use((req, res, next) => {
req.app.locals.wap = app.locals.wap;
next();
});
// router
app.use(require('./router'));
... ...
/**
* 支付成功页
* @author: jing.li<jing.li@yoho.cn>
* @date: 2016/10/25
*/
'use strict';
const api = global.yoho.API;
const serviceAPI = global.yoho.ServiceAPI;
const utils = '../../../utils';
const productProcess = require(`${utils}/product-process`);
// 资源位
const _getBanner = (param) => {
return serviceAPI.get('operations/api/v5/resource/get', {
content_code: param.contentCode
}, {
code: 200
}).then((result) => {
result = result.data;
return result;
});
};
// 购买此商品的用户也购买了
const _getOthersBuy2 = (param) => {
return api.get('', {
method: 'app.recommend.purchased',
productSkn: param.skn,
udid: param.uid,
rec_pos: '100005',
limit: 2
}, {
code: 200
}).then((result) => {
if (result && result.data && result.data.product_list) {
return productProcess.processProductList(result.data.product_list);
}
});
};
// 订单信息
const _getOtherDetail = (param) => {
return api.get('', {
method: 'app.SpaceOrders.detail',
uid: param.uid,
order_code: param.orderCode
}, {
code: 200
}).then((result) => {
return result;
});
};
// 购买此商品的用户也购买了,要先从订单详情获取商品skn
const _getOthersBuy = (param) => {
return api.all([
_getOtherDetail(param)
]).then((result) => {
let goodSkn = '';
if (result && result[0] && result[0].data && result[0].data.order_goods) {
goodSkn = result[0].data.order_goods[0].product_skn;
}
return _getOthersBuy2(Object.assign(param, {skn: goodSkn}));
}).then((result) => {
return result;
});
};
// 货到付款
const getPayCod = (param) => {
return api.all([
_getBanner(param),
_getOthersBuy(param),
_getOtherDetail(param)
]).then((result) => {
let resu = {
match: true,
banner: [],
othersBuy: []
};
if (result && result[0]) {
resu.banner = result[0];
}
if (result && result[1]) {
resu.othersBuy = result[1];
}
if (result && result[2] && result[2].data && result[2].data.payment_amount) {
resu.payment = result[2].data.payment_amount;
} else {
resu.match = false;
}
resu.orderCode = param.orderCode;
resu.orderUrl = '/home/orders/detail?order_code=' + param.orderCode;
return resu;
});
};
// 支付宝支付
const getPayAli = (param) => {
return api.all([
_getBanner(param),
_getOthersBuy(param),
_getOtherDetail(param)
]).then((result) => {
let resu = {
match: true,
banner: [],
othersBuy: []
};
if (result && result[0]) {
resu.banner = result[0];
}
if (result && result[1]) {
resu.othersBuy = result[1];
}
if (result && result[2] && result[2].data && result[2].data.payment_amount) {
resu.payment = result[2].data.payment_amount;
} else {
resu.match = false;
}
resu.orderCode = param.orderCode;
resu.orderUrl = '/home/orders/detail?order_code=' + param.orderCode;
return resu;
});
};
module.exports = {
getPayCod,
getPayAli
};
... ...
... ... @@ -12,6 +12,7 @@ const authMW = require('../../doraemon/middleware/auth');
const seckill = require(cRoot + '/seckill');
const countController = require(`${cRoot}/count`);
const payController = require(`${cRoot}/pay`);
// Your controller here
router.all('/index/seckill/', authMW);
... ... @@ -21,5 +22,7 @@ router.post('/index/seckill/compute', seckill.compute);
router.post('/index/seckill/submit', seckill.submit);
router.get('/index/count', countController.cartCount);
router.get('/paySuccess/payCod', payController.payCod);// 支付成功,货到付款
router.get('/shopping/pay/aliwapreturn', payController.payAli);// 支付成功,支付宝付款
module.exports = router;
... ...
<div class="pay-success">
<div class="top-tip">
<div class="img-c"></div>
<p class="ok-tip">恭喜您,付款成功!</p>
</div>
<div class="info-table-c">
<table class="info-table">
<tr>
<td>订单编号</td>
<td>{{orderCode}}</td>
</tr>
<tr>
<td>付款金额</td>
<td>¥{{payment}}</td>
</tr>
<tr>
<td>付款方式</td>
<td>支付宝</td>
</tr>
</table>
</div>
<div class="btn-c">
<a href="/">随便逛逛</a>
<a href="{{orderUrl}}">查看订单</a>
</div>
{{# banner}}
{{#data}}
<a href="{{url}}" class="ad-pic" alt="{{alt}}">
<img src="{{image src 640 200}}" />
</a>
{{/data}}
{{/banner}}
<div class="others-buy clearfix">
<p>购买此商品的用户也购买了</p>
{{# othersBuy}}
{{> common/goods}}
{{/ othersBuy}}
</div>
{{> home/maybe-like}}
</div>
... ...
<div class="pay-success">
<div class="top-tip">
<div class="img-c"></div>
<p class="ok-tip">订单提交成功</p>
<p class="left-tip">您需要在收货时向售货员支付¥{{payment}}</p>
</div>
<div class="info-table-c">
<table class="info-table">
<tr>
<td>订单编号</td>
<td>{{orderCode}}</td>
</tr>
<tr>
<td>付款金额</td>
<td>¥{{payment}}</td>
</tr>
<tr>
<td>付款方式</td>
<td>货到付款</td>
</tr>
</table>
</div>
<div class="btn-c">
<a href="/">随便逛逛</a>
<a href="{{orderUrl}}">查看订单</a>
</div>
{{# banner}}
{{#data}}
<a href="{{url}}" class="ad-pic" alt="{{alt}}">
<img src="{{image src 640 200}}" />
</a>
{{/data}}
{{/banner}}
<div class="others-buy clearfix">
<p>购买此商品的用户也购买了</p>
{{# othersBuy}}
{{> common/goods}}
{{/ othersBuy}}
</div>
{{> home/maybe-like}}
</div>
... ...
... ... @@ -16,6 +16,11 @@ module.exports = () => {
req.url = `/activity${req.url}`;
}
if (/^\/shopping\/pay\/aliwapreturn/.test(req.url)) {
// 兼容php的url
req.url = `/cart${req.url}`;
}
if (/^\/sale/.test(req.url)) {
// sale 兼容php的url
res.redirect(301, helpers.urlFormat('/product/sale', req.query, 'default'));
... ...
var $ = require('yoho-jquery'),
lazyLoad = require('yoho-jquery-lazyload');
require('../common');
lazyLoad($('img.lazy'));
function getGender() {
return window.cookie('_Channel') || 'boys';
}
require('../channel/maybe-like')(getGender());
if ($('#goods-list').length === 0) {
$('.maybe-like').hide();
}
... ...
.pay-success {
width: 100%;
overflow: hidden;
position: relative;
background-color: #f0f0f0;
.top-tip {
width: 100%;
height: 240px;
border-bottom: solid 1px #e0e0e0;
text-align: center;
background-color: #fff;
.img-c {
margin-top: 25px;
width: 102px;
height: 102px;
background: resolve("cart/pay-ok.png") no-repeat;
background-size: 100% 100%;
display: inline-block;
}
.ok-tip {
font-size: 24px;
color: #d0021b;
line-height: 60px;
}
.left-tip {
font-size: 19px;
color: #b0b0b0;
}
}
.info-table-c {
height: 160px;
border-bottom: solid 1px #e0e0e0;
padding: 20px 25px;
background-color: #fff;
table {
width: 100%;
tr {
height: 40px;
}
td {
font-size: 24px;
color: #444;
}
td:nth-child(2) {
text-align: right;
}
}
}
.btn-c {
width: 100%;
height: 102px;
background-color: #fff;
border-bottom: solid 1px #e0e0e0;
padding: 0 25px;
a {
width: 270px;
height: 53px;
border: solid 2px #444;
display: block;
float: left;
line-height: 53px;
text-align: center;
border-radius: 5px;
box-sizing: border-box;
-moz-box-sizing: border-box;
margin-top: 24px;
font-size: 24px;
color: #444;
}
a:nth-child(2) {
margin-left: 50px;
}
}
.ad-pic {
width: 100%;
height: 200px;
display: block;
background-color: #fff;
margin: 25px 0;
}
.others-buy {
width: 100%;
margin-bottom: 25px;
background-color: #fff;
padding: 25px 0;
border-top: solid 1px #e4e4e4;
padding-left: 15px;
p {
text-align: center;
color: #444;
font-size: 27px;
}
}
}
... ...
... ... @@ -27,3 +27,4 @@
@import "cart/index";
@import "home/index";
@import "me/index";
@import "cart/pay-success"
... ...