Authored by biao

update for change apply

... ... @@ -71,7 +71,29 @@ const refundApply = (req, res, next) => {
};
const exchange = (req, res, next) => {
next();
const code = req.params.orderCode;
const uid = req.user.uid || '8050560';
returns.getChangeGoodsList(code, uid).then(result => {
res.display('index', {
page: 'returns-change',
isMe: true,
content: Object.assign({
nav: mcHandler.getMeCrumb('我的退/换货'),
navigation: mcHandler.getSideMenu('我的退/换货'),
banner: 'http://placehold.it/{width}x{height}'
}, result)
});
}).catch(next);
};
const getProductInfo = (req, res, next) => {
const productId = req.query.productId;
const productSkn = req.query.productSkn;
returns.getProductInfo(productId, productSkn).then(result => {
res.json(result);
}).catch(next);
};
module.exports = {
... ... @@ -79,5 +101,6 @@ module.exports = {
detail,
refund,
refundApply,
exchange
exchange,
getProductInfo
};
... ...
... ... @@ -34,9 +34,27 @@ const refundSubmitAsync = (orderCode, uid, goods, payment) => {
});
};
const getChangeGoodsListAsync = (orderCode, uid) => {
return api.get('', {
method: 'app.change.goodsList',
order_code: orderCode,
uid: uid
});
};
const getProductInfoAsync = (productId, productSkn) => {
return api.get('', {
method: 'app.product.data',
product_id: productId,
product_skn: productSkn
});
};
module.exports = {
getOrderInfoAsync,
getRefundGoodsAsync,
refundSubmitAsync
refundSubmitAsync,
getChangeGoodsListAsync,
getProductInfoAsync
};
... ...
... ... @@ -16,6 +16,20 @@ const helpers = global.yoho.helpers;
const pageSize = 10;
const _reduceArrByProductSku = data => {
const d = [];
d.push(data[0]);
data.reduce((p, c) => { //eslint-disable-line
if (p && c && p.productSku !== c.productSku) {
d.push[c];
}
});
return d;
};
const getUserReturn = (uid, page) => {
return api.get('', {
... ... @@ -133,8 +147,52 @@ const saveRefund = (orderCode, uid, goods, payment) => {
});
};
const getProductInfo = (productId, productSkn) => {
return returnsAPI.getProductInfoAsync(productId, productSkn).then(result => {
if (result.code === 200) {
camelCase(result);
result.data.goodsList.forEach(good => {
good.colorImage = helpers.image(good.colorImage, 20, 20);
});
}
return result;
});
};
const getChangeGoodsList = (orderCode, uid) => {
return returnsAPI.getChangeGoodsListAsync(orderCode, uid).then(result => {
const basicData = {
title: '申请退货'
};
let data;
console.log(result);
if (result && result.data) {
data = camelCase(result.data);
data.goodsList = _reduceArrByProductSku(data.goodsList);
data.hidePrice = true;
data.goodsList.forEach(good => {
good.showCheckbox = true;
good.hidePrice = true;
good.buyNumber = good.num;
});
}
return {
returnsChange: Object.assign(basicData, data)
};
});
};
module.exports = {
getUserReturn,
getRefundGoodsData,
saveRefund
saveRefund,
getChangeGoodsList,
getProductInfo
};
... ...
... ... @@ -32,6 +32,7 @@ router.get('/return/refund/:orderCode', returns.refund);
router.get('/return/exchange/:orderCode', returns.exchange);
router.get('/return/:returnId', returns.detail);
router.post('/return/refund/apply', returns.refundApply);
router.get('/return/getProductInfo', returns.getProductInfo);
// 个人中心首页/收货地址
router.get('/address', address.index);
... ...
... ... @@ -41,6 +41,11 @@
{{> returns-list}}
{{/if}}
{{!-- 发起换货申请 --}}
{{#if returnsChange}}
{{> returns-change}}
{{/if}}
{{!-- 我的收藏 --}}
{{#if collection}}
{{> collection}}
... ...
<div class="good-info {{#if @last}}last{{/if}}">
<img src="{{image goodsImage 65 90}}">
<div class="detail">
<p class="with-bottom-space">{{productName}}</p>
<span class="with-space">颜色:{{colorName}}</span>
<span>尺码:
<span class="bold">{{sizeName}}</span>
</span>
<p class="bold buy-number">{{> icon/error-round}}{{buyNumber}}</p>
</div>
</div>
... ...
<div class="goods-container special-border {{#if hidePrice}}no-price{{/if}}">
{{#orderGoods}}
<div class="good-info {{#if @last}}last{{/if}}">
<img src="{{image goodsImage 65 90}}">
<div class="detail">
<p class="with-bottom-space">{{productName}}</p>
<span class="with-space">颜色:{{colorName}}</span>
<span>尺码:
<span class="bold">{{sizeName}}</span>
</span>
<p class="bold buy-number">{{> icon/error-round}}{{buyNumber}}</p>
</div>
</div>
{{> order/good-info}}
{{#unless hidePrice}}
<div class="sub-column right-border bold">
<p class="{{#if @last}}last{{/if}}">¥{{goodsPrice}}</p>
</div>
{{/unless}}
<div class="sub-column right-border special-column bold">
<p class="bold">{{buyNumber}}</p>
</div>
<div class="sub-column special-column bold">
<p class="bold">¥{{goodsAmount}}</p>
</div>
{{/unless}}
{{/orderGoods}}
</div>
... ...
... ... @@ -28,7 +28,9 @@
{{#if showEditOption}}
<p class="subtext">评价晒单</p>
<p class="subtext">申请退货</p>
<p class="subtext">申请换货</p>
<a href="/return/exchange?code={{orderCode}}&id={{productId}}&skn={{productSkn}}">
<p class="subtext">申请换货</p>
</a>
<p class="subtext delete">删除订单</p>
{{/if}}
{{#if showGetBtn}}
... ...
<div class="return-wrap user-order change">
{{#returnsChange}}
{{> common/subtitle}}
<div class="order">
<div class="table returns">
<ul class="header">
<li class="info">商品信息</li>
<li class="change-reason">换货原因</li>
<li class="change-num">换货数量</li>
</ul>
{{#goodsList}}
<div class="table-body">
<div class="goods-container no-price" data-id="{{productId}}" data-skn="{{productSkn}}">
{{# showCheckbox}}
{{> icon/checkbox}}
<!--
<span class="iconfont checkbox {{#if checked}}checked{{/if}}">{{#if checked}}&#xe602;{{^}}&#xe601;{{/if}}</span>
-->
{{/ showCheckbox}}
{{> order/good-info}}
<div class="sub-column">
退货原因
</div>
<div class="sub-column">
数量
</div>
</div>
</div>
<div class="form">
<div class="group color">
<span class="title">
<span class="artirisk">*</span>
换货Color: <span class="color-text" data-color={{colorId}}>{{colorName}}</span>
</span>
</div>
<div class="group size">
<span class="title">
<span class="artirisk">*</span>
换货Size: <span class="size-text" data-size="{{sizeId}}">{{sizeName}}</span>
</span>
</div>
</div>
{{/goodsList}}
</div>
</div>
{{/returnsChange}}
</div>
... ...
... ... @@ -19,7 +19,7 @@ module.exports = {
},
cookieDomain: 'yohoblk.com',
domains: {
api: 'http://testapi.yoho.cn:28078/', // devapi.yoho.cn:58078 testapi.yoho.cn:28078 devapi.yoho.cn:58078
api: 'http://devapi.yoho.cn:58078/', // devapi.yoho.cn:58078 testapi.yoho.cn:28078 devapi.yoho.cn:58078
service: 'http://testservice.yoho.cn:28077/', // testservice.yoho.cn:28077 devservice.yoho.cn:58077
search: 'http://192.168.102.216:8080/yohosearch/'
},
... ...
var colorTpl = require('../../tpl/me/color-list.hbs');
var sizeTpl = require('../../tpl/me/size-list.hbs');
// var scope = {
// 1: {
// min: true,
// do: function() {
// console.log('min');
// }
// }
// }
function renderList(data) {
var cTpl;
var sTpl;
var $c = $('.group.color');
var $s = $('.group.size');
if (data) {
cTpl = colorTpl(data);
sTpl = sizeTpl(data);
$c.append(cTpl);
$s.append(sTpl);
}
}
function bindColorEvent() {
$('.color-list img').on('click', function() {
var $this = $(this);
var $sizeList = $('.size-list');
var index = $this.data('index');
var colorId = $this.data('color');
var colorText = $this.attr('alt');
var $c = $('.group.color .color-text');
$c.text(colorText);
$c.attr('data-color', colorId);
$sizeList.removeClass('hide');
$sizeList.addClass('hide');
$sizeList.eq(index).removeClass('hide');
});
}
function initSizeId() {
var s = $('.size-list:not("hide")').find('span').eq(0).data('size');
$('.group.size .size-text').eq(0).attr('data-size', s);
}
function bindSizeEvent() {
$('.size-list span').on('click', function() {
var $this = $(this);
var s = $this.text();
var id = $this.data('size');
var $s = $('.group.size .size-text');
$s.text(s);
$s.attr('data-size', id);
});
}
// function bindNumberEvent() {
// $('.number .minus').on('click', function() {
// var val = $('.number .value').text();
//
// if (scope[val].min) {
// scope[val].do();
// }
// });
// }
function getProductInfo() {
var $el = $('.goods-container');
var id = $el.data('id');
var skn = $el.data('skn');
if (id && skn) {
$.ajax({
url: '/me/return/getProductInfo',
data: {
productId: id,
productSkn: skn
}
}).done(function(result) {
console.log(result);
if (result.code === 200) {
renderList(result.data);
initSizeId();
bindColorEvent();
bindSizeEvent();
}
});
}
}
getProductInfo();
... ...
.return-wrap {
.table {
width: 100%;
max-width: 990px;
.header {
.info {
... ... @@ -9,12 +10,26 @@
}
.st,
.op {
.op,
.change-reason,
.change-num {
width: 206px;
}
}
&.returns {
.good-info {
border: none;
.detail {
width: 380px !important;
}
}
}
.goods-container {
width: 990px;
.for-return {
display: block;
}
... ... @@ -23,24 +38,36 @@
.no-price {
.good-info {
border-right: none;
}
.good-info {
.detail {
width: 408px;
}
}
}
.sub-column {
width: 204px !important;
}
.checkbox-column {
display: table-cell;
width: 100px;
}
.common-column {
width: 208px;
.refund-status {
margin-bottom: 10px;
}
.refund-type {
position: static;
}
&.no-border {
width: 204px !important;
}
}
}
... ...
<div class="color-list">
{{#goodsList}}
<img src="{{colorImage}}" alt="{{colorName}}" data-index="{{@index}}" data-color={{colorId}}>
{{/goodsList}}
</div>
... ...
<div>
{{#goodsList}}
<div class="{{#unless @first}}hide{{/unless}} size-list" data-index="{{@index}}">
{{#sizeList}}
<span data-size="{{sizeId}}">{{sizeName}}</span>
{{/sizeList}}
</div>
{{/goodsList}}
</div>
... ...