Authored by biao

update for pay when receive and fix some bugs

... ... @@ -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 = global.yoho.uid || '10931021';
const uid = global.yoho.uid || '7394907';
orderModel.getOrderData(uid, type, page).then(result => {
res.render('index', {
... ... @@ -32,7 +32,7 @@ const index = (req, res) => {
const detail = (req, res) => {
const code = req.query.code;
const uid = global.yoho.uid || '10931021';
const uid = global.yoho.uid || '7394907';
orderModel.getOrderDetail(uid, code).then(result => {
res.render('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 = global.yoho.uid || '10931021';
const uid = global.yoho.uid || '7394907';
orderModel.getOrderData(uid, type, page).then(result => {
res.render('order-table', {
... ... @@ -65,7 +65,7 @@ const getOrderList = (req, res) => {
const getOrderTotal = (req, res) => {
const type = req.query.type;
const uid = global.yoho.uid || '10931021';
const uid = global.yoho.uid || '7394907';
orderModel.getOrderData(uid, type).then(result => {
... ... @@ -78,7 +78,7 @@ const getOrderTotal = (req, res) => {
};
const cancelOrder = (req, res) => {
const uid = global.yoho.uid || '10931021';
const uid = global.yoho.uid || '7394907';
const code = req.query.orderCode;
orderModel.cancelOrder(uid, code).then(result => {
... ... @@ -87,7 +87,7 @@ const cancelOrder = (req, res) => {
};
const deleteOrder = (req, res) => {
const uid = global.yoho.uid || '10931021';
const uid = global.yoho.uid || '7394907';
const code = req.query.orderCode;
orderModel.deleteOrder(uid, code).then(result => {
... ... @@ -96,7 +96,7 @@ const deleteOrder = (req, res) => {
};
const getExpressInfo = (req, res) => {
const uid = global.yoho.uid || '10931021';
const uid = global.yoho.uid || '7394907';
const code = req.query.orderCode;
orderModel.getExpressInfo(uid, code).then(result => {
... ... @@ -111,7 +111,7 @@ const getCancelOrderReason = (req, res) => {
};
const editOrder = (req, res) => {
const uid = global.yoho.uid || '10931021';
const uid = global.yoho.uid || '7394907';
const query = req.query;
query.uid = uid;
... ...
... ... @@ -15,6 +15,13 @@ const typeActiveIndexMap = {
3: 2
};
const paymentTypeStr = {
1: '在线支付',
2: '货到付款',
3: '现金支付',
4: '抵消支付'
};
const btnMap = {
all: [
{
... ... @@ -30,6 +37,12 @@ const btnMap = {
classStr: 'btn white cancel-btn'
}
],
cancel: [
{
name: '取消订单',
classStr: 'btn white cancel-btn'
}
],
edit: [
{
name: '修改订单',
... ... @@ -41,8 +54,22 @@ const btnMap = {
name: '确认收货',
classStr: 'btn complete-btn'
}
],
special: [
{
name: '修改订单',
classStr: 'btn white edit-btn mr'
},
{
name: '取消订单',
classStr: 'btn white cancel-btn'
}
]
};
const invoiceText = {
1: '纸质',
2: '电子'
};
// 订单状态
... ... @@ -100,6 +127,10 @@ const isMobileOrder = {
6: true
};
// const _removeRmbIcon = str => {
// return str.replace('¥', '');
// }
// 转换时间戳
const _convertUnixTime = src => {
return moment.unix(src).format('YYYY-MM-DD hh:mm:ss');
... ... @@ -204,7 +235,8 @@ const _getUserOrder = (uid, type, page) => {
item.createTime = _convertUnixTime(item.createTime);
// 没有取消订单并且状态为0的时候显示付款按钮
if (item.isCancel === 'N' && st === 0) {
if (item.isCancel === 'N' &&
st === 0) {
item.showPayButton = true;
}
... ... @@ -225,7 +257,7 @@ const _getUserOrder = (uid, type, page) => {
if (item.isCancel === 'Y') {
item.showBuyBtn = true;
item.statusStr = '已取消';
} else {
} else if (item.isOnlinePaid) {
item.statusStr = statusMap[st].valueStr;
}
... ... @@ -334,23 +366,48 @@ const getOrderDetail = (uid, code) => {
return api.all([_getDetail(uid, code), getExpressInfo(uid, code)]).then(result => {
let detail = result[0] && camelCase(result[0].data);
let express = result[1] && camelCase(result[1].data);
const st = parseInt(detail.status, 10);
const basicData = {
title: '订单详情'
};
detail.createTime = _convertUnixTime(detail.createTime);
detail.amount = detail.amount.replace('¥', '');
// 需要和接口确认如何获取运费,接口文档和线上数据不一致
// 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 (parseInt(detail.status, 10) !== 0 && detail.isCancel !== 'Y') {
if (st !== 0 && detail.isCancel !== 'Y') {
detail.showPaid = true;
}
if (detail.isCancel !== 'Y') {
detail.steps = _getStepByOrderStatus(detail.status);
detail.btns = statusMap[detail.status].btns;
detail.steps = _getStepByOrderStatus(st);
detail.btns = statusMap[st].btns;
if (parseInt(detail.paymentType, 10) === 2 &&
(statusMap[st].valueStr === '备货中' ||
detail.statusStr === '备货中')) {
detail.btns = btnMap.special;
}
}
if (detail.invoice) {
detail.invoice.typeText = invoiceText[detail.invoice.type];
}
detail.paymentTypeStr = paymentTypeStr[detail.paymentType];
detail.expressInfo = express;
detail.expressInfo.addressList = _convertAddress(express.expressDetail, detail.createTime);
... ...
... ... @@ -14,21 +14,15 @@
</div>
<div class="payment-info info-box">
{{# promotionFormulas }}
<p>
<span class="tip">商品金额:</span>
<span class="amount">{{amount}}</span>
</p>
<p>
<span class="tip">有货币:</span>
<span class="amount">{{yohoGiveCoin}}</span>
</p>
<p>
<span class="tip">运费:</span>
<span class="amount">{{yohoGiveCoin}}</span>
<span class="tip">{{promotion}}</span>
<span class="amount">{{promotionAmount}}</span>
</p>
{{/ promotionFormulas }}
<p class="payment-amount">
<span class="tip">实付金额:</span>
<span class="amount">{{paymentAmount}}</span>
<span class="amount">¥{{paymentAmount}}</span>
</p>
{{#if showPaid}}
<p class="paid">
... ...
... ... @@ -8,16 +8,24 @@
<div class="info-box">
<h4 class="status-title">支付及配送方式</h4>
<p class="text">支付类型:{{paymentType}}</p>
<p class="text">支付类型:{{paymentTypeStr}}</p>
{{#if paymentName}}
<p class="text">支付方式:{{paymentName}}</p>
{{/if}}
<p class="text">送货时间:{{deliveryTime}}</p>
</div>
<div class="info-box">
<h4 class="status-title">发票信息</h4>
<p class="text">发票类型:{{paymentType}}</p>
<p class="text">发票抬头:{{paymentName}}</p>
<p class="text">发票内容:{{deliveryTime}}</p>
{{#if invoice}}
{{# invoice}}
<p class="text">发票类型:{{typeText}}</p>
<p class="text">发票抬头:{{title}}</p>
<p class="text">发票内容:{{contentValue}}</p>
{{/ invoice}}
{{^}}
<p class="text">暂不需要发票</p>
{{/if}}
</div>
{{#if remark}}
... ...
... ... @@ -13,13 +13,13 @@
</div>
</div>
<div class="sub-column right-border bold">
<p class="{{#if @last}}last{{/if}}">{{goodsPrice}}</p>
<p class="{{#if @last}}last{{/if}}">¥{{goodsPrice}}</p>
</div>
<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>
<p class="bold">¥{{goodsAmount}}</p>
</div>
{{/orderGoods}}
</div>
... ...
... ... @@ -12,7 +12,7 @@
<div class="table-body">
{{> order/goods-box}}
<div class="common-column special-border">
<p class="bold">{{amount}}</p>
<p class="bold">¥{{amount}}</p>
<p class="subtext">{{paymentTypeStr}}</p>
</div>
<div class="common-column special-border status">
... ...
... ... @@ -134,7 +134,7 @@ function getOrderTotal(type, key) {
}).done(function(result) {
var $navItme = $('*[data-type="' + key + '"]');
if (!$navItme.hasClass('active') && result.total !== 0) {
if (!$navItme.hasClass('active') && result.total) {
$navItme.find('.badge').text(result.total);
} else if (!$navItme.hasClass('active')) {
$navItme.find('.badge').text('');
... ... @@ -204,14 +204,18 @@ function bindPaginationClick() {
}
// 删除订单
function deleteOrder(code, $el) {
function deleteOrder(code) {
$.ajax({
url: '/me/deleteOrder',
data: {
orderCode: code
}
}).done(function() {
$el.remove();
var type = getCurrentTabType();
var page = getCurrentPage();
type = typeMap[type];
getOrderList(type, page);
}).fail(function(err) {
console.log(err);
});
... ... @@ -288,7 +292,7 @@ function bindDeleteEvent() {
btnClass: ['confirm'],
name: '确认',
cb: function() {
deleteOrder(code, $this.closest('.order'));
deleteOrder(code);
tip.close();
}
},
... ...
... ... @@ -54,7 +54,7 @@
p {
height: 18px;
font-size: 12px;
color: #ccc;
color: #a3a3a3;
}
}
... ...