save.js
4.7 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
$(document).ready(function() {
// var header = {
// "Content-Type": "application/x-www-form-urlencoded",
// "token": localStorage.getItem('token'),
// }
// ajax("/login/userInfo", "GET", header, function(res) {
// console.log(res);
// alert('保存成功!')
// window.location.href = 'index.html'
// }, function(res) {
// console.log(res);
// })
});
//获取用户VIP信息判断是否是VIP
function setPersonal() {
alert('请完善个人信息!')
}
$(".btnSave").click(function() {
//姓
var inputSurname = $("#surname").val();
console.log(inputSurname);
//名
var inputUserName = $("#userName").val();
console.log(inputUserName);
//专业(null)
var inputSpecialty = $("#specialty").val();
console.log(inputSpecialty);
//学校
var inputSchool = $("#school").val();
console.log(inputSchool);
//手机号
var inputPhone = $("#phone").val();
console.log(inputPhone);
//邮箱
var inputEmailAddress = $("#emailAddress").val();
console.log(inputEmailAddress);
var reg_phone = /^1[3|4|5|6|7|8][0-9]\d{8}$/;
if (inputSurname.length === 0) {
alert("姓氏不能为空!")
} else if (inputUserName.length === 0) {
alert("名字不能为空!")
} else if (inputSchool.length === 0) {
alert("学校不能为空!")
} else if (inputPhone.length === 0) {
alert("手机号码不能为空!")
} else if (!reg_phone.test(inputPhone)) {
alert("请填写正确的手机号");
return false;
} else if (inputEmailAddress.length === 0) {
alert("邮箱不能为空!")
} else if (/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/.test(inputEmailAddress) == false) {
alert("邮箱格式不正确,请重新填写!")
} else {
var url = "/login/updateSysUser";
var header = {
"Content-Type": "application/json",
"token": localStorage.getItem('token'),
}
var params = JSON.stringify({
emailAddress: inputEmailAddress,
// id: localStorage.getItem("userId"),
img: null,
phone: inputPhone,
specialty: inputSpecialty,
school: inputSchool,
surname: inputSurname,
userName: inputUserName
})
ajax(url, "PUT", header, params, function(res) {
console.log(res);
alert('保存成功!')
window.location.href = 'index.html'
}, function(res) {
console.log(res);
})
}
})
$(".btnSave1").click(function() {
token = localStorage.getItem('token')
console.log(token);
//姓
var inputSurname = $("#surname1").val();
console.log(inputSurname);
//名
var inputUserName = $("#userName1").val();
console.log(inputUserName);
//专业(null)
var inputSpecialty = $("#specialty1").val();
console.log(inputSpecialty);
//学校
var inputSchool = $("#school1").val();
console.log(inputSchool);
//手机号
var inputPhone = $("#phone1").val();
console.log(inputPhone);
//邮箱
var inputEmailAddress = $("#emailAddress1").val();
console.log(inputEmailAddress);
var reg_phone = /^1[3|4|5|6|7|8][0-9]\d{8}$/;
if (inputSurname.length === 0) {
alert("姓氏不能为空!")
} else if (inputUserName.length === 0) {
alert("名字不能为空!")
} else if (inputSchool.length === 0) {
alert("学校不能为空!")
} else if (inputPhone.length === 0) {
alert("手机号码不能为空!")
} else if (!reg_phone.test(inputPhone)) {
alert("请填写正确的手机号");
return false;
} else if (inputEmailAddress.length === 0) {
alert("邮箱不能为空!")
} else if (/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/.test(inputEmailAddress) == false) {
alert("邮箱格式不正确,请重新填写!")
} else {
var url = "/login/updateSysUser";
var header = {
"Content-Type": "application/json",
"token": localStorage.getItem('token'),
}
var params = JSON.stringify({
emailAddress: inputEmailAddress,
// id: localStorage.getItem("userId"),
img: null,
phone: inputPhone,
specialty: inputSpecialty,
school: inputSchool,
surname: inputSurname,
userName: inputUserName
})
ajax(url, "PUT", header, params, function(res) {
console.log(res);
alert('保存成功!')
window.location.href = 'index.html'
}, function(res) {
console.log(res);
})
}
})