Authored by wenjiekong

修改个人资料编辑接口

... ... @@ -108,11 +108,11 @@ exports.editUserLikeBrand = (req, res, next) => {
*/
exports.isBrandName = (req, res, next) => {
let uid = '8039836';
// let uid = '8039836';
// 真实数据输出
userService.isBrandName(req).then(result => {
// console.info(result);
console.info(result);
}).catch(next);
};
... ...
... ... @@ -207,6 +207,30 @@ const isEmpty = (value) => {
(Object.prototype.isPrototypeOf(value) && Object.keys(value).length === 0);
};
const getHotBrands = (brandList) => {
let hotBrands = [],
i = 20;
if (brandList) {
for (let j = 0; j < brandList.length; j++) {
if (brandList[j].is_hot === 'Y') {
hotBrands.push({
id: 'pp-' + brandList[j].id,
name: 'pp[]',
value: brandList[j].id,
text: brandList[j].brand_name
});
i--;
}
if (i <= 0) {
break;
}
}
}
return hotBrands;
};
/**
* 联动取地区信息
*/
... ... @@ -215,7 +239,7 @@ const getProviceCityInfo = (parentId, checkValue) => {
let addressInfo = yield userApi.getProviceCityInfo(parentId),
res = [{value: 0}],
defaultText;
if (parentId.length === 2) {
defaultText = '请选择省份';
} else if (parentId.length === 4) {
... ... @@ -382,12 +406,9 @@ const getUserInfo = (channel, uid) => {
if (result[3].code === 200) {
let contactInfo = result[3].data || '',
areaCode = contactInfo.areaCode || '',
prov;
areaCode;
// getProviceCityInfo(0, areaCode.substr(0, 2)).then(result => {
// console.info(result);
// });
getProviceCityInfo(0, areaCode.substr(0, 2));
finalResult.contactInfo = {
subTitle: '联系信息',
... ... @@ -396,15 +417,18 @@ const getUserInfo = (channel, uid) => {
labelText: '来自:',
selects: [
{
key: 'province',
key: 'province'
// options: getProviceCityInfo(0, areaCode.substr(0, 2))
},
{
key: 'city',
key: 'city'
// options: getProviceCityInfo(areaCode.substr(0, 2), areaCode.substr(0, 4))
},
{
key: 'areaCode',
key: 'areaCode'
// options: getProviceCityInfo(areaCode.substr(0, 4), areaCode)
}
]
... ... @@ -495,7 +519,7 @@ const getUserInfo = (channel, uid) => {
for (let i; i < brandArr.length; i++) {
for (let j; j < brandList.length; j++) {
if (brandList.id == brandArr[i]) {
if (brandList.id === brandArr[i]) {
favBrands.push({
name: brandList.brand_name,
id: 'brand-' . brandList.id
... ... @@ -508,7 +532,7 @@ const getUserInfo = (channel, uid) => {
finalResult.favorite = {
subTitle: '喜爱品牌',
submitId: 'favorite-brand',
likebrand: (likeBrandStr.substr(0, 1) == ',') ? likeBrandStr : ',' + likeBrandStr,
likebrand: (likeBrandStr.substr(0, 1) === ',') ? likeBrandStr : ',' + likeBrandStr,
favoriteBrands: favBrands,
hotBrands: hotBrands
};
... ... @@ -520,30 +544,6 @@ const getUserInfo = (channel, uid) => {
});
};
const getHotBrands = (brandList) => {
let hotBrands = [],
i = 20;
if (brandList) {
for (let j = 0; j < brandList.length; j++) {
if (brandList[j].is_hot == 'Y') {
hotBrands.push({
id: 'pp-' + brandList[j].id,
name: 'pp[]',
value: brandList[j].id,
text: brandList[j].brand_name
});
i--;
}
if (i <= 0) {
break;
}
}
}
return hotBrands;
};
const editUserInfo = (req, uid) => {
let userInfo = {},
respData;
... ... @@ -621,10 +621,10 @@ const editUserHabitsInfo = (req, uid) => {
return respData;
}
return co(function*() {
return co(function*() {
respData = yield userApi.editUserHabitsInfo(habitsInfo);
return respData;
})();
};
... ... @@ -643,10 +643,10 @@ const editUserLikeBrand = (req, uid) => {
};
return respData;
}
return co(function*() {
}
return co(function*() {
respData = yield userApi.editUserLikeBrand(uid, brand);
return respData;
})();
};
... ...
... ... @@ -159,7 +159,7 @@ router.post('/user/edituserhabitsinfo', UserController.editUserHabitsInfo);
router.post('/user/edituserlikebrand', UserController.editUserLikeBrand);
router.post('/user/isbrandname', UserController.editUserLikeBrand);
router.post('/user/isbrandname', UserController.editUserLikeBrand);
router.get('/favorite', FavoriteController.index);
... ...