Authored by yyq

退换货列表页

... ... @@ -4,17 +4,15 @@
*/
'use strict';
const cookie = global.yoho.cookie;
const returnsModel = require('../models/returns');
/*
我的退换货-列表页
*/
const index = (req, res, next) => {
const uid = cookie.getUid(req);
const page = req.query.page;
returnsModel.getReturnsList(uid, page /* ,limit=10*/)
returnsModel.getReturnsList(req.user.uid, page, 10)
.then(data => {
const viewData = Object.assign({
module: 'home',
... ...
... ... @@ -6,13 +6,16 @@
'use strict';
const _ = require('lodash');
const path = require('path');
// const path = require('path');
const Promise = require('bluebird');
const returnAPI = require('./returns-api');
const pager = require(`${global.utils}/pager`).setPager;
// 使用 product中的分页逻辑
const pagerPath = path.join(global.appRoot, '/apps/product/models/public-handler.js');
const pager = require(pagerPath).handlePagerData;
// const pagerPath = path.join(global.appRoot, '/apps/product/models/public-handler.js');
// const pager = require(pagerPath).handlePagerData;
const co = Promise.coroutine;
const api = global.yoho.API;
... ... @@ -23,6 +26,8 @@ const REFUND = 1; // 退货
const EXCHANGE = 2; // 换货
const TRUE = 'Y';
const RETURNS_EMPTY = '您没有退/换货订单';
const CANCEL_REFUND_URI = '/home/returns/cancelRefund';
const CANCEL_EXCHANGE_URI = '/home/returns/cancelChange';
const REFUND_URI = '/home/returns/refundDetail';
const EXCHANGE_URI = '/home/returns/exchangeDetail';
... ... @@ -48,19 +53,18 @@ const setDetailGoods = (list) => {
// 处理订单商品的数据
function getGoodsData(goods) {
const arr = [];
let arr = [];
goods.forEach(good => {
const obj = {};
const cnAlphabet = good.cn_alphabet || '';
obj.href = getProductUrlBySkc(good.product_id, good.goods_id, cnAlphabet);
obj.thumb = helpers.image(good.goods_image, 60, 60);
obj.name = good.product_name;
obj.color = good.color_name;
obj.size = good.size_name;
arr.push(obj);
let cnAlphabet = good.cn_alphabet || '';
arr.push({
href: getProductUrlBySkc(good.product_id, good.goods_id, cnAlphabet),
thumb: helpers.image(good.goods_image, 60, 60),
name: good.product_name,
color: good.color_name,
size: good.size_name
});
});
return arr;
... ... @@ -77,57 +81,60 @@ const getReturnsList = co(function*(uid, page, limit) {
page = Number.parseInt(page, 10) || 1;
limit = Number.parseInt(limit, 10) || 10;
const obj = {
let obj = {
orders: [],
pager: {}
};
let response = yield api.post('', {
method: 'app.refund.getList',
data: { uid: uid, page: page, limit: limit }
uid: uid,
page: page,
limit: limit
});
let repData = response.data;
// 处理数据
if (response.code === 200 && repData && repData.list.length) {
obj.pager = pager(repData.total, {
page: page,
limit: limit
});
obj.pager = Object.assign({
count: repData.total,
curPage: page,
totalPages: repData.total_page || 1
}, pager(repData.total_page, {page: page}));
repData.list.forEach(item => {
const t = {};
t.returnId = item.id;
t.orderNum = item.order_code;
t.orderTime = item.oreder_create_time.replace('-', '/');
t.returnTime = item.create_time;
t.returnStatus = item.status_name;
let t = {
returnId: item.id,
orderNum: item.order_code,
orderTime: _.replace(item.oreder_create_time, '-', '/'),
returnTime: item.create_time,
returnStatus: item.status_name
};
const canCancel = item.canCancel === TRUE;
let isChange, uri;
let canCancel = item.canCancel === TRUE;
let isChange, uri = '', cancelUri = '';
switch (item.refund_type) {
case REFUND:
isChange = false;
if (canCancel) {
uri = REFUND_URI;
}
uri = REFUND_URI;
cancelUri = CANCEL_REFUND_URI;
break;
case EXCHANGE:
isChange = true;
if (canCancel) {
uri = EXCHANGE_URI;
}
uri = EXCHANGE_URI;
cancelUri = CANCEL_EXCHANGE_URI;
break;
default:
break;
}
t.isChange = isChange;
t.canCancelUrl = helpers.urlFormat(uri);
t.moreHref = helpers.urlFormat(uri, { id: item.id });
t.goods = getGoodsData(item.goods);
Object.assign(t, {
isChange: isChange,
canCancel: canCancel,
canCancelUrl: cancelUri,
moreHref: helpers.urlFormat(uri, { id: item.id }),
goods: getGoodsData(item.goods)
});
obj.orders.push(t);
});
... ...
... ... @@ -21,7 +21,8 @@ const commentController = require(`${cRoot}/comment`);
// const complaintsController = require(`${cRoot}/complaints`);
const messageController = require(`${cRoot}/message`);
// const returnsController = require(`${cRoot}/returns`);
const returnsController = require(`${cRoot}/returns`);
// const IndexController = require(`${cRoot}/index`);
// const CurrencyController = require(`${cRoot}/currency`);
const personalController = require(`${cRoot}/qrcode`);
... ... @@ -204,12 +205,12 @@ router.get('/message/read', messageController.readMsg);
router.get('/message/pickCoupon', messageController.pickCoupon);
// 我的退/换货
// router.get('/returns', returnsController.index);
// router.get('/refund/apply', returnsController.refundApply);
// router.get('/refund/detail', returnsController.refundDetail);
// router.get('/exchange/apply', returnsController.exchangeApply);
// router.get('/exchange/detail', returnsController.refundDetail);
// router.get('/returns/success', returnsController.index);
router.get('/returns', [getCommonHeader, getHomeNav], returnsController.index);
router.get('/refund/apply', [getCommonHeader, getHomeNav], returnsController.refundApply);
router.get('/refund/detail', [getCommonHeader, getHomeNav], returnsController.refundDetail);
router.get('/exchange/apply', [getCommonHeader, getHomeNav], returnsController.exchangeApply);
router.get('/exchange/detail', [getCommonHeader, getHomeNav], returnsController.refundDetail);
router.get('/returns/success', returnsController.index);
// router.get('/index', [getCommonHeader, getHomeNav], IndexController.index);
... ...
... ... @@ -50,14 +50,15 @@
{{returnStatus}}
</div>
<div class="operation">
{{#if canCancel}}
<a class="op-item cancel-trigger" href="javascript:;" data-id="{{returnId}}" data-url="{{canCancelUrl}}">取消申请</a>
{{/ if}}
<a class="op-item" href="{{moreHref}}" target="_blank">查看详情</a>
</div>
</div>
</div>
{{/each}}
{{#with ../pager}}
{{> common/foot-pager footPager=this}}
{{/with}}
{{> pager}}
{{else}}
{{#with orders}}
{{> empty}}
... ...

45 KB | W: | H:

46.1 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin
... ... @@ -4,13 +4,16 @@
* @date: 2016/2/26
*/
var $ = require('yoho-jquery');
var $ = require('yoho-jquery'),
Handlebars = require('yoho-handlebars'),
dialog = require('../common/dialog');
var $returnState = $('.visual-return-state li'),
$detail = $('.detail-container'),
$courierCode = $('.courier-code'),
$expressCompany = $('#express-company'),
$expressNumber = $('#express-number'),
$expressName = $('#express-name'),
$expressViewBox = $('.express-view-box > span');
var returnId = $('#return-id').val(),
... ... @@ -20,6 +23,10 @@ var returnId = $('#return-id').val(),
expList = {},
isChange = false;
var Dialog = dialog.Dialog,
active,
cancelApplyDialog = '<p class="message-title"><i class="{{messageIcon}}"></i>{{messageTitle}}</p><p class="message-summary">{{messageSummary}}</p>'; // eslint-disable-line
function syncExpressInfo() {
expCompany = expList[expId] ? expList[expId] : '';
$expressViewBox.html(expCompany + ' 快递单号:' + expNumber);
... ... @@ -27,20 +34,35 @@ function syncExpressInfo() {
$expressNumber.val(expNumber);
}
// 其他快递公司需要填写物流
$expressCompany.on('change', function() {
if (+$(this).val() === 100) {
$expressName.removeClass('hide');
} else {
$expressName.addClass('hide');
}
});
function validateExpress() {
var send = {};
send.number = $expressNumber.val();
send.id = $expressCompany.val() * 1;
send.name = expList[send.id];
if (send.id === 100) {
send.name = $expressName.val();
}
if (!send.id) {
alert('请选择快递公司');
new dialog.Alert('请选择快递公司').show();
} else if (!send.name) {
new dialog.Alert('请填写快递公司').show();
} else if (!send.number) {
alert('请填入快递单号');
new dialog.Alert('请填入快递单号').show();
} else {
return send;
}
return false;
}
... ... @@ -59,7 +81,7 @@ function sendExpressCode() {
isChange: isChange,
expressId: sendParm.id,
expressNumber: sendParm.number,
expressCompany: expList[sendParm.id]
expressCompany: sendParm.name
}
}).then(function(jsonData) {
if (jsonData.code === 200) {
... ... @@ -67,13 +89,57 @@ function sendExpressCode() {
expNumber = sendParm.number;
$returnState.eq(2).addClass('act');
} else {
alert(jsonData.message);
new dialog.Alert(jsonData.message).show();
}
syncExpressInfo();
$courierCode.removeClass('in-edit');
});
}
function cancelApply(id, url) {
var template = Handlebars.compile(cancelApplyDialog);
var html = template({messageIcon: 'icon-warn', messageTitle: '取消申请', messageSummary: '您确定要请取消申请吗?'});
var options = {
mask: true,
btns: [
{
id: 'cancel-sure',
name: '确定',
btnClass: ['cancel-sure'],
cb: function() {
$.ajax({
type: 'POST',
url: url,
data: {
id: id
}
}).then(function(data) {
active.close();
if (data.code === 200) {
location.reload();
} else {
new dialog.Alert(data.message).show();
}
});
}
},
{
id: 'cancel-no',
name: '取消',
btnClass: ['cancel-no'],
cb: function() {
active.close();
}
}
],
content: html,
className: 'returns-cancel-dialog'
};
return new Dialog(options);
}
if ($detail.parent().hasClass('exchange-detail')) {
isChange = true;
}
... ... @@ -93,3 +159,8 @@ $('#modify').click(function() {
$('#submit-btn').click(function() {
sendExpressCode();
});
$('.cancel-trigger').click(function() {
active = cancelApply($(this).data('id'), $(this).data('url'));
active.show();
});
... ...
... ... @@ -4,5 +4,6 @@
* @date: 2016/2/26
*/
require('../common');
require('./returns-detail');
require('./returns-apply');
... ...
... ... @@ -47,3 +47,65 @@
}
}
}
.returns-cancel-dialog{
width: 350px;
background: #fff;
padding: 20px 30px 35px 30px;
.message-title{
margin-top: 40px;
margin-bottom: 27px;
font-size: 24px;
font-weight: 700;
}
.message-summary{
width: 250px;
margin: 0 auto 22px;
font-size: 14px;
word-wrap: break-word;
line-height: 20px;
color: #444;
}
.btns {
padding: 15px 30px 0;
text-align: center;
.btn {
height: 35px;
font-size: 15px;
line-height: 35px;
}
.cancel-sure {
width: 130px;
color: #fff;
background: #000;
border: none;
}
.cancel-no {
margin-left: 30px;
background: #fff;
color: #000;
border-color: #000;
width: 126px;
}
}
.close{
top: 15px;
right: 15px;
.iconfont{
font-size: 30px;
}
}
.icon-warn{
display: inline-block;
margin-right: 10px;
background: url('/home/icon-warn.png') no-repeat;
width: 30px;
height: 30px;
vertical-align: -6px;
}
}
... ...