-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdateproduct.html
179 lines (173 loc) · 6.03 KB
/
updateproduct.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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>添加商品</title>
<link href="css/mui.min.css" rel="stylesheet" />
<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">
<link rel="stylesheet" href="css/mui.min.css">
<!--App自定义的css-->
<link rel="stylesheet" type="text/css" href="css/app.css"/>
<link rel="stylesheet" type="text/css" href="css/iconfont.css"/>
<script type="text/javascript" src="js/jquery-3.2.1.min.js"></script>
<script src="js/mui.min.js"></script>
<script src="js/tool.js"></script>
<script src="js/app.js"></script>
<style>
#reg{
height:50px;
background-color:#0099FF;
}
input{
width:100%;
}
</style>
<script>
var userid = GetUseridCookie().get("userid");
if(userid==undefined){
alert("登录过期,请重新登录!");
javascript:window.location.href="login.html"
}
window.onload = function(){
mui.ajax('http://'+url+'/jizhibackend/servlet/GetStudentClassServlet',{
data:
{
userid:userid,
},
xhrFields: {
withCredentials: true
},
crossDomain: true,
dataType: 'json', //服务器返回json格式数据
type: 'post', //HTTP请求类型
timeout: 10000, //超时时间设置为10秒;
headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' },
success: function(data) {
data1=data.classes;
// alert(data1.length);
jQuery.each(data1,function(index,item){
document.getElementById('class').options.add(new Option(item.name,item.id));
});
},
error: function(xhr, type, errorThrown) {
console.log(errorThrown);
}
});
}
</script>
</head>
<body>
<header class="mui-bar mui-bar-nav">
<a class=" mui-icon mui-icon-left-nav mui-pull-left" href="t_shop.html"></a>
<h1 class="mui-title">添加商品</h1>
</header>
<div class="mui-content">
<form>
<p></p>
<p><strong> 名字</strong></p>
<p>
<input id="name" >
</p>
<p></p>
<p><strong> 所需兑换积分</strong></p>
<p>
<input id="price" name="price">
</p>
<p></p>
<p><strong> 总共数量</strong></p>
<p>
<input id="number" name="number">
</p>
<p></p>
<p><strong> 选择添加的班级</strong></p>
<p>
<select id="class">
<option></option>
</select>
</p>
</form>
</div>
<div class="mui-content-padded">
<button id='reg' class="mui-btn mui-btn-block mui-btn-primary">完成</button>
</div>
</body>
<script>
mui('body').on('tap','a',function(){document.location.href=this.href;});
function select()
{
document.getElementById('file').click();
}
function preview(file){
var prevDiv = document.getElementById('pre');
if (file.files && file.files[0]){
var reader = new FileReader();
reader.onload = function(evt){
// prevDiv.innerHTML = '<img width="100%" height="100%" id="qw_img" src="' + evt.target.result + '" />';
$('.preview').attr('src' , evt.target.result);
}
reader.readAsDataURL(file.files[0]);
}else{
// prevDiv.innerHTML = '<div class="img" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale,src=\'' + file.value + '\'"></div>';
$('.preview').attr('src' , file.value);
}
}
var userid = GetUseridCookie().get("userid");
var btnlogin=document.getElementById("reg");
btnlogin.onclick = function() {
var classid= document.getElementById('class').value;
// var fname=document.getElementById("file").files[0];
// var formData = new FormData();
//// formData.append("classid",classid);
// formData.append("file",fname);
// var xhr = new XMLHttpRequest();
// xhr.open("post", 'http://'+url+'/jizhibackend/servlet/Uploadimg', true);
// xhr.onload = function () {
// alert(xhr.responseText);
// };
// xhr.send(formData);
var prices=document.getElementById('price');
var numbers=document.getElementById('number');
var giftid=UrlParm.parm('giftid');
mui.ajax('http://'+url+'/jizhibackend/servlet/UpdateGiftServlet',{
data:
{
userid:userid,
giftid:giftid,
numbers:numbers.value,
price:prices.value,
name:document.getElementById('name').value,
},
xhrFields: {
withCredentials: true
},
crossDomain: true,
dataType: 'json', //服务器返回json格式数据
type: 'post', //HTTP请求类型
timeout: 10000, //超时时间设置为10秒;
headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' },
success: function(data) {
if(data.errcode==100)
{
mui.toast("修改商品成功!");
javascript:window.location.href="shop.html?userid="+userid;
}
else if(data.errcode==102)
{
mui.toast("修改商品失败!");
}
else if(data.errcode==101)
{
mui.toast("没有权限!");
}
},
error: function(xhr, type, errorThrown) {
console.log(errorThrown);
console.log(type);
console.log(xhr);
}
});
}
</script>
</html>