Authored by htoooth

Merge branch 'feature/yohood' into release/5.9

  1 +/**
  2 + * 立即购买controller
  3 + * @author: yyq<yanqing.yang@yoho.cn>
  4 + * @date: 2016/9/23
  5 + */
  6 +'use strict';
  7 +
  8 +const headerModel = require('../../../doraemon/models/simple-header');
  9 +const ticketService = require('../models/ticket-service');
  10 +const _ = require('lodash');
  11 +
  12 +const stepper = [
  13 + { name: '填写订单', focus: true },
  14 + { name: '付款,完成购买' }
  15 +];
  16 +
  17 +const ticketEnsure = (req, res, next) => {
  18 + let uid = req.user.uid;
  19 + let sku = req.body.productSku || 0;
  20 + let buyNumber = req.body.buyNumber || 0;
  21 +
  22 + ticketService.addTicket(uid, sku, buyNumber).then(result => {
  23 + let header = headerModel.setSimpleHeaderData() || {};
  24 +
  25 + result.stepper = stepper;
  26 +
  27 + res.render('ticket-ensure', {
  28 + title: '填写订单 | ' + (res.locals.title || ''),
  29 + page: 'ticket',
  30 + content: result,
  31 + simpleHeader: header,
  32 + pageClass: 'order-easypay-page'
  33 + });
  34 + }).catch(next);
  35 +};
  36 +
  37 +const ticketSubmit = (req, res, next) => {
  38 + let uid = req.user.uid;
  39 + let sku = req.body.sku || 0;
  40 + let count = req.body.count || 0;
  41 + let mobile = req.body.mobile || 0;
  42 + let yohoCoin = req.body.yohoCoin || 0;
  43 +
  44 + if (!sku || !count || !mobile) {
  45 + return res.json({
  46 + code: 410,
  47 + message: '参数错误'
  48 + });
  49 + }
  50 +
  51 + ticketService.submitTicket(uid, sku, count, mobile, yohoCoin).then(result => {
  52 + return res.json(result);
  53 + }).catch(next);
  54 +};
  55 +
  56 +const ticketCompute = (req, res, next) => {
  57 + let uid = req.user.uid;
  58 + let sku = req.body.sku || 0;
  59 + let buyNumber = req.body.count || 0;
  60 + let yohoCoin = req.body.coin || 0;
  61 +
  62 + ticketService.addTicket(uid, sku, buyNumber, yohoCoin).then(result => {
  63 + if (_.isEmpty(result)) {
  64 + return res.json({
  65 + code: 401,
  66 + message: '不成功'
  67 + });
  68 + }
  69 +
  70 + return res.json({
  71 + code: 200,
  72 + data: result
  73 + });
  74 + }).catch(next);
  75 +};
  76 +
  77 +module.exports = {
  78 + ticketSubmit,
  79 + ticketEnsure,
  80 + ticketCompute
  81 +};
  1 +/**
  2 + * Created by TaoHuang on 2017/6/22.
  3 + */
  4 +
  5 +const api = global.yoho.API;
  6 +
  7 +/**
  8 + * 电子票下单
  9 + * @param uid 用户id
  10 + * @param sku 商品sku
  11 + * @param count 购买数量 1-4
  12 + * @param mobile 手机号码
  13 + * @param yohoCoin 有货币
  14 + */
  15 +function submit(uid, sku, count, mobile, yohoCoin) {
  16 + let params = {
  17 + method: 'app.shopping.submitTicket',
  18 + uid,
  19 + product_sku: sku,
  20 + buy_number: count,
  21 + mobile: mobile
  22 + };
  23 +
  24 + if (yohoCoin) {
  25 + params.use_yoho_coin = yohoCoin / 100;
  26 + }
  27 +
  28 + return api.get('', params);
  29 +}
  30 +
  31 +/**
  32 + * 电子票添加和查询
  33 + * @param uid 用户 id
  34 + * @param sku 商品sku
  35 + * @param count 购买数量 1-4
  36 + * @param yohoCoin 有货币
  37 + */
  38 +function add(uid, sku, count, yohoCoin) {
  39 + let params = {
  40 + method: 'app.shopping.ticket',
  41 + uid,
  42 + product_sku: sku,
  43 + buy_number: count
  44 + };
  45 +
  46 + if (yohoCoin) {
  47 + params.use_yoho_coin = yohoCoin / 100;
  48 + }
  49 +
  50 + return api.get('', params);
  51 +}
  52 +
  53 +module.exports = {
  54 + submit,
  55 + add
  56 +};
  1 +/**
  2 + * Created by TaoHuang on 2017/6/22.
  3 + */
  4 +
  5 +const api = require('./ticket-api');
  6 +const Promise = require('bluebird');
  7 +const co = Promise.coroutine;
  8 +const _ = require('lodash');
  9 +const helpers = global.yoho.helpers;
  10 +const _handleUseYhoCoin = require('./order-ensure-handle').handleUseYohoCoin;
  11 +
  12 +function _handleGoodsList(list) {
  13 + return list.map((i) => {
  14 + i.linkToGoods = helpers.getUrlBySkc(i.product_skn);
  15 + i.productPrice = i.sales_price;
  16 + return i;
  17 + });
  18 +}
  19 +
  20 +function _handleAmount(info) {
  21 + return _.get(info, 'data.shopping_cart_data.last_order_amount', 0);
  22 +}
  23 +
  24 +const addTicket = co(function * (uid, sku, count, yohoCoin) {
  25 + let ticketInfo = yield api.add(uid, sku, count, yohoCoin);
  26 + let result = {};
  27 +
  28 + if (ticketInfo.code !== 200) {
  29 + return result;
  30 + }
  31 +
  32 + result.goodsList = _handleGoodsList(_.get(ticketInfo, 'data.goods_list', []));
  33 + result.last_order_amount = _handleAmount(ticketInfo);
  34 + Object.assign(result, _handleUseYhoCoin(_.get(ticketInfo, 'data.shopping_cart_data', {})));
  35 +
  36 + return result;
  37 +});
  38 +
  39 +const submitTicket = co(function * (uid, sku, count, mobile, yohoCoin) {
  40 + let result = yield api.submit(uid, sku, count, mobile, yohoCoin);
  41 +
  42 + if (result.code !== 200) {
  43 + return {
  44 + code: 410,
  45 + message: '提交失败'
  46 + };
  47 + }
  48 +
  49 + return {
  50 + code: 200,
  51 + message: '提交成功',
  52 + data: {
  53 + refer: helpers.urlFormat('/shopping/newpay', {
  54 + ordercode: result.data.order_code
  55 + })
  56 + }
  57 + };
  58 +});
  59 +
  60 +module.exports = {
  61 + addTicket,
  62 + submitTicket
  63 +};
