-
Notifications
You must be signed in to change notification settings - Fork 0
/
personal_info.html
190 lines (177 loc) · 5.49 KB
/
personal_info.html
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Hello MUI</title>
<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<!--标准mui.css-->
<link rel="stylesheet" href="css/mui.min.css">
<link rel="stylesheet" type="text/css" href="css/icons-extra.css" />
<!--App自定义的css-->
<link rel="stylesheet" type="text/css" href="css/app.css" />
<link rel="stylesheet" type="text/css" href="css/loaders.min.css" />
<link rel="stylesheet" type="text/css" href="css/loading.css" />
<script src="js/jquery.min.js" type="text/javascript"></script>
<script src="js/config.js" type="text/javascript"></script>
<script src="js/loading.animation.js" type="text/javascript"></script>
<style>
.mui-icon-clear {
margin-top: 8px;
}
</style>
</head>
<body>
<header class="mui-bar mui-bar-nav">
<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
<h1 class="mui-title">个人信息</h1>
</header>
<div class="mui-content">
<div class="mui-content-padded">
<ul class="mui-table-view mui-table-view-chevron">
<li class="mui-table-view-cell mui-media">
<a id="uploadUserimg" class="mui-navigate-right">
<img id="userimg" class="mui-media-object mui-pull-left" src="images/portrait.jpg">
<div class="mui-media-body" style="margin-left: 21%;">
<p style="font-size: 15px; margin-top: 5.5%; color: #6D6D72;">
我的头像
</p>
</div>
</a>
</li>
</ul>
</div>
<div class="mui-content-padded" style="margin: 23px 10px 0px;">
<form class="mui-input-group">
<div class="mui-input-row" style="height: 50px; padding: 8px;">
<label>手机号</label>
<input id="phone" type="text" class="mui-input-clear" placeholder="手机号是关键信息呦">
</div>
<div class="mui-input-row" style="height: 50px; padding: 8px;">
<label>昵称</label>
<input id="nickname" type="text" class="mui-input-clear" placeholder="昵称会展示在动态中呦">
</div>
<div class="mui-input-row" style="height: 50px; padding: 8px;">
<label>姓名</label>
<input id="username" type="text" class="mui-input-clear" placeholder="最好输入真实姓名,亲">
</div>
</form>
</div>
<div class="mui-content-padded" style="margin: 23px 10px 0px;">
<center>
<button id="modify" type="button" class="mui-btn mui-btn-primary mui-btn-outlined" data-loading-text="修改中" data-loading-icon-position="right" style="font-size: 15px; width: 150px;">
<span style=" padding-right: 2px;">修改信息</span>
<span class="mui-icon mui-icon-compose"></span>
</button>
</center>
</div>
</div>
</body>
<script src="js/mui.min.js"></script>
<script>
mui.init({
swipeBack: true //启用右滑关闭功能
});
$(function() {
jqxhr=$.ajax({
type: "post",
dataType: "json",
url:PREPATH + "/user/selectUserByUID",
xhrFields: {
withCredentials: true
},
headers:{
"X-Requested-With":"XMLHttpRequest"
},
crossDomain: true,
success: function(data) {
if(data.userimg !== null && data.userimg !== "") {
$("#userimg").attr("src", IMGPATH + data.userimg);
}
if(data.tel !== null && data.tel !== "") {
$("#phone").val(data.tel);
}
if(data.nickname !== null && data.nickname !== "") {
$("#nickname").val(data.nickname);
}
if(data.username !== null && data.username !== "") {
$("#username").val(data.username);
}
},
error: function() {
mui.toast("信息获取失败");
}
});
})
//验证手机号(返回:true/false)
var telReg = /^((1[3,8][0-9])|(15[012356789])|(14[5,7,9])|(17[0,1,3,5,6,7,8]))\d{8}$/;
function checkTel(tel) {
if(tel !== null && tel !== "") {
if(telReg.test(tel)) {
return true;
} else {
mui.toast("请核对手机号");
return false;
}
} else {
mui.toast("请输入手机号");
return false;
}
}
$('#modify').click(function() {
var tel = $("#phone").val();
var nickname = $("#nickname").val();
var username = $("#username").val();
if(!checkTel(tel)) {
return;
}
if(nickname === null || nickname === "") {
mui.toast("请输入昵称");
return;
}
if(username === null) {
username = "";
}
jqxhr =$.ajax( {
type: "post",
data: {
tel: tel,
nickname: nickname,
username: username
},
url:PREPATH + "/user/updateUser",
dataType: "json",
xhrFields: {
withCredentials: true
},
headers:{
"X-Requested-With":"XMLHttpRequest"
},
crossDomain: true,
beforeSend: function() {
mui($("#modify")).button('loading');
},
success: function(data) {
mui($("#modify")).button('reset');
mui.toast("修改成功");
if(data.state === 1) {
mui.openWindow({
url: 'my_own.html'
});
} else {
mui.toast("修改失败");
}
},
error: function() {
mui.toast("修改失败");
}
});
})
$("#uploadUserimg").click(function() {
mui.openWindow({
url: 'upload_userimg.html',
});
})
</script>
</html>