Repository navigation
Expand file tree
/
Copy pathpostbook.html
More file actions
165 lines (158 loc) · 6.57 KB
/
Copy pathpostbook.html
File metadata and controls
165 lines (158 loc) · 6.57 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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>我要发布</title>
<!-- <link href="style/reset.css" type="text/css" rel="stylesheet"> -->
<link rel="stylesheet" type="text/css" href="style/otherhtm.css">
</head>
<body>
<a href="index.html"><img src="images/gohome.png" style="z-index: 9999px;margin-top: 25px;margin-left: 10px; position: absolute;padding-left:23px;"> </a><a href="index.html" style="position: absolute;left: 76px;top: 30px;text-decoration: none;font-size: 18px;">返回首页</a>
<div id="post">
<div>
<div id="titleText">
<h2>发布卖书信息</h2>
</div>
</div>
<form action="" method="POST" id="upform">
<!-- 后续我准备把表格布局改成CSS布局 -->
<table>
<tr>
<td>
<div id="isbnText"><span>ISBN:</span></div>
</td>
<td>
<input type="text" name="b_isbn" id="findISBN" value="" placeholder="例如:9787121242533" required="required">
</td>
<input type="button" value="联网查询图书信息" onclick="find_isbn1()" style="margin-left: 540px;margin-top: 15px;position: absolute;z-index: 9999;border-radius: 5px;">
</tr>
<tr>
<td><span>书籍名称:</span></td>
<td>
<input type="text" name="b_name" id="b_name"> </td>
</tr>
<tr>
<td><span>作者:</span></td>
<td>
<input type="text" name="b_author" id="b_author"> </td>
</tr>
<tr>
<td><span>出版社:</span></td>
<td>
<input type="text" name="b_press" id="b_press"> </td>
</tr>
<tr>
<td><span>原价参考:</span></td>
<td>
<input type="text" id="price">
</td>
</tr>
<tr>
<td><span>出售单价:</span></td>
<td>
<input type="text" name="b_price" id="b_price" placeholder="请输入出售价格,免费赠送请输入0">
</td>
</tr>
<tr>
<td><span>出售数量:</span></td>
<td>
<input type="text" name="b_quantity" placeholder="请输入出售数量">
</td>
</tr>
<tr>
<td><span>封面链接:</span></td>
<td>
<input type="text" name="pic_url" id="pic_url" oninput="get_imag()" placeholder="查询不到时可选择文件自动获取图片链接">
</td>
</tr>
<tr>
<td>
</td>
<td>
<img src="" id="image">
</table>
<tr>
<td>
<input type="button" value="发布图书" id="submitbtn" onclick="submit_book()">
</td>
</tr>
</form>
<div id="" style="position: relative;width: 400px;top: -65px;left: 240px;">
<form method="post" action="" enctype="multipart/form-data" id="upload_my_img">
<input type="file" id="files" name="smfile" accept="image/gif,image/jpeg,image/jpg,image/png,image/svg" style="border:none;color: lightsteelblue;margin-left:5px; padding: 0;width: 170px;word-break: normal;float: left;list-style-type: none;">
<input type="button" value="确定上传图片" onclick="uploadimag()" style="color: lightsteelblue;width: 115px;height: 24px;background-color:rgb(235, 235, 235);color: #000; float: left;text-align: center;margin: 2px; padding: 3px 3px;border-radius: 2px;border:0.8px rgb(160, 145, 150) solid" />
</form>
</div>
</div>
<script src="script/jquery.min.js"></script>
<script src="layer/layer.js"></script>
<script type="text/javascript" src="script/index.js"></script>
<script type="text/javascript">
function get_imag() {
var pic = String($("#pic_url").val());
console.log(pic);
$("#image").attr("src", pic);
}
function submit_book() {
var formData = new FormData($('#upform')[0]);
$.ajax({
url: "postbook.php",
type: 'POST',
data: formData,
// 告诉jQuery不要去处理发送的数据
processData: false,
// 告诉jQuery不要去设置Content-Type请求头
contentType: false,
beforeSend: function() {
$("#logintips").html("正在进行,请稍候...");
},
success: function(responseStr) {
if (responseStr == 1) {
layer.alert("发布成功")
} else {
console.log(responseStr);
layer.alert("发布失败");
}
},
error: function(responseStr) {
layer.alert("系统出错");
}
});
}
function uploadimag() {
var formData = new FormData($('#upload_my_img'));
$.ajax({
url: "https://sm.ms/api/upload",
type: 'POST',
data: formData,
// 告诉jQuery不要去处理发送的数据
processData: false,
// 告诉jQuery不要去设置Content-Type请求头
contentType: false,
datatype: "json",
success: function(rs) {
if (rs.code != "error") {
$('#pic_url').val(rs.data.url);
$("#image").src = rs.data.url;
} else {
layer.alert(rs.msg);
}
}
});
}
function find_isbn1() {
var isbn = $("#findISBN").val();
$.ajax({
type: 'get',
url: "https://api.douban.com/v2/book/isbn/:" + isbn,
dataType: 'jsonp',
success: function(rs) {
if (rs != 0) {
dealISBN(rs);
} else layer.alert("查无此书!");
}
});
}
</script>
</body>
</html>