thirdlogin.js
3.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/**
* 登录
* @author: wq
* @date: 2016/1/21
*/
var $ = require('yoho.jquery');
function chooseProtocol() {
$('.choosetag').on('change', function() {
if ($(this).attr('checked')) {
$('.choosewrapper').css({
'background-image': 'url("http://webstatic.dev.yohobuy.com/img/passport/choosed.png")'
});
} else {
$('.choosewrapper').css({
'background-image': 'none'
});
}
});
}
function chooseAreaToogle() {
$('.optionshow').on('click', function() {
$('.optionslist').toggleClass('hide');
});
}
function cancelChooseArea() {
$(document).on('click', 'body', function(e) {
var $target = $(e.target);
if ($target.hasClass('yohoselectarea') ||
$target.hasClass('yohoselectarea') ||
$target.hasClass('areaname') ||
$target.hasClass('righttag') ||
$target.hasClass('optionslist') ||
$target.hasClass('optionitem')) {
return;
} else {
$('.optionslist').addClass('hide');
}
});
}
function chooseArea() {
$('.optionitem').on('click', function() {
var $option = $(this);
var areanum = $option.attr('areanum');
var areaname = $option.text();
$('#areaname').text(areaname);
$('#areanum').text(areanum);
$('#areacode').val(areanum);
$('.optionslist').addClass('hide');
});
}
function isagree() {
return $('.choosetag').attr('checked');
}
function closeMask() {
var $target;
$(document).on('click', '#alreayregist', function(e) {
$target = $(e.target);
if ($target.hasClass('mask') || $target.hasClass('backdrop')) {
$('#alreayregist').hide();
}
})
}
function nextStep() {
var openId = '';
var sourceType = '';
var mobile = '';
var areaCode = '';
$('#bindfirststep').on('click', function(e) {
e.preventDefault();
mobile = $('.phonenum').val();
areaCode = $('.areanum').text();
if (mobile === '') {
alert('手机号码不能为空');
return;
}
if (!isagree()) {
alert('请先同意我们的协议');
return;
}
openId = $('#openId').val() || '29803EC6D4AAC3AAB8ABDB6AE829D579';
sourceType = $('#sourceType').val() || 'qq';
$.ajax({
type: 'post',
url: '/passport/autouserinfo/bindCheck',
data: {
mobile: mobile,
area: areaCode,
openId: openId,
sourceType: sourceType
},
dataType: 'json',
success: function(data) {
if (data.code === 200) {
if (data.data.isReg === 0) {
$('#bindmobileform').attr('action', '/passport/thirdlogin/noregist');
$('#bindmobileform').submit();
} else {
$('#alreayregist').show();
}
} else {
alert(data.message);
}
}
});
});
}
function init() {
chooseProtocol();
chooseArea();
chooseAreaToogle();
cancelChooseArea();
nextStep();
closeMask();
}
init();