Authored by biao

Merge branch 'fix/confirm' into develop

... ... @@ -15,7 +15,7 @@ const orderModel = require('../models/order');
const index = (req, res) => {
const type = req.query.type;
const page = req.query.page;
const uid = req.user.uid || '10931021';
const uid = req.user.uid;
orderModel.getOrderData(uid, type, page).then(result => {
res.display('index', {
... ... @@ -32,7 +32,7 @@ const index = (req, res) => {
const detail = (req, res) => {
const code = req.query.code;
const uid = req.user.uid || '10931021';
const uid = req.user.uid;
orderModel.getOrderDetail(uid, code).then(result => {
res.display('index', {
... ... @@ -50,7 +50,7 @@ const detail = (req, res) => {
const getOrderList = (req, res) => {
const type = req.query.type;
const page = req.query.page;
const uid = req.user.uid || '10931021';
const uid = req.user.uid;
orderModel.getOrderData(uid, type, page).then(result => {
res.display('order-table', {
... ... @@ -67,7 +67,7 @@ const getOrderList = (req, res) => {
const getOrderTotal = (req, res) => {
const type = req.query.type;
const uid = req.user.uid || '10931021';
const uid = req.user.uid;
orderModel.getOrderData(uid, type).then(result => {
... ... @@ -80,7 +80,7 @@ const getOrderTotal = (req, res) => {
};
const cancelOrder = (req, res) => {
const uid = req.user.uid || '10931021';
const uid = req.user.uid;
const data = req.query;
orderModel.cancelOrder(uid, data).then(result => {
... ... @@ -89,7 +89,7 @@ const cancelOrder = (req, res) => {
};
const deleteOrder = (req, res) => {
const uid = req.user.uid || '10931021';
const uid = req.user.uid;
const code = req.query.orderCode;
orderModel.deleteOrder(uid, code).then(result => {
... ... @@ -98,7 +98,7 @@ const deleteOrder = (req, res) => {
};
const getExpressInfo = (req, res) => {
const uid = req.user.uid || '10931021';
const uid = req.user.uid;
const code = req.query.orderCode;
orderModel.getExpressInfo(uid, code).then(result => {
... ... @@ -113,7 +113,7 @@ const getCancelOrderReason = (req, res) => {
};
const editOrder = (req, res) => {
const uid = req.user.uid || '10931021';
const uid = req.user.uid;
const query = req.query;
query.uid = uid;
... ... @@ -124,7 +124,7 @@ const editOrder = (req, res) => {
};
const reAdd = (req, res) => {
const uid = req.user.uid || '10931021';
const uid = req.user.uid;
const code = req.query.orderCode;
orderModel.reAddCart(uid, code).then(result => {
... ... @@ -132,6 +132,15 @@ const reAdd = (req, res) => {
});
};
const confirmReceive = (req, res) => {
const uid = req.user.uid;
const code = req.query.orderCode;
orderModel.confirmReceive(uid, code).then(result => {
res.json(result);
});
};
module.exports = {
index,
detail,
... ... @@ -142,5 +151,6 @@ module.exports = {
editOrder,
getExpressInfo,
getCancelOrderReason,
reAdd
reAdd,
confirmReceive
};
... ...
... ... @@ -130,10 +130,6 @@ const isMobileOrder = {
6: true
};
// const _removeRmbIcon = str => {
// return str.replace('¥', '');
// }
// 转换时间戳
const _convertUnixTime = src => {
return moment.unix(src).format('YYYY-MM-DD hh:mm:ss');
... ... @@ -286,8 +282,6 @@ const deleteOrder = (uid, code) => {
method: 'app.SpaceOrders.delOrderByCode',
uid: uid,
order_code: code
}, {
cache: true
});
};
... ... @@ -298,8 +292,6 @@ const cancelOrder = (uid, data) => {
order_code: data.orderCode,
reason_id: data.reasonId,
reason: data.reason
}, {
cache: true
});
};
... ... @@ -409,18 +401,6 @@ const getOrderDetail = (uid, code) => {
detail.showLeftTime = true;
}
// 需要和接口确认如何获取运费,接口文档和线上数据不一致
// if (detail.shippingCost) {
// detail.shippingCost = _removeRmbIcon(detail.shippingCost);
// } else if (detail.promotionFormulas) {
// detail.promotionFormulas.forEach(d => {
// if (d.promotion === '运费') {
// detail.shippingCost = _removeRmbIcon(d.promotionAmount);
// }
// });
// }
if (st !== 0 && detail.isCancel !== 'Y') {
detail.showPaid = true;
}
... ... @@ -461,9 +441,8 @@ const editOrder = data => {
area_code: data.areaCode,
address: data.address,
mobile: data.mobile,
phone: data.phone
}, {
cache: true
phone: data.phone,
app_type: 1
});
};
... ... @@ -471,9 +450,17 @@ const reAddCart = (uid, code) => {
return api.get('', {
method: 'app.Shopping.readd',
uid: uid,
order_code: code
}, {
cache: true
order_code: code,
app_type: 1
});
};
const confirmReceive = (uid, code) => {
return api.get('', {
method: 'app.SpaceOrders.confirm',
uid: uid,
order_code: code,
app_type: 1
});
};
... ... @@ -485,5 +472,6 @@ module.exports = {
deleteOrder,
editOrder,
getExpressInfo,
reAddCart: reAddCart
reAddCart,
confirmReceive
};
... ...
... ... @@ -22,8 +22,8 @@ const favorite = require(`${cRoot}/favorite`);
const returns = require(`${cRoot}/returns`);
// 个人中心首页/订单
router.get(['/', '/order'], order.index);
router.get(['/', '/order/detail'], order.detail);
router.get(['/', '/order'], auth, order.index);
router.get(['/', '/order/detail'], auth, order.detail);
router.get('/getOrderList', order.getOrderList);
router.get('/getOrderTotal', order.getOrderTotal);
router.get('/deleteOrder', order.deleteOrder);
... ... @@ -32,6 +32,7 @@ router.get('/getCancelOrderReason', order.getCancelOrderReason);
router.get('/getExpressInfo', order.getExpressInfo);
router.get('/editOrder', order.editOrder);
router.get('/reAdd', order.reAdd);
router.get('/confirmReceive', order.confirmReceive);
// 退换货
router.get('/return', returns.index);
... ...
... ... @@ -38,7 +38,7 @@
<p class="subtext delete">删除订单</p>
{{/if}}
{{#if showGetBtn}}
<span class="btn black">确认收货</span>
<span class="btn black confirm-receive">确认收货</span>
<p class="subtext express">物流进度</p>
{{/if}}
... ...
... ... @@ -14,6 +14,8 @@ var cancelOrder = require('./order/cancel-order');
var reOrder = require('./order/readd-order');
var confirmReceive = require('./order/confirm-receive');
// 订单剩余时间显示及倒计时
var countDown = require('./order/countdown');
... ... @@ -300,6 +302,14 @@ function bindExpressEvent() {
});
}
function bindConfirmReceiveEvent() {
$('.confirm-receive').on('click', function() {
var code = $(this).closest('.order').data('code');
confirmReceive.done(code);
});
}
function bindEvent() {
bindPaginationClick();
... ... @@ -307,6 +317,7 @@ function bindEvent() {
bindCancelEvent();
bindExpressEvent();
bindBuyEvent();
bindConfirmReceiveEvent();
}
bindEvent();
... ...
var _alert = require('../../plugins/dialog').Alert;
function confirmReceive(orderCode) {
$.ajax({
url: '/me/confirmReceive',
data: {
orderCode: orderCode
}
}).done(function(r) {
if (r.code === 200) {
location.reload();
} else {
new _alert('<h1>' + r.message + '</h1>').show();
}
}).fail(function(e) {
new _alert('<h1>' + e + '</h1>').show();
});
}
module.exports = {
done: confirmReceive
};
... ...