Authored by 姜枫

add bind page

@@ -9,6 +9,7 @@ @@ -9,6 +9,7 @@
9 9
10 const helpers = require(global.library + '/helpers'); 10 const helpers = require(global.library + '/helpers');
11 const RegService = require('../models/reg-service'); 11 const RegService = require('../models/reg-service');
  12 +const BindService = require('../models/bind-service');
12 const _ = require('lodash'); 13 const _ = require('lodash');
13 14
14 const Sources = { 15 const Sources = {
@@ -32,7 +33,7 @@ const bind = { @@ -32,7 +33,7 @@ const bind = {
32 let sourceType = req.query.sourceType; 33 let sourceType = req.query.sourceType;
33 34
34 res.render('bind/index', { 35 res.render('bind/index', {
35 - bindIndex: true, //js标识 36 + bindIndex: true, // js标识
36 backUrl: helpers.urlFormat('/signin.html'), // 返回的URL链接 37 backUrl: helpers.urlFormat('/signin.html'), // 返回的URL链接
37 showHeaderImg: true, // 控制显示头部图片 38 showHeaderImg: true, // 控制显示头部图片
38 isPassportPage: true, // 模板中模块标识 39 isPassportPage: true, // 模板中模块标识
@@ -40,9 +41,9 @@ const bind = { @@ -40,9 +41,9 @@ const bind = {
40 platform: Sources[sourceType], 41 platform: Sources[sourceType],
41 isWechatLogin: sourceType === 'wechat', 42 isWechatLogin: sourceType === 'wechat',
42 openId: openId, // openId 43 openId: openId, // openId
43 - areaCode: '+86', //默认区号  
44 - countrys: RegService.getAreaData(), //国别码  
45 - serviceUrl: 'http://chat8.live800.com/live800/chatClient/chatbox.jsp?companyID=620092&configID=149091&jid=8732423409&info=', //在线客服 44 + areaCode: '+86', // 默认区号
  45 + countrys: RegService.getAreaData(), // 国别码
  46 + serviceUrl: 'http://chat8.live800.com/live800/chatClient/chatbox.jsp?companyID=620092&configID=149091&jid=8732423409&info=', // 在线客服
46 module: 'passport', 47 module: 'passport',
47 page: 'bind', 48 page: 'bind',
48 title: '绑定手机号' 49 title: '绑定手机号'
@@ -79,8 +80,37 @@ const bind = { @@ -79,8 +80,37 @@ const bind = {
79 let areaCode = req.body.areaCode || '86'; 80 let areaCode = req.body.areaCode || '86';
80 let sourceType = req.body.sourceType; 81 let sourceType = req.body.sourceType;
81 82
82 - if (!(_.isNumber(parseInt(phoneNum, 0)) && openId && areaCode && sourceType)) {  
83 - 83 + if (_.isNumber(parseInt(phoneNum, 0)) && openId && areaCode && sourceType) {
  84 + BindService.bindCheck(phoneNum, openId, sourceType, areaCode).then(result => {
  85 + let data = {
  86 + code: result.code,
  87 + message: result.message,
  88 + data: {}
  89 + };
  90 +
  91 + if (result.code === 200) {
  92 + let nextUrl = helpers.urlFormat('/passport/bind/code', {
  93 + isReg: res.data.is_register, // esline-disable-line
  94 + openId: openId,
  95 + sourceType: sourceType,
  96 + areaCode: areaCode,
  97 + phoneNum: phoneNum
  98 + });
  99 +
  100 + data.data.isReg = res.data.is_register;
  101 + data.data.next = nextUrl;
  102 + } else {
  103 + data.data = result.data;
  104 + }
  105 +
  106 + res.json(data);
  107 + });
  108 + } else {
  109 + res.json({
  110 + code: 400,
  111 + message: '',
  112 + data: ''
  113 + });
84 } 114 }
85 } 115 }
86 }; 116 };
@@ -12,7 +12,7 @@ const api = new API(); @@ -12,7 +12,7 @@ const api = new API();
12 12
13 class RegService { 13 class RegService {
14 14
15 - static bindCheck(mobile, openId, sourceType, area){ 15 + static bindCheck(mobile, openId, sourceType, area) {
16 let params = { 16 let params = {
17 method: 'app.passport.signCheck', 17 method: 'app.passport.signCheck',
18 area: area, 18 area: area,
@@ -8,7 +8,6 @@ @@ -8,7 +8,6 @@
8 'use strict'; 8 'use strict';
9 9
10 const API = require(`${global.library}/api`).API; 10 const API = require(`${global.library}/api`).API;
11 -const sign = require(`${global.library}/sign`);  
12 const api = new API(); 11 const api = new API();
13 12
14 class RegService { 13 class RegService {
@@ -73,7 +72,7 @@ class RegService { @@ -73,7 +72,7 @@ class RegService {
73 mobile: mobile 72 mobile: mobile
74 }; 73 };
75 74
76 - return api.post('', sign.apiSign(params)); 75 + return api.post('', params);
77 } 76 }
78 77
79 static validMobileCode(area, mobile, code) { 78 static validMobileCode(area, mobile, code) {
@@ -84,7 +83,7 @@ class RegService { @@ -84,7 +83,7 @@ class RegService {
84 code: code 83 code: code
85 }; 84 };
86 85
87 - return api.post('', sign.apiSign(params)); 86 + return api.post('', params);
88 } 87 }
89 88
90 static regMobile(area, mobile, password, shoppingKey) { 89 static regMobile(area, mobile, password, shoppingKey) {
@@ -99,7 +98,7 @@ class RegService { @@ -99,7 +98,7 @@ class RegService {
99 params.shopping_key = shoppingKey; // esline-disable-line 98 params.shopping_key = shoppingKey; // esline-disable-line
100 } 99 }
101 100
102 - return api.post('', sign.apiSign(params)); 101 + return api.post('', params);
103 } 102 }
104 } 103 }
105 104
@@ -15,6 +15,7 @@ module.exports = { @@ -15,6 +15,7 @@ module.exports = {
15 domains: { 15 domains: {
16 api: 'http://api.yoho.yohoops.org/', 16 api: 'http://api.yoho.yohoops.org/',
17 service: 'http://service.yoho.yohoops.org/' 17 service: 'http://service.yoho.yohoops.org/'
  18 +
18 // api: 'http://testapi.yoho.cn:28078/', 19 // api: 'http://testapi.yoho.cn:28078/',
19 // service: 'http://testservice.yoho.cn:28077/' 20 // service: 'http://testservice.yoho.cn:28077/'
20 }, 21 },
@@ -47,7 +47,7 @@ function nextStep(url, mobileNo, areaCode) { @@ -47,7 +47,7 @@ function nextStep(url, mobileNo, areaCode) {
47 // 统计代码:用于统计从哪个渠道登录 47 // 统计代码:用于统计从哪个渠道登录
48 if (window._yas && window._yas.sendCustomInfo) { 48 if (window._yas && window._yas.sendCustomInfo) {
49 window._yas.sendCustomInfo({ 49 window._yas.sendCustomInfo({
50 - 'loginRefer' : $sourceType.val() 50 + loginRefer: $sourceType.val()
51 }, false); 51 }, false);
52 } 52 }
53 53
@@ -106,14 +106,14 @@ $btnNext.on('touchstart', function() { @@ -106,14 +106,14 @@ $btnNext.on('touchstart', function() {
106 106
107 // console.log(res); 107 // console.log(res);
108 108
109 - //res : { 109 + // res : {
110 // code: 'xxx', 110 // code: 'xxx',
111 // data: { 111 // data: {
112 // isReg: 0, 112 // isReg: 0,
113 // next: 'xxxx' 113 // next: 'xxxx'
114 // }, 114 // },
115 // message: 'xxxx', 115 // message: 'xxxx',
116 - //} 116 + // }
117 117
118 118
119 if (res.code === 200) { 119 if (res.code === 200) {
@@ -34,27 +34,27 @@ function startBind(password) { @@ -34,27 +34,27 @@ function startBind(password) {
34 password: password, 34 password: password,
35 code: code 35 code: code
36 }, 36 },
37 - success: function(res) { 37 + success: function (res) {
38 if (res.code === 200) { 38 if (res.code === 200) {
39 tip.show('登录成功'); 39 tip.show('登录成功');
40 - setTimeout(function() { 40 + setTimeout(function () {
41 location.href = res.data.refer; 41 location.href = res.data.refer;
42 }, 2000); 42 }, 2000);
43 } else { 43 } else {
44 tip.show(res.message); 44 tip.show(res.message);
45 } 45 }
46 }, 46 },
47 - error: function(err) { 47 + error: function () {
48 tip.show('登录失败,请重试!'); 48 tip.show('登录失败,请重试!');
49 } 49 }
50 }); 50 });
51 } 51 }
52 52
53 api.bindEyesEvt({ 53 api.bindEyesEvt({
54 - status: 'open' //默认眼睛打开 54 + status: 'open' // 默认眼睛打开
55 }); 55 });
56 56
57 -$pwd.bind('input', function() { 57 +$pwd.bind('input', function () {
58 if (trim($pwd.val()) === '') { 58 if (trim($pwd.val()) === '') {
59 $btnSure.addClass('disable'); 59 $btnSure.addClass('disable');
60 } else { 60 } else {
@@ -62,7 +62,7 @@ $pwd.bind('input', function() { @@ -62,7 +62,7 @@ $pwd.bind('input', function() {
62 } 62 }
63 }); 63 });
64 64
65 -$btnSure.on('touchstart', function() { 65 +$btnSure.on('touchstart', function () {
66 var pwd = trim($pwd.val()); 66 var pwd = trim($pwd.val());
67 67
68 if ($btnSure.hasClass('disable')) { 68 if ($btnSure.hasClass('disable')) {