Authored by htoooth

add refactor

  1 +/**
  2 + * 注册数据接口
  3 + *
  4 + * @author JiangFeng<jeff.jiang@yoho.cn>
  5 + * @date 2016/06/21
  6 + */
  7 +
  8 +'use strict';
  9 +
  10 +const api = global.yoho.API;
  11 +
  12 +const bindCheck = (mobile, openId, sourceType, area) => {
  13 + let params = {
  14 + method: 'app.passport.signCheck',
  15 + area: area,
  16 + mobile: mobile,
  17 + open_id: openId,
  18 + source_type: sourceType
  19 + };
  20 +
  21 + return api.get('', params);
  22 +};
  23 +
  24 +const sendBindMsg = (area, mobile) => {
  25 + let params = {
  26 + method: 'app.passport.smsbind',
  27 + mobile: mobile,
  28 + area: area
  29 + };
  30 +
  31 + return api.get('', params);
  32 +};
  33 +
  34 +const checkBindCode = (area, mobile, code) => {
  35 + return api.get('', {
  36 + method: 'app.register.validRegCode',
  37 + mobile: mobile,
  38 + area: area,
  39 + code: code
  40 + });
  41 +};
  42 +
  43 +const bindMobile = (openId, sourceType, mobile, area, password, nickname) => {
  44 + let params = {
  45 + method: 'app.passport.bind',
  46 + mobile: mobile,
  47 + open_id: openId,
  48 + source_type: sourceType,
  49 + area: area
  50 + };
  51 +
  52 + if (password) {
  53 + params.password = password;
  54 + }
  55 +
  56 + if (nickname) {
  57 + params.nickname = nickname;
  58 + }
  59 +
  60 + return api.get('', params);
  61 +};
  62 +
  63 +const relateMobile = (openId, sourceType, mobile, area) => {
  64 + return api.get('', {
  65 + method: 'app.passport.relatedMobile',
  66 + mobile: mobile,
  67 + openId: openId,
  68 + source_type: sourceType,
  69 + area: area
  70 + });
  71 +};
  72 +
  73 +const changeCheck = (mobile, area) => {
  74 + return api.get('', {
  75 + method: 'app.passport.changeCheck',
  76 + mobile: mobile,
  77 + area: area
  78 + });
  79 +};
  80 +
  81 +const changeMobile = (uid, mobile, area, code) => {
  82 + return api.get('', {
  83 + method: 'app.passport.changeMobile',
  84 + mobile: mobile,
  85 + uid: uid,
  86 + code: code,
  87 + area: area
  88 + });
  89 +};
  90 +
  91 +module.exports = {
  92 + bindCheck,
  93 + sendBindMsg,
  94 + checkBindCode,
  95 + bindMobile,
  96 + relateMobile,
  97 + changeCheck,
  98 + changeMobile
  99 +};
