Authored by wenjiekong

添加修改购物习惯接口

@@ -47,3 +47,18 @@ exports.editUserInfo = (req, res, next) => { @@ -47,3 +47,18 @@ exports.editUserInfo = (req, res, next) => {
47 userService.editUserInfo(req, uid).then().catch(next); 47 userService.editUserInfo(req, uid).then().catch(next);
48 48
49 }; 49 };
  50 +
  51 +/**
  52 + * 编辑购物着装、习惯
  53 + * @param {[type]} req [description]
  54 + * @param {[type]} res [description]
  55 + * @return {[type]} [description]
  56 + */
  57 +exports.editUserHabitsInfo = (req, res, next) => {
  58 +
  59 + let uid = '8039836';
  60 +
  61 + // 真实数据输出
  62 + userService.editUserHabitsInfo(req, uid).then().catch(next);
  63 +
  64 +};
@@ -60,13 +60,36 @@ const editUserInfo = (userInfo) => { @@ -60,13 +60,36 @@ const editUserInfo = (userInfo) => {
60 }); 60 });
61 }; 61 };
62 62
  63 +const editUserContactInfo = (contactInfo) => {
  64 + return api.get('', {
  65 + method: 'web.passport.modifyUserContacts',
  66 + uid: contactInfo.uid,
  67 + area_code: contactInfo.areaCode,
  68 + phone: contactInfo.phone,
  69 + mobile: contactInfo.mobile,
  70 + qq: contactInfo.qq,
  71 + full_address: contactInfo.fullAddress,
  72 + zip_code: contactInfo.zipCode
  73 + });
  74 +};
  75 +
  76 +const editUserHabitsInfo = (habitsInfo) => {
  77 + return api.get('', {
  78 + method: 'web.passport.modifyUserHabits',
  79 + uid: habitsInfo.uid,
  80 + shopping: habitsInfo.shopping,
  81 + dress: habitsInfo.dress
  82 + });
  83 +};
63 84
64 module.exports = { 85 module.exports = {
65 getUserInfo, 86 getUserInfo,
66 editUserInfo, 87 editUserInfo,
67 getUserContactInfo, 88 getUserContactInfo,
  89 + editUserContactInfo,
68 getProviceCityInfo, 90 getProviceCityInfo,
69 getUserHabitsInfo, 91 getUserHabitsInfo,
  92 + editUserHabitsInfo,
70 getUserLikeBrand, 93 getUserLikeBrand,
71 getTipConfig 94 getTipConfig
72 }; 95 };
@@ -7,6 +7,7 @@ @@ -7,6 +7,7 @@
7 'use strict'; 7 'use strict';
8 const api = global.yoho.API; 8 const api = global.yoho.API;
9 const userApi = require('./user-api'); 9 const userApi = require('./user-api');
  10 +const searchApi = global.yoho.SearchAPI;
