Authored by 沈志敏

Merge branch 'feature/home' into develop

... ... @@ -119,7 +119,7 @@ const component = {
saveFeedback: (req, res, next) => {
let saveFeedbackPara = {
uid: req.user.uid,
udid: req.user.udid, // todo
udid: req.sessionID,
content: req.body.content,
suggest_type: 2
};
... ...
... ... @@ -79,8 +79,8 @@ const order = {
let orderCode = req.body.orderCode;
let reasonId = req.body.reasonId;
let reason = req.body.reason;
orderModel.cancelOrder(orderCode, reasonId, reason).then(result => {
console.log(orderCode+'------'+reasonId);
orderModel.cancelOrder(orderCode, reasonId, reason, isBLK).then(result => {
return res.json(result);
});
... ... @@ -160,6 +160,17 @@ const order = {
}).then(result => {
res.json(result);
});
},
/**
* 获取退换货原因
* @param req
* @param res
*/
getCancelReason: (req, res) => {
orderModel.getCancelReason().then(result => {
return res.json(result);
});
}
};
... ...
... ... @@ -43,18 +43,20 @@ exports.getOrderDetail = (uid, orderCode) => {
/**
* 取消订单
* @param orderCode
* @param reasonId
* @param reason
* @param orderCode 订单号
* @param reasonId 原因id
* @param reason 原因描述
* @param appType 0:yohobuy 1:blk(blk必传)
* @returns {Promise.<T>|*}
*/
exports.cancelOrder = (orderCode, reasonId, reason) => {
exports.cancelOrder = (orderCode, reasonId, reason, appType) => {
return api.post('', {
method: 'app.SpaceOrders.close',
order_code: orderCode,
reason_id: reasonId,
reason: reason
reason: reason,
app_type: appType
}).then(result => {
return result;
});
... ... @@ -148,3 +150,13 @@ exports.getCoinDetail = (uid, page, limit) => {
method: 'app.yohocoin.lists'
}).then(camelCase);
};
/**
* 获取退换货原因
* @returns {*|Promise.<T>}
*/
exports.getCancelReason = () => {
return api.get('', {
method: 'app.SpaceOrders.closeReasons'
}).then(camelCase);
};
... ...
... ... @@ -24,6 +24,7 @@ router.get('/order-detail', order.orderDetail); // 订单详情
router.get('/get-orders', order.getOrderData); // 获取订单数据
router.get('/get-order', order.getOrderDetailData); // 获取订单详情数据
router.get('/order-detail', order.orderDetail); // 订单详情
router.get('/order/cancel-reason', order.getCancelReason); // 获取订单原因
router.post('/cancel-order', order.cancelOrder); // 取消订单
router.post('/delete-order', order.deleteOrder); // 删除订单
router.post('/confirm-order', order.confirmOrder); // 确认订单
... ...
... ... @@ -239,6 +239,13 @@ body {
}
}
.select .overdue{
.select .overdue {
color: #b0b0b0;
}
.cancel-reason {
width: 0;
height: 0;
overflow: hidden;
opacity: 0;
}
\ No newline at end of file
... ...
... ... @@ -236,3 +236,10 @@ $white: #fff;
font-size: 28px;
}
}
.cancel-reason {
width: 0;
height: 0;
overflow: hidden;
opacity: 0;
}
\ No newline at end of file
... ...
... ... @@ -49,6 +49,9 @@
<button v-if="order.status == 6" class="normal">再次购买</button>
<button v-if="order.isSupportRefund == 'Y' || order.isSupportExchange == 'Y'" class="normal" @click="applyRefund()">申请售后</button>
</div>
<select id="cancel-reason" class="cancel-reason" v-on:change="reasonChange" v-model="selected">
<option v-for="option in options" v-bind:value="{id:option.id}">{{option.reason}}</option>
</select>
</template>
<script>
'use strict';
... ... @@ -62,7 +65,9 @@
module.exports = {
data() {
return {
order: {}
order: {},
options: [],
selected: null
};
},
ready() {
... ... @@ -96,6 +101,9 @@
val: '在线客服'
}
]);
if (this.order.status == 0) {
this.getCancelReason();
}
} else {
tip(result.message);
}
... ... @@ -103,15 +111,40 @@
tip('网络错误');
});
},
reasonChange(){
this.orderDetail().cancel({
orderCode: this.order.orderCode,
reasonId: this.selected.id
}, (result) => {
if (result.code === 200) {
location.reload();
} else {
tip(result.message);
}
}, () => {
tip('操作失败');
});
},
getCancelReason() {
let that = this;
$.ajax({
url: '/home/order/cancel-reason',
}).then(result => {
if (result.data.length > 0) {
that.options = result.data;
}
}).fail(() => {
tip('操作失败');
});
},
orderDetail() {
return {
cancel(code, success, fail) {
cancel(param, success, fail) {
$.ajax({
url: '/home/cancel-order',
type: 'post',
data: {
orderCode: code
}
data: param
}).then(success).fail(fail);
}
};
... ... @@ -120,7 +153,9 @@
let _that = this;
return () => {
_that.orderDetail().cancel(code, (result) => {
_that.orderDetail({
orderCode: code
}).cancel({orderCode: code}, (result) => {
if (result.code === 200) {
location.href = '/home/orders?type=2';
}
... ... @@ -131,19 +166,13 @@
let _that = this;
Modal.confirm('订单取消后不能恢复,确认取消订单吗?', '', function() {
_that.orderDetail().cancel(code, (result) => {
if (result.code === 200) {
location.href = '/home/orders?type=2';
} else {
tip(result.message);
}
}, () => {
tip('操作失敗');
});
this.hide();
_that.dropDown('cancel-reason');
});
},
deleteOrder(code) {
Modal.confirm('确认删除订单?', '', function() {
this.hide();
$.ajax({
url: '/home/delete-order',
type: 'post',
... ... @@ -157,7 +186,7 @@
tip(result.message);
}
}).fail(() => {
tip('操作失');
tip('操作失');
});
});
},
... ... @@ -175,7 +204,7 @@
tip(result.message);
}
}).fail(() => {
tip('操作失');
tip('操作失');
});
},
goBuy(code) {
... ... @@ -194,6 +223,22 @@
return;
location.href = item.url;
});
},
dropDown(elementId){
let dropdown = document.getElementById(elementId);
try {
this.showDropdown(dropdown);
} catch(e) {
console.log(e)
}
return false;
},
showDropdown(element) {
let event;
event = document.createEvent('MouseEvents');
event.initMouseEvent('mousedown', true, true, window);
element.dispatchEvent(event);
}
}
};
... ...
... ... @@ -44,6 +44,9 @@
<p>Your do not have an order <br>for the time being</p>
<a href="">去购物</a>
</div>
<select id="cancel-reason" class="cancel-reason" v-on:change="reasonChange" v-model="selected">
<option v-for="option in options" v-bind:value="{id:option.id}">{{option.reason}}</option>
</select>
</template>
<script>
... ... @@ -63,12 +66,16 @@
type: this.$parent.$data.type,
orderList: [],
busy: false,
emptybox: 'hide'
emptybox: 'hide',
selected: null,
options: [],
currentCode: ''
};
},
ready() {
this.getOrderData();
this.getCancelReason();
},
methods: {
... ... @@ -102,11 +109,39 @@
tip('网络错误');
});
},
reasonChange(){
console.log(this.currentCode)
this.order().cancel({
orderCode: this.currentCode,
reasonId: this.selected.id
}, (result) => {
if (result.code === 200) {
location.href = '/home/orders?type=2';
} else {
tip(result.message);
}
}, () => {
tip('操作失败');
});
},
getCancelReason() {
let that = this;
$.ajax({
url: '/home/order/cancel-reason',
}).then(result => {
if (result.data.length > 0) {
that.options = result.data;
}
}).fail(() => {
tip('操作失败');
});
},
autoCancel(code) {
let _that = this;
return () => {
_that.order().cancel(code, (result) => {
_that.order().cancel({orderCode: code}, (result) => {
if (result.code === 200) {
location.reload();
}
... ... @@ -115,13 +150,11 @@
},
order() {
return {
cancel(code, success, fail) {
cancel(param, success, fail) {
$.ajax({
url: '/home/cancel-order',
type: 'post',
data: {
orderCode: code
}
data: param
}).then(success).fail(fail);
}
};
... ... @@ -130,21 +163,16 @@
let _that = this;
Modal.confirm('订单取消后不能恢复,确认取消订单吗?', '', function() {
_that.order().cancel(code, (result) => {
if (result.code === 200) {
location.reload();
} else {
tip(result.message);
}
}, () => {
tip('操作失敗');
});
this.hide();
_that.currentCode = code;
_that.dropDown('cancel-reason');
});
},
deleteOrder(order, index) {
let that = this;
Modal.confirm('确认删除订单?', '', function() {
this.hide();
$.ajax({
url: '/home/delete-order',
type: 'post',
... ... @@ -153,12 +181,12 @@
}
}).then(result => {
if (result.code === 200) {
that.$el.querySelectorAll('.order-item')[index].remove();
that.orderList.splice(index, 1);
} else {
tip(result.message);
}
}).fail(() => {
tip('操作失');
tip('操作失');
});
});
},
... ... @@ -176,7 +204,7 @@
tip(result.message);
}
}).fail(() => {
tip('操作失');
tip('操作失');
});
},
goBuy(code) {
... ... @@ -184,6 +212,22 @@
},
seeExpress(code) {
location.href = '/home/logistic?order_code='+code;
},
dropDown(elementId){
let dropdown = document.getElementById(elementId);
try {
this.showDropdown(dropdown);
} catch(e) {
console.log(e)
}
return false;
},
showDropdown(element) {
let event;
event = document.createEvent('MouseEvents');
event.initMouseEvent('mousedown', true, true, window);
element.dispatchEvent(event);
}
}
};
... ...