Authored by yyq

confirm

  1 +'use strict';
  2 +const _ = require('lodash');
  3 +const magazineModel = require('../models/magazine'); // 头部model
  4 +const headerModel = require('../../../doraemon/models/header'); // 头部model
  5 +
  6 +const confirm = (req, res, next) => {
  7 + req.ctx(magazineModel).getMagazinePayment(req.user.uid, req.query).then(result => {
  8 + res.render('magazine-confirm', {
  9 + pageHeader: headerModel.setNav({
  10 + navTitle: '支付订单',
  11 + navBtn: false
  12 + }),
  13 + page: 'magazine-confirm',
  14 + localCss: true,
  15 + result
  16 + });
  17 + });
  18 +};
  19 +
  20 +const compute = (req, res, next) => {
  21 +};
  22 +
  23 +const submit = (req, res, next) => {
  24 +};
  25 +
  26 +module.exports = {
  27 + confirm,
  28 + compute,
  29 + submit
  30 +};
@@ -360,10 +360,25 @@ const payZero = (req, res, next) => { @@ -360,10 +360,25 @@ const payZero = (req, res, next) => {
360 }).catch(next); 360 }).catch(next);
361 }; 361 };
362 362
  363 +
  364 +const payMagazine = (req, res) => {
  365 + res.render('pay/pay-magazine', {
  366 + pageHeader: headerModel.setNav({
  367 + navTitle: '支付订单',
  368 + navBtn: false
  369 + }),
  370 + page: 'pay-magazine',
  371 + localCss: true,
  372 + result: {
  373 + }
  374 + });
  375 +};
  376 +
363 module.exports = { 377 module.exports = {
364 payCenter, 378 payCenter,
365 pay, 379 pay,
366 payCod, 380 payCod,
367 payAli, 381 payAli,
368 - payZero 382 + payZero,
  383 + payMagazine
369 }; 384 };
  1 +const _ = require('lodash');
  2 +
  3 +class magazineModel extends global.yoho.BaseModel {
  4 + constructor(ctx) {
  5 + super(ctx);
  6 + }
  7 + getMagazinePayment(uid, { sku, buyNumber }) {
  8 + return this.get({data: {
  9 + method: 'app.Shopping.virtual.ebook.payment',
  10 + product_sku: sku,
  11 + uid: uid,
  12 + buy_number: buyNumber || 1
  13 + }}).then((data) => {
  14 + if (data.code === 200) {
  15 + data = data.data;
  16 +
  17 + let totalPrice = '';
  18 + let prices = _.forEach(_.get(data, 'eBook.prices'), val => {
  19 + if (val.select === 'Y') {
  20 + val.className = 'active';
  21 + totalPrice = val.price;
  22 + }
  23 + });
  24 +
  25 + return {
  26 + goodsList: data.goods_list || [],
  27 + maxBuyNumber: _.get(data, 'eBook.maxBuyNumber'),
  28 + prices,
  29 + totalPrice,
  30 + };
  31 + }
  32 +
  33 + return {};
  34 + });
  35 + }
  36 +}
  37 +
  38 +module.exports = magazineModel;
@@ -17,8 +17,11 @@ const countController = require(`${cRoot}/count`); @@ -17,8 +17,11 @@ const countController = require(`${cRoot}/count`);
17 const payController = require(`${cRoot}/pay`); 17 const payController = require(`${cRoot}/pay`);
18 const indexController = require(`${cRoot}/index`); 18 const indexController = require(`${cRoot}/index`);
19 const ticketsConfirmController = require(`${cRoot}/ticketsConfirm`); 19 const ticketsConfirmController = require(`${cRoot}/ticketsConfirm`);
  20 +const magazineController = require(`${cRoot}/magazine`);
  21 +
20 const BuyNowController = require(`${cRoot}/buy-now-controller`); 22 const BuyNowController = require(`${cRoot}/buy-now-controller`);
21 23
  24 +
22 // Your controller here 25 // Your controller here
23 router.all('/index/seckill/', authMW); 26 router.all('/index/seckill/', authMW);
24 router.all('/index/seckill/*', authMW); 27 router.all('/index/seckill/*', authMW);
@@ -92,4 +95,7 @@ router.post('/index/submitTicket', ticketsConfirmController.submitTicket); @@ -92,4 +95,7 @@ router.post('/index/submitTicket', ticketsConfirmController.submitTicket);
92 // 添加门票 95 // 添加门票
93 router.post('/index/checkTickets', ticketsConfirmController.checkTickets); 96 router.post('/index/checkTickets', ticketsConfirmController.checkTickets);
94 97
  98 +router.get('/magazine/ensure', magazineController.confirm); // 电子杂志
  99 +router.get('/magazine/pay/success', payController.payMagazine); // 电子杂志支付成功
  100 +