10 const Images = require('../../../utils/images'); 11 const Images = require('../../../utils/images');
11 const headerModel = require('../../../doraemon/models/header'); 12 const headerModel = require('../../../doraemon/models/header');
12 13
@@ -88,49 +89,49 @@ const configData = { @@ -88,49 +89,49 @@ const configData = {
88 // 着装习惯 89 // 着装习惯
89 dressHabits: [{ 90 dressHabits: [{
90 type: 'checkbox', 91 type: 'checkbox',
91 - key: 'dress[]', 92 + key: 'dress',
92 index: 'dress-1', 93 index: 'dress-1',
93 value: '1', 94 value: '1',
94 text: '正装' 95 text: '正装'
95 }, 96 },
96 { 97 {
97 type: 'checkbox', 98 type: 'checkbox',
98 - key: 'dress[]', 99 + key: 'dress',
99 index: 'dress-2', 100 index: 'dress-2',
100 value: '2', 101 value: '2',
101 text: '商务' 102 text: '商务'
102 }, 103 },
103 { 104 {
104 type: 'checkbox', 105 type: 'checkbox',
105 - key: 'dress[]', 106 + key: 'dress',
106 index: 'dress-3', 107 index: 'dress-3',
107 value: '3', 108 value: '3',
108 text: '街头流行' 109 text: '街头流行'
109 }, 110 },
110 { 111 {
111 type: 'checkbox', 112 type: 'checkbox',
112 - key: 'dress[]', 113 + key: 'dress',
113 index: 'dress-4', 114 index: 'dress-4',
114 value: '4', 115 value: '4',
115 text: '运动休闲' 116 text: '运动休闲'
116 }, 117 },
117 { 118 {
118 type: 'checkbox', 119 type: 'checkbox',
119 - key: 'dress[]', 120 + key: 'dress',
120 index: 'dress-5', 121 index: 'dress-5',
121 value: '5', 122 value: '5',
122 text: '文艺气质' 123 text: '文艺气质'
123 }, 124 },
124 { 125 {
125 type: 'checkbox', 126 type: 'checkbox',
126 - key: 'dress[]', 127 + key: 'dress',
127 index: 'dress-6', 128 index: 'dress-6',
128 value: '6', 129 value: '6',
129 text: '甜美可爱' 130 text: '甜美可爱'
130 }, 131 },
131 { 132 {
132 type: 'checkbox', 133 type: 'checkbox',
133 - key: 'dress[]', 134 + key: 'dress',
134 index: 'dress-7', 135 index: 'dress-7',
135 value: '7', 136 value: '7',
136 text: '另类' 137 text: '另类'
@@ -248,7 +249,12 @@ const getUserInfo = (channel, uid) => { @@ -248,7 +249,12 @@ const getUserInfo = (channel, uid) => {
248 ]).then(result => { 249 ]).then(result => {
249 let finalResult = {}, 250 let finalResult = {},
250 headerData = {}, 251 headerData = {},
251 - userInfo = {}; 252 + userInfo = {},
  253 + brandList;
  254 +
  255 + brandList = searchApi.get('/brand/list.json', {is_hot: 'Y'}, {
  256 + cache: true
  257 + });
252 258
253 if (result[0].code === 200) { 259 if (result[0].code === 200) {
254 headerData = result[0]; 260 headerData = result[0];
@@ -471,11 +477,10 @@ const getUserInfo = (channel, uid) => { @@ -471,11 +477,10 @@ const getUserInfo = (channel, uid) => {
471 } 477 }
472 478
473 if (result[5].code === 200) { 479 if (result[5].code === 200) {
474 - // let brandInfo = result[4].data || ''; 480 + // let brandInfo = result[5].data || '';
475 finalResult.favorite = { 481 finalResult.favorite = {
476 subTitle: '喜爱品牌', 482 subTitle: '喜爱品牌',
477 submitId: 'favorite-brand' 483 submitId: 'favorite-brand'
478 -  
479 // likebrand: (substr($userLikeBrandInfo['likeBrandStr'], 0, 1) == ',') ? 484 // likebrand: (substr($userLikeBrandInfo['likeBrandStr'], 0, 1) == ',') ?
480 // $userLikeBrandInfo['likeBrandStr'] : ',' . $userLikeBrandInfo['likeBrandStr'], 485 // $userLikeBrandInfo['likeBrandStr'] : ',' . $userLikeBrandInfo['likeBrandStr'],
481 // favoriteBrands: $userLikeBrandInfo['favBrands'], 486 // favoriteBrands: $userLikeBrandInfo['favBrands'],
@@ -514,7 +519,39 @@ const editUserInfo = (req, uid) => { @@ -514,7 +519,39 @@ const editUserInfo = (req, uid) => {
514 return respData; 519 return respData;
515 }; 520 };
516 521
  522 +const editUserHabitsInfo = (req, uid) => {
  523 + let habitsInfo = {},
  524 + dressArr = [],
  525 + respData;
  526 +
  527 + habitsInfo.uid = uid;
  528 + habitsInfo.shopping = req.body.shopping;
  529 +
  530 + if (req.body.dress) {
  531 + dressArr = req.body.dress;
  532 + habitsInfo.dress = dressArr.join(',');
  533 + }else {
  534 + habitsInfo.dress = '';
  535 + }
  536 +
  537 + console.info(habitsInfo);
  538 + if (!habitsInfo.shopping) {
  539 + respData = {
  540 + code: 400,
  541 + message: '缺失必填项',
  542 + data: ''
  543 + };
  544 +
  545 + } else {
  546 + respData = userApi.editUserHabitsInfo(habitsInfo);
  547 + }
  548 +
  549 + console.info(respData);
  550 + return respData;
  551 +};
  552 +
517 module.exports = { 553 module.exports = {
518 getUserInfo, 554 getUserInfo,
519 - editUserInfo 555 + editUserInfo,
  556 + editUserHabitsInfo
520 }; 557 };
@@ -153,6 +153,8 @@ router.get('/user', [getCommonHeader, getHomeNav], UserController.index); @@ -153,6 +153,8 @@ router.get('/user', [getCommonHeader, getHomeNav], UserController.index);
153 153
154 router.post('/user/edituserinfo', UserController.editUserInfo); 154 router.post('/user/edituserinfo', UserController.editUserInfo);
155 155
  156 +router.post('/user/edituserhabitsinfo', UserController.editUserHabitsInfo);
  157 +
156 router.get('/favorite', FavoriteController.index); 158 router.get('/favorite', FavoriteController.index);
157 159
158 router.get('/coupons', CouponsController.index); 160 router.get('/coupons', CouponsController.index);