...
|
...
|
@@ -9,7 +9,6 @@ |
|
|
const mRoot = '../models';
|
|
|
const headerModel = require('../../../doraemon/models/header'); // 头部model
|
|
|
const addressModel = require(`${mRoot}/address`); // 地址管理 MODEL
|
|
|
const helpers = global.yoho.helpers;
|
|
|
|
|
|
/**
|
|
|
* 地址管理页面
|
...
|
...
|
@@ -68,8 +67,8 @@ exports.addressAct = (req, res, next) => { |
|
|
exports.saveAddress = (req, res, next) => {
|
|
|
|
|
|
/* 没有用户,返回 */
|
|
|
if (!req.body.uid) {
|
|
|
res.json({
|
|
|
if (!req.user.uid) {
|
|
|
return res.json({
|
|
|
code: 400,
|
|
|
message: '用户不可用'
|
|
|
});
|
...
|
...
|
@@ -77,7 +76,7 @@ exports.saveAddress = (req, res, next) => { |
|
|
|
|
|
/* 没有地址信息,返回 */
|
|
|
if (!req.body.address) {
|
|
|
res.json({
|
|
|
return res.json({
|
|
|
code: 401,
|
|
|
message: '请输入可用的地址信息'
|
|
|
});
|
...
|
...
|
@@ -85,7 +84,7 @@ exports.saveAddress = (req, res, next) => { |
|
|
|
|
|
/* 没有地区码,返回 */
|
|
|
if (!req.body.area_code) {
|
|
|
res.json({
|
|
|
return res.json({
|
|
|
code: 402,
|
|
|
message: '地区码不可用'
|
|
|
});
|
...
|
...
|
@@ -93,19 +92,19 @@ exports.saveAddress = (req, res, next) => { |
|
|
|
|
|
/* 没有收件人姓名,返回 */
|
|
|
if (!req.body.consignee) {
|
|
|
res.json({
|
|
|
return res.json({
|
|
|
code: 403,
|
|
|
message: '请输入收件人姓名'
|
|
|
});
|
|
|
}
|
|
|
|
|
|
/* 邮箱地址校验不通过,返回 */
|
|
|
if (!req.body.email || !helpers.verifyEmail(req.body.email)) {
|
|
|
res.json({
|
|
|
code: 404,
|
|
|
message: '输入的邮箱地址格式不正确'
|
|
|
});
|
|
|
}
|
|
|
// if (!req.body.email || !helpers.verifyEmail(req.body.email)) {
|
|
|
// return res.json({
|
|
|
// code: 404,
|
|
|
// message: '输入的邮箱地址格式不正确'
|
|
|
// });
|
|
|
// }
|
|
|
|
|
|
addressModel.saveAddress({
|
|
|
uid: req.user.uid,
|
...
|
...
|
@@ -164,7 +163,7 @@ exports.addressModify = (req, res, next) => { |
|
|
pageHeader: headerModel.setNav({
|
|
|
navTitle: '选择地址'
|
|
|
}),
|
|
|
title: '选择地址'
|
|
|
title: '选择地址',
|
|
|
};
|
|
|
|
|
|
addressModel.address({
|
...
|
...
|
@@ -188,6 +187,6 @@ exports.locationList = (req, res, next) => { |
|
|
addressModel.locationList({
|
|
|
uid: req.user.uid
|
|
|
}).then(result => {
|
|
|
res.render('address/location-list', result);
|
|
|
res.render('address/location-list', Object.assign(result, {layout: false}));
|
|
|
}).catch(next);
|
|
|
}; |
...
|
...
|
|