Authored by 郭成尧

detail-page

... ... @@ -10,6 +10,7 @@ const helpers = global.yoho.helpers;
const _ = require('lodash');
const headerModel = require('../../../doraemon/models/header'); // 头部model
const orderDetailModel = require('../models/orderDetail');
const orderModel = require('../models/order');
const payModel = require('../../cart/models/pay');
const orderDetailData = (req, res, next) => {
... ... @@ -26,10 +27,12 @@ const orderDetailData = (req, res, next) => {
Promise.all([
orderDetailModel.orderDetailData(uid, orderCode),
orderDetailModel.closeReasons()
orderDetailModel.closeReasons(),
orderModel.refundReason()
]).then(result => {
let orderDetail = result[0];
let cancelReason = result[1];
let refundReason = result[2];
Object.assign(orderDetail, {
cancelReason: cancelReason
... ... @@ -50,6 +53,7 @@ const orderDetailData = (req, res, next) => {
title: '订单详情',
pageFooter: true,
orderDetail: orderDetail,
refundReason: refundReason,
localCss: true,
});
}).catch(next);
... ...
... ... @@ -309,6 +309,16 @@ const orderDetailData = (uid, orderCode) => {
orderDetail.invoice.type = (orderDetail.invoice.type + '' === '2');
}
/* 申请退款 */
if (orderDetail.isMultiPackage === 'N' &&
parseInt(orderDetail.paymentType, 10) === 1 &&
orderDetail.paymentStatus === 'Y' &&
4 <= parseInt(orderDetail.status, 10) <= 5) {
Object.assign(orderDetail, {
refundApply: true
});
}
return orderDetail;
} else {
logger.error('detail info return no 200');
... ...
... ... @@ -153,6 +153,11 @@
<span class="btn btn-check-logistics">查看二维码</span>
</a>
{{/if}}
{{!-- 申请退款 --}}
{{#if refundApply}}
<span class="btn refund">申请退款</span>
{{/if}}
{{/if}}
</div>
</div>
... ... @@ -171,6 +176,22 @@
</div>
</div>
{{/ orderDetail}}
{{!-- 申请退款原因 --}}
<div class="refund-reason-mask">
<div class="refund-reason-box" >
<div class="box-head"><span class="box-cmp">完成</span></div>
<div class="swiper-container refund-box-main">
<ul class="swiper-wrapper">
{{#refundReason}}
<li class="swiper-slide" data-reason-id="{{id}}"><span >{{reason}}</span></li>
{{/refundReason}}
</ul>
<div class="refund-active-mask"></div>
</div>
</div>
</div>
</div>
<script>_ozprm = "orderid={{orderCode}}&ordertotal={{orderTotal}}";</script>
<script type="text/javascript" src="//static.yohobuy.com/m/v1/js/AG_Tracking.js"></script>
... ...
... ... @@ -18,7 +18,9 @@ var orderId = $('#order-detail').data('id'),
Swiper = require('yoho-swiper'),
$ownerInfo = $('.owner-info'),
$reaMask = $('.reason-mask'),
$refundReaMask = $('.refund-reason-mask'),
reasonSwiper,
refundReasonSwiper,
optHammer,
$createTime = new Date($('.createTime').text() * 1000);
... ... @@ -148,7 +150,7 @@ $(function() {
centeredSlides: true,
slidesPerView: 5,
direction: 'vertical',
onSlideChangeStart: function(reasonSwiper) {
onSlideChangeStart: function(reasonSwiper) {//eslint-disable-line
var activeIndex = reasonSwiper.activeIndex,
slides = reasonSwiper.slides,
i = 0;
... ... @@ -174,6 +176,39 @@ $(function() {
$(slides[activeIndex]).css('transform', '');
}
});
// 申请退款 Swiper
refundReasonSwiper = new Swiper('.refund-box-main', {
direction: 'vertical',
slidesPerView: 5,
centeredSlides: true,
initialSlide: 0,
onSlideChangeStart: function(refundReasonSwiper) {//eslint-disable-line
let activeIndex = refundReasonSwiper.activeIndex,
slides = refundReasonSwiper.slides,
i = 0;
if (slides.length !== 1) {
if (activeIndex === 0) {
for (i = 1; i < slides.length; i++) {
$(slides[i]).css('transform', '');
}
} else if (activeIndex === slides.length - 1) {
for (i = 0; i < activeIndex; i++) {
$(slides[i]).css('transform', 'rotateX(' + (30 + (activeIndex - i) * 12) + 'deg)');
}
} else {
for (i = 0; i < activeIndex; i++) {
$(slides[i]).css('transform', 'rotateX(' + (30 + (activeIndex - i) * 12) + 'deg)');
}
for (i = activeIndex + 1; i < slides.length; i++) {
$(slides[i]).css('transform', '');
}
}
}
$(slides[activeIndex]).css('transform', '');
}
});
});
$reaMask.find('.box-cmp').on('touchend', function(e) {
... ... @@ -205,6 +240,36 @@ $reaMask.find('.box-cmp').on('touchend', function(e) {
});
});
// 申请退款
$refundReaMask.find('.box-cmp').on('touchend', function() {
let selSolid = refundReasonSwiper.slides[refundReasonSwiper.activeIndex],
reason = $(selSolid).text(),
reasonId = $(selSolid).data('reasonId');
$.ajax({
type: 'GET',
url: '/home/refundApply',
data: {
id: $refundReaMask.data('orderId'),
reason: reason,
reasonId: reasonId
}
}).then(function(res) {
$refundReaMask.fadeOut();
if ($.type(res) !== 'object') {
return;
}
if (res.message) {
tip.show(res.message);
}
setTimeout(function() {
window.location.href = '/home/orders';
}, 2000);
}).fail(function() {
tip.show('网络错误');
});
});
$reaMask.on('touchend', function(event) {
if (event.target.className !== 'reason-mask') {
return false;
... ... @@ -214,6 +279,16 @@ $reaMask.on('touchend', function(event) {
event.stopPropagation();
});
// 申请退款
$refundReaMask.on('touchend', function(event) {
if (event.target.className !== 'reason-mask') {
return false;
}
$refundReaMask.css('visibility', 'hidden');
event.stopPropagation();
});
function formatDate(objD) {
var str,
yy = objD.getYear(),
... ...
... ... @@ -231,7 +231,8 @@
}
}
.reason-mask {
.reason-mask,
.refund-reason-mask {
position: fixed;
width: 100%;
height: 100%;
... ... @@ -241,7 +242,8 @@
z-index: 1;
visibility: hidden;
.reason-box {
.reason-box,
.refund-reason-box {
border-bottom: 1px solid #ccc;
font: inherit;
vertical-align: baseline;
... ... @@ -262,7 +264,8 @@
padding-right: 30px;
}
.box-main {
.box-main,
.refund-box-main {
background: #fff;
padding: 20px;
height: 300px;
... ...