|
@@ -7,77 +7,111 @@ module.exports = class AddressController extends shopController {
|
|
|
const that = this;
|
|
|
return that.app.model.Address;
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
- * [selectValidate 查询用户地址]
|
|
|
- * @return {[type]} [description]
|
|
|
- */
|
|
|
+ * [selectValidate 查询用户地址]
|
|
|
+ * @return {[type]} [description]
|
|
|
+ */
|
|
|
get selectValidate() {
|
|
|
const that = this;
|
|
|
return {
|
|
|
- is_use: that.ctx.rules.default(0).required().number(),
|
|
|
- user_id: that.ctx.rules.default(that.service.shop.getWebUserId()).number(),
|
|
|
+ is_use: that.ctx.rules.default(0)
|
|
|
+ .required()
|
|
|
+ .number(),
|
|
|
+ user_id: that.ctx.rules.default(that.service.shop.getWebUserId())
|
|
|
+ .number(),
|
|
|
};
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * [createValidate 添加收货地址]
|
|
|
- * @return {[type]} [description]
|
|
|
- */
|
|
|
+ * [createValidate 添加收货地址]
|
|
|
+ * @return {[type]} [description]
|
|
|
+ */
|
|
|
get createValidate() {
|
|
|
const that = this;
|
|
|
return {
|
|
|
- user_id: that.ctx.rules.default(that.service.shop.getWebUserId()).number(),
|
|
|
- uname: that.ctx.rules.name('收货人姓名').required().notEmpty()
|
|
|
+ user_id: that.ctx.rules.default(that.service.shop.getWebUserId())
|
|
|
+ .number(),
|
|
|
+ uname: that.ctx.rules.name('收货人姓名')
|
|
|
+ .required()
|
|
|
+ .notEmpty()
|
|
|
.trim(),
|
|
|
- mobile: that.ctx.rules.name('收货人电话').required().notEmpty()
|
|
|
+ mobile: that.ctx.rules.name('收货人电话')
|
|
|
+ .required()
|
|
|
+ .notEmpty()
|
|
|
.trim()
|
|
|
.phone(),
|
|
|
- province_name: that.ctx.rules.name('所在省').required().notEmpty()
|
|
|
+ province_name: that.ctx.rules.name('所在省')
|
|
|
+ .required()
|
|
|
+ .notEmpty()
|
|
|
.trim(),
|
|
|
- province_id: that.ctx.rules.name('所在省ID').required().notEmpty()
|
|
|
+ province_id: that.ctx.rules.name('所在省ID')
|
|
|
+ .required()
|
|
|
+ .notEmpty()
|
|
|
.number(),
|
|
|
- city_id: that.ctx.rules.name('所在市ID').required().notEmpty()
|
|
|
+ city_id: that.ctx.rules.name('所在市ID')
|
|
|
+ .required()
|
|
|
+ .notEmpty()
|
|
|
.number(),
|
|
|
- city_name: that.ctx.rules.name('所在城市').required().notEmpty()
|
|
|
+ city_name: that.ctx.rules.name('所在城市')
|
|
|
+ .required()
|
|
|
+ .notEmpty()
|
|
|
.trim(),
|
|
|
- county_id: that.ctx.rules.name('所在区/县ID').required().notEmpty()
|
|
|
+ county_id: that.ctx.rules.name('所在区/县ID')
|
|
|
+ .required()
|
|
|
+ .notEmpty()
|
|
|
.number(),
|
|
|
- county_name: that.ctx.rules.name('所在区/县').required().notEmpty()
|
|
|
+ county_name: that.ctx.rules.name('所在区/县')
|
|
|
+ .required()
|
|
|
+ .notEmpty()
|
|
|
.trim(),
|
|
|
- address: that.ctx.rules.name('详细地址').required().notEmpty()
|
|
|
+ address: that.ctx.rules.name('详细地址')
|
|
|
+ .required()
|
|
|
+ .notEmpty()
|
|
|
.trim(),
|
|
|
- is_use: that.ctx.rules.default(0).number(),
|
|
|
- create_time: that.ctx.rules.default(that.app.szjcomo.date('Y-m-d H:i:s')).required(),
|
|
|
+ is_use: that.ctx.rules.default(0)
|
|
|
+ .number(),
|
|
|
+ create_time: that.ctx.rules.default(that.app.szjcomo.date('Y-m-d H:i:s'))
|
|
|
+ .required(),
|
|
|
};
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
- * [updateValidate 更新收货地址]
|
|
|
- * @return {[type]} [description]
|
|
|
- */
|
|
|
+ * [updateValidate 更新收货地址]
|
|
|
+ * @return {[type]} [description]
|
|
|
+ */
|
|
|
get updateValidate() {
|
|
|
const that = this;
|
|
|
return {
|
|
|
- user_id: that.ctx.rules.default(that.service.shop.getWebUserId()).number(),
|
|
|
- address_id: that.ctx.rules.name('收货地址ID').required().notEmpty()
|
|
|
+ user_id: that.ctx.rules.default(that.service.shop.getWebUserId())
|
|
|
+ .number(),
|
|
|
+ address_id: that.ctx.rules.name('收货地址ID')
|
|
|
+ .required()
|
|
|
+ .notEmpty()
|
|
|
.number(),
|
|
|
};
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
- * [deleteValidate 删除收货地址]
|
|
|
- * @return {[type]} [description]
|
|
|
- */
|
|
|
+ * [deleteValidate 删除收货地址]
|
|
|
+ * @return {[type]} [description]
|
|
|
+ */
|
|
|
get deleteValidate() {
|
|
|
const that = this;
|
|
|
return {
|
|
|
- user_id: that.ctx.rules.default(that.service.shop.getWebUserId()).number(),
|
|
|
- address_id: that.ctx.rules.name('收货地址ID').required().notEmpty()
|
|
|
+ user_id: that.ctx.rules.default(that.service.shop.getWebUserId())
|
|
|
+ .number(),
|
|
|
+ address_id: that.ctx.rules.name('收货地址ID')
|
|
|
+ .required()
|
|
|
+ .notEmpty()
|
|
|
.number(),
|
|
|
};
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
- * [select 用户收货地址列表]
|
|
|
- * @return {[type]} [description]
|
|
|
- */
|
|
|
+ * [select 用户收货地址列表]
|
|
|
+ * @return {[type]} [description]
|
|
|
+ */
|
|
|
async select() {
|
|
|
const that = this;
|
|
|
try {
|
|
@@ -92,10 +126,11 @@ module.exports = class AddressController extends shopController {
|
|
|
return that.ctx.appJson(that.app.szjcomo.appResult('SUCCESS', false, false));
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
- * [create 添加收货地址]
|
|
|
- * @return {[type]} [description]
|
|
|
- */
|
|
|
+ * [create 添加收货地址]
|
|
|
+ * @return {[type]} [description]
|
|
|
+ */
|
|
|
async create() {
|
|
|
const that = this;
|
|
|
try {
|
|
@@ -107,10 +142,11 @@ module.exports = class AddressController extends shopController {
|
|
|
return that.ctx.appJson(that.app.szjcomo.appResult(err.message));
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
- * [update 更新收货地址]
|
|
|
- * @return {[type]} [description]
|
|
|
- */
|
|
|
+ * [update 更新收货地址]
|
|
|
+ * @return {[type]} [description]
|
|
|
+ */
|
|
|
async update() {
|
|
|
const that = this;
|
|
|
try {
|
|
@@ -130,10 +166,11 @@ module.exports = class AddressController extends shopController {
|
|
|
return that.ctx.appJson(that.app.szjcomo.appResult(err.message));
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
- * [delete 删除收货地址]
|
|
|
- * @return {[type]} [description]
|
|
|
- */
|
|
|
+ * [delete 删除收货地址]
|
|
|
+ * @return {[type]} [description]
|
|
|
+ */
|
|
|
async delete() {
|
|
|
const that = this;
|
|
|
try {
|