user-api.js 4.85 KB
/**
 * 个人中心 编辑资料api
 * @author: gaohongwei<hongwei.gao@yoho.cn>
 * @date: 2016/8/16
 */
module.exports = class extends global.yoho.BaseModel {
    constructor(ctx) {
        super(ctx);
    }

    getUserInfo(uid) {

        let data = {
            method: 'app.passport.profile',
            uid: uid
        };

        return this.get({
            data: data
        });
    }

    getUserContactInfo(uid) {

        let data = {
            method: 'web.passport.getUserContacts',
            uid: uid
        };

        return this.get({
            data: data
        });
    }

    getProviceCityInfo(parentId) {

        let data = {
            method: 'app.address.provinces',
            id: parentId
        };

        return this.get({
            data: data
        });
    }

    getUserHabitsInfo(uid) {

        let data = {
            method: 'web.passport.getUserHabits',
            uid: uid
        };

        return this.get({
            data: data
        });
    }

    getUserLikeBrand(uid) {

        let data = {
            method: 'web.passport.getLikeBrand',
            uid: uid
        };

        return this.get({
            data: data
        });
    }

    getTipConfig(uid) {

        let data = {
            method: 'app.resources.config.clientInitConfig',
            uid: uid
        };

        return this.get({
            data: data
        });
    }

    /**
     * 修改用户联系信息
     */
    editUserInfo(userInfo) {

        let data = {
            method: 'app.passport.modifyUserInfo',
            uid: userInfo.uid,
            nick_name: userInfo.nickname,
            username: userInfo.username,
            gender: userInfo.gender,
            profession: userInfo.profession,
            income: userInfo.income
        };

        return this.get({
            data: data
        });
    }

    /**
     * 修改用户联系信息
     */
    editUserContactInfo(contactInfo) {

        let data = {
            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
        };

        return this.get({
            data: data
        });
    }

    /**
     * 修改用户购物着装习惯信息
     */
    editUserHabitsInfo(habitsInfo) {

        let data = {
            method: 'web.passport.modifyUserHabits',
            uid: habitsInfo.uid,
            shopping: habitsInfo.shopping,
            dress: habitsInfo.dress
        };

        return this.get({
            data: data
        });
    }

    /**
     * 修改用户喜欢品牌
     */
    editUserLikeBrand(uid, brand) {

        let data = {
            method: 'web.passport.modifyLikeBrand',
            uid: uid,
            brand: brand
        };

        return this.get({
            data: data
        });
    }

    /**
     * 根据手机号获取用户信息[TODO +cache]
     * @param string $area
     * @param string $mobile
     * @return array
     */
    getUserInfoByMobile(area, mobile) {

        let data = {
            method: 'app.passport.getProfileByMobile',
            area: area,
            mobile: mobile
        };

        return this.get({
            data: data
        });
    }

    /**
     * 兑换礼品卡
     * @param type $uid
     * @param type $giftCardCode1
     * @param type $giftCardCode2
     * @param type $giftCardCode3
     * @param type $captchaCode
     */
    exchangeGift(params, uid) {

        let data = {
            method: 'web.personCen.giftExchange',
            uid: uid,
            giftCardCode1: params.giftCardCode1,
            giftCardCode2: params.giftCardCode2,
            giftCardCode3: params.giftCardCode3
        };

        return this.get({
            data: data
        });
    }

    bind3partyAccount(uid, param) {

        let data = {
            method: 'app.passport.bindOpenId',
            uid: uid,
            open_id: param.openId,
            source_type: param.sourceType,
            nickname: param.nickname
        };

        return this.get({
            data: data
        });
    }

    cancelBind3partyAccount(uid, type) {

        let data = {
            method: 'app.passport.removeBindOpenId',
            uid: uid,
            source_type: type
        };

        return this.get({
            data: data
        });
    }

    getFavorBrand() {

        let data = {
            method: 'web.search.favorBrand'
        };

        return this.get({
            data: data
        });
    }

    getCanRemoveBindOpenIdTag(uid) {

        let data = {
            method: 'app.passport.isCanRemoveBindOpenId',
            uid: uid
        };

        return this.get({
            data: data
        });

    }

};