@@ -7,81 +7,6 @@ @@ -7,81 +7,6 @@
7 7
8 'use strict'; 8 'use strict';
9 9
10 -const api = global.yoho.API; 10 +const api = require('./bind-api');
11 11
12 -const BindService = {  
13 - bindCheck(mobile, openId, sourceType, area) {  
14 - let params = {  
15 - method: 'app.passport.signCheck',  
16 - area: area,  
17 - mobile: mobile,  
18 - open_id: openId,  
19 - source_type: sourceType  
20 - };  
21 -  
22 - return api.get('', params);  
23 - },  
24 - sendBindMsg(area, mobile) {  
25 - let params = {  
26 - method: 'app.passport.smsbind',  
27 - mobile: mobile,  
28 - area: area  
29 - };  
30 -  
31 - return api.get('', params);  
32 - },  
33 - checkBindCode(area, mobile, code) {  
34 - return api.get('', {  
35 - method: 'app.register.validRegCode',  
36 - mobile: mobile,  
37 - area: area,  
38 - code: code  
39 - });  
40 - },  
41 - bindMobile(openId, sourceType, mobile, area, password, nickname) {  
42 - let params = {  
43 - method: 'app.passport.bind',  
44 - mobile: mobile,  
45 - open_id: openId,  
46 - source_type: sourceType,  
47 - area: area  
48 - };  
49 -  
50 - if (password) {  
51 - params.password = password;  
52 - }  
53 -  
54 - if (nickname) {  
55 - params.nickname = nickname;  
56 - }  
57 -  
58 - return api.get('', params);  
59 - },  
60 - relateMobile(openId, sourceType, mobile, area) {  
61 - return api.get('', {  
62 - method: 'app.passport.relatedMobile',  
63 - mobile: mobile,  
64 - openId: openId,  
65 - source_type: sourceType,  
66 - area: area  
67 - });  
68 - },  
69 - changeCheck(mobile, area) {  
70 - return api.get('', {  
71 - method: 'app.passport.changeCheck',  
72 - mobile: mobile,  
73 - area: area  
74 - });  
75 - },  
76 - changeMobile(uid, mobile, area, code) {  
77 - return api.get('', {  
78 - method: 'app.passport.changeMobile',  
79 - mobile: mobile,  
80 - uid: uid,  
81 - code: code,  
82 - area: area  
83 - });  
84 - }  
85 -};  
86 -  
87 -module.exports = BindService; 12 +module.exports = api;
  1 +/**
  2 + * Created by TaoHuang on 2016/10/21.
  3 + */
  4 +
  5 +/**
  6 + * 注册 model
  7 + */
  8 +'use strict';
  9 +const aes = require('./aes-pwd');
  10 +const api = global.yoho.API;
  11 +
  12 +let sendCodeToMobile = (area, mobile) => {
  13 + let params = {
  14 + method: 'app.register.sendRegCodeToMobile',
  15 + area: area,
  16 + mobile: mobile
  17 + };
  18 +
  19 + return api.post('', params);
  20 +};
  21 +
  22 +let validMobileCode = (area, mobile, code) => {
  23 + let params = {
  24 + method: 'app.register.validRegCode',
  25 + area: area,
  26 + mobile: mobile,
  27 + code: code
  28 + };
  29 +
  30 + return api.post('', params);
  31 +};
  32 +
  33 +let regMobile = (area, mobile, password, shoppingKey)=> {
  34 + let params = {
  35 + method: 'app.passport.register',
  36 + area: area,
  37 + profile: mobile,
  38 + password: password
  39 + };
  40 +
  41 + if (shoppingKey) {
  42 + params.shopping_key = shoppingKey;
  43 + }
  44 +
  45 + return api.post('', params);
  46 +};
  47 +
  48 +let regMobileAes = (area, mobile, password, shoppingKey)=> {
  49 + let params = {
  50 + method: 'app.passport.registerAES',
  51 + area: area,
  52 + profile: mobile,
  53 + password: aes.aesPwd(password)
  54 + };
  55 +
  56 + if (shoppingKey) {
  57 + params.shopping_key = shoppingKey;
  58 + }
  59 +
  60 + return api.post('', params);
  61 +};
  62 +
  63 +module.exports = {
  64 + sendCodeToMobile,
  65 + validMobileCode,
  66 + regMobile,
  67 + regMobileAes
  68 +};
@@ -3,69 +3,14 @@ @@ -3,69 +3,14 @@
3 */ 3 */
4 'use strict'; 4 'use strict';
5 const passportHelper = require('./passport-helper'); 5 const passportHelper = require('./passport-helper');
6 -const aes = require('./aes-pwd'); 6 +const api = require('./reg-api');
  7 +
7 const REGISTER_LEFT_BANNER_CODE = 'c479ec90120cae7f96e52922b4917064'; // 注册左边的banner 8 const REGISTER_LEFT_BANNER_CODE = 'c479ec90120cae7f96e52922b4917064'; // 注册左边的banner
8 -const api = global.yoho.API;  
9 9
10 let getRegData = () => { 10 let getRegData = () => {
11 return passportHelper.getLeftBannerAsync(REGISTER_LEFT_BANNER_CODE); 11 return passportHelper.getLeftBannerAsync(REGISTER_LEFT_BANNER_CODE);
12 }; 12 };
13 13
14 -let sendCodeToMobile = (area, mobile) => {  
15 - let params = {  
16 - method: 'app.register.sendRegCodeToMobile',  
17 - area: area,  
18 - mobile: mobile  
19 - };  
20 -  
21 - return api.post('', params);  
22 -};  
23 -  
24 -let validMobileCode = (area, mobile, code) => {  
25 - let params = {  
26 - method: 'app.register.validRegCode',  
27 - area: area,  
28 - mobile: mobile,  
29 - code: code  
30 - };  
31 -  
32 - return api.post('', params);  
33 -};  
34 -  
35 -let regMobile = (area, mobile, password, shoppingKey)=> {  
36 - let params = {  
37 - method: 'app.passport.register',  
38 - area: area,  
39 - profile: mobile,  
40 - password: password  
41 - };  
42 -  
43 - if (shoppingKey) {  
44 - params.shopping_key = shoppingKey;  
45 - }  
46 -  
47 - return api.post('', params);  
48 -};  
49 -  
50 -let regMobileAes = (area, mobile, password, shoppingKey)=> {  
51 - let params = {  
52 - method: 'app.passport.registerAES',  
53 - area: area,  
54 - profile: mobile,  
55 - password: aes.aesPwd(password)  
56 - };  
57 -  
58 - if (shoppingKey) {  
59 - params.shopping_key = shoppingKey;  
60 - }  
61 -  
62 - return api.post('', params);  
63 -};  
64 -  
65 -module.exports = {  
66 - getRegData,  
67 - sendCodeToMobile,  
68 - validMobileCode,  
69 - regMobile,  
70 - regMobileAes  
71 -}; 14 +module.exports = Object.assign(api, {
  15 + getRegData
  16 +});