-
Notifications
You must be signed in to change notification settings - Fork 144
/
Copy pathadd.jade
106 lines (95 loc) · 4.13 KB
/
add.jade
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
!!! 5
html
head
include ./../head
title 前端乱炖-活动
link(href='#{assets_head}/css/Markdown.Editor.css', type='text/css', rel='stylesheet', charset='utf-8')
script(src='#{assets_head}/js/jquery.js')
body#act-add
- locals.pageId=5;
include ./../header
#content.clearfix
form(action="",method="post")
fieldset
label isbn(可以在<a href="http://book.douban.com/subject_search?search_text=%E6%90%9C%E7%B4%A2&cat=1001" target="_blank">豆瓣</a>查询)
input#isbn.input-xlarge(type="text",placeholder="输入isbn号码,可以自动填写书籍信息",name="isbn")
button.btn#isbn_to_info(type="button",style="margin-left:20px;vertical-align:top;") 查询
label 书名
input.input-xxlarge(type="text",placeholder="书名",name="title")
label 简介
textarea(placeholder="简介",name="desc")
label 封面图片
input(type="text",placeholder="自动填充,请等待",name="pic")
label 地址
input.input(type="text",placeholder="地址",name="url")
label 价格
input.input(type="text",placeholder="价格",name="price")
label 作者
input.input-xxlarge(type="text",placeholder="作者",name="author")
div
button.btn(type="submit") 提交
script(src='#{assets_head}/js/ajaxfileupload.js')
script(src='#{assets_head}/js/loadingTip.js')
script(src='#{assets_head}/js/messageTip.js')
script
$("#isbn_to_info").click(function(){
loadingTip.show("抓取中")
$.ajax({
url:"/book/isbn_to_info",
dataType:"json",
type:"get",
data:{
isbn:$("#isbn").val()
},
success:function(data){
if (data.success){
if (data.data.msg){
messageTip.show(data.data.msg)
}else{
book= data.data
if(book.images.large){
loadingTip.show("封面上传中")
$("#cover_status").html("封面正在上传中")
$.ajax({
url:"/online_to_local",
dataType:"json",
type:"post",
data:{
url:book.images.large
},
success:function(data){
$("input[name='title']").val(book.title)
$("textarea[name='desc']").val(book.summary)
$("input[name='pic']").val(book.images.large)
$("input[name='price']").val((book.price.replace(/[^0-9.]/,"")*1).toFixed(2))
$("input[name='url']").val(book.alt)
$("input[name='author']").val(book.author.join(" "))
$("textarea[name='author_desc']").val(book.author_intro)
if(data.success){
$("input[name='pic']").val(data.data.filename)
}else{
alert("封面上传失败,请重试")
}
loadingTip.hide()
}
})
}else{
loadingTip.hide()
$("input[name='title']").val(book.title)
$("textarea[name='desc']").val(book.summary)
$("input[name='pic']").val(book.images.large)
$("input[name='price']").val((book.price.replace(/[^0-9.]/,"")*1).toFixed(2))
$("input[name='url']").val(book.alt)
$("input[name='author']").val(book.author.join(" "))
$("textarea[name='author_desc']").val(book.author_intro)
}
}
}else{
messageTip.show(data.info)
}
},
error:function(){
loadingTip.hide()
}
})
})