Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
yoho-blk
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
1
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Plain Diff
Browse Files
Authored by
zhangxiaoru
9 years ago
Commit
fdb22f3939ca93c7a170f5f00241d413ae2905d7
2 parents
a44a5158
230b7ca1
editorial
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
68 additions
and
42 deletions
apps/me/views/partial/returns/special-reason.hbs
public/js/me/exchange.page.js
public/js/plugins/upload.js
apps/me/views/partial/returns/special-reason.hbs
View file @
fdb22f3
...
...
@@ -13,7 +13,7 @@
<span
class=
"red"
>
*
</span>
上传凭证:
</div>
<div
class=
"left right-content"
>
<div
class=
"img-upload"
>
<div
class=
"img-upload"
data-good-index=
"
{{
@index
}}
"
>
<span
class=
"iconfont"
>

</span>
</div>
<span
class=
"img-up-tip"
>
0/4
</span>
...
...
public/js/me/exchange.page.js
View file @
fdb22f3
...
...
@@ -17,6 +17,8 @@ var validate = require('./order/validation');
var
imgBoxTpl
=
require
(
'../../tpl/me/thumbnail.hbs'
);
var
changeTypeTpl
=
require
(
'../../tpl/me/change-type.hbs'
);
var
upload
=
require
(
'../plugins/upload'
);
var
validateMap
=
{
user
:
{
sl
:
'#user'
,
...
...
@@ -300,6 +302,9 @@ function bindConfirmEvent() {
var
$f
=
$good
.
find
(
'.form'
);
var
$specialReason
=
$good
.
find
(
'.special-reason'
);
$imgs
=
null
;
imgs
=
[];
goodObj
.
product_skn
=
$c
.
data
(
'skn'
);
goodObj
.
product_skc
=
$c
.
data
(
'skc'
);
goodObj
.
product_sku
=
$c
.
data
(
'sku'
);
...
...
@@ -371,51 +376,64 @@ function bindImgDeleteEvent() {
});
}
function
bindUploadEvent
()
{
var
$tip
=
$
(
'.img-up-tip'
);
function
doUpload
(
count
,
goodIndex
)
{
var
$el
=
$
(
'*[data-good-index='
+
goodIndex
+
']'
);
$tip
.
text
(
'0/4'
);
if
(
count
<
4
)
{
upload
.
up
({
callback
:
function
(
result
)
{
var
img
;
var
$t
;
var
o
;
var
n
;
$
(
'.img-upload'
).
on
(
'click'
,
function
()
{
var
upload
=
require
(
'../plugins/upload'
);
var
that
=
this
;
var
n
=
parseInt
(
$
(
that
).
siblings
(
'.thumb-box'
).
length
,
10
);
if
(
result
.
code
===
200
)
{
n
=
parseInt
(
$el
.
siblings
(
'.thumb-box'
).
length
,
10
);
o
=
{
src
:
result
.
data
};
if
(
result
.
imgs
&&
result
.
imgs
.
length
)
{
o
.
url
=
result
.
imgs
[
0
];
}
if
(
n
<
4
)
{
upload
.
up
({
callback
:
function
(
result
)
{
var
img
;
var
$t
;
var
o
;
img
=
imgBoxTpl
(
o
);
$t
=
$el
.
next
(
'.img-up-tip'
);
$el
.
before
(
img
);
if
(
result
.
code
===
200
)
{
n
=
parseInt
(
$
(
that
).
siblings
(
'.thumb-box'
).
length
,
10
);
o
=
{
src
:
result
.
data
};
n
+=
1
;
$t
.
text
(
n
+
'/4'
);
bindImgDeleteEvent
();
if
(
result
.
imgs
&&
result
.
imgs
.
length
)
{
o
.
url
=
result
.
imgs
[
0
];
}
if
(
n
>=
4
)
{
$el
.
hide
();
}
img
=
imgBoxTpl
(
o
);
$t
=
$
(
that
).
next
(
'.img-up-tip'
);
$
(
that
).
before
(
img
);
}
else
{
new
_alert
(
result
.
message
).
show
();
}
}
});
}
n
+=
1
;
$t
.
text
(
n
+
'/4'
);
bindImgDeleteEvent
();
}
if
(
n
>=
4
)
{
$
(
that
).
hide
();
}
function
bindUploadEvent
()
{
var
$tip
=
$
(
'.img-up-tip'
);
}
else
{
new
_alert
(
result
.
message
).
show
();
}
}
});
}
$tip
.
text
(
'0/4'
);
$
(
'.img-upload'
).
each
(
function
(
index
,
uploadBtn
)
{
$
(
uploadBtn
).
on
(
'click'
,
function
()
{
var
that
=
this
;
var
n
=
parseInt
(
$
(
that
).
siblings
(
'.thumb-box'
).
length
,
10
);
var
goodIndex
=
$
(
that
).
data
(
'good-index'
);
if
(
n
>
4
)
{
return
false
;
}
doUpload
(
n
,
goodIndex
);
});
});
}
...
...
public/js/plugins/upload.js
View file @
fdb22f3
...
...
@@ -16,6 +16,8 @@ var $result,
$upload
,
$filename
;
var
uping
;
var
num
,
inter
,
callback
;
...
...
@@ -27,8 +29,12 @@ $upload = $('#yoho-upload');
$filename
=
$upload
.
find
(
'.file-name'
);
function
up
(
opt
)
{
if
(
uping
)
{
return
;
}
$filename
.
click
();
if
(
opt
)
{
if
(
opt
&&
typeof
opt
.
callback
===
'function'
)
{
callback
=
opt
.
callback
;
}
else
{
callback
=
''
;
...
...
@@ -40,22 +46,24 @@ function getResponse(cb) {
inter
=
setInterval
(
function
()
{
var
res
=
$result
[
0
].
contentDocument
.
body
.
innerText
||
''
;
if
(
num
>
20
||
res
)
{
uping
=
false
;
clearInterval
(
inter
);
}
num
++
;
if
(
res
)
{
$result
[
0
].
contentDocument
.
body
.
innerText
=
''
;
if
(
cb
)
{
return
cb
(
$
.
parseJSON
(
res
));
}
}
if
(
num
>
20
||
res
)
{
clearInterval
(
inter
);
}
num
++
;
},
500
);
}
$filename
.
change
(
function
()
{
uping
=
true
;
$upload
.
submit
();
getResponse
(
callback
);
});
...
...
Please
register
or
login
to post a comment