Authored by yyq

confirm

'use strict';
const _ = require('lodash');
const magazineModel = require('../models/magazine'); // 头部model
const headerModel = require('../../../doraemon/models/header'); // 头部model
const confirm = (req, res, next) => {
req.ctx(magazineModel).getMagazinePayment(req.user.uid, req.query).then(result => {
res.render('magazine-confirm', {
pageHeader: headerModel.setNav({
navTitle: '支付订单',
navBtn: false
}),
page: 'magazine-confirm',
localCss: true,
result
});
});
};
const compute = (req, res, next) => {
};
const submit = (req, res, next) => {
};
module.exports = {
confirm,
compute,
submit
};
... ...
... ... @@ -360,10 +360,25 @@ const payZero = (req, res, next) => {
}).catch(next);
};
const payMagazine = (req, res) => {
res.render('pay/pay-magazine', {
pageHeader: headerModel.setNav({
navTitle: '支付订单',
navBtn: false
}),
page: 'pay-magazine',
localCss: true,
result: {
}
});
};
module.exports = {
payCenter,
pay,
payCod,
payAli,
payZero
payZero,
payMagazine
};
... ...
const _ = require('lodash');
class magazineModel extends global.yoho.BaseModel {
constructor(ctx) {
super(ctx);
}
getMagazinePayment(uid, { sku, buyNumber }) {
return this.get({data: {
method: 'app.Shopping.virtual.ebook.payment',
product_sku: sku,
uid: uid,
buy_number: buyNumber || 1
}}).then((data) => {
if (data.code === 200) {
data = data.data;
let totalPrice = '';
let prices = _.forEach(_.get(data, 'eBook.prices'), val => {
if (val.select === 'Y') {
val.className = 'active';
totalPrice = val.price;
}
});
return {
goodsList: data.goods_list || [],
maxBuyNumber: _.get(data, 'eBook.maxBuyNumber'),
prices,
totalPrice,
};
}
return {};
});
}
}
module.exports = magazineModel;
... ...
... ... @@ -17,8 +17,11 @@ const countController = require(`${cRoot}/count`);
const payController = require(`${cRoot}/pay`);
const indexController = require(`${cRoot}/index`);
const ticketsConfirmController = require(`${cRoot}/ticketsConfirm`);
const magazineController = require(`${cRoot}/magazine`);
const BuyNowController = require(`${cRoot}/buy-now-controller`);
// Your controller here
router.all('/index/seckill/', authMW);
router.all('/index/seckill/*', authMW);
... ... @@ -92,4 +95,7 @@ router.post('/index/submitTicket', ticketsConfirmController.submitTicket);
// 添加门票
router.post('/index/checkTickets', ticketsConfirmController.checkTickets);
router.get('/magazine/ensure', magazineController.confirm); // 电子杂志
router.get('/magazine/pay/success', payController.payMagazine); // 电子杂志支付成功
module.exports = router;
... ...
<div class="yoho-page magazine-confirm-page">
{{# result}}
{{# goodsList}}
<div class="magazine-info">
<div class="thumb">
<img src="{{image goods_images 200 260}}">
</div>
<div class="info">
<p class="name">{{product_name}}</p>
<p class="time">{{bookNumber}}</p>
</div>
</div>
{{/ goodsList}}
<div class="magazine-buy-num">
<div class="buy-num-title">
<div>请选择购买数量</div>
<a href="#">
查看购买说明
<i class="iconfont">&#xe614;</i>
</a>
</div>
<div class="choose-list">
{{# prices}}
<div class="{{className}}" data-price="{{price}}">
<span>
<i class="iconfont choose-btn">&#xe6ea;</i>{{number}}{{unit}}
</span>
<span>{{price}}</span>
</div>
{{/ prices}}
<div class="custom-choose">
<span>
<i class="iconfont choose-btn">&#xe6ea;</i>自定义
</span>
<div class="custom-num">
<input type="text" name="number" placeholder="输入购买数量(10的倍数,如50、100)" data-max="{{maxBuyNumber}}">
</div>
</div>
</div>
</div>
<div class="total-price">总计:<span class="total-num">{{totalPrice}}</span></div>
{{/ result}}
<div class="buy-btn-wrap">
<button>立即支付</button>
</div>
</div>
... ...
<div class="yoho-page pay-magazine-success">
<div class="failure-order">
<div class="status-img"></div>
<p class="status-tip">购买成功!</p>
<p class="download-tip">请下载有货APP查看阅读码和兑换/阅读电子刊。</p>
<a href="#" class="download-btn">
<span class="download-icon"></span>点击下载Yoho!Buy有货
</a>
</div>
</div>
... ...
require('scss/cart/magazine-confirm.page.scss');
... ...
require('scss/cart/pay-magazine.page.scss');
... ...
html,
body {
height: 100%;
}
.main-wrap {
min-height: 100%;
}
.yoho-header {
background-image: none !important;
background-color: initial !important;
.iconfont,
.nav-title {
color: #030303;
}
}
.magazine-confirm-page {
padding-bottom: 150px;
}
.magazine-info {
padding: 34px;
display: flex;
.thumb {
width: 170px;
height: 220px;
margin-right: 34px;
flex-shrink: 0;
flex-grow: 0;
img {
display: block;
width: 100%;
}
}
.info {
font-weight: 500;
font-size: 24px;
line-height: 1.4;
}
.name {
margin-top: 8px;
color: #292934;
}
.time {
margin-top: 18px;
color: #bbb;
}
}
.magazine-buy-num {
margin-top: 35px;
padding: 0 34px;
.buy-num-title {
font-size: 26px;
color: #292934;
display: flex;
justify-content: space-between;
font-weight: 500;
> a {
color: #bbb;
font-size: 24px;
font-weight: 300;
}
}
.choose-list {
margin-top: 6px;
> * {
padding: 25px 0;
display: flex;
justify-content: space-between;
}
.custom-choose {
flex-direction: column;
}
.custom-num {
width: 100%;
background: #e5e8ec;
border-radius: 4px;
margin-top: 25px;
input {
width: 94%;
height: 60px;
margin: 0 auto;
line-height: 60px;
background: none;
border: none;
display: block;
font-size: 24px;
}
}
}
.choose-btn {
width: 50px;
height: 50px;
line-height: 48px;
text-align: center;
font-size: 20px;
color: #fff;
border: 1px solid #bbb;
border-radius: 100%;
margin-right: 17px;
overflow: hidden;
vertical-align: middle;
display: inline-block;
transform: scale(0.8, 0.8);
margin-top: -1px;
}
.active .choose-btn {
background: #292934;
border-color: #292934;
}
}
.total-price {
margin-top: 42px;
font-size: 28px;
font-weight: 500;
color: #292934;
padding: 0 34px;
.total-num {
color: #d90025;
}
}
.buy-btn-wrap {
width: 100%;
height: 136px;
padding: 17px 34px 0;
position: fixed;
left: 0;
bottom: 0;
background-color: #fff;
border-top: 1px solid #eee;
button {
width: 100%;
height: 74px;
display: block;
border-radius: 8px;
background: #292934;
color: #fff;
}
}
... ...
.yoho-header {
background-image: none !important;
background-color: initial !important;
.iconfont,
.nav-title {
color: #030303;
}
}
.pay-magazine-success {
text-align: center;
}
.status-img {
width: 132px;
height: 164px;
background-image: url("img/cart/magazine-pay-ok.png");
background-size: 100% 100%;
background-repeat: no-repeat;
margin: 120px auto 37px;
}
.status-tip {
font-size: 32px;
color: #292934;
margin-bottom: 8px;
font-weight: 500;
padding-left: 30px;
}
.download-tip {
font-size: 25px;
color: #bbb;
margin-bottom: 76px;
}
.download-btn {
width: 410px;
height: 76px;
line-height: 76px;
color: #fff;
background: #292934;
border-radius: 6px;
display: flex;
justify-content: center;
align-items: center;
margin: auto;
.download-icon {
display: inline-block;
width: 42px;
height: 42px;
margin-right: 16px;
background-image: url("img/cart/yohobuy.png");
background-size: 100% 100%;
background-repeat: no-repeat;
}
}
... ...