contact.js
11.5 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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
// get code
console.log(111)
window.downHttpContact = 'https://ieva.lianxinzhiping.com'//'https://ieva.lianxinzhiping.com';
function draw() {
$('#code1 img').attr('src', window.location.origin + '/api' + "/web/businessUser/getKaptchaImage")
}
//切换验证码
$('#code1').on('click', function () {
draw()
})
//删除名片
$(".img_box1").on("click", "#deleImg1", function () {
var textHtml = '<img src="img/addCard.png" alt=""><input type="file" value="上传文件" id="upload1" class="uploader-file" accept="image/*" onchange="getImgURL1(this)">';
$(".img_box1").html(textHtml);
})
//验证码倒计时
var interval1;
var c1=60
function timeDown1(id) {
$("#" + id).attr("disabled", "disabled"); //点击一次不可再点
interval1 = setInterval(function () { //定义定时器
$("#" + id).val(c1 + "s之后重试");
c1--;
if (c1 == 0) {
clearInterval(interval1); //清除定时器
$("#" + id).val("重新获取验证码");
$("#" + id).removeAttr("disabled"); //删除这个属性
c1 = 60;
}
}, 1000);
}
//申请账号获取验证码
$("#getCode1").on('click', function () {
console.log($("#setTel1").val())
if ($("#setTel1").val() == '') {
$("#register1 .jiaoyan").text('手机号码不能为空')
return false
}
if (!(/^1[3456789]\d{9}$/.test($("#setTel1").val()))) {
$("#register1 .jiaoyan").text('请输入正确的手机号')
return false
}
console.log($("#register1 .jiaoyan").text())
var obj = {
phone: $("#setTel1").val(),
type: 3 //1
}
$.ajax({
url: window.downHttpContact + '/api' + "/web/register/sendSms",
data: obj,
type: "POST",
dataType: "json",
success: function (res) {
if (res.code == 2000) {
$("#register1 .jiaoyan").text('')
timeDown1('getCode1')
} else {
$("#register1 .jiaoyan").text(res.msg)
}
}
});
})
//申请账号下一步
$("#applyNext1").on('click', function () {
if ($("#setTel1").val() == '') {
$("#register1 .jiaoyan").text('手机号码不能为空')
return false
}
if (!/^1[0-9]{10}$/.test($("#setTel1").val())) {
$("#register1 .jiaoyan").text('请输入正确的手机号')
return false
}
if ($("#setCode1").val() == '') {
$("#register1 .jiaoyan").text('验证码不能为空')
return false
}
if ($("#setName1").val() == '') {
$("#register1 .jiaoyan").text('姓名不能为空')
return false
}
if ($("#setEmail1").val() == '') {
$("#register1 .jiaoyan").text('邮箱不能为空')
return false
}
if (!/^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/.test($("#setEmail1").val())) {
$("#register1 .jiaoyan").text('请输入正确的邮箱')
return false
}
if ($("#setCompany1").val() == '') {
$("#register1 .jiaoyan").text('公司名称不能为空')
return false
}
if ($("#setPost1").val() == '') {
$("#register1 .jiaoyan").text('职务不能为空')
return false
}
if ($("#cardImg1").data('url') == "" || $("#cardImg1").data('url') == undefined) {
$("#register1 .jiaoyan").text('名片不能为空')
return false
}
apply1()
})
// 获取地址栏参数
function GetRequest1() {
var url = location.search; //获取url中"?"符后的字串
var theRequest = new Object();
if (url.indexOf("?") != -1) {
var str = url.substr(1);
strs = str.split("?");
console.log(strs)
for (var i = 0; i < strs.length; i++) {
theRequest[strs[i].split("=")[0]] = decodeURIComponent(strs[i].split("=")[1]);
}
}
return theRequest;
}
function apply1() {
var a = GetRequest1();
var userSource = a['userSource'];
let applyForm = {
city: $("#setCity1").val(),
code: $("#setCode1").val(),
companyName: $("#setCompany1").val(),
dept: $("#setDpartment1").val(),
email: $("#setEmail1").val(),
job: $("#setPost1").val(),
phone: $("#setTel1").val(),
qq: "",
userName: $("#setName1").val(),
wx: "",
remark: $("#setMessage1").val(),
// password:$("#intoPassword").val(),
cardPath: $("#cardImg1").data('url'),
userSource: "gw"
}
$.ajax({
url: window.downHttpContact + '/api' + "/web/userApplyAccount/UserApplyRegister",
data: applyForm,
type: "POST",
dataType: "json",
success: function (res) {
if (res.code == 2000) {
$("#register1 .jiaoyan").text('');
var textHtml = '<img src="img/addCard.png" alt=""><input type="file" value="上传文件" id="upload1" class="uploader-file" accept="image/*" onchange="getImgURL1(this)">';
$(".img_box1").html(textHtml);
// $("#zhanghao").text('您的账号为:'+res.data)
// $('#setPassword').hide()
$("#setTel1").val('')
$("#setCode1").val('')
$("#setName1").val('')
$("#setEmail1").val('')
$("#setCompany1").val('')
$("#setDpartment1").val('')
$("#setPost1").val('')
$("#setCity1").val('')
$("#setMessage1").val('')
$('#black').show()
$('#registerSuccess').show()
closeSuccese1();
} else {
$("#register1 .jiaoyan").text(res.msg)
}
}
});
}
//申请账号取消
$("#applyCancle1").on('click', function () {
$("#register1 .jiaoyan").text('')
var textHtml = '<img src="img/addCard.png" alt=""><input type="file" value="上传文件" id="upload1" class="uploader-file" accept="image/*" onchange="getImgURL1(this)">';
$(".img_box1").html(textHtml);
// $("#zhanghao").text('您的账号为:'+res.data)
// $('#setPassword').hide()
$("#setTel1").val('')
$("#setCode1").val('')
$("#setName1").val('')
$("#setEmail1").val('')
$("#setCompany1").val('')
$("#setDpartment1").val('')
$("#setPost1").val('')
$("#setCity1").val('')
$("#setMessage1").val('')
})
//申请成功关闭
$("#successClose").on('click', function () {
setTimeout(function () {
$('#black').hide()
$('#registerSuccess').hide()
clearInterval(interval1); //清除定时器
$("#getCode1").val("重新获取验证码");
$("#getCode1").removeAttr("disabled"); //删除这个属性
c1 = 60;
}, 1000)
})
function kp1(txt, len) {
var v = txt.value;
console.log('v',v)
if (len == 12) {
var reg = /^[a-zA-Z\d`~@#\$%\^&\*\(\)\-_=\+\[\]\{\}\\\|;\:'",<\.>\/\?]{0,12}$/;
} else if (len == 20) {
var reg = /^[a-zA-Z\d`~@#\$%\^&\*\(\)\-_=\+\[\]\{\}\\\|;\:'",<\.>\/\?]{0,20}$/;
} else if (len == 40) {
var reg = /^[a-zA-Z\d`~@#\$%\^&\*\(\)\-_=\+\[\]\{\}\\\|;\:'",<\.>\/\?]{0,40}$/;
} else if (len == 200) {
var reg = /^[a-zA-Z\d`~@#\$%\^&\*\(\)\-_=\+\[\]\{\}\\\|;\:'",<\.>\/\?]{0,200}$/;
}
var vv = v.replace(/[^\x00-\xff]/g, "aa");
if (!reg.test(vv)) {
txt.value = txt.pv ? txt.pv : "";
} else {
txt.pv = v;
}
}
function closeSuccese1() {
var count = 3;
$("#setPassword .jiaoyan").text('')
$('#registerSuccess').show()
var intervalBox = setInterval(() => {
count--
$("#registerSuccess .one").text('申请信息提交成功,请耐心等待' + " " + count)
$('#setPassword').hide()
if (count == 0) {
clearInterval(intervalBox)
clearInterval(interval1); //清除定时器
$("#getCode1").val("重新获取验证码");
$("#getCode1").removeAttr("disabled"); //删除这个属性
c1 = 60;
$('#black').hide()
$('#registerSuccess').hide()
}
}, 1000);
}
//上传名片
function isAssetTypeAnImage1(ext) {
return [
'png', 'jpg', 'jpeg', 'bmp', 'gif', 'webp', 'psd', 'svg', 'tiff'
].
indexOf(ext.toLowerCase()) !== -1;
}
function getImgURL1(node) {
var imgURL = "";
try {
var file = null;
if (node.files && node.files[0]) {
file = node.files[0];
} else if (node.files && node.files.item(0)) {
file = node.files.item(0);
}
//Firefox 因安全性问题已无法直接通过input[file].value 获取完整的文件路径
try {
//Firefox7.0
imgURL = file.getAsDataURL();
//alert("//Firefox7.0"+imgRUL);
} catch (e) {
//Firefox8.0以上
imgRUL = window.URL.createObjectURL(file);
//alert("//Firefox8.0以上"+imgRUL);
}
} catch (e) { //这里不知道怎么处理了,如果是遨游的话会报这个异常
//支持html5的浏览器,比如高版本的firefox、chrome、ie10
if (node.files && node.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
imgURL = e.target.result;
};
reader.readAsDataURL(node.files[0]);
}
}
console.log(node.files[0])
var index = node.files[0].name.lastIndexOf(".");
//获取后缀
var imgType = node.files[0].name.substr(index + 1);
if (!isAssetTypeAnImage1(imgType)) {
$("#register1 .jiaoyan").text('名片只能选择图片格式')
return false
}
if ($("#register1 .jiaoyan").text() == "名片只能选择图片格式") {
$("#register1 .jiaoyan").text("")
}
if (node.files[0].size >= 1024 * 1024 * 20) {
$("#register1 .jiaoyan").text('图片请限制在20M以内')
return false
} else {
if ($("#register1 .jiaoyan").text() == "图片请限制在20M以内") {
$("#register1 .jiaoyan").text("")
}
}
var obj = new FormData();
obj.append("file", node.files[0])
$.ajax({
url: window.downHttpContact + '/api' + '/web/oss/uploadFile',
type: 'post',
// dataType: 'json',
data: obj,
contentType: false,
processData: false
})
.done(res => {
if (res.code == "2000") {
window.fileUrl = res.data.rows[0].url;
var textHtml = "<div class='deleImg' id='deleImg1'>×</div> <img id='cardImg1' data-url='" + res.data.rows[0].url + "' src='" + res.data.rows[0].path + "'/>";
$(".img_box1").html(textHtml);
if ($("#register1 .jiaoyan").text() == '名片不能为空') {
$("#register1 .jiaoyan").text('');
}
} else {
$("#services1 .contact_error_box").text('上传失败,请重新上传')
}
})
.fail(res => {
$("#services1 .contact_error_box").text('上传失败,请重新上传')
});
// return imgURL;
}
function creatImg(imgRUL) { //根据指定URL创建一个Img对象
var textHtml = "<img src='" + imgRUL + "'/>";
$(".img_box1").html(textHtml);
}