Authored by 郝肖肖

Merge branch 'release/5.4.1' of git.yoho.cn:fe/yohobuywap-node into release/5.4.1

@@ -51,7 +51,7 @@ exports.orderEnsure = (req, res, next) => { @@ -51,7 +51,7 @@ exports.orderEnsure = (req, res, next) => {
51 headerData.backUrl = returnUrl; 51 headerData.backUrl = returnUrl;
52 } 52 }
53 53
54 - let orderPromise = cartModel.cartPay(uid, cartType, orderInfo, sku, skn, buyNumber); 54 + let orderPromise;
55 let userProfilePromise = userModel.queryProfile(uid); 55 let userProfilePromise = userModel.queryProfile(uid);
56 let addressPromise = addressModel.addressData(uid); 56 let addressPromise = addressModel.addressData(uid);
57 57
@@ -59,6 +59,8 @@ exports.orderEnsure = (req, res, next) => { @@ -59,6 +59,8 @@ exports.orderEnsure = (req, res, next) => {
59 let activityInfo = JSON.parse(req.cookies['activity-info']); 59 let activityInfo = JSON.parse(req.cookies['activity-info']);
60 60
61 orderPromise = cartModel.cartPay(uid, cartType, orderInfo, sku, skn, buyNumber, activityInfo); 61 orderPromise = cartModel.cartPay(uid, cartType, orderInfo, sku, skn, buyNumber, activityInfo);
  62 + } else {
  63 + orderPromise = cartModel.cartPay(uid, cartType, orderInfo, sku, skn, buyNumber);
62 } 64 }
63 65
64 return Promise.all([orderPromise, userProfilePromise, addressPromise]).then(result => { 66 return Promise.all([orderPromise, userProfilePromise, addressPromise]).then(result => {
@@ -70,9 +70,27 @@ const cancelOrder = (req, res, next) => { @@ -70,9 +70,27 @@ const cancelOrder = (req, res, next) => {
70 }).catch(next); 70 }).catch(next);
71 }; 71 };
72 72
  73 +/**
  74 + * 我的订单-查看物流信息
  75 + */
  76 +const logistic = (req, res, next) => {
  77 + orderDetailModel.logistics(req.query.order_code, req.user.uid).then(result => {
  78 + res.render('logistic', _.assign(result, {
  79 + pageHeader: headerModel.setNav({
  80 + navTitle: '订单详情',
  81 + navBtn: false
  82 + }),
  83 + module: 'home',
  84 + page: 'logistic',
  85 + logisticInfoPage: true
  86 + }));
  87 + }).catch(next);
  88 +};
  89 +
73 module.exports = { 90 module.exports = {
74 orderDetailData, 91 orderDetailData,
75 delOrder, 92 delOrder,
76 readdData, 93 readdData,
77 - cancelOrder 94 + cancelOrder,
  95 + logistic
78 }; 96 };
@@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
2 2
3 3
4 const api = global.yoho.API; 4 const api = global.yoho.API;
  5 +const serviceApi = global.yoho.ServiceAPI;
5 6
6 const _ = require('lodash'); 7 const _ = require('lodash');
7 8
@@ -10,6 +11,8 @@ const helpers = global.yoho.helpers; @@ -10,6 +11,8 @@ const helpers = global.yoho.helpers;
10 const camelCase = global.yoho.camelCase; 11 const camelCase = global.yoho.camelCase;
11 const logger = global.yoho.logger; 12 const logger = global.yoho.logger;
12 13
  14 +const CODE_LOGISTIC_BANNER = '1fc9b2484fcd559049f2f7e0db313f20'; // 物流详情banner资源码
  15 +
