mydata.html
5.8 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
<title>我要问诊</title>
<script src="__TMPL__/public/assets/js/fontsize.js"></script>
<script src="__TMPL__/public/assets/js/jquery-2.1.0.js"></script>
<link rel="stylesheet" href="__TMPL__/public/assets/css/init.css">
<link rel="stylesheet" href="__TMPL__/public/assets/css/swiper-3.4.2.min.css">
<link rel="stylesheet" href="http://at.alicdn.com/t/font_793738_d49fodige36.css">
<link rel="stylesheet" href="__TMPL__/public/assets/css/weui.css">
<link rel="stylesheet" href="__TMPL__/public/assets/css/myweui.css">
<link rel="stylesheet" href="__TMPL__/public/assets/css/myData.css">
<link rel="stylesheet" href="__TMPL__/public/assets/css/comment.css">
</head>
<body style="background-color: #F5F6FA">
<div class="banner_box">
<div class="head_img">
<img class="" id="pic" src="{:cmf_get_image_url($user.avatar)}" onclick="chargeImg()">
<input id="upload" name="file" accept="image/*" type="file" style="display: none">
<div class="iconfont icon-zhaoxiangji" id="pic_mask" onclick="chargeImg()"></div>
</div>
</div>
<div class="content_box">
<div class="item_list">
<div class="list_title">姓名</div>
<div class="list_input"><input type="text" value="{$user.user_login}" placeholder="请填写姓名" id="user_name"></div>
</div>
<div class="item_list">
<div class="list_title">手机号</div>
<div class="list_input"><input type="text" value="{$user.mobile}" placeholder="请填写手机号" id="phone_num"></div>
</div>
<div class="item_list">
<div class="list_title">医院</div>
<div class="list_input"><input readonly type="text" placeholder="{$user.hospital}" id="hospital"></div>
</div>
<div class="item_list">
<div class="list_title">科室</div>
<div class="list_input"><input readonly type="text" placeholder="{$user.office}" id="department"></div>
</div>
</div>
<div class="bottom_btn">
<div class="edit_btn">修改</div>
</div>
<!--表单判断弹窗-->
<div class="form_popup_box">
<text></text>
</div>
</body>
<script>
//上传头像
function chargeImg() {
$("#upload").click(); //隐藏了input:file样式后,点击头像就可以本地上传
$("#upload").on("change", function () {
var objUrl = getObjectURL(this.files[0]); //获取图片的路径,该路径不是图片在本地的路径
if (objUrl) {
$("#pic").attr("src", objUrl); //将图片路径存入src中,显示出图片
$('#pic_mask').hide()
upimg();
}
});
}
//建立一?可存取到?file的url
function getObjectURL(file) {
var url = null;
if (window.createObjectURL != undefined) { // basic
url = window.createObjectURL(file);
} else if (window.URL != undefined) { // mozilla(firefox)
url = window.URL.createObjectURL(file);
} else if (window.webkitURL != undefined) { // webkit or chrome
url = window.webkitURL.createObjectURL(file);
}
return url;
}
//上传头像到服务器
function upimg() {
var pic = $('#upload')[0].files[0];
var file = new FormData();
file.append('image', pic);
$.ajax({
url: "{:url('uploadAvatar')}",
type: "post",
data: file,
cache: false,
contentType: false,
processData: false,
success: function (data) {
console.log(data);
var res = data;
$("#resimg").append("<img src='/" + res + "'>")
}
});
}
//form判断
$('.form_popup_box').hide()
$('.edit_btn').click(function () {
var user_name = $('#user_name').val()
var phone_num = $('#phone_num').val()
var hospital = $('#hospital').val()
var department = $('#department').val()
if (user_name == '') {
$('.form_popup_box').show()
$('.form_popup_box').text('姓名不能为空')
$('.form_popup_box').delay(1000).hide(0);
} else if (phone_num == '') {
$('.form_popup_box').show()
$('.form_popup_box').text('手机号不能为空')
$('.form_popup_box').delay(1000).hide(0);
} /*else if (hospital == '') {
$('.form_popup_box').show()
$('.form_popup_box').text('医院不能为空')
$('.form_popup_box').delay(1000).hide(0);
} else if (department == '') {
$('.form_popup_box').show()
$('.form_popup_box').text('科室不能为空')
$('.form_popup_box').delay(1000).hide(0);
} */ else {
$.ajax({
url:'{:url('editInfo')}',
type:'POST',
data:{
name:user_name,
mobile:phone_num,
},
success:function (res) {
if (res.code==1){
$('.form_popup_box').show()
$('.form_popup_box').text('修改成功!')
$('.form_popup_box').delay(1000).hide(0);
window.location.href='{:url('')}';
}else {
$('.form_popup_box').show()
$('.form_popup_box').text('修改失败!')
$('.form_popup_box').delay(1000).hide(0);
}
}
})
}
}
)
</script>
</html>