95 module.exports = router; 101 module.exports = router;
  1 +<div class="yoho-page magazine-confirm-page">
  2 + {{# result}}
  3 + {{# goodsList}}
  4 + <div class="magazine-info">
  5 + <div class="thumb">
  6 + <img src="{{image goods_images 200 260}}">
  7 + </div>
  8 + <div class="info">
  9 + <p class="name">{{product_name}}</p>
  10 + <p class="time">{{bookNumber}}</p>
  11 +
  12 + </div>
  13 + </div>
  14 + {{/ goodsList}}
  15 + <div class="magazine-buy-num">
  16 + <div class="buy-num-title">
  17 + <div>请选择购买数量</div>
  18 + <a href="#">
  19 + 查看购买说明
  20 + <i class="iconfont">&#xe614;</i>
  21 + </a>
  22 + </div>
  23 + <div class="choose-list">
  24 + {{# prices}}
  25 + <div class="{{className}}" data-price="{{price}}">
  26 + <span>
  27 + <i class="iconfont choose-btn">&#xe6ea;</i>{{number}}{{unit}}
  28 + </span>
  29 + <span>{{price}}</span>
  30 + </div>
  31 + {{/ prices}}
  32 + <div class="custom-choose">
  33 + <span>
  34 + <i class="iconfont choose-btn">&#xe6ea;</i>自定义
  35 + </span>
  36 + <div class="custom-num">
  37 + <input type="text" name="number" placeholder="输入购买数量(10的倍数,如50、100)" data-max="{{maxBuyNumber}}">
  38 + </div>
  39 + </div>
  40 + </div>
  41 + </div>
  42 + <div class="total-price">总计:<span class="total-num">{{totalPrice}}</span></div>
  43 + {{/ result}}
  44 +
  45 + <div class="buy-btn-wrap">
  46 + <button>立即支付</button>
  47 + </div>
  48 +</div>
  1 +<div class="yoho-page pay-magazine-success">
  2 + <div class="failure-order">
  3 + <div class="status-img"></div>
  4 + <p class="status-tip">购买成功!</p>
  5 + <p class="download-tip">请下载有货APP查看阅读码和兑换/阅读电子刊。</p>
  6 +
  7 + <a href="#" class="download-btn">
  8 + <span class="download-icon"></span>点击下载Yoho!Buy有货
  9 + </a>
  10 + </div>
  11 +</div>
  1 +require('scss/cart/magazine-confirm.page.scss');
  1 +require('scss/cart/pay-magazine.page.scss');
  1 +
  2 +html,
  3 +body {
  4 + height: 100%;
  5 +}
  6 +
  7 +.main-wrap {
  8 + min-height: 100%;
  9 +}
  10 +
  11 +.yoho-header {
  12 + background-image: none !important;
  13 + background-color: initial !important;
  14 +
  15 + .iconfont,
  16 + .nav-title {
  17 + color: #030303;
  18 + }
  19 +}
  20 +
  21 +.magazine-confirm-page {
  22 + padding-bottom: 150px;
  23 +}
  24 +
  25 +.magazine-info {
  26 + padding: 34px;
  27 + display: flex;
  28 +
  29 + .thumb {
  30 + width: 170px;
  31 + height: 220px;
  32 + margin-right: 34px;
  33 + flex-shrink: 0;
  34 + flex-grow: 0;
  35 +
  36 + img {
  37 + display: block;
  38 + width: 100%;
  39 + }
  40 + }
  41 +
  42 + .info {
  43 + font-weight: 500;
  44 + font-size: 24px;
  45 + line-height: 1.4;
  46 + }
  47 +
  48 + .name {
  49 + margin-top: 8px;
  50 + color: #292934;
  51 + }
  52 +
  53 + .time {
  54 + margin-top: 18px;
  55 + color: #bbb;
  56 + }
  57 +}
  58 +
  59 +.magazine-buy-num {
  60 + margin-top: 35px;
  61 + padding: 0 34px;
  62 +
  63 + .buy-num-title {
  64 + font-size: 26px;
  65 + color: #292934;
  66 + display: flex;
  67 + justify-content: space-between;
  68 + font-weight: 500;
  69 +
  70 + > a {
  71 + color: #bbb;
  72 + font-size: 24px;
  73 + font-weight: 300;
  74 + }
  75 + }
  76 +
  77 + .choose-list {
  78 + margin-top: 6px;
  79 +
  80 + > * {
  81 + padding: 25px 0;
  82 + display: flex;
  83 + justify-content: space-between;
  84 + }
  85 +
  86 + .custom-choose {
  87 + flex-direction: column;
  88 + }
  89 +
  90 + .custom-num {
  91 + width: 100%;
  92 + background: #e5e8ec;
  93 + border-radius: 4px;
  94 + margin-top: 25px;
  95 +
  96 + input {
  97 + width: 94%;
  98 + height: 60px;
  99 + margin: 0 auto;
  100 + line-height: 60px;
  101 + background: none;
  102 + border: none;
  103 + display: block;
  104 + font-size: 24px;
  105 + }
  106 + }
  107 + }
  108 +
  109 + .choose-btn {
  110 + width: 50px;
  111 + height: 50px;
  112 + line-height: 48px;
  113 + text-align: center;
  114 + font-size: 20px;
  115 + color: #fff;
  116 + border: 1px solid #bbb;
  117 + border-radius: 100%;
  118 + margin-right: 17px;
  119 + overflow: hidden;
  120 + vertical-align: middle;
  121 + display: inline-block;
  122 + transform: scale(0.8, 0.8);
  123 + margin-top: -1px;
  124 + }
  125 +
  126 + .active .choose-btn {
  127 + background: #292934;
  128 + border-color: #292934;
  129 + }
  130 +}
  131 +
  132 +.total-price {
  133 + margin-top: 42px;
  134 + font-size: 28px;
  135 + font-weight: 500;
  136 + color: #292934;
  137 + padding: 0 34px;
  138 +
  139 + .total-num {
  140 + color: #d90025;
  141 + }
  142 +}
  143 +
  144 +.buy-btn-wrap {
  145 + width: 100%;
  146 + height: 136px;
  147 + padding: 17px 34px 0;
  148 + position: fixed;
  149 + left: 0;
  150 + bottom: 0;
  151 + background-color: #fff;
  152 + border-top: 1px solid #eee;
  153 +
  154 + button {
  155 + width: 100%;
  156 + height: 74px;
  157 + display: block;
  158 + border-radius: 8px;
  159 + background: #292934;
  160 + color: #fff;
  161 + }
  162 +}
  1 +
  2 +.yoho-header {
  3 + background-image: none !important;
  4 + background-color: initial !important;
  5 +
  6 + .iconfont,
  7 + .nav-title {
  8 + color: #030303;
  9 + }
  10 +}
  11 +
  12 +.pay-magazine-success {
  13 + text-align: center;
  14 +}
  15 +
  16 +.status-img {
  17 + width: 132px;
  18 + height: 164px;
  19 + background-image: url("img/cart/magazine-pay-ok.png");
  20 + background-size: 100% 100%;
  21 + background-repeat: no-repeat;
  22 + margin: 120px auto 37px;
  23 +}
  24 +
  25 +.status-tip {
  26 + font-size: 32px;
  27 + color: #292934;
  28 + margin-bottom: 8px;
  29 + font-weight: 500;
  30 + padding-left: 30px;
  31 +}
  32 +
  33 +.download-tip {
  34 + font-size: 25px;
  35 + color: #bbb;
  36 + margin-bottom: 76px;
  37 +}
  38 +
  39 +.download-btn {
  40 + width: 410px;
  41 + height: 76px;
  42 + line-height: 76px;
  43 + color: #fff;
  44 + background: #292934;
  45 + border-radius: 6px;
  46 + display: flex;
  47 + justify-content: center;
  48 + align-items: center;
  49 + margin: auto;
  50 +
  51 + .download-icon {
  52 + display: inline-block;
  53 + width: 42px;
  54 + height: 42px;
  55 + margin-right: 16px;
  56 + background-image: url("img/cart/yohobuy.png");
  57 + background-size: 100% 100%;
  58 + background-repeat: no-repeat;
  59 + }
  60 +}