@@ -15,6 +15,7 @@ const cart = require(`${cRoot}/cart`); @@ -15,6 +15,7 @@ const cart = require(`${cRoot}/cart`);
15 const address = require(`${cRoot}/address`); 15 const address = require(`${cRoot}/address`);
16 const easypay = require(`${cRoot}/easypay`); 16 const easypay = require(`${cRoot}/easypay`);
17 const ensure = require(`${cRoot}/order-ensure`); 17 const ensure = require(`${cRoot}/order-ensure`);
  18 +const ticket = require(`${cRoot}/ticket`);
18 19
19 router.get('/index/getProductInfo', cart.getProductInfo); 20 router.get('/index/getProductInfo', cart.getProductInfo);
20 router.post('/cart/detailAdd', cart.cartAddIndex); // 加入购物车 商品详情页 21 router.post('/cart/detailAdd', cart.cartAddIndex); // 加入购物车 商品详情页
@@ -36,6 +37,10 @@ router.get('/easypay', auth, easypay.index); // 限购商品快捷结算页 @@ -36,6 +37,10 @@ router.get('/easypay', auth, easypay.index); // 限购商品快捷结算页
36 router.post('/easypay/compute', auth, easypay.compute); // 价格重新计算 37 router.post('/easypay/compute', auth, easypay.compute); // 价格重新计算
37 router.post('/easypay/submit', auth, easypay.submit); // 限购商品订单提交 38 router.post('/easypay/submit', auth, easypay.submit); // 限购商品订单提交
38 39
  40 +router.post('/ticketEnsure', auth, ticket.ticketEnsure);
  41 +router.post('/ticketSubmit', auth, ticket.ticketSubmit);
  42 +router.post('/ticketCompute', auth, ticket.ticketCompute);
  43 +
