Authored by wenjiekong

添加修改购物习惯接口

... ... @@ -47,3 +47,18 @@ exports.editUserInfo = (req, res, next) => {
userService.editUserInfo(req, uid).then().catch(next);
};
/**
* 编辑购物着装、习惯
* @param {[type]} req [description]
* @param {[type]} res [description]
* @return {[type]} [description]
*/
exports.editUserHabitsInfo = (req, res, next) => {
let uid = '8039836';
// 真实数据输出
userService.editUserHabitsInfo(req, uid).then().catch(next);
};
... ...
... ... @@ -60,13 +60,36 @@ const editUserInfo = (userInfo) => {
});
};
const editUserContactInfo = (contactInfo) => {
return api.get('', {
method: 'web.passport.modifyUserContacts',
uid: contactInfo.uid,
area_code: contactInfo.areaCode,
phone: contactInfo.phone,
mobile: contactInfo.mobile,
qq: contactInfo.qq,
full_address: contactInfo.fullAddress,
zip_code: contactInfo.zipCode
});
};
const editUserHabitsInfo = (habitsInfo) => {
return api.get('', {
method: 'web.passport.modifyUserHabits',
uid: habitsInfo.uid,
shopping: habitsInfo.shopping,
dress: habitsInfo.dress
});
};
module.exports = {
getUserInfo,
editUserInfo,
getUserContactInfo,
editUserContactInfo,
getProviceCityInfo,
getUserHabitsInfo,
editUserHabitsInfo,
getUserLikeBrand,
getTipConfig
};
... ...
... ... @@ -7,6 +7,7 @@
'use strict';
const api = global.yoho.API;
const userApi = require('./user-api');
const searchApi = global.yoho.SearchAPI;
const Images = require('../../../utils/images');
const headerModel = require('../../../doraemon/models/header');
... ... @@ -88,49 +89,49 @@ const configData = {
// 着装习惯
dressHabits: [{
type: 'checkbox',
key: 'dress[]',
key: 'dress',
index: 'dress-1',
value: '1',
text: '正装'
},
{
type: 'checkbox',
key: 'dress[]',
key: 'dress',
index: 'dress-2',
value: '2',
text: '商务'
},
{
type: 'checkbox',
key: 'dress[]',
key: 'dress',
index: 'dress-3',
value: '3',
text: '街头流行'
},
{
type: 'checkbox',
key: 'dress[]',
key: 'dress',
index: 'dress-4',
value: '4',
text: '运动休闲'
},
{
type: 'checkbox',
key: 'dress[]',
key: 'dress',
index: 'dress-5',
value: '5',
text: '文艺气质'
},
{
type: 'checkbox',
key: 'dress[]',
key: 'dress',
index: 'dress-6',
value: '6',
text: '甜美可爱'
},
{
type: 'checkbox',
key: 'dress[]',
key: 'dress',
index: 'dress-7',
value: '7',
text: '另类'
... ... @@ -248,7 +249,12 @@ const getUserInfo = (channel, uid) => {
]).then(result => {
let finalResult = {},
headerData = {},
userInfo = {};
userInfo = {},
brandList;
brandList = searchApi.get('/brand/list.json', {is_hot: 'Y'}, {
cache: true
});
if (result[0].code === 200) {
headerData = result[0];
... ... @@ -471,11 +477,10 @@ const getUserInfo = (channel, uid) => {
}
if (result[5].code === 200) {
// let brandInfo = result[4].data || '';
// let brandInfo = result[5].data || '';
finalResult.favorite = {
subTitle: '喜爱品牌',
submitId: 'favorite-brand'
// likebrand: (substr($userLikeBrandInfo['likeBrandStr'], 0, 1) == ',') ?
// $userLikeBrandInfo['likeBrandStr'] : ',' . $userLikeBrandInfo['likeBrandStr'],
// favoriteBrands: $userLikeBrandInfo['favBrands'],
... ... @@ -514,7 +519,39 @@ const editUserInfo = (req, uid) => {
return respData;
};
const editUserHabitsInfo = (req, uid) => {
let habitsInfo = {},
dressArr = [],
respData;
habitsInfo.uid = uid;
habitsInfo.shopping = req.body.shopping;
if (req.body.dress) {
dressArr = req.body.dress;
habitsInfo.dress = dressArr.join(',');
}else {
habitsInfo.dress = '';
}
console.info(habitsInfo);
if (!habitsInfo.shopping) {
respData = {
code: 400,
message: '缺失必填项',
data: ''
};
} else {
respData = userApi.editUserHabitsInfo(habitsInfo);
}
console.info(respData);
return respData;
};
module.exports = {
getUserInfo,
editUserInfo
editUserInfo,
editUserHabitsInfo
};
... ...
... ... @@ -153,6 +153,8 @@ router.get('/user', [getCommonHeader, getHomeNav], UserController.index);
router.post('/user/edituserinfo', UserController.editUserInfo);
router.post('/user/edituserhabitsinfo', UserController.editUserHabitsInfo);
router.get('/favorite', FavoriteController.index);
router.get('/coupons', CouponsController.index);
... ...