Authored by biao

udapte for edit

... ... @@ -110,6 +110,19 @@ const getCancelOrderReason = (req, res) => {
});
};
const editOrder = (req, res) => {
const uid = global.yoho.uid || '10931021';
const query = req.query;
query.uid = uid;
console.log(query);
orderModel.editOrder(query).then(result => {
res.json(result);
});
};
module.exports = {
index: index,
detail: detail,
... ... @@ -117,6 +130,7 @@ module.exports = {
getOrderTotal: getOrderTotal,
cancelOrder: cancelOrder,
deleteOrder: deleteOrder,
editOrder: editOrder,
getExpressInfo: getExpressInfo,
getCancelOrderReason: getCancelOrderReason
};
... ...
... ... @@ -100,8 +100,47 @@ const isMobileOrder = {
6: true
};
// 转换时间戳
const _convertUnixTime = src => {
return moment.unix(src).format('YYYY-MM-DD hh:mm:ss');
};
const _convertAddress = (addressList, createTime) => {
let addrList = [];
addressList.forEach(addr => {
let address = {
time: '',
city: '',
action: ''
};
address.time = addr.acceptTime;
addr = addr.acceptAddress.split(' ');
if (addr.length > 1 && /市/.test(addr[0])) {
address.city = addr[0].replace('市', '');
addr.splice(0, 1);
address.action = addr.join('');
} else {
address.action = addr.join('');
}
addrList.push(address);
});
// 增加一个默认初始状态
addrList.push({
time: createTime,
action: '您的订单已提交,等待付款'
});
return _.reverse(addrList);
};
// 根据订单状态获取当前步骤
const _getStepByOrderStatus = (st) => {
const _getStepByOrderStatus = st => {
let steps = [
{
stepStr: '1.提交订单'
... ... @@ -128,50 +167,6 @@ const _getStepByOrderStatus = (st) => {
return steps;
};
// 转换时间戳
const _convertUnixTime = (src) => {
return moment.unix(src).format('YYYY-MM-DD hh:mm:ss');
};
const deleteOrder = (uid, code) => {
return api.get('', {
method: 'app.SpaceOrders.delOrderByCode',
uid: uid,
order_code: code
}, {
cache: true
});
};
const cancelOrder = (uid, code) => {
return api.get('', {
method: 'app.SpaceOrders.close',
uid: uid,
order_code: code
}, {
cache: true
});
};
const getCancelOrderReason = () => {
return api.get('', {
method: 'app.SpaceOrders.closeReasons'
}, {
cache: true
});
};
const getExpressInfo = (uid, code) => {
return api.get('', {
method: 'app.express.get',
uid: uid,
order_code: code
}, {
cache: true
});
};
const _getDetail = (uid, code) => {
return api.get('', {
method: 'app.SpaceOrders.detail',
... ... @@ -244,38 +239,43 @@ const _getUserOrder = (uid, type, page) => {
});
};
const _convertAddress = (addressList, createTime) => {
let addrList = [];
addressList.forEach(addr => {
let address = {
time: '',
city: '',
action: ''
};
address.time = addr.acceptTime;
addr = addr.acceptAddress.split(' ');
if (addr.length > 1 && /市/.test(addr[0])) {
address.city = addr[0].replace('市', '');
addr.splice(0, 1);
address.action = addr.join('');
} else {
address.action = addr.join('');
}
const deleteOrder = (uid, code) => {
return api.get('', {
method: 'app.SpaceOrders.delOrderByCode',
uid: uid,
order_code: code
}, {
cache: true
});
};
addrList.push(address);
const cancelOrder = (uid, code) => {
return api.get('', {
method: 'app.SpaceOrders.close',
uid: uid,
order_code: code
}, {
cache: true
});
};
// 增加一个默认初始状态
addrList.push({
time: createTime,
action: '您的订单已提交,等待付款'
const getCancelOrderReason = () => {
return api.get('', {
method: 'app.SpaceOrders.closeReasons'
}, {
cache: true
});
};
return _.reverse(addrList);
const getExpressInfo = (uid, code) => {
return api.get('', {
method: 'app.express.get',
uid: uid,
order_code: code
}, {
cache: true
});
};
const getOrderData = (uid, type, page) => {
... ... @@ -362,11 +362,27 @@ const getOrderDetail = (uid, code) => {
});
};
const editOrder = data => {
return api.get('', {
method: 'app.SpaceOrders.updateDeliveryAddress',
uid: data.uid,
order_code: data.orderCode,
user_name: data.userName,
area_code: data.areaCode,
address: data.address,
mobile: data.mobile,
phone: data.phone
}, {
cache: true
});
};
module.exports = {
getOrderData: getOrderData,
getOrderDetail: getOrderDetail,
cancelOrder: cancelOrder,
getCancelOrderReason: getCancelOrderReason,
deleteOrder: deleteOrder,
editOrder: editOrder,
getExpressInfo: getExpressInfo
};
... ...
... ... @@ -23,6 +23,7 @@ router.get('/deleteOrder', order.deleteOrder);
router.get('/cancelOrder', order.cancelOrder);
router.get('/getCancelOrderReason', order.getCancelOrderReason);
router.get('/getExpressInfo', order.getExpressInfo);
router.get('/editOrder', order.editOrder);
// 个人中心首页/收货地址
router.get('/address', address.index);
... ...
... ... @@ -31,6 +31,14 @@ var validateMap = {
reg: phoneReg,
errMsg: '您输入的联系电话格式不正确'
}
},
phone: {
sl: '#user-phone',
v: {
isNumber: true,
minLength: 8,
errMsg: '您输入的电话号码给是不正确'
}
}
};
... ... @@ -85,7 +93,7 @@ function editOrder() {
var phone = $('#user-phone').val();
$.ajax({
url: '/me/order/editOrder',
url: '/me/editOrder',
data: {
orderCode: code,
areaCode: areaCode,
... ... @@ -94,6 +102,8 @@ function editOrder() {
mobile: mobile,
phone: phone
}
}).done(function(result) {
console.log(result);
});
}
... ... @@ -109,6 +119,7 @@ function showDiaglog(tpl, code, onEdit) {
name: '确定',
cb: function() {
if (validateData()) {
editOrder();
tip.close(onEdit);
} else {
console.log('err');
... ...
... ... @@ -25,7 +25,7 @@
<div class="input-row">
<span class="asterisk vhide">*</span>
<label for="user-phone">电话号码:</label>
<input class="input" type="text" id="user-phone" placeholder="请输入电话号码(选填)" value="{{phone}}">
<input class="input validate" type="text" id="user-phone" placeholder="请输入电话号码(选填)">
</div>
</div>
{{/ data}}
... ...