39 router.get('/cart', cart.cart); 44 router.get('/cart', cart.cart);
40 router.post('/cart/select', cart.selectProduct); 45 router.post('/cart/select', cart.selectProduct);
41 router.post('/cart/modifyNum', cart.modifyProductNum); 46 router.post('/cart/modifyNum', cart.modifyProductNum);
  1 +<div class="order-ensure2016 yoho-page {{pageClass}}">
  2 + {{# content}}
  3 + <div class="order-ensure-title">
  4 + {{> shopping-step}}
  5 + </div>
  6 +
  7 + <div class="address-wrap">
  8 + <div class="block-title">请填写并核对以下信息</div>
  9 +
  10 + <div class="ticket-selection">
  11 + <div class="title">支付及发劵时间:</div>
  12 + <ul class="modity-pay-info">
  13 + <li>付款方式:<span>在线支付</span></li>
  14 + <li>发劵时间:<span>自动发货 - 在您支付成功后,系统将立即为您发放二维码,您可以在您的订单中查看。</span></li>
  15 + <li>手机号:
  16 + <span class="show-ticket-mobile hide">
  17 + <span class="ticket-mobile"></span><span class="ticket-modify-btn">[修改]</span>
  18 + </span>
  19 + <span class="set-ticket-mobile">
  20 + <input type="text" value="" class="ticket-mobile-input"/>
  21 + <span class="ticket-mobile-tip">请填写正确手机号以便于接收票条信息</span>
  22 + </span>
  23 + </li>
  24 + </ul>
  25 + </div>
  26 + </div>
  27 +
  28 + <div class="goods-wrap">
  29 + <div class="block-title">订单商品信息</div>
  30 + <table class="goods-table">
  31 + <thead>
  32 + <tr>
  33 + <th width="3%"></th>
  34 + <th class="aline-left" width="46%">商品信息</th>
  35 + <th>颜色/尺码</th>
  36 + <th width="18%">单价</th>
  37 + <th width="6%">数量</th>
  38 + <th width="3%"></th>
  39 + </tr>
  40 + </thead>
  41 + <tbody>
  42 + {{#each goodsList}}
  43 + <tr class="goods-item" data-skn="{{product_skn}}" data-sku="{{product_sku}}"
  44 + data-price="{{last_price}}" data-num="{{buy_number}}">
  45 + <td{{#if @first}} class="border-top"{{/if}}></td>
  46 + <td class="border-top aline-left">
  47 + <a class="image" href="{{linkToGoods}}">
  48 + <img src="{{image2 goods_images w=64 h=85}}" class="thumb">
  49 + <p class="name">
  50 + {{product_name}}
  51 + </p>
  52 + </a>
  53 + </td>
  54 + <td class="border-top color-size">
  55 + 颜色:<span class="color">{{color_name}}</span>
  56 + 尺码:<span class="size">{{size_name}}</span>
  57 + </td>
  58 + <td class="border-top price">
  59 + <p class="red">¥ {{round productPrice 2}}</p>
  60 + </td>
  61 + <td class="border-top">× {{buy_number}}</td>
  62 + <td{{#if @first}} class="border-top"{{/if}}></td>
  63 + </tr>
  64 + {{/each}}
  65 + </tbody>
  66 + </table>
  67 + </div>
  68 +
  69 + <div class="extra-wrap ticket-wrapper">
  70 + <dl>
  71 + <dt><span class="locker-switch"></span>使用有货币</dt>
  72 + <dd id="yoho-coin-box" class="yoho-coin-box" data-coin="{{usedCoinNum}}"
  73 + data-max={{canUseCoinNum}} data-total="{{total_yoho_coin_num}}">
  74 + <div class="outer-view">
  75 + <p class="coin-err-tip">{{coinErrorTip}}</p>
  76 + <p>有货币满<span class="red">{{yoho_coin_pay_rule.num_limit}}</span>个即可使用,每次使用有货币为<span
  77 + class="red">{{yoho_coin_pay_rule.num_limit}}</span>的整数倍</p>
  78 + <i class="help-icon"></i>
  79 + <div class="coin-tip-help">
  80 + <p>有货币使用提示:</p>
  81 + <p>
  82 + 1.订单金额大于20元(含20元)<br>
  83 + 2.有货币数量大于{{yoho_coin_pay_rule.num_limit}}个(含{{yoho_coin_pay_rule.num_limit}}个) <br>
  84 + 3.有货币支付上限为每笔订单应付金额的{{yoho_coin_pay_rule.max_pay_rate_desc}}
  85 + </p>
  86 + <p class="rs-text">备注:使用有货币数量为{{yoho_coin_pay_rule.num_limit}}的整数倍,100有货币抵1元</p>
  87 + </div>
  88 + </div>
  89 + <div class="coin-main-view">
  90 + <p>本次使用有货币<span class="red">{{canUseCoinNum}}</span>个,抵扣 <span class="red">¥{{yoho_coin}}</span>
  91 + </p>
  92 + <p class="grey fw300">您当前共有有货币 <span class="red">{{total_yoho_coin_num}}</span> 个,可用 <span
  93 + class="red">{{canUseCoinNum}}</span></p>
  94 + <label class="coin-cancel-btn fw300">取消使用</label>
  95 + <label class="coin-use-btn">确定</label>
  96 + </div>
  97 + </dd>
  98 +
  99 + </dl>
  100 + </div>
  101 +
  102 + <div class="sum-wrap">
  103 + 应付金额:<span id="order-price" class="price">¥ {{round last_order_amount 2}}</span>
  104 + <button id="order-submit">提交订单</button>
  105 + </div>
  106 + {{/ content}}
  107 +</div>
@@ -6,7 +6,7 @@ @@ -6,7 +6,7 @@
6 6
7 'use strict'; 7 'use strict';
8 8
9 -const QRcodeModel = require('../models/qrcode'); 9 +const QRcodeModel = require('../models/qrcode-api');
10 const helpers = global.yoho.helpers; 10 const helpers = global.yoho.helpers;
11 11
12 exports.QRcode = (req, res, next) => { 12 exports.QRcode = (req, res, next) => {
@@ -76,7 +76,7 @@ const ORDER_OP_ALL = [ @@ -76,7 +76,7 @@ const ORDER_OP_ALL = [
76 type: 'lookQrcode', 76 type: 'lookQrcode',
77 name: '查看二维码', 77 name: '查看二维码',
78 qrcode: true, 78 qrcode: true,
79 - hrefFun: it => helpers.urlFormat('/home/orders/detail', {orderCode: it}) 79 + hrefFun: it => helpers.urlFormat('/home/qrcode', {orderCode: it})
80 }, 80 },
81 { 81 {
82 type: 'afterService', 82 type: 'afterService',
@@ -404,7 +404,8 @@ const getOrders = (uid, page, limit, type, isPage)=> { @@ -404,7 +404,8 @@ const getOrders = (uid, page, limit, type, isPage)=> {
404 newGood.refundStatus = refundNum > 0;// 只要发生一件退换,退换过的标记 404 newGood.refundStatus = refundNum > 0;// 只要发生一件退换,退换过的标记
405 newGood.goRefundUrl = helpers.urlFormat('/home/returns'); 405 newGood.goRefundUrl = helpers.urlFormat('/home/returns');
406 newGood.arrivalDate = good.expect_arrival_time; 406 newGood.arrivalDate = good.expect_arrival_time;
407 - let goodsTagName = _getGoodsTag(order.attribute, good.goods_type); 407 +
  408 + let goodsTagName = _getGoodsTag(+order.attribute, good.goods_type);
408 409
409 if (goodsTagName) { 410 if (goodsTagName) {
410 newGood[goodsTagName] = true; 411 newGood[goodsTagName] = true;
@@ -525,7 +526,7 @@ const _getVirtualPro = (isCancel, status, createTime) => { @@ -525,7 +526,7 @@ const _getVirtualPro = (isCancel, status, createTime) => {
525 process.middleStatus[1].cur = true; 526 process.middleStatus[1].cur = true;
526 } else if (status === 6) { 527 } else if (status === 6) {
527 process.percent = '100%'; 528 process.percent = '100%';
528 - process.middleStatus[3].cur = true; 529 + process.middleStatus[2].cur = true;
529 } 530 }
530 } 531 }
531 532
@@ -707,7 +708,7 @@ const _getOrderDetail = co(function * (uid, orderId) { @@ -707,7 +708,7 @@ const _getOrderDetail = co(function * (uid, orderId) {
707 708
708 detail.progress = statusInfo.cancel ? false : (function() { 709 detail.progress = statusInfo.cancel ? false : (function() {
709 // 未取消订单,进度 710 // 未取消订单,进度
710 - if (orderDetail.attribute === 3) { 711 + if (+orderDetail.attribute === 3) {
711 return _getVirtualPro(orderDetail.is_cancel, +orderDetail.status, orderDetail.create_time); 712 return _getVirtualPro(orderDetail.is_cancel, +orderDetail.status, orderDetail.create_time);
712 } else { 713 } else {
713 if (isOfflineBySelf(orderDetail)) { 714 if (isOfflineBySelf(orderDetail)) {
@@ -735,7 +736,7 @@ const _getOrderDetail = co(function * (uid, orderId) { @@ -735,7 +736,7 @@ const _getOrderDetail = co(function * (uid, orderId) {
735 detail.traceOrder.courierNumbe = expressInfo.courierNumbe; 736 detail.traceOrder.courierNumbe = expressInfo.courierNumbe;
736 737
737 // 虚拟商品 738 // 虚拟商品
738 - if (orderDetail.attribute === 3) { 739 + if (+orderDetail.attribute === 3) {
739 detail.virtualGoods = true; 740 detail.virtualGoods = true;
740 detail.virtualPayMode = { 741 detail.virtualPayMode = {
741 payMode: ChannelConfig.payType[orderDetail.payment_type], 742 payMode: ChannelConfig.payType[orderDetail.payment_type],
@@ -797,7 +798,7 @@ const _getOrderDetail = co(function * (uid, orderId) { @@ -797,7 +798,7 @@ const _getOrderDetail = co(function * (uid, orderId) {
797 num: good.buy_number, 798 num: good.buy_number,
798 sum: good.goods_amount, 799 sum: good.goods_amount,
799 sku: good.product_sku, 800 sku: good.product_sku,
800 - [_getGoodsTag(good.attribute, good.goods_type)]: true 801 + [_getGoodsTag(+good.attribute, good.goods_type)]: true
801 }; 802 };
802 803
803 // 划线的价格 804 // 划线的价格
@@ -847,6 +848,7 @@ const _getOrderDetail = co(function * (uid, orderId) { @@ -847,6 +848,7 @@ const _getOrderDetail = co(function * (uid, orderId) {
847 detail.operation = _getOrderDetailOp(orderDetail.order_code, +orderDetail.payment, +orderDetail.status, 848 detail.operation = _getOrderDetailOp(orderDetail.order_code, +orderDetail.payment, +orderDetail.status,
848 orderDetail.is_cancel, orderDetail.payment_status, orderDetail.payment_type, 849 orderDetail.is_cancel, orderDetail.payment_status, orderDetail.payment_type,
849 +orderDetail.order_type, +orderDetail.attribute, +orderDetail.refund_status); 850 +orderDetail.order_type, +orderDetail.attribute, +orderDetail.refund_status);
  851 +
850 detail.packageTitle = orderDetail.package_title; 852 detail.packageTitle = orderDetail.package_title;
851 detail.packages = _getPackageInfo(orderDetail); 853 detail.packages = _getPackageInfo(orderDetail);
852 854
@@ -38,7 +38,6 @@ @@ -38,7 +38,6 @@
38 <div class='clearfix'></div> 38 <div class='clearfix'></div>
39 </div> 39 </div>
40 </div> 40 </div>
41 - <a class='btn-qcode' href='#'>打印二维码</a>  
42 </div> 41 </div>
43 {{/qrcodeData}} 42 {{/qrcodeData}}
44 <div class='subtitle'> 43 <div class='subtitle'>
@@ -50,26 +49,11 @@ @@ -50,26 +49,11 @@
50 如何使用二维码 49 如何使用二维码
51 </p> 50 </p>
52 <p class='tro'> 51 <p class='tro'>
53 - 1、点击【打印二维码】按钮打印,入场时出示二维码电子票检验入场;  
54 - 2、每个二维码只能使用一次,请保管好您的序列号,不要随意泄露给其他  
55 - 人。 52 + 1、入场时出示二维码电子票检验入场。
56 </p> 53 </p>
57 - </div>  
58 - <div class="main-info">  
59 - <p class="p1">  
60 - 如何获取二维码  
61 - </p>  
62 - <p class='tro'>  
63 - 1、您可以点击【打印二维码】将票面打印,请在打印时将版面设置成横向打  
64 - 印;  
65 - 2、如果您的电脑未连接打印机,请点击【打印二维码】后,将弹出的票面图  
66 - 片截图并保存,然后另行打印。  
67 - </p>  
68 - </div>  
69 - <div class="main-info">  
70 - <p class='gray'>  
71 - 1、请保持票面干净完整,入场时只需要出示打印票面进行检验即可入场,每个  
72 - 二维码只可使用一次,请您妥善保管。2、如果您的电脑未连接打印机,请点击【打印二维码后】,将弹出的票面图片截图并保存,然后另行打印。 54 +
  55 + <p class="tro">
  56 + 2、每个二维码只能使用一次,请保管好您的序列号,不要随意泄露给其他人。
73 </p> 57 </p>
74 </div> 58 </div>
75 </div> 59 </div>
@@ -166,6 +166,7 @@ @@ -166,6 +166,7 @@
166 </a> 166 </a>
167 <div class="logistics hide"> </div> 167 <div class="logistics hide"> </div>
168 {{/if}} 168 {{/if}}
  169 +
169 {{/ operation}} 170 {{/ operation}}
170 </div> 171 </div>
171 </div> 172 </div>
@@ -37,9 +37,6 @@ const BUNDLE_PRODUCE = 2; // 量贩 @@ -37,9 +37,6 @@ const BUNDLE_PRODUCE = 2; // 量贩
37 const BUNDLE_PACKAGE = 1; // 套餐 37 const BUNDLE_PACKAGE = 1; // 套餐
38 const tdk = require('../../../utils/getTDK'); 38 const tdk = require('../../../utils/getTDK');
39 39
40 -// 展览票  
41 -const YOHOOD_TICKET = 51335912;  
42 -  
43 const _getProductAdditionInfoAsync = (data) => { 40 const _getProductAdditionInfoAsync = (data) => {
44 return co(function * () { 41 return co(function * () {
45 let productId = _.get(data, 'product_id', 0); 42 let productId = _.get(data, 'product_id', 0);
@@ -1383,12 +1380,13 @@ const _detailDataPkg = (origin, uid, vipLevel, cookies) => { @@ -1383,12 +1380,13 @@ const _detailDataPkg = (origin, uid, vipLevel, cookies) => {
1383 }; 1380 };
1384 } 1381 }
1385 1382
1386 - // 电子票  
1387 - result.isTicket = propOrigin('product_skn') === YOHOOD_TICKET; 1383 + // 虚拟商品目前只有电子票
  1384 + result.isTicket = virtualGoods;
  1385 +
1388 if (virtualGoods && result.isTicket) { 1386 if (virtualGoods && result.isTicket) {
1389 // 虚拟商品 1387 // 虚拟商品
1390 result.buyNow = true; // 是否立即购买 1388 result.buyNow = true; // 是否立即购买
1391 - result.buyNowBase = helpers.urlFormat('/ticket', null, 'shopping'); 1389 + result.buyNowBase = helpers.urlFormat('/cart/ticketEnsure');
1392 if (result.salePrice) { 1390 if (result.salePrice) {
1393 result.advancePrice = result.salePrice; // 先行价格 1391 result.advancePrice = result.salePrice; // 先行价格
1394 delete result.salePrice; 1392 delete result.salePrice;
@@ -131,7 +131,7 @@ @@ -131,7 +131,7 @@
131 {{#if virtualGoods}} 131 {{#if virtualGoods}}
132 {{!-- 电子门票按钮 --}} 132 {{!-- 电子门票按钮 --}}
133 {{#if isVirtualBtn}} 133 {{#if isVirtualBtn}}
134 - <form name="ticket-form" action="//www.yohobuy.com/cart/index/ticketEnsure" method="POST" 134 + <form name="ticket-form" action="{{buyNowBase}}" method="POST"
135 class="hide"></form> 135 class="hide"></form>
136 <span id="buy-ticket" class="buy-ticket buy-now item-buy{{#if dis}} dis{{/if}}">立即购买</span> 136 <span id="buy-ticket" class="buy-ticket buy-now item-buy{{#if dis}} dis{{/if}}">立即购买</span>
137 {{/if}} 137 {{/if}}
@@ -10,7 +10,7 @@ @@ -10,7 +10,7 @@
10 </ul> 10 </ul>
11 </div> 11 </div>
12 12
13 -<div class="chose-size row clearfix {{#if isTicket}} hide {{/if}}"> 13 +<div class="chose-size row clearfix {{#unless isTicket}} hide {{/unless}}">
14 <input type="hidden" name="isTicket" value="{{isTicket}}"/> 14 <input type="hidden" name="isTicket" value="{{isTicket}}"/>
15 <span class="title pull-left"> 15 <span class="title pull-left">
16 选区域: 16 选区域:
@@ -24,13 +24,21 @@ module.exports = { @@ -24,13 +24,21 @@ module.exports = {
24 // global: 'http://global-test-soa.yohops.com:9999/', 24 // global: 'http://global-test-soa.yohops.com:9999/',
25 // platformApi: 'http://192.168.102.48:8088/', 25 // platformApi: 'http://192.168.102.48:8088/',
26 26
  27 + // test2
  28 + singleApi: 'http://api-test2.yohops.com:9999/',
  29 + api: 'http://api-test2.yohops.com:9999/',
  30 + service: 'http://service-test2.yohops.com:9999/',
  31 + serviceNotify: 'http://service-test2.yohops.com:9999/',
  32 + global: 'http://global-test-soa.yohops.com:9999/',
  33 + platformApi: 'http://192.168.102.48:8088/',
  34 +
27 // prod 35 // prod
28 - singleApi: 'http://single.yoho.cn/',  
29 - api: 'http://api.yoho.cn/',  
30 - service: 'http://service.yoho.cn/',  
31 - serviceNotify: 'http://service.yoho.cn/',  
32 - global: 'http://api-global.yohobuy.com/',  
33 - platformApi: 'http://172.16.6.210:8088/', 36 + // singleApi: 'http://single.yoho.cn/',
  37 + // api: 'http://api.yoho.cn/',
  38 + // service: 'http://service.yoho.cn/',
  39 + // serviceNotify: 'http://service.yoho.cn/',
  40 + // global: 'http://api-global.yohobuy.com/',
  41 + // platformApi: 'http://172.16.6.210:8088/',
34 42
35 // gray 43 // gray
36 // singleApi: 'http://single.gray.yohops.com/', 44 // singleApi: 'http://single.gray.yohops.com/',
@@ -220,8 +228,7 @@ if (isProduction) { @@ -220,8 +228,7 @@ if (isProduction) {
220 search: process.env.TEST_SEARCH || 'http://192.168.102.216:8080/yohosearch/', 228 search: process.env.TEST_SEARCH || 'http://192.168.102.216:8080/yohosearch/',
221 serviceNotify: process.env.TEST_SERVICE || 'http://testservice.yoho.cn:28077/', 229 serviceNotify: process.env.TEST_SERVICE || 'http://testservice.yoho.cn:28077/',
222 imSocket: 'ws://socket.yohobuy.com:10240', 230 imSocket: 'ws://socket.yohobuy.com:10240',
223 - imCs: 'http://im.yohobuy.com/api',  
224 - platformApi: 'http://192.168.102.48:8088/' 231 + imCs: 'http://im.yohobuy.com/api'
225 }, 232 },
226 useOneapm: true, 233 useOneapm: true,
227 useCache: true, 234 useCache: true,
  1 +/**
  2 + * Created by TaoHuang on 2017/6/22.
  3 + */
  4 +
  5 +
  6 +var $ = require('jquery');
  7 +
  8 +var yas = require('../common/data-yas'),
  9 + dialog = require('../common/dialog');
  10 +
  11 +var $orderPrice = $('#order-price');
  12 +var order = {};
  13 +
  14 +var yohoCoin;
  15 +var submitting = false;
  16 +
  17 +require('../common');
  18 +require('../simple-header');
  19 +
  20 +function validateUserInfo(info) {
  21 + var errTip = '';
  22 +
  23 + if (!info.mobile) {
  24 + errTip = '您还没有填写手机号';
  25 + }
  26 +
  27 + if (errTip) {
  28 + new dialog.Alert((errTip)).show();
  29 + return false;
  30 + }
  31 +
  32 + return true;
  33 +}
  34 +
  35 +function handleOrderInfo(info) {
  36 + var $goods = $('.goods-item');
  37 +
  38 + info.sku = $goods.data('sku');
  39 + info.count = $goods.data('num');
  40 + info.mobile = $('.ticket-mobile-input').val();
  41 +
  42 + return info;
  43 +}
  44 +
  45 +function compute(coin) {
  46 + var req;
  47 +
  48 + order = handleOrderInfo(order);
  49 + req = $.extend({}, order, {
  50 + coin: coin || 0
  51 + });
  52 +
  53 + $.ajax({
  54 + type: 'POST',
  55 + url: '/cart/ticketcompute',
  56 + data: req
  57 + }).then((result) => {
  58 + if (result.code === 200) {
  59 + order.coin = result.data.usedCoinNum;
  60 + yohoCoin.maxCoin = result.data.canUseCoinNum;
  61 +
  62 + $orderPrice.html('¥ ' + result.data.last_order_amount);
  63 + }
  64 + });
  65 +}
  66 +
  67 +// 有货币
  68 +yohoCoin = {
  69 + $el: $('#yoho-coin-box'),
  70 + init: function() {
  71 + var data;
  72 +
  73 + if (!this.$el.length) {
  74 + return;
  75 + }
  76 +
  77 + data = this.$el.data();
  78 +
  79 + if (data) {
  80 + order.coin = data.coin || 0;
  81 + this.maxCoin = data.max;
  82 + this.totalCoin = data.total;
  83 + }
  84 +
  85 + this.eventBind();
  86 + },
  87 + eventBind: function() {
  88 + var that = this;
  89 +
  90 + this.$el.on('click', '.coin-use-btn', function() {
  91 + if (order.coin * 1 !== this.maxCoin * 1) {
  92 + compute(that.maxCoin);
  93 + }
  94 +
  95 + that.close();
  96 + }).on('click', '.coin-cancel-btn', function() {
  97 + if (order.coin * 1 !== 0) {
  98 + order.coin = 0;
  99 + compute();
  100 + }
  101 +
  102 + that.close();
  103 + });
  104 + },
  105 + close: function() {
  106 + this.$el.prev().children('.locker-switch').trigger('click');
  107 + }
  108 +};
  109 +
  110 +$('.locker-switch').click(function() {
  111 + var $this = $(this),
  112 + $par = $this.parent();
  113 +
  114 + $par.toggleClass('open');
  115 +});
  116 +
  117 +
  118 +$('#order-submit').on('click', function() {
  119 + if (submitting) {
  120 + return;
  121 + }
  122 +
  123 + order = handleOrderInfo(order);
  124 +
  125 + if (!validateUserInfo(order)) {
  126 + return;
  127 + }
  128 +
  129 + submitting = true;
  130 + $.ajax({
  131 + type: 'POST',
  132 + url: '/cart/ticketSubmit',
  133 + data: order
  134 + }).then(function(data) {
  135 + if (data.code === 200) {
  136 + window.location.href = data.data.refer;
  137 + }
  138 + }).always(function() {
  139 + submitting = false;
  140 + });
  141 +});
  142 +
  143 +yohoCoin.init();
  144 +
  145 +// 获取用户是否新客(品众统计)写cookie
  146 +$.ajax({type: 'GET', url: '/home/newuser'});
  147 +
  148 +// 订单确认页默认埋点
  149 +yas.givePoint('YB_SC_ORDER_ENSURE');
@@ -3,9 +3,6 @@ var Slide = require('../plugins/yohoui/YH.slide'); @@ -3,9 +3,6 @@ var Slide = require('../plugins/yohoui/YH.slide');
3 3
4 var $item = $('li', '.qrctxt'); 4 var $item = $('li', '.qrctxt');
5 var len = $item.length, slide; 5 var len = $item.length, slide;
6 -var src = /url\("([^'"]*)"\)/g.exec($('.print-qrcode').css('background'))[1];  
7 -  
8 -$('.print-qrcode').find('img').attr('src', src);  
9 6
10 require('../common'); 7 require('../common');
11 8
@@ -212,7 +212,7 @@ bindEvent.add(function() { @@ -212,7 +212,7 @@ bindEvent.add(function() {
212 var $descColor = $('#desc-color'); 212 var $descColor = $('#desc-color');
213 213
214 var thumbsLoaded = {}; 214 var thumbsLoaded = {};
215 - var isTicket = $('input[name="isTicket"]').length > 0 && $('input[name="isTicket"]').val() === 'true'; 215 + var isTicket = $('input[name="isTicket"]').length > 0;
216 216
217 var brandDomain = $('.home').attr('href'); 217 var brandDomain = $('.home').attr('href');
218 218
@@ -598,21 +598,25 @@ bindEvent.add(function() { @@ -598,21 +598,25 @@ bindEvent.add(function() {
598 $sizes.not('.hide').addClass('hide').children('li').removeClass('focus'); 598 $sizes.not('.hide').addClass('hide').children('li').removeClass('focus');
599 $sizes.eq(index).removeClass('hide'); 599 $sizes.eq(index).removeClass('hide');
600 600
601 - // 是否展览 601 + // 是否
602 if (isTicket) { 602 if (isTicket) {
603 $sizes.eq(index).children('li').trigger('click'); 603 $sizes.eq(index).children('li').trigger('click');
604 - $('.chose-size').addClass('hide');  
605 } 604 }
606 605
607 // 隐藏 仅剩 X 件 提示 606 // 隐藏 仅剩 X 件 提示
608 $('.few-sold').addClass('hide'); 607 $('.few-sold').addClass('hide');
609 } 608 }
610 609
611 - // 没有选中尺码 610 + // 选中尺码
  611 + if ($('.size:not(.hide) li.focus').length === 1) {
612 maxStock = +$('.size:not(.hide) li.focus').data('num'); 612 maxStock = +$('.size:not(.hide) li.focus').data('num');
  613 + } else {
  614 + // 没有选中
  615 + maxStock = -1;
  616 + }
613 617
  618 + // 如果库存数量为 0,表示已售罄
614 if (!maxStock) { 619 if (!maxStock) {
615 - maxStock = -1;  
616 $enableNotifyYou.addClass('hide'); // 没有 620 $enableNotifyYou.addClass('hide'); // 没有
617 621
618 // 初始化color-size显示或隐藏 622 // 初始化color-size显示或隐藏
@@ -935,31 +939,13 @@ bindEvent.add(function() { @@ -935,31 +939,13 @@ bindEvent.add(function() {
935 sku = $('.size:not(.hide) li.focus').data('sku'); 939 sku = $('.size:not(.hide) li.focus').data('sku');
936 buyNumber = getNum(); 940 buyNumber = getNum();
937 941
938 - $.ajax({  
939 - type: 'POST',  
940 - url: '/cart/index/setTicket',  
941 - data: {  
942 - productSku: sku,  
943 - buyNumber: buyNumber  
944 - }  
945 - }).then(function(data) {  
946 - var $ticketForm,  
947 - myAlert; 942 + var $ticketForm = $('form[name="ticket-form"]'); // eslint-disable-line
948 943
949 - if (data.code * 1 === 200) {  
950 - $ticketForm = $('form[name="ticket-form"]');  
951 $ticketForm.html( 944 $ticketForm.html(
952 '<input name="productSku" value="' + sku + '" />' + 945 '<input name="productSku" value="' + sku + '" />' +
953 '<input name="buyNumber" value="' + buyNumber + '" />' 946 '<input name="buyNumber" value="' + buyNumber + '" />'
954 ); 947 );
955 $ticketForm.submit(); 948 $ticketForm.submit();
956 - } else if (data.code * 1 === 401) {  
957 - document.location.href = data.message;  
958 - } else {  
959 - myAlert = new Alert(data.message);  
960 - myAlert.show();  
961 - }  
962 - });  
963 }); 949 });
964 950
965 // 立即购买 951 // 立即购买
@@ -827,6 +827,44 @@ @@ -827,6 +827,44 @@
827 } 827 }
828 } 828 }
829 829
  830 + .ticket-wrapper {
  831 + border-bottom-color: #e8e8e8;
  832 + border-top-color: #fff;
  833 + }
  834 +
  835 + .ticket-selection {
  836 + font-size: 15px;
  837 + line-height: 1.5;
  838 +
  839 + .title {
  840 + line-height: 40px;
  841 + font-size: 16px;
  842 + padding-left: 25px;
  843 + font-weight: bold;
  844 + margin-top: 10px;
  845 + }
  846 +
  847 + .modity-pay-info {
  848 + li {
  849 + padding-left: 30px;
  850 + margin-bottom: 15px;
  851 +
  852 + .ticket-mobile-input {
  853 + width: 208px;
  854 + border: 1px solid #b0b0b0;
  855 + padding: 5px;
  856 + margin-right: 10px;
  857 + font-size: 14px;
  858 + }
  859 +
  860 + .ticket-mobile-tip {
  861 + color: #da0045;
  862 + margin-left: 15px;
  863 + }
  864 + }
  865 + }
  866 + }
  867 +
830 .use-coupons { 868 .use-coupons {
831 .tip-box { 869 .tip-box {
832 width: 60%; 870 width: 60%;