account
顾客账号。
API
.current(callback)
获取当前顾客信息
- callback
- 类型:Function( 返回对象 )
 获取后的回调函数- customer类型:Object
 null: 当前未登录
 用户对象:当前登录的用户 查看详情
 
 
.login(user, callback)
顾客登录
- user
- 类型:Object- account类型:String
 登录的用户名
- password类型:String
 登录的密码
 
 
- callback
- 类型:Function( 返回对象 ) 
 登录后的回调函数- code类型:Number
 200:登录成功
 201:登录失败
- message类型:String
 登录失败原因(当 code 为 201 时)
- account类型:String
 当前登录的用户名
- customer类型:Object
 当前登录的用户信息 查看详情
 - { "code" : 200, "message" : "", "account" : "yhsduser", "customer" : { "id" : 15, "social_type" : false, "name" : "yhsduser", "metas" : {}, "notify_email" : "user@youhaosuda.com", "notify_phone" : "13824402932", "accept_marketing" : false, "regist_at" : "2014-08-27T13:52:34.964+08:00", "orders_count" : 15, "total_spent" : 144291, "last_order_no" : "201505263782651", "last_order_at" : "2015-05-26T19:25:53.667+08:00" } }
 
.vcodeLogin(user, callback)
顾客手机账号短信验证码登录或注册
- user
- 类型:Object- account类型:String
 手机号码
- verify_code类型:String
 手机短信验证码
- auto_register类型:Boolean
 选填,账号不存在时,是否自动注册,默认- true
 
 
- callback
- 类型:Function( 返回对象 ) 
 登录或注册后的回调函数- code类型:Number
 200:登录或注册成功
 201:登录或注册失败
- message类型:String
 登录或注册失败原因(当 code 为 201 时)
- account类型:String
 当前登录或注册的用户名
- customer类型:Object
 当前登录或注册的用户信息 查看详情
 - { "code" : 200, "message" : "", "account" : "yhsduser", "customer" : { "id" : 15, "social_type" : false, "name" : "yhsduser", "metas" : {}, "notify_email" : "user@youhaosuda.com", "notify_phone" : "13824402932", "accept_marketing" : false, "regist_at" : "2014-08-27T13:52:34.964+08:00", "orders_count" : 15, "total_spent" : 144291, "last_order_no" : "201505263782651", "last_order_at" : "2015-05-26T19:25:53.667+08:00" } }
 
.socialAuth(config, callback)
社交授权登录,可用社交授权相关接口获取到的一次性验证令牌换取 API Session Token
- config
- 类型:Object- uid类型:String
 用户 UID
- auth_token类型:String
 社交授权成功的一次性验证令牌
- type类型:String
 默认填- weixin即可
 
 
- callback
- 类型:Function( 返回对象 ) 
 数据回调函数- code类型:Number
 200:获取数据成功
- message类型:String
 获取数据失败原因(当 code 不为 200 时)
- token类型:String
 API Session Token
- customer类型:Object
 当前用户信息 查看详情
 - { "code" : 200, "message" : "", "token" : "...", "customer" : { "id" : 15, "social_type" : false, "name" : "yhsduser", "metas" : {}, "notify_email" : "user@youhaosuda.com", "notify_phone" : "13824402932", "accept_marketing" : false, "regist_at" : "2014-08-27T13:52:34.964+08:00", "orders_count" : 15, "total_spent" : 144291, "last_order_no" : "201505263782651", "last_order_at" : "2015-05-26T19:25:53.667+08:00" } }
 
.logout(callback)
顾客登出 (必须登录)
- callback
- 类型:Function( 返回对象 )
 成功登出后的回调函数
 
.changePassword(password, callback)
顾客修改密码 (必须登录)
- password
- 类型:Object- password_old类型:String
 旧密码
- password类型:String
 新密码
- password_again类型:String
 重复新密码
 
 
- callback
- 类型:Function( 返回对象 )
 提交后的回调函数
 注:密码修改成功后,顾客当前登录状态将会失效- code类型:Number
 200:密码修改成功
 201:密码修改失败
- message类型:String
 密码修改失败原因(当 code 为 201 时)
 
 
.save(notify, callback)
更新顾客信息 (必须登录)
- notify
- 类型:Object- notify_email类型:String
 顾客用于接收通知的邮箱
- notify_phone类型:String
 顾客用于接收通知的手机
- real_name类型:String
 真实姓名
- sex类型:String
 性别,可选的值包括:- male: 男
- female: 女
- undefined: 保密
 
- birthday类型:String
 生日,如"1926-08-17"
- indentity_card类型:String
 身份证号码
- meta_fields(选填) 类型:String
 序列化的地址拓展字段(JSON字符串),包含下列属性- name:String 类型,MetaField 的唯一字符串标识。仅支持小写字母、数字、中横和下划线,最多 200 个字符。
- description:String 类型,MetaField 的说明,最多 2000 个字符。
- fields:Object 类型,MetaField 的字段,Key-Value 结构对象。
 - meta_fields = JSON.stringify({ name: 'info', description: '信息', fields: { city: '深圳' } })
 
 
- callback
- 类型:Function( 返回对象 )
 更新后的回调函数- code类型:Number
 200:更新信息成功
 201:更新信息失败
- message类型:String
 更新信息失败原因(当 code 为 201 时)
- customer类型:Object
 更新后的用户信息 查看详情
 
 
.socialBind(user, callback)
社交账号绑定普通账号(系统强制绑定)
- user
- 类型:Object- account类型:String
 用户账号(非必须)
- password类型:String
 用户密码(非必须)
- notify_email类型:String
 通知邮箱(非必须)
- notify_phone类型:String
 通知手机(非必须)
 
 
- callback
- 类型:Function( 返回对象 ) 
 发送后的回调函数- code类型:Number
 200:绑定成功
 非 200:绑定失败
- message类型:String
 绑定失败原因(当 code 为非 200 时)
- bind_success类型:Boolean
 社交账号是否绑定相关信息成功
- customer类型:Object
 主账号用户信息 查看详情
- current_customer类型:Object
 社交账号用户信息(信息格式与 customer 类似)
 - { "code": 200, "message": "", "bind_success": true, "current_customer": { "accept_marketing": false, "avatar_url": "//asset.ibanquan.com/image/5bebcd3c8c77402e52000333/avatar_url.jpg", "birthday": null, "customer_level": { "avatar_url": "//asset.ibanquan.com/image/569547ca0abc3e71be000003/custom_level_default.png", "credits": 10000, "discount": 50, "id": 1557, "name": "lvmax" }, "email": null, "id": 888, "indentity_card": null, "last_order_at": "2019-02-12T10:51:12.878+08:00", "last_order_no": "2019021215059454044", "last_year_point": 42, "metas": {}, "mobile": "13800138000", "name": "13800138000", "notify_email": "", "notify_phone": "13800138000", "orders_count": 33, "point": 0, "real_name": null, "reg_type": 2, "regist_at": "2018-05-13T17:25:05.757+08:00", "sex": "undefined", "social_accounts": [ { "avatar_url": "", "bind_url": "https://youhaosuda.com/api/auth?type=douban&direct_bind=true", "binded": false, "name": "", "type": "douban" }, { "avatar_url": "", "bind_url": "https://youhaosuda.com/api/auth?type=weibo&direct_bind=true", "binded": false, "name": "", "type": "weibo" }, { "avatar_url": "", "bind_url": "https://youhaosuda.com/api/auth?type=qq&direct_bind=true", "binded": false, "name": "", "type": "qq" }, { "avatar_url": "", "bind_url": "https://youhaosuda.com/api/auth?type=renren&direct_bind=true", "binded": false, "name": "", "type": "renren" }, { "avatar_url": "", "bind_url": "https://youhaosuda.com/api/auth?type=netease&direct_bind=true", "binded": false, "name": "", "type": "netease" }, { "avatar_url": "", "bind_url": "https://youhaosuda.com/api/auth?type=weixin&direct_bind=true", "binded": false, "name": "", "type": "weixin" }, { "avatar_url": "", "bind_url": "https://youhaosuda.com/api/auth?type=facebook&direct_bind=true", "binded": false, "name": "", "type": "facebook" } ], "social_id": null, "social_type": false, "total_credit": 101114, "total_spent": 21078, "uname": null }, "customer": null }
 
.socialSync(config, callback)
社交账号绑定普通账号(用户主动绑定)
- config
- 类型:Object- account类型:String
 用户账号
- password类型:String
 选填,用户密码
- verify_code类型:String
 选填,手机短信验证码,
- auto_register类型:Boolean
 选填,账号不存在时,是否自动注册,默认- false
 
 
- callback
- 类型:Function( 返回对象 ) 
 发送后的回调函数- code类型:Number
 200:绑定成功
 非 200:绑定失败
- message类型:String
 绑定失败原因(当 code 为非 200 时)
- bind_success类型:Boolean
 社交账号是否绑定相关信息成功
- customer类型:Object
 主账号用户信息 查看详情
- current_customer类型:Object
 社交账号用户信息(信息格式与 customer 类似)
 - { "code": 200, "message": "", "bind_success": true, "current_customer": { "accept_marketing": false, "avatar_url": "//asset.ibanquan.com/image/5bebcd3c8c77402e52000333/avatar_url.jpg", "birthday": null, "customer_level": { "avatar_url": "//asset.ibanquan.com/image/569547ca0abc3e71be000003/custom_level_default.png", "credits": 10000, "discount": 50, "id": 1557, "name": "lvmax" }, "email": null, "id": 888, "indentity_card": null, "last_order_at": "2019-02-12T10:51:12.878+08:00", "last_order_no": "2019021215059454044", "last_year_point": 42, "metas": {}, "mobile": "13800138000", "name": "13800138000", "notify_email": "", "notify_phone": "13800138000", "orders_count": 33, "point": 0, "real_name": null, "reg_type": 2, "regist_at": "2018-05-13T17:25:05.757+08:00", "sex": "undefined", "social_accounts": [ { "avatar_url": "", "bind_url": "https://youhaosuda.com/api/auth?type=douban&direct_bind=true", "binded": false, "name": "", "type": "douban" }, { "avatar_url": "", "bind_url": "https://youhaosuda.com/api/auth?type=weibo&direct_bind=true", "binded": false, "name": "", "type": "weibo" }, { "avatar_url": "", "bind_url": "https://youhaosuda.com/api/auth?type=qq&direct_bind=true", "binded": false, "name": "", "type": "qq" }, { "avatar_url": "", "bind_url": "https://youhaosuda.com/api/auth?type=renren&direct_bind=true", "binded": false, "name": "", "type": "renren" }, { "avatar_url": "", "bind_url": "https://youhaosuda.com/api/auth?type=netease&direct_bind=true", "binded": false, "name": "", "type": "netease" }, { "avatar_url": "", "bind_url": "https://youhaosuda.com/api/auth?type=weixin&direct_bind=true", "binded": false, "name": "", "type": "weixin" }, { "avatar_url": "", "bind_url": "https://youhaosuda.com/api/auth?type=facebook&direct_bind=true", "binded": false, "name": "", "type": "facebook" } ], "social_id": null, "social_type": false, "total_credit": 101114, "total_spent": 21078, "uname": null }, "customer": null }
 
.register(param, callback)
注册顾客账号
- param
- 类型:Object- type类型:String
 注册的账号类型,可选 type 包括:- uname: 用户名
- email: 邮箱
- mobile: 手机号码
 
- account类型:String
 用户名/邮箱/手机号码
- password类型:String
 密码
- password_again类型:String
 重复密码
- verify_code类型:String 选填
 手机验证码,当 type 为- mobile必须提供,使用 sendRegistValidateSms 获取
- meta_fields(选填) 类型:String
 序列化的地址拓展字段(JSON字符串),包含下列属性- name:String 类型,MetaField 的唯一字符串标识。仅支持小写字母、数字、中横和下划线,最多 200 个字符。
- description:String 类型,MetaField 的说明,最多 2000 个字符。
- fields:Object 类型,MetaField 的字段,Key-Value 结构对象。
 - meta_fields = JSON.stringify({ name: 'info', description: '信息', fields: { city: '深圳' } })
 
 
- callback
- 类型:Function( 返回对象 )
 提交后的回调函数- code类型:Number
 200:注册成功
 201:注册失败
- message类型:String
 注册失败原因(当 code 为 201 时)
- customer类型:Object
 注册成功的用户信息 查看详情
 
 
.sendRegistValidateSms(param, callback)
顾客注册手机号码账号时,获取短信验证码
.sendResetValidateSms(param, callback)
顾客找回手机号码账号密码时,获取短信验证码
.sendMobileValidateSms(param, callback)
顾客用手机号码登录或注册时,获取短信验证码
.resetPasswordWithMobile(param, callback)
重设手机号码账号密码
- param
- 类型:Object- account类型:String
 需要重设密码的顾客手机号码账号
- password类型:String
 密码
- password_again类型:String
 重复密码
- verify_code类型:String
 手机验证码,使用 sendResetValidateSms 获取
 
 
- callback
- 类型:Function( 返回对象 )
 发送后的回调函数- code类型:Number
 200:发送成功
 214:该操作需要验证码
 201:发送失败
- message类型:String
 发送信息失败原因(当 code 为 201 时)
 
 
.resetPasswordWithEmail(param, callback)
发送邮箱账号重置密码邮件
- param
- 类型:Object- email类型:String
 需要重置密码的邮箱地址
 
 
- callback
- 类型:Function( 返回对象 )
 发送重置邮件后的回调函数- code类型:Number
 200:发送成功
 214:该操作需要验证码
 201:发送失败
- message类型:String
 发送信息失败原因(当 code 为 201 时)
 
 
.resendRegistEmailValidate(param, callback)
重发邮箱注册激活邮件
- param
- 类型:Object- email类型:String
 需要重发激活邮件的邮箱地址
 
 
- callback
- 类型:Function( 返回对象 )
 重发激活邮件后的回调函数- code类型:Number
 200:发送成功
- message类型:String
 发送信息失败原因(当 code 不为 200 时)
 
 
.checkRegistMobile(param, callback)
检测手机是否未注册(多用于顾客注册手机号码账号时检测用)
- param
- 类型:Object- mobile类型:String
 中国大陆手机号码
 
 
- callback
- 类型:Function( 返回对象 )
 请求后的回调函数- code类型:Number
 200:手机号码未注册,可以使用
 201:已注册或其他失败信息
- message类型:String
 已注册或其他失败信息(当 code 为 201 时)
 
 
.checkResetMobile(param, callback)
检测手机是否已注册(用于顾客重设手机号码账号密码时检测用)
- param
- 类型:Object- mobile类型:String
 中国大陆手机号码
 
 
- callback
- 类型:Function( 返回对象 )
 请求后的回调函数- code类型:Number
 200:手机号码已注册,可以重置密码
 201:手机号码尚未注册或其他失败信息
- message类型:String
 201:手机号码尚未注册或其他失败信息(当 code 为 201 时)
 
 
.rewardPointDetails(param, callback)
获取当前账号积分详细信息
- param
- 类型:Object- three_month_ago类型:Boolean 选填
 三个月前的积分
- last_three_month类型:Boolean 选填
 三个月内的积分
- size类型:Number 选填
 指定返回每页的数目
- page类型:Number 选填
 指定返回分页页码
- nopage类型:String 选填
 指定是否分页
 
 
- callback
- 类型:Function( 返回对象 )
 请求后的回调函数- reward_point_total类型:Number
 账号积分总数
- last_year_point类型:Number
 账号上一年积分总数
- reward_point_details类型:Array
 账号积分详细信息
- is_empty类型:Boolean
 是否为空
- 返回对象中包含分页对象 paging 查看详情
 
 
.remove(callback)
注销账号
- callback
- 类型:Function( 返回对象 )
 删除账号后的回调函数{ "code": 200, "message": "" }
 
 
 
 