13 const closeReasons = () => { 16 const closeReasons = () => {
14 return api.get('', { 17 return api.get('', {
15 method: 'app.SpaceOrders.closeReasons' 18 method: 'app.SpaceOrders.closeReasons'
@@ -370,10 +373,84 @@ const cancelOrder = (orderCode, uid, reasonId, gender, channel, reason) => { @@ -370,10 +373,84 @@ const cancelOrder = (orderCode, uid, reasonId, gender, channel, reason) => {
370 }); 373 });
371 }; 374 };
372 375
  376 +/*
  377 +* 我的订单-查看物流
  378 +* @param int $orderCode 订单号
  379 +* @param int $uid 用户ID
  380 +* @return array
  381 +*/
  382 +const _logisticsData = (orderCode, uid) => {
  383 + return api.get('', {
  384 + method: 'app.express.li',
  385 + order_code: orderCode,
  386 + uid: uid
  387 + });
  388 +};
  389 +
  390 +/**
  391 + * 获取物流详情页banner
  392 + */
  393 +const _getLogisterBanner = () => {
  394 + return serviceApi.get('operations/api/v5/resource/get', {
  395 + content_code: CODE_LOGISTIC_BANNER
  396 + }, {code: 200});
  397 +};
  398 +
  399 +/**
  400 + * 查看物流
  401 + *
  402 + * @param int orderCode 订单编号
  403 + * @param int uid 用户ID
  404 + * @return array
  405 + */
  406 +const logistics = (orderCode, uid) => {
  407 + return Promise.all([
  408 + _getLogisterBanner(),
  409 + _logisticsData(orderCode, uid),
  410 + ]).then(result => {
  411 + let finalResult = {
  412 + banner: []
  413 + };
  414 + let banners = result[0];
  415 + let logistic = result[1];
  416 +
  417 + // 获取物流详情页banner
  418 + if (banners && banners.data) {
  419 + _.forEach(banners.data, value => {
  420 + _.forEach(value.data, subValue => {
  421 + finalResult.banner.push({
  422 + url: subValue.url,
  423 + img: subValue.src
  424 + });
  425 + });
  426 + });
  427 + }
  428 +
  429 + if (logistic && logistic.data) {
  430 + finalResult.logisticUrl = _.get(logistic, 'data.url', '');
  431 + finalResult.logisticImg = _.get(logistic, 'data.logo', '');
  432 + finalResult.logisticCompany = _.get(logistic, 'data.caption', '');
  433 + finalResult.logisticNumber = _.get(logistic, 'data.express_number', '');
  434 + finalResult.logisticDetail = [];
  435 +
  436 + _.forEach(_.get(logistic, 'data.express_detail', []), value => {
  437 + finalResult.logisticDetail.push({
  438 + status: value.accept_address,
  439 + date: value.acceptTime,
  440 + });
  441 + });
  442 +
  443 + }
  444 +
  445 + return finalResult;
  446 + });
  447 +};
  448 +
373 module.exports = { 449 module.exports = {
374 orderDetailData, 450 orderDetailData,
375 closeReasons, 451 closeReasons,
376 delOrder, 452 delOrder,
377 readdData, 453 readdData,
378 - cancelOrder 454 + cancelOrder,
  455 + logistics
379 }; 456 };
@@ -134,4 +134,6 @@ router.get('/installment/setMasterCard', installment.setMasterCard); // 銝 @@ -134,4 +134,6 @@ router.get('/installment/setMasterCard', installment.setMasterCard); // 銝
134 134
135 router.get('/getaddress.json', addressController.newGetAddress); // TODO 模拟省数据 135 router.get('/getaddress.json', addressController.newGetAddress); // TODO 模拟省数据
136 136
  137 +router.get('/logistic', auth, orderDetailController.logistic); // 查看物流页面
  138 +
137 module.exports = router; 139 module.exports = router;
  1 +<div class="logistic-page yoho-page">
  2 + <div class="overview">
  3 + <div class="left" >
  4 + <a href="{{logisticUrl}}"><img class="icon" src="{{logisticImg}}" /></a>
  5 + </div>
  6 + <div class="right">
  7 + <div>
  8 + <span class='info'>物流公司:</span>
  9 + <span >{{logisticCompany}}</span>
  10 + </div>
  11 + <div>
  12 + <span class='info'>快递单号:</span>
  13 + <span>{{logisticNumber}}</span>
  14 + </div>
  15 + </div>
  16 +
  17 + </div>
  18 +
  19 + <div class="title">
  20 + <span>物流详情</span>
  21 + </div>
  22 +
  23 + <div class="detail">
  24 + {{# logisticDetail}}
  25 + <div class="timeline-box ">
  26 + <span class="timeline-node"></span>
  27 + <div class="timeline-info">
  28 + <div class="timeline-info-row">
  29 + {{status}}
  30 + </div>
  31 + <div class="timeline-info-row">
  32 + {{date}}
  33 + </div>
  34 + </div>
  35 + </div>
  36 + {{/ logisticDetail}}
  37 + </div>
  38 +
  39 + <div class="banner">
  40 + {{#banner}}
  41 + <a href="{{url}}">
  42 + <img src="{{image2 img w=640 h=200}}" alt="img">
  43 + </a>
  44 + {{/banner}}
  45 + </div>
  46 +
  47 + {{#unless @root.wap.ucenter.removePrefer}}
  48 + {{> common/recommend-for-you}}
  49 + {{/unless}}
  50 +</div>
@@ -6,6 +6,7 @@ const _ = require('lodash'); @@ -6,6 +6,7 @@ const _ = require('lodash');
6 6
7 const detailModel = require('../models/detail'); 7 const detailModel = require('../models/detail');
8 const newDetailModel = require('../models/new-detail'); 8 const newDetailModel = require('../models/new-detail');
  9 +const listModel = require('../models/list');
9 const headerModel = require('../../../doraemon/models/header'); // 头部model 10 const headerModel = require('../../../doraemon/models/header'); // 头部model
10 11
11 const newDetail = { 12 const newDetail = {
@@ -115,6 +116,37 @@ const newDetail = { @@ -115,6 +116,37 @@ const newDetail = {
115 result.studentPrice = req.__User__.isStudent && result && result.goodsPrice && result.goodsPrice.studentPrice ? result.goodsPrice.studentPrice : false; 116 result.studentPrice = req.__User__.isStudent && result && result.goodsPrice && result.goodsPrice.studentPrice ? result.goodsPrice.studentPrice : false;
116 return res.json(result); 117 return res.json(result);
117 }).catch(next); 118 }).catch(next);
  119 + },
  120 +
  121 + /**
  122 + * 商品收藏/取消收藏
  123 + */
  124 + favoriteProduct(req, res, next) {
  125 + let allowOrigin = _.get(req, 'headers.origin', null) ?
  126 + req.headers.origin : req.protocol + '://' + req.headers.host;
  127 +
  128 + res.setHeader('Access-Control-Allow-Origin', allowOrigin);
  129 + res.setHeader('Access-Control-Allow-Credentials', 'true');
  130 +
  131 + if (req.body.opt === 'ok') {
  132 + listModel.setFavorite(req.body.id, req.user.uid, 'product').then(result => {
  133 + return res.json(result);
  134 + }).catch(next);
  135 + } else {
  136 + listModel.setFavoriteCancel(req.body.id, req.user.uid, 'product').then(result => {
  137 + return res.json(result);
  138 + }).catch(next);
  139 + }
  140 + },
  141 +
  142 + /**
  143 + * 限购商品说明页面
  144 + */
  145 + limitHelp(req, res) {
  146 + res.render('detail/limit-help', {
  147 + module: 'product',
  148 + page: 'limit-help'
  149 + });
118 } 150 }
119 }; 151 };
120 152
@@ -176,4 +176,7 @@ router.get('/newsale/selectHotrank', newsale.selectHotrank); // 热销排行榜 @@ -176,4 +176,7 @@ router.get('/newsale/selectHotrank', newsale.selectHotrank); // 热销排行榜
176 176
177 router.get('/bundle/detail', bundle.detail); // 套装详情页 177 router.get('/bundle/detail', bundle.detail); // 套装详情页
178 178
  179 +router.post('/opt/favoriteProduct', newDetail.favoriteProduct); // 商品收藏、取消收藏
  180 +router.get('/detail/limitHelp', newDetail.limitHelp);
  181 +
179 module.exports = router; 182 module.exports = router;
  1 +<div class="limit-help-page yoho-page">
  2 + <h2>不同限定商品获取限购码方式不同,获取限购码目前有两种方式:</h2>
  3 + <span class="method">方式一</span>
  4 + <ul class="method-1">
  5 + <li>1.在限定发售详情页点击分享或者底部“获取限购码”图标。
  6 + <div class="intro-img"></div>
  7 + </li>
  8 + <li>2.从弹出的分享中选取需要分享的渠道。
  9 + <div class="intro-img"></div>
  10 + </li>
  11 + <li>3.分享成功后返回Yoho!Buy有货APP会提示已获得限购码。
  12 + <div class="intro-img"></div>
  13 + </li>
  14 + </ul>
  15 + <span class="method">方式二</span>
  16 + <ul class="method-2">
  17 + <li>1.在限定发售详情页点击参加排队赢取限购码图标。
  18 + <div class="intro-img"></div>
  19 + </li>
  20 + <li>2.进入限定发售排队页面,点击参加排队。
  21 + <div class="intro-img"></div>
  22 + </li>
  23 + <li>3.排队成功后凭排队序列号作为抽奖凭证,等待开奖时间。
  24 + <div class="intro-img"></div>
  25 + </li>
  26 + <li>4.开奖后,排队页面会公布中奖名单,限购码会直接发送至账户。
  27 + <div class="intro-img"></div>
  28 + </li>
  29 + </ul>
  30 + <h2>查看和使用限购码</h2>
  31 + <ul class="how">
  32 + <li>1.从个人中心进入我的限购码页面,可查看所获取的限购码。
  33 + <div class="intro-img"></div>
  34 + </li>
  35 + <li>2.商品开售后,可凭此限购码购买对应商品。
  36 + <div class="intro-img"></div>
  37 + </li>
  38 + </ul>
  39 +</div>
@@ -5,7 +5,6 @@ @@ -5,7 +5,6 @@
5 */ 5 */
6 6
7 var $ = require('yoho-jquery'), 7 var $ = require('yoho-jquery'),
8 - Hammer = require('yoho-hammer'),  
9 ellipsis = require('yoho-mlellipsis'), 8 ellipsis = require('yoho-mlellipsis'),
10 loading = require('../plugin/loading'), 9 loading = require('../plugin/loading'),
11 tip = require('../plugin/tip'), 10 tip = require('../plugin/tip'),
@@ -83,9 +82,10 @@ $couponList.on('touchstart', '.employ-main', function() { @@ -83,9 +82,10 @@ $couponList.on('touchstart', '.employ-main', function() {
83 $('body').on('touchend', '.not-use', function() { 82 $('body').on('touchend', '.not-use', function() {
84 orderInfo('couponCode', null); 83 orderInfo('couponCode', null);
85 orderInfo('couponName', null); 84 orderInfo('couponName', null);
86 - //实付金额发生变化,使用有货币为0 85 +
  86 + // 实付金额发生变化,使用有货币为0
87 orderInfo('yohoCoin', 0); 87 orderInfo('yohoCoin', 0);
88 - location.href = '/cart/index/orderEnsure'; 88 + location.href = '/cart/index/new/orderEnsure';
89 }); 89 });
90 90
91 91
@@ -124,12 +124,8 @@ function getCouponHandle(allCoupons) { @@ -124,12 +124,8 @@ function getCouponHandle(allCoupons) {
124 // 渲染可用的优惠券 124 // 渲染可用的优惠券
125 $couponList.append(conponTmpl({ 125 $couponList.append(conponTmpl({
126 coupons: coupons 126 coupons: coupons
127 - })).find('.employ-main').each(function(i, elem) {  
128 - var employHammer = new Hammer(elem);  
129 -  
130 - employHammer.on('tap', function(e) {  
131 - var $this = $(e.srcEvent.currentTarget);  
132 - var couponCode = $this.data('coupon-code'); 127 + })).find('.employ-main').on('touchstart', function() {
  128 + var couponCode = $(this).data('coupon-code');
133 129
134 $.ajax({ 130 $.ajax({
135 method: 'POST', 131 method: 'POST',
@@ -140,12 +136,13 @@ function getCouponHandle(allCoupons) { @@ -140,12 +136,13 @@ function getCouponHandle(allCoupons) {
140 }).then(function(res) { 136 }).then(function(res) {
141 if (res.code === 200) { 137 if (res.code === 200) {
142 138
143 - //tip.show('优惠券可用'); 139 + // tip.show('优惠券可用');
144 orderInfo('couponCode', res.data.coupon_code); 140 orderInfo('couponCode', res.data.coupon_code);
145 orderInfo('couponName', res.data.coupon_title); 141 orderInfo('couponName', res.data.coupon_title);
146 - //实付金额发生变化,使用有货币为0 142 +
  143 + // 实付金额发生变化,使用有货币为0
147 orderInfo('yohoCoin', 0); 144 orderInfo('yohoCoin', 0);
148 - window.location.href = '/cart/index/orderEnsure'; 145 + window.location.href = '/cart/index/new/orderEnsure';
149 } else if (res.message) { 146 } else if (res.message) {
150 tip.show(res.message); 147 tip.show(res.message);
151 } 148 }
@@ -153,7 +150,6 @@ function getCouponHandle(allCoupons) { @@ -153,7 +150,6 @@ function getCouponHandle(allCoupons) {
153 tip.show('网络错误'); 150 tip.show('网络错误');
154 }); 151 });
155 }); 152 });
156 - });  
157 153
158 if (notAvailableCoupons.length) { 154 if (notAvailableCoupons.length) {
159 $('.not-avaliable-coupon-line').show(); 155 $('.not-avaliable-coupon-line').show();
  1 +/**
  2 + * 物流信息页面
  3 + * @author: 赵彪<bill.zhao@yoho.cn>
  4 + * @date: 2015/12/02
  5 + */
  6 +
  7 +var $ = require('yoho-jquery');
  8 +
  9 +var $footer = $('#yoho-footer'),
  10 + winH = window.outerHeight,
  11 + bodyH = document.body.offsetHeight,
  12 + footH = $footer.height();
  13 +
  14 +require('../common');
  15 +function addFooterTopBorder() {
  16 + if (footH + bodyH > winH) {
  17 + window.rePosFooter();
  18 + } else {
  19 + $footer.css('border-top', '1px solid #f1f1f1');
  20 + }
  21 +}
  22 +
  23 +$(document).ready(addFooterTopBorder);
  24 +
  25 +require('./recommend-for-you-user-center');
  26 +
  27 +// 提前触发lazyload
  28 +$(window).scrollTop(1).scrollTop(0);
  1 +require('../common');
@@ -65,7 +65,7 @@ @@ -65,7 +65,7 @@
65 } 65 }
66 66
67 .kind-list { 67 .kind-list {
68 - padding-top: 15px; 68 + padding-top: 40px;
69 69
70 li { 70 li {
71 font-size: 22px; 71 font-size: 22px;
@@ -87,7 +87,7 @@ @@ -87,7 +87,7 @@
87 height: auto; 87 height: auto;
88 overflow: hidden; 88 overflow: hidden;
89 padding-left: 10%; 89 padding-left: 10%;
90 - padding-bottom: 12px; 90 + padding-bottom: 32px;
91 position: relative; 91 position: relative;
92 92
93 span { 93 span {
@@ -7,3 +7,4 @@ @@ -7,3 +7,4 @@
7 @import "new/new-arrival"; 7 @import "new/new-arrival";
8 @import "newsale/hot-rank"; 8 @import "newsale/hot-rank";
9 @import "bundle/index"; 9 @import "bundle/index";
  10 +@import "detail/limit-help";
  1 +.limit-help-page {
  2 + padding: 28px;
  3 + color: #444;
  4 +
  5 + h2 {
  6 + font-size: 30px;
  7 + font-weight: bold;
  8 + }
  9 +
  10 + .method {
  11 + display: block;
  12 + width: 80px;
  13 + height: 35px;
  14 + line-height: 35px;
  15 + background-color: #444;
  16 + color: #fff;
  17 + border-radius: 20px;
  18 + text-align: center;
  19 + margin: 20px 0;
  20 + }
  21 +
  22 + li {
  23 + font-size: 24px;
  24 + }
  25 +
  26 + .intro-img {
  27 + width: 100%;
  28 + height: 220px;
  29 + background-size: 100%;
  30 + background-repeat: no-repeat;
  31 + margin: 20px 0;
  32 + }
  33 +
  34 + .method-1 {
  35 + li:nth-child(1) .intro-img{
  36 + background-image: resolve(product/help/1.png);
  37 + }
  38 + li:nth-child(2) .intro-img{
  39 + background-image: resolve(product/help/2.png);
  40 + }
  41 + li:nth-child(3) .intro-img{
  42 + background-image: resolve(product/help/3.png);
  43 + }
  44 + }
  45 + .method-2 {
  46 + li:nth-child(1) .intro-img{
  47 + background-image: resolve(product/help/4.png);
  48 + }
  49 + li:nth-child(2) .intro-img{
  50 + background-image: resolve(product/help/5.png);
  51 + }
  52 + li:nth-child(3) .intro-img{
  53 + background-image: resolve(product/help/6.png);
  54 + }
  55 + li:nth-child(4) .intro-img{
  56 + background-image: resolve(product/help/7.png);
  57 + }
  58 + }
  59 +
  60 + .how {
  61 + li:nth-child(1) .intro-img{
  62 + background-image: resolve(product/help/8.png);
  63 + }
  64 + li:nth-child(2) .intro-img{
  65 + background-image: resolve(product/help/9.png);
  66 + margin-bottom: 0;
  67 + }
  68 + }
  69 +}
@@ -308,22 +308,14 @@ const procCartData = (data, onlyGift, onlyAdvanceBuy, isAdvanceCart) => { @@ -308,22 +308,14 @@ const procCartData = (data, onlyGift, onlyAdvanceBuy, isAdvanceCart) => {
308 result.freebieOrAdvanceBuy = true; 308 result.freebieOrAdvanceBuy = true;
309 309
310 // 赠品 310 // 赠品
311 - result.freebie = data.g_gift_list.filter(freebie => {  
312 - return freebie.status !== 30 && freebie.status !== 0;  
313 - }); 311 + result.freebie = data.g_gift_list.filter(freebie => freebie.status !== 30 && freebie.status !== 0);
314 result.giftCount = result.freebie.length; 312 result.giftCount = result.freebie.length;
315 - result.giftHasStorage = _.some(result.freebie, freebie => {  
316 - return freebie.status === 10;  
317 - }); 313 + result.giftHasStorage = _.some(result.freebie, freebie => freebie.status === 10);
318 314
319 // 加价购 315 // 加价购
320 - result.advanceBuy = data.g_price_gift_list.filter(advanceBuy => {  
321 - return advanceBuy.status !== 30 && advanceBuy.status !== 0;  
322 - }); 316 + result.advanceBuy = data.g_price_gift_list.filter(advanceBuy => advanceBuy.status !== 30 && advanceBuy.status !== 0);
323 result.advanceBuyCount = result.advanceBuy.length; 317 result.advanceBuyCount = result.advanceBuy.length;
324 - result.advanceHasStorage = _.some(result.advanceBuy, advanceBuy => {  
325 - return advanceBuy.status === 10;  
326 - }); 318 + result.advanceHasStorage = _.some(result.advanceBuy, advanceBuy => advanceBuy.status === 10);
327 } 319 }
328 320
329 // 已参加的活动 321 // 已参加的活动