Authored by 沈志敏

fix bug

... ... @@ -35,7 +35,7 @@ const order = {
orderCode: orderCode
});
},
getOrderData: (req, res) => {
getOrderData: (req, res, next) => {
const uid = req.user.uid;
if (!uid && req.xhr) {
... ... @@ -53,9 +53,9 @@ const order = {
orderModel.getOrders(param).then(result => {
return res.json(result);
});
}).catch(next);
},
getOrderDetailData: (req, res) => {
getOrderDetailData: (req, res, next) => {
const orderCode = req.query.orderCode;
const uid = req.user.uid;
... ... @@ -68,25 +68,25 @@ const order = {
orderModel.getOrderDetail(uid, orderCode).then(result => {
return res.json(result);
});
}).catch(next);
},
cancelOrder: (req, res) => {
cancelOrder: (req, res, next) => {
const orderCode = req.body.orderCode;
const reasonId = req.body.reasonId;
const reason = req.body.reason;
orderModel.cancelOrder(orderCode, reasonId, reason).then(result => {
return res.json(result);
});
}).catch(next);
},
confirmOrder: (req, res) => {
confirmOrder: (req, res, next) => {
const orderode = req.body.orderCode;
orderModel.confirmOrder(orderode).then(result => {
return res.json(result);
});
}).catch(next);
},
deleteOrder: (req, res) => {
deleteOrder: (req, res, next) => {
const orderCode = req.body.orderCode;
const uid = req.user.uid;
... ... @@ -99,12 +99,10 @@ const order = {
orderModel.deleteOrder(orderCode, uid).then(result => {
return res.json(result);
});
}).catch(next);
},
coin: (req, res, next) => {
const uid = req.user.uid;
orderModel.getCoins(uid).then(result => {
orderModel.getCoins(req.user.uid).then(result => {
res.render('coin', {
module: 'me',
page: 'coin',
... ... @@ -119,7 +117,7 @@ const order = {
* @param res
* @returns {*|{read, write}}
*/
getCoinDetail: (req, res) => {
getCoinDetail: (req, res, next) => {
const uid = req.user.uid;
const page = req.query.page;
const limit = req.query.limit;
... ... @@ -133,7 +131,7 @@ const order = {
orderModel.getCoinDetail(uid, page, limit).then(result => {
return res.json(result);
});
}).catch(next);
},
// 订单-物流
... ... @@ -145,7 +143,7 @@ const order = {
},
// API- 订单-物流
getOrderLogisticdate: (req, res) => {
getOrderLogisticdate: (req, res, next) => {
(req.query.type === 'exchange') && (req.query.type = 'change');
orderModel.getOrderLogisticdate({
... ... @@ -154,19 +152,21 @@ const order = {
order_code: req.query.orderCode,
id: req.query.id
}).then(result => {
res.json(result);
return res.json(result);
}).catch(next);
},
cancelReason: (req, res) => {
res.render('cancelreason', {
module: 'me',
page: 'cancelreason'
});
},
/**
* 获取退换货原因
* @param req
* @param res
*/
getCancelReason: (req, res) => {
// 获取取消订单原因
getCancelReason: (req, res, next) => {
orderModel.getCancelReason().then(result => {
return res.json(result);
});
}).catch(next);
}
};
... ...
... ... @@ -22,10 +22,12 @@ router.get('/me/', home.index); // 个人中心主页
router.get('/me/userdata', home.userdata); // 个人中心数据
router.get('/me/order', order.orders); // 订单
router.get('/me/order/detail', order.orderDetail);
router.get('/me/order/detail', order.orderDetail); // 订单详情
router.get('/me/order/cancelreason', order.cancelReason); // 取消订单原因选择
router.get('/me/getOrderList', order.getOrderData); // 获取订单数据
router.get('/me/get-order', order.getOrderDetailData); // AJAX 获取订单详情数据
router.get('/me/getCancelOrderReason', order.getCancelReason); // 获取订单原因
router.get('/me/getCancelOrderReason', order.getCancelReason); // 获取取消订单原因
router.post('/me/cancelOrder', order.cancelOrder); // 取消订单
router.post('/me/deleteOrder', order.deleteOrder); // AJAX 删除订单
router.post('/me/confirmReceive', order.confirmOrder); // 确认订单
... ...
<div class="cancel-reason" id="reason">
<cancel-reason></cancel-reason>
</div>
\ No newline at end of file
... ...
<div id="home-order-list">
<Order></Order>
<input type="hidden" value="{{type}}" id="order-type">
<Order type="{{type}}"></Order>
</div>
... ...
... ... @@ -129,6 +129,12 @@ const matchHeader = (path, qs, titleMap) => {
return header;
}
if (/\/me\/order\/cancelreason$/.test(path)) {
header = titleMap[1];
header.title.des = '取消订单理由';
return header;
}
if (/\/me\/return\/refund$/.test(path)) {
header = titleMap[3];
header.title.des = '退货申请';
... ...
const Vue = require('vue');
const cancelReason = require('me/cancel-reason.vue');
const yoho = require('yoho');
yoho.ready(() => {
new Vue({
el: '#reason',
components: {
cancelReason
}
});
});
... ...
... ... @@ -16,10 +16,7 @@ require('common/count-down');
new Vue({
el: '#home-order-list',
data: {
type: document.getElementById('order-type').value
},
components: {
Order
}
});
});
\ No newline at end of file
... ...
... ... @@ -18,7 +18,7 @@
position: relative;
color: #000;
font-size: 34px;
border-bottom: 1px solid #e0e0e0;
border-bottom: 1px solid #eee;
&:last-of-type:after {
content: none;
... ...
<template>
<div class="reason-list">
<span v-for="val in options" track-by="id" @click="select(val.id, val.reason)">{{val.reason}}</span>
</div>
</template>
<script>
'use strict';
const $ = require('jquery');
const yoho = require('yoho');
module.exports = {
data() {
return {
options: [],
};
},
created() {
yoho.store.set('cancelReason', {
iscancel: true
});
$.ajax({
url: '/me/getCancelOrderReason',
}).then(result => {
if (result && result.data) {
this.options = result.data;
}
}).fail(() => {
tip('操作失败');
});
},
methods: {
select(id, reason) {
yoho.store.set('cancelReason', Object.assign(yoho.store.get('cancelReason'), {
id: id,
reason: reason
}));
yoho.goBack();
}
}
};
</script>
<style>
.cancel-reason {
width: 100%;
.reason-list {
width: 100%;
margin-left: 30px;
span {
display: block;
height: 90px;
line-height: 90px;
font-size: 34px;
border-bottom: 1px solid #eee;
}
}
}
</style>
... ...
... ... @@ -49,16 +49,13 @@
<div class="order-button" v-show="order.status != 1 && order.status != 2 && order.status != 3">
<button v-if="order.isCancel === 'Y'" @click="deleteOrder(order.orderCode)" class="normal">删除订单</button>
<template v-else>
<button v-if="order.status == 0" @click="cancelOrder(order.orderCode)">取消订单</button>
<button v-if="order.status == 0" @click="cancelOrder()">取消订单</button>
<button v-if="order.status == 0 " class="countdown" @click="goBuy(order)">去支付 <span class="count-down" v-count-down :left-time="order.payLefttime" :callback="autoCancel()"></span></button>
<a v-if="order.status == 4 || order.status == 5 || order.status == 6" href="/me/logistic?order_code={{order.orderCode}}">查看物流</a>
<button v-if="order.status == 4 || order.status == 5 " class="black" @click="confirmGoods(order.orderCode)">确认收货</button>
<button v-if="order.isSupportRefund == 'Y' || order.isSupportExchange == 'Y'" class="normal" @click="applyRefund()">申请售后</button>
</template>
</div>
<select id="cancel-reason" class="cancel-reason" @change="reasonChange" v-model="selected">
<option v-for="option in options" :value="{id:option.id,reason:option.reason}">{{option.reason}}</option>
</select>
</template>
</template>
<script>
... ... @@ -78,7 +75,6 @@
show: false,
order: {},
options: [],
selected: {},
genderSel: {}
};
},
... ... @@ -92,8 +88,15 @@
});
document.addEventListener('visibilitychange', () => {
if (!document.hidden && yoho.store.get('orderDetail')) {
this.reload();
if (!document.hidden) {
const cr = yoho.store.get('cancelReason');
if (cr && cr.iscancel) {
this.reasonChange(cr);
yoho.store.remove('cancelReason');
} else if (yoho.store.get('orderDetail')) {
this.reload();
}
}
});
},
... ... @@ -111,7 +114,6 @@
reload() {
this.show = false;
this.order = {};
this.selected = {};
this.getOrderData();
},
... ... @@ -143,9 +145,6 @@
url: '/me/service'
}
]);
if (Number(this.order.status) === 0) {
this.getCancelReason();
}
} else if (result.code !== 500) {
tip(result.message);
} else {
... ... @@ -155,50 +154,20 @@
tip('网络错误');
});
},
reasonChange() {
setTimeout(() => {
if (!this.selected.id || document.hidden) {
return false;
}
this.orderDetail().cancel({
orderCode: this.order.orderCode,
reasonId: this.selected.id,
reason: this.selected.reason
}, (result) => {
if (result.code === 200) {
tip({
delay: 500,
txt: '取消成功'
});
setTimeout(() => {
this.reload();
}, 300);
yoho.store.set('orderReload', true);
} else if (result.code !== 500) {
tip(result.message);
}
}, () => {
tip('操作失败');
});
}, 700);
},
getCancelReason() {
$.ajax({
url: '/me/getCancelOrderReason',
}).then(result => {
if (result.data.length > 0) {
this.options = result.data;
if (yoho.isiOS) {
this.options.unshift({
id: 0,
reason: '请选择'
});
}
reasonChange(cr) {
this.orderDetail().cancel({
orderCode: this.order.orderCode,
reasonId: cr.id,
reason: cr.reason
}, (result) => {
if (result.code === 200) {
tip('取消成功');
this.order.isCancel = 'Y';
yoho.store.set('orderReload', true);
} else if (result.code !== 500) {
tip(result.message);
}
}).fail(() => {
}, () => {
tip('操作失败');
});
},
... ... @@ -220,11 +189,9 @@
};
},
cancelOrder() {
let _that = this;
Modal.confirm('', '取消后不能恢复,确认取消吗?', function() {
this.hide();
_that.dropDown('cancel-reason');
interceptClick.intercept('/me/order/cancelreason');
});
},
deleteOrder(code) {
... ... @@ -297,18 +264,6 @@
}
return false;
});
},
dropDown(elementId) {
let dropdown = document.getElementById(elementId);
this.showDropdown(dropdown);
return false;
},
showDropdown(element) {
let event = document.createEvent('MouseEvents');
event.initMouseEvent('mousedown', true, true, window);
element.dispatchEvent(event);
}
}
};
... ...
... ... @@ -34,7 +34,7 @@
<div class="options">
<button v-if="order.isCancel === 'Y'" @click="deleteOrder(order, index)" class="normal">删除订单</button>
<template v-else>
<button v-if="order.status == 0" @click="cancelOrder(order.orderCode)" class="leftpad">取消订单</button>
<button v-if="order.status == 0" @click="cancelOrder(order)" class="leftpad">取消订单</button>
<button v-if="order.status == 0 " class="countdown" @click="goBuy(order)">去支付
<span class="count-down" v-count-down :left-time="order.payLefttime" :callback="autoCancel(order)"></span>
</button>
... ... @@ -54,9 +54,6 @@
<p>Your do not have an order <br>for the time being</p>
<a href="/product/new">随便逛逛</a>
</div>
<select id="cancel-reason" class="cancel-reason" @change="reasonChange" v-model="selected">
<option v-for="option in options" :value="{id:option.id,reason:option.reason}">{{option.reason}}</option>
</select>
</template>
<script>
... ... @@ -65,30 +62,36 @@
const $ = require('jquery');
const tip = require('common/tip');
const Modal = require('common/modal');
const interceptClick = require('common/intercept-click');
const yoho = require('yoho');
module.exports = {
props: ['type'],
data() {
return {
page: 0,
limit: 10,
pageTotal: 1,
type: this.$parent.$data.type,
busy: false,
emptybox: 'hide',
currentCode: '',
selected: {},
currentOrder: {},
options: [],
orderList: []
};
},
created() {
this.getOrderData();
this.getCancelReason();
document.addEventListener('visibilitychange', () => {
if (!document.hidden && yoho.store.get('orderReload')) {
this.reload();
if (!document.hidden) {
const cr = yoho.store.get('cancelReason');
if (cr && cr.iscancel) {
this.reasonChange(cr);
yoho.store.remove('cancelReason');
} else if (yoho.store.get('orderReload')) {
this.reload();
}
}
});
},
... ... @@ -98,8 +101,7 @@
this.pageTotal = 1;
this.busy = false;
this.emptybox = 'hide';
this.currentCode = '';
this.selected = {};
this.currentOrder = {};
this.orderList = [];
this.getOrderData();
... ... @@ -132,48 +134,19 @@
tip('网络错误');
});
},
reasonChange() {
setTimeout(() => {
if (!this.selected.id || document.hidden) {
return false;
reasonChange(cr) {
this.order().cancel({
orderCode: this.currentOrder.orderCode,
reasonId: cr.id,
reason: cr.reason
}, (result) => {
if (result.code === 200) {
this.currentOrder.isCancel = 'Y';
tip('取消成功');
} else if (result.code !== 500) {
tip(result.message);
}
this.order().cancel({
orderCode: this.currentCode,
reasonId: this.selected.id,
reason: this.selected.reason
}, (result) => {
if (result.code === 200) {
tip({
delay: 500,
txt: '取消成功'
});
setTimeout(() => {
this.reload();
}, 300);
} else if (result.code !== 500) {
tip(result.message);
}
}, () => {
tip('操作失败');
});
}, 700);
},
getCancelReason() {
$.ajax({
url: '/me/getCancelOrderReason',
}).then(result => {
if (result && result.data) {
this.options = result.data;
if (yoho.isiOS) {
this.options.unshift({
id: 0,
reason: '请选择'
});
}
}
}).fail(() => {
}, () => {
tip('操作失败');
});
},
... ... @@ -193,13 +166,13 @@
}
};
},
cancelOrder(code) {
cancelOrder(order) {
let _that = this;
Modal.confirm('', '取消后不能恢复,确认取消吗?', function() {
this.hide();
_that.currentCode = code;
_that.dropDown('cancel-reason');
_that.currentOrder = order;
interceptClick.intercept('/me/order/cancelreason');
});
},
deleteOrder(order, index) {
... ... @@ -265,18 +238,6 @@
}, () => {
this.reload();
});
},
dropDown(elementId) {
let dropdown = document.getElementById(elementId);
this.showDropdown(dropdown);
return false;
},
showDropdown(element) {
let event = document.createEvent('MouseEvents');
event.initMouseEvent('mousedown', true, true, window);
element.dispatchEvent(event);
}
}
};
... ...