Authored by wenjiekong

地区接口

... ... @@ -44,7 +44,9 @@ exports.editUserInfo = (req, res, next) => {
let uid = '8039836';
// 真实数据输出
userService.editUserInfo(req, uid).then().catch(next);
userService.editUserInfo(req, uid).then(result => {
res.json(result);
}).catch(next);
};
... ... @@ -60,7 +62,7 @@ exports.editUserContactInfo = (req, res, next) => {
// 真实数据输出
userService.editUserContactInfo(req, uid).then(result => {
console.info(result);
res.json(result);
}).catch(next);
};
... ... @@ -77,7 +79,7 @@ exports.editUserHabitsInfo = (req, res, next) => {
// 真实数据输出
userService.editUserHabitsInfo(req, uid).then(result => {
console.info(result);
res.json(result);
}).catch(next);
};
... ... @@ -95,7 +97,7 @@ exports.editUserLikeBrand = (req, res, next) => {
// 真实数据输出
userService.editUserLikeBrand(req, uid).then(result => {
console.info(result);
res.json(result);
}).catch(next);
};
... ... @@ -112,7 +114,18 @@ exports.isBrandName = (req, res, next) => {
// 真实数据输出
userService.isBrandName(req).then(result => {
console.info(result);
res.json(result);
}).catch(next);
};
exports.getProviceList = (req, res, next) => {
// let uid = '8039836';
console.info(req.query.id);
// 真实数据输出
userService.getProviceList(req.query.id).then(result => {
res.json(result);
}).catch(next);
};
... ...
... ... @@ -255,7 +255,7 @@ const getProviceCityInfo = (parentId, checkValue) => {
text: addressInfo.data[i].caption
};
if (addressInfo.data[i].id === checkValue) {
if (!checkValue && addressInfo.data[i].id === checkValue) {
addressJson.isChecked = true;
}
res.push(addressJson);
... ... @@ -268,16 +268,18 @@ const getProviceCityInfo = (parentId, checkValue) => {
const getUserInfo = (channel, uid) => {
return api.all([
headerModel.requestHeaderData(channel),
userApi.getUserInfo(uid),
userApi.getTipConfig(uid),
userApi.getUserContactInfo(uid),
userApi.getUserHabitsInfo(uid),
userApi.getUserLikeBrand(uid),
searchApi.get('/brand/list.json', {}, {cache: true})
return co(function*(){
let result = yield api.all([
headerModel.requestHeaderData(channel),
userApi.getUserInfo(uid),
userApi.getTipConfig(uid),
userApi.getUserContactInfo(uid),
userApi.getUserHabitsInfo(uid),
userApi.getUserLikeBrand(uid),
searchApi.get('/brand/list.json', {}, {cache: true})
]);
]).then(result => {
let finalResult = {},
headerData = {},
userInfo = {};
... ... @@ -406,9 +408,21 @@ const getUserInfo = (channel, uid) => {
if (result[3].code === 200) {
let contactInfo = result[3].data || '',
areaCode;
areaCode = result[3].data.area_code || '';
console.info(areaCode);
let proviceOpts = yield getProviceCityInfo(0, areaCode.substr(0, 2)),
cityOpts = [{value: 0, text: '请选择市'}],
areaOpts = [{value: 0, text: '请选择区县'}];
getProviceCityInfo(0, areaCode.substr(0, 2));
if (areaCode.length === 4) {
cityOpts = yield getProviceCityInfo(areaCode.substr(0, 2), areaCode.substr(0, 4));
}
if (areaCode.length > 4) {
areaOpts = yield getProviceCityInfo(areaCode.substr(0, 4), areaCode);
}
finalResult.contactInfo = {
subTitle: '联系信息',
... ... @@ -417,19 +431,16 @@ const getUserInfo = (channel, uid) => {
labelText: '来自:',
selects: [
{
key: 'province'
// options: getProviceCityInfo(0, areaCode.substr(0, 2))
key: 'province',
options: proviceOpts
},
{
key: 'city'
// options: getProviceCityInfo(areaCode.substr(0, 2), areaCode.substr(0, 4))
key: 'city',
options: cityOpts
},
{
key: 'areaCode'
// options: getProviceCityInfo(areaCode.substr(0, 4), areaCode)
key: 'areaCode',
options: areaOpts
}
]
},
... ... @@ -466,6 +477,7 @@ const getUserInfo = (channel, uid) => {
}]
};
}
if (result[4].code === 200) {
... ... @@ -541,7 +553,7 @@ const getUserInfo = (channel, uid) => {
finalResult.headerData = headerData;
finalResult.meEditPage = true;
return finalResult;
});
})();
};
const editUserInfo = (req, uid) => {
... ... @@ -657,26 +669,52 @@ const isBrandName = (req) => {
]).then(result => {
let brandList = result.data,
brandName = req.body.brandName;
brandName = req.body.brandName,
brandInfo = {},
flag = false;
if (brandList) {
for (let i = 0; i < brandList.length; i++) {
if (brandList[i].brand_name === brandName) {
// $ret['flag'] = true;
// $ret['data']['brandName'] = $brandName;
// $ret['data']['brandId'] = $value['id'];
flag = true;
brandInfo.brand_name = brandName;
brandInfo.id = brandList[i].id;
break;
}
}
}
if (flag) {
return {
code: 200,
message: '',
data: brandInfo
}
}else {
return {
code: 400,
message: '很抱歉,您要添加的品牌不在我们的品牌库中。',
data: ''
}
}
});
};
const getProviceList = (pid) => {
return co(function*() {
let proList = yield userApi.getProviceCityInfo(pid);
return proList.data;
})();
};
module.exports = {
getUserInfo,
editUserInfo,
editUserContactInfo,
editUserHabitsInfo,
editUserLikeBrand,
getProviceList,
isBrandName
};
... ...
... ... @@ -161,6 +161,8 @@ router.post('/user/edituserlikebrand', UserController.editUserLikeBrand);
router.post('/user/isbrandname', UserController.editUserLikeBrand);
router.get('/address/area', UserController.getProviceList);
router.get('/favorite', FavoriteController.index);
router.get('/coupons', CouponsController.index);
... ...