Authored by 郭成尧

'handle-todo'

... ... @@ -9,8 +9,7 @@
const mRoot = '../models';
const headerModel = require('../../../doraemon/models/header'); // 头部model
const addressModel = require(`${mRoot}/address`); // 地址管理 MODEL
// const helpers = global.yoho.helpers;
const helpers = global.yoho.helpers;
/**
* 地址管理页面
* @param req
... ... @@ -28,7 +27,7 @@ exports.address = (req, res, next) => {
};
addressModel.address({
uid: req.user.uid || 8039759 // TODO 待删除
uid: req.user.uid
}).then(result => {
res.render('address/index', Object.assign(responseData, result));
}).catch(next);
... ... @@ -44,7 +43,7 @@ exports.address = (req, res, next) => {
exports.addressAct = (req, res, next) => {
addressModel.address({
id: req.params.id,
uid: req.user.uid || 8039759 // TODO 待删除
uid: req.user.uid
}).then(result => {
let responseData = {
module: 'home',
... ... @@ -67,14 +66,15 @@ exports.addressAct = (req, res, next) => {
*/
exports.saveAddress = (req, res, next) => {
// TODO 开发完成后放开
// if (!req.body.uid) {
// res.json({
// code: 400,
// message: '用户不可用'
// });
// }
/* 没有用户,返回 */
if (!req.body.uid) {
res.json({
code: 400,
message: '用户不可用'
});
}
/* 没有地址信息,返回 */
if (!req.body.address) {
res.json({
code: 401,
... ... @@ -82,6 +82,7 @@ exports.saveAddress = (req, res, next) => {
});
}
/* 没有地区码,返回 */
if (!req.body.area_code) {
res.json({
code: 402,
... ... @@ -89,6 +90,7 @@ exports.saveAddress = (req, res, next) => {
});
}
/* 没有收件人姓名,返回 */
if (!req.body.consignee) {
res.json({
code: 403,
... ... @@ -96,16 +98,16 @@ exports.saveAddress = (req, res, next) => {
});
}
// TODO 开发完成后放开
// if (!req.body.email || !helpers.verifyEmail(req.body.email)) {
// res.json({
// code: 404,
// message: '输入的邮箱地址格式不正确'
// });
// }
/* 邮箱地址校验不通过,返回 */
if (!req.body.email || !helpers.verifyEmail(req.body.email)) {
res.json({
code: 404,
message: '输入的邮箱地址格式不正确'
});
}
addressModel.saveAddress({
uid: req.user.uid || 8039759, // TODO 待删除
uid: req.user.uid,
address: req.body.address,
area_code: req.body.area_code,
consignee: req.body.consignee,
... ... @@ -127,7 +129,7 @@ exports.saveAddress = (req, res, next) => {
exports.delAddress = (req, res, next) => {
addressModel.delAddress({
id: req.body.id,
uid: req.user.uid || 8039759 // TODO 待删除
uid: req.user.uid
}).then(result => {
res.json(result);
}).catch(next);
... ... @@ -141,7 +143,7 @@ exports.delAddress = (req, res, next) => {
*/
exports.defaultAddress = (req, res, next) => {
addressModel.setDefaultAddress({
uid: req.user.uid || 8039759, // TODO 待删除
uid: req.user.uid,
id: req.body.id
}).then(result => {
res.json(result);
... ... @@ -165,7 +167,7 @@ exports.addressModify = (req, res, next) => {
};
addressModel.address({
uid: req.user.uid || 8039759 // TODO 待删除
uid: req.user.uid
}).then(result => {
res.render('address/address-modify', Object.assign(responseData, result, {
showAddBtn: (result.address.length <= 5),
... ... @@ -183,7 +185,7 @@ exports.addressModify = (req, res, next) => {
*/
exports.locationList = (req, res, next) => {
addressModel.locationList({
uid: req.user.uid || 8039759 // TODO 待删除
uid: req.user.uid
}).then(result => {
res.render('address/location-list', result);
}).catch(next);
... ...
... ... @@ -21,7 +21,7 @@ exports.order = (req, res, next) => {
page: req.query.page || 1,
gender: req.query.gender || '1,3',
yh_channel: req.query.channel || 1,
uid: req.user.uid || 8039759 // TODO 待删除
uid: req.user.uid
};
orderModel.order(params).then(result => {
... ... @@ -49,7 +49,7 @@ exports.getOrders = (req, res, next) => {
page: req.query.page || 1,
gender: req.query.gender || '1,3',
yh_channel: req.query.channel || 1,
uid: req.user.uid || 8039759 // TODO 待删除
uid: req.user.uid
}).then(result => {
res.render('order-content', {
layout: false,
... ...
... ... @@ -23,7 +23,7 @@ let orderDetail = (req, res, next) => {
};
orderDetailModel.orderDetail({
uid: req.user.uid || 8039759, // TODO 待删除
uid: req.user.uid,
order_code: req.query.order_code
}).then(result => {
if (result) {
... ...