Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
白杨
/
shrae-app
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 929874d9
authored
Mar 07, 2018
by
lixiaofeng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
删除图片
1 parent
7c374b3a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
35 deletions
dataPage.html
src/js/imgUp.js
uploadImage.html
dataPage.html
View file @
929874d
...
...
@@ -153,7 +153,6 @@
var
strImg
=
''
var
Imgarr
=
[]
var
photo
=
data
.
result
.
photos
console
.
log
(
photo
)
for
(
var
i
=
0
;
i
<
msg
.
length
;
i
++
){
// console.log(msg[i])
var
num
=
i
+
1
...
...
@@ -165,10 +164,10 @@
for
(
var
i
=
0
;
i
<
photo
.
length
;
i
++
){
photo
[
i
].
photoPath
=
saas
.
url
+
"/v1/point/getFile?ak=30bdc45ee00940cda7917d134fdb1523&filePath="
+
photo
[
i
].
photoPath
strImg
+=
"<img src="
+
photo
[
i
].
photoPath
+
" class=\"item\"/>"
Imgarr
.
push
(
photo
[
i
].
photoPath
)
Imgarr
.
push
(
{
photoPath
:
photo
[
i
].
photoPath
,
id
:
photo
[
i
].
id
}
)
}
console
.
log
(
Imgarr
)
localStorage
.
setItem
(
'Imgarr'
,
Imgarr
.
join
(
'@'
))
localStorage
.
setItem
(
'Imgarr'
,
JSON
.
stringify
(
Imgarr
))
$
(
'.picNum'
).
html
(
photo
.
length
)
$
(
'#form'
).
append
(
str
)
$
(
'#picdiv'
).
append
(
strImg
)
...
...
src/js/imgUp.js
View file @
929874d
//网点id
var
pointId
=
localStorage
.
getItem
(
'pointId'
);
// console.log(pointId)
var
upArr
=
[]
var
delImgId
=
null
;
$
(
function
(){
var
delParent
;
...
...
@@ -9,15 +11,14 @@ $(function(){
fileSize
:
1024
*
1024
*
10
// 上传文件的大尿 10M
};
/*点击图片的文本框*/
var
upArr
=
[]
$
(
".file"
).
change
(
function
(){
var
idFile
=
$
(
this
).
attr
(
"id"
);
var
file
=
document
.
getElementById
(
idFile
);
var
imgContainer
=
$
(
this
).
parents
(
".z_photo"
);
//存放图片的父亲元紿
var
fileList
=
file
.
files
;
//获取的图片文仿
upArr
.
push
(
fileList
)
console
.
log
(
upArr
)
console
.
log
(
fileList
)
//
console.log(upArr)
//
console.log(fileList)
var
input
=
$
(
this
).
parent
();
//文本框的父亲元素
var
imgArr
=
[];
//遍历得到的图片文仿
...
...
@@ -68,9 +69,13 @@ $(function(){
$
(
".z_photo"
).
delegate
(
".close-upimg"
,
"click"
,
function
(){
$
(
".z_photo"
).
delegate
(
".close-upimg"
,
"click"
,
function
(
e
){
$
(
".works-mask"
).
show
();
delParent
=
$
(
this
).
parent
();
// console.log($(this).siblings('.up-img').attr('id'))
delImgId
=
$
(
this
).
siblings
(
'.up-img'
).
attr
(
'id'
)
// console.log(delParent)
// console.log($(this).siblings('.up-img'))
});
$
(
".wsdel-ok"
).
click
(
function
(){
...
...
@@ -79,7 +84,15 @@ $(function(){
// if(numUp < 6){
// delParent.parent().find(".z_file").show();
// }
delParent
.
remove
();
delParent
.
remove
()
$
.
ajax
({
type
:
"POST"
,
url
:
"http://114.55.43.0:16907/v1/point/deletePhoto?ak=30bdc45ee00940cda7917d134fdb1523&fileId="
+
delImgId
,
success
:
function
(
msg
){
console
.
log
(
msg
)
}
});
console
.
log
(
delImgId
)
});
$
(
".wsdel-no"
).
click
(
function
(){
...
...
@@ -128,29 +141,16 @@ function backReturn(){
* 保存图片
*/
function
saveReturn
(){
var
file
=
document
.
getElementById
(
"file"
).
files
[
0
];
console
.
log
(
"file数据"
+
file
);
var
formData
=
new
FormData
();
formData
.
append
(
'file'
,
file
);
// $.ajax({
// url: "/home/about",
// type: "post",
// data: formData,
// contentType: false,
// processData: false,
// mimeType: "multipart/form-data",
// success: function (data) {
//
// console.log("返回正确数据"+data);
// },
// error: function (data) {
// console.log("错误返回数据"+data);
// }
// });
var
url
=
"/v1/point/uploadPhoto?ak="
+
saas
.
ak
+
"&pointId="
+
pointId
;
saas
.
upLoadHttpRequest
(
url
,
formData
,
function
(
data
)
{
console
.
log
(
"返回正确数据"
+
data
);
},
function
(
error
)
{
console
.
log
(
"错误返回数据"
+
error
);
});
for
(
var
i
=
0
;
i
<
upArr
.
length
;
i
++
){
var
file
=
upArr
[
i
][
0
]
var
formData
=
new
FormData
();
formData
.
append
(
'file'
,
file
);
var
url
=
"/v1/point/uploadPhoto?ak="
+
saas
.
ak
+
"&pointId="
+
pointId
;
saas
.
upLoadHttpRequest
(
url
,
formData
,
function
(
data
)
{
console
.
log
(
"返回正确数据"
+
data
);
},
function
(
error
)
{
console
.
log
(
"错误返回数据"
+
error
);
});
}
}
\ No newline at end of file
uploadImage.html
View file @
929874d
...
...
@@ -39,10 +39,11 @@
<script
src=
"src/js/saasService.js"
></script>
<script
src=
"src/js/imgUp.js"
></script>
<script>
var
strImg
=
localStorage
.
getItem
(
'Imgarr'
).
split
(
'@'
)
var
strImg
=
JSON
.
parse
(
localStorage
.
getItem
(
'Imgarr'
)
)
var
tagImg
=
''
// console.log(strImg)
for
(
var
i
=
0
;
i
<
strImg
.
length
;
i
++
){
tagImg
+=
"<section class=\"up-section fl\"><span class=\"up-span\"></span><img class=\"close-upimg\" src=\"src/image/sc.png\"><img class=\"up-img\"
src="
+
strImg
[
i
]
+
"><p class=\"img-name-p\">201995-120HG1030762.jpg</p><input id=\"taglocation\" name=\"taglocation\" value=\"\" type=\"hidden\"><input id=\"tags\" name=\"tags\" value=\"\" type=\"hidden\"></section>"
tagImg
+=
"<section class=\"up-section fl\"><span class=\"up-span\"></span><img class=\"close-upimg\" src=\"src/image/sc.png\"><img class=\"up-img\"
id="
+
strImg
[
i
].
id
+
" src="
+
strImg
[
i
].
photoPath
+
"><p class=\"img-name-p\">201995-120HG1030762.jpg</p><input id=\"taglocation\" name=\"taglocation\" value=\"\" type=\"hidden\"><input id=\"tags\" name=\"tags\" value=\"\" type=\"hidden\"></section>"
}
$
(
'.upimg-div'
).
prepend
(
tagImg
)
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment