Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
yohobuy-portal-fe
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
weiqingting
9 years ago
Commit
6da87dcf946990b929f1e6aa42065cccbb909d68
1 parent
e0503043
视频上传
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
225 additions
and
104 deletions
client/js/common/edit.js
client/js/common/upload.js
client/js/common/util.js
client/js/product/limit-add.js
server/stub/service/upload.js
server/views/pages/limit/add.html
client/js/common/edit.js
View file @
6da87dc
...
...
@@ -165,7 +165,7 @@ edit.prototype={
_w
.
prepend
(
'<img width="76" height="80" src="'
+
response
.
data
+
'">'
);
}
$
(
this
).
attr
(
"value"
,
response
.
data
);
that
.
__listen
(
"callback"
,{
key
:
"file_onComplete_"
+
$
(
this
).
attr
(
"id"
)});
that
.
__listen
(
"callback"
,{
key
:
"file_onComplete_"
+
$
(
this
).
attr
(
"id"
)
,
data
:
response
.
data
});
},
'onStart'
:
function
()
{
that
.
__listen
(
"callback"
,{
key
:
"file_onStart_"
+
$
(
this
).
attr
(
"id"
)});
...
...
@@ -330,7 +330,9 @@ edit.prototype={
}
};
callback
&&
callback
(
options
);
$
.
ajax
(
options
);
if
(
!
options
.
debug
){
$
.
ajax
(
options
);
}
//return false;
},
__listen
:
function
(
key
,
o
,
callback
){
...
...
client/js/common/upload.js
View file @
6da87dc
...
...
@@ -10,7 +10,7 @@ $.fn.ajaxfileupload = function(options) {
onComplete
:
function
(
response
)
{
},
onCancel
:
function
()
{
},
validate_extensions
:
true
,
valid_extensions
:
[
'gif'
,
'png'
,
'jpg'
,
'jpeg'
],
valid_extensions
:
[
'gif'
,
'png'
,
'jpg'
,
'jpeg'
,
'mp4'
],
submit_button
:
null
};
...
...
client/js/common/util.js
View file @
6da87dc
...
...
@@ -14,12 +14,15 @@ var util={
success
:
function
(
res
)
{
res
=
res
.
data
;
if
((
""
+
res
.
code
)
===
"200"
)
{
notip
?
callback
.
bind
(
this
,
res
)():
util
.
__tip
(
res
.
message
,
"success"
,
callback
.
bind
(
this
,
res
));
notip
?
(
callback
&&
callback
.
bind
(
this
,
res
)()):
util
.
__tip
(
res
.
message
,
"success"
,
callback
&&
callback
.
bind
(
this
,
res
)(
));
return
true
;
}
else
{
(
!
notip
)
&&
util
.
__tip
(
res
.
message
,
"danger"
);
return
false
;
}
},
error
:
function
(){
return
false
;
}
});
}
...
...
client/js/product/limit-add.js
View file @
6da87dc
...
...
@@ -10,15 +10,19 @@ var $ = require('jquery'),
require
(
'../common/bootstrap-wysihtml5'
);
var
ENMA
=
{
attachType
:{
1
:
"图片"
,
2
:
"视频"
,
3
:
"文本"
},
type
:{}
attachType
:{
1
:
"图片"
,
2
:
"视频"
,
3
:
"文本"
}
}
//日期插件
$
(
'#saleTime'
).
fdatepicker
({
format
:
'yyyy-mm-dd'
});
function
getLocalTime
(
nS
)
{
var
date
=
new
Date
(
parseInt
(
nS
)
*
1000
);
var
mm
=
date
.
getMonth
()
+
1
;
var
dd
=
date
.
getDate
();
return
date
.
getFullYear
()
+
"-"
+
(
mm
<
10
?
"0"
+
mm
:
mm
)
+
"-"
+
(
dd
<
10
?
"0"
+
dd
:
dd
);
}
if
(
$
(
"#saleTime"
).
data
(
"time"
)){
var
date
=
getLocalTime
(
$
(
"#saleTime"
).
data
(
"time"
));
$
(
"#saleTime"
).
val
(
date
);
}
//测试数据
var
g
=
new
common
.
grid
({
...
...
@@ -31,8 +35,9 @@ var g=new common.grid({
return
ENMA
.
attachType
[
item
.
attachType
];
}},
{
display
:
"内容"
,
render
:
function
(
item
){
item
.
orderBy
==
item
.
__index
;
if
(
item
.
isDefault
==
1
){
return
'<input type="file" name="coverImg" id="coverImg" placeholder="封面图" required/>'
;
return
'<input type="file" name="coverImg" id="coverImg"
value="'
+
item
.
attachUrl
+
'"
placeholder="封面图" required/>'
;
}
else
{
if
(
item
.
attachType
==
1
){
return
"<img src='"
+
item
.
attachUrl
+
"' style='width:120px;height:80px' />"
;
...
...
@@ -46,60 +51,167 @@ var g=new common.grid({
{
display
:
"操作"
,
render
:
function
(
item
){
var
htmlArr
=
[];
if
(
!
item
.
isDefault
){
htmlArr
.
push
(
"<button type='button' data-index='0' class='delete btn btn-danger btn-xs'>删除</button>"
);
htmlArr
.
push
(
"<button type='button' data-index='0' class='delete btn btn-info btn-xs'>编辑</button>"
);
htmlArr
.
push
(
"<button type='button' data-index='"
+
item
.
__index
+
"' class='delete btn btn-danger btn-xs'>删除</button>"
);
htmlArr
.
push
(
"<button type='button' data-index='"
+
item
.
__index
+
"' class='edit btn btn-info btn-xs'>编辑</button>"
);
}
return
htmlArr
.
join
(
','
);
}}
]
});
g
.
__rows
=
[
{
"attachType"
:
1
,
"attachUrl"
:
"https://ss1.baidu.com/6ONXsjip0QIZ8tyhnq/it/u=1444256491,538988776&fm=80"
,
"isDefault"
:
1
,
"orderBy"
:
1
},
var
__ac
=
$
.
trim
(
$
(
"#attachmentContent"
).
val
());
g
.
__rows
=
__ac
?
JSON
.
parse
(
__ac
):[
{
"attachType"
:
1
,
"attachUrl"
:
"https://ss1.baidu.com/6ONXsjip0QIZ8tyhnq/it/u=1444256491,538988776&fm=80"
,
"isDefault"
:
0
,
"orderBy"
:
2
},
{
"attachType"
:
3
,
"intro"
:
"限售商品详情"
,
"isDefault"
:
0
,
"orderBy"
:
3
"attachUrl"
:
""
,
"isDefault"
:
1
}
]
];
g
.
init
(
g
.
__rows
);
var
e1
=
new
common
.
edit
(
'#baseTable'
);
e1
.
on
(
"callback"
,
function
(
obj
){
if
(
obj
.
key
==
"file_onComplete_coverImg"
){
g
.
__rows
[
0
].
attachUrl
=
obj
.
data
;
}
});
e1
.
init
();
//初始化form表单
var
$editorgroup
=
$
(
'#editor-group'
);
$editorgroup
.
init
();
var
e
=
new
common
.
edit
(
'#editor-group'
);
e
.
on
(
"validate"
,
function
(){
var
param
=
{
batchNo
:
$
(
'#batchNo'
).
val
(),
id
:
$
(
"#id"
).
val
()
};
return
common
.
util
.
__ajax
({
url
:
'/limit/checkBatch'
,
async
:
true
,
data
:
param
},
null
,
true
);
});
e
.
on
(
"validate"
,
function
(){
if
(
!
g
.
__rows
[
0
].
attachUrl
){
return
"请上传默认封面"
;
}
});
e
.
init
();
//添加修改
$
(
'.limit-add-btn'
).
click
(
function
(
option
)
{
e
.
submit
(
$
(
'#limit-add-form'
).
attr
(
'action'
),
function
(
option
){
//option.debug=true;
option
.
data
.
attachmentContent
=
JSON
.
stringify
(
g
.
__rows
);
option
.
data
.
saleTime
=
new
Date
(
option
.
data
.
saleTime
.
replace
(
'-'
,
','
)).
getTime
()
/
1000
;
option
.
success
=
function
(
res
){
res
=
res
.
data
;
if
(
res
.
code
==
"200"
){
e
.
$tip
(
'提交成功'
,
function
(){
location
.
href
=
"/limit/product/index"
;
},
'growl-success'
);
}
else
{
e
.
$tip
(
res
.
message
);
}
return
false
;
}
option
.
error
=
function
(
res
){
e
.
$tip
(
"提交失败"
);
};
});
});
// var $editor = $('#editor'), //文字,图片,视频容器
// type = $('#limit-add-form').attr('type');
// //添加文字
// $('body').on('click', '#textDialog', function() {
// common.dialog.confirm("添加文本",'<textarea id="text-editor"></textarea>',function(){
// var textStr = $('#text-editor').val();
// var $oText = $('<div class="quota-content quota-text" data-type="3"><span>' + textStr + '</span><a href="javascript:;" class="editor-delete btn btn-default">删除</a></div>');
var
Bll
=
{
imgVideo
:
function
(
title
,
item
,
index
){
common
.
dialog
.
confirm
(
title
,
common
.
util
.
__template
(
$
(
"#picDialogTemp"
).
html
(),
item
),
function
(){
var
_html
=
$
.
trim
(
$
(
"#imgVideoText"
).
val
());
if
(
_html
){
if
(
item
.
attachType
){
//修改
g
.
__rows
[
index
].
attachUrl
=
_html
;
}
else
{
//添加
g
.
__rows
.
push
({
"attachType"
:
item
.
__attachType
,
"attachUrl"
:
_html
,
"isDefault"
:
0
,
"attachName"
:
$
(
"#attachName"
).
val
()
});
}
g
.
reload
();
e1
.
init
();
}
});
var
a
=
new
common
.
edit
(
"#upload-wrapper"
);
a
.
on
(
"callback"
,
function
(
obj
){
if
(
obj
.
key
==
"file_onComplete_imgVideo"
){
$
(
"#imgVideoText"
).
val
(
obj
.
data
);
}
});
a
.
init
();
},
wenZi
:
function
(
title
,
item
,
index
){
common
.
dialog
.
confirm
(
title
,
common
.
util
.
__template
(
'<textarea id="text-editor">{attachUrl}</textarea>'
,
item
),
function
(){
var
_html
=
$
.
trim
(
$
(
"#text-editor"
).
val
());
if
(
_html
){
if
(
item
.
attachType
){
//修改
g
.
__rows
[
index
].
attachUrl
=
_html
;
}
else
{
//添加
g
.
__rows
.
push
({
"attachType"
:
3
,
"attachUrl"
:
_html
,
"isDefault"
:
0
});
}
g
.
reload
();
e1
.
init
();
}
});
$
(
'#text-editor'
).
wysihtml5
();
}
}
// $oText.appendTo($editor);
//添加文字
$
(
'body'
).
on
(
'click'
,
'#textDialog'
,
function
()
{
Bll
.
wenZi
(
"添加文字"
,{});
return
false
;
});
$
(
'body'
).
on
(
'click'
,
'#picDialog'
,
function
()
{
Bll
.
imgVideo
(
"添加图片"
,{
name
:
"图片"
,
__attachType
:
1
});
return
false
;
});
$
(
'body'
).
on
(
'click'
,
'#videoDialog'
,
function
()
{
Bll
.
imgVideo
(
"添加视频"
,{
name
:
"视频"
,
__attachType
:
2
});
return
false
;
});
//删除
$
(
'body'
).
on
(
'click'
,
".delete"
,
function
(){
var
index
=
$
(
this
).
data
(
"index"
);
g
.
__rows
.
splice
(
index
,
1
);
g
.
reload
();
e1
.
init
();
});
//修改
$
(
'body'
).
on
(
'click'
,
".edit"
,
function
(){
var
item
=
g
.
rows
[
$
(
this
).
data
(
"index"
)];
Bll
[
item
.
attachType
==
3
?
"wenZi"
:
"imgVideo"
](
"修改"
+
ENMA
.
attachType
[
item
.
attachType
],
item
,
$
(
this
).
data
(
"index"
));
});
// });
// $('#text-editor').wysihtml5();
// return false;
// });
// //添加图片
// $('body').on('click', '#picDialog', function() {
...
...
server/stub/service/upload.js
View file @
6da87dc
...
...
@@ -3,6 +3,7 @@ var fs=require('fs');
var
domain
=
require
(
'../../config/common.js'
).
domain
;
//var domain = 'http://172.16.6.227:8083/yohobuy-platform-web';
//var domain = 'http://192.168.102.202:8088/platform';
//var domain = 'http://172.16.6.240:8088/platform';
var
env
=
process
.
env
.
NODE_ENV
||
'development'
;
exports
.
uploadFile
=
function
(
req
,
res
){
...
...
server/views/pages/limit/add.html
View file @
6da87dc
...
...
@@ -19,77 +19,77 @@
<form
id=
"limit-add-form"
class=
"form-horizontal form-bordered"
type=
"{{type}}"
action=
"{{action}}"
>
{{# data}}
<div
class=
"panel-group"
id=
"editor-group"
>
<div
class=
"panel-group"
>
<div
class=
"pannel"
>
<div
class=
"panel-heading"
>
<h4>
限购商品基本信息
</h4>
</div>
<div
class=
"panel-body"
>
<div
class=
"row"
>
<div
class=
"form-group"
>
<label
class=
"col-sm-2 control-label"
>
商品名称
<span
class=
"red"
>
*
</span>
:
</label>
<div
class=
"col-sm-8"
>
<input
type=
"text"
id=
"productName"
placeholder=
"商品名称"
class=
"form-control"
required
maxlength=
"30"
value=
"{{productName}}"
>
<div
class=
"panel-group"
id=
"editor-group"
>
<input
type=
"hidden"
id=
"id"
value=
"{{id}}"
>
<div
class=
"pannel"
>
<div
class=
"panel-heading"
>
<h4>
限购商品基本信息
</h4>
</div>
<div
class=
"panel-body"
>
<div
class=
"row"
>
<div
class=
"form-group"
>
<label
class=
"col-sm-2 control-label"
>
商品名称
<span
class=
"red"
>
*
</span>
:
</label>
<div
class=
"col-sm-8"
>
<input
type=
"text"
id=
"productName"
placeholder=
"商品名称"
class=
"form-control"
required
maxlength=
"30"
value=
"{{productName}}"
>
</div>
</div>
</div>
<div
class=
"form-group"
>
<label
class=
"col-sm-2 control-label"
>
限购码批次
<span
class=
"red"
>
*
</span>
:
</label>
<div
class=
"col-sm-8"
>
<input
type=
"text"
id=
"batchNo"
data-id=
"{{id}}"
placeholder=
"限购码批次"
class=
"form-control"
required
maxlength=
"30"
value=
"{{batchNo}}"
>
<div
class=
"form-group"
>
<label
class=
"col-sm-2 control-label"
>
限购码批次
<span
class=
"red"
>
*
</span>
:
</label>
<div
class=
"col-sm-8"
>
<input
type=
"text"
id=
"batchNo"
placeholder=
"限购码批次"
class=
"form-control"
required
maxlength=
"30"
value=
"{{batchNo}}"
>
</div>
</div>
</div>
<div
class=
"form-group"
>
<label
class=
"col-sm-2 control-label"
>
发售日期
<span
class=
"red"
>
*
</span>
:
</label>
<div
class=
"col-sm-4"
>
<input
id=
"saleTime"
data-time=
"{{saleTime}}"
value=
""
type=
"text"
class=
"form-control"
placeholder=
"发售日期"
readonly
required
>
</div>
<div
class=
"col-md-3"
>
<label>
是否显示日期:
</label>
<label
class=
"radio-inline"
><input
type=
"radio"
name=
"dayFlag"
value=
"1"
>
是
</label>
<label
class=
"radio-inline"
><input
type=
"radio"
name=
"dayFlag"
value=
"0"
>
否
</label>
<input
type=
"hidden"
value=
"{{dayFlag}}"
id=
"dayFlag"
for=
"radio"
>
<div
class=
"form-group"
>
<label
class=
"col-sm-2 control-label"
>
发售日期
<span
class=
"red"
>
*
</span>
:
</label>
<div
class=
"col-sm-4"
>
<input
id=
"saleTime"
data-time=
"{{saleTime}}"
value=
""
type=
"text"
class=
"form-control"
jsaction=
"date"
placeholder=
"发售日期"
readonly
required
>
</div>
<div
class=
"col-md-3"
>
<label>
是否显示日期:
</label>
<label
class=
"radio-inline"
><input
type=
"radio"
name=
"dayFlag"
value=
"1"
>
是
</label>
<label
class=
"radio-inline"
><input
type=
"radio"
name=
"dayFlag"
value=
"0"
>
否
</label>
<input
type=
"hidden"
value=
"{{dayFlag}}"
id=
"dayFlag"
for=
"radio"
>
</div>
</div>
</div>
</div>
</div>
</div>
<div
class=
"pannel"
>
<div
class=
"panel-heading"
>
<h4>
限购商品排序
</h4>
</div>
<div
class=
"panel-body"
>
<div
class=
"row"
>
<div
class=
"col-md-3"
>
<label>
是否热门:
</label>
<label
class=
"radio-inline"
><input
type=
"radio"
name=
"hotFlag"
value=
"1"
>
是
</label>
<label
class=
"radio-inline"
><input
type=
"radio"
name=
"hotFlag"
value=
"0"
>
否
</label>
<input
type=
"hidden"
value=
"{{hotFlag}}"
id=
"hotFlag"
for=
"radio"
>
</div>
<div
class=
"col-md-3 height60"
>
<label>
热门发售排序:
</label>
<label><input
id=
"orderBy"
value=
"{{orderBy}}"
type=
"text"
class=
"form-control"
placeholder=
""
></label>
<p>
(提示:数字越大越靠前)
</p>
</div>
<div
class=
"col-md-3"
>
<label>
未发售排序:
</label>
<label><input
id=
"notSaleOrderBy"
value=
"{{notSaleOrderBy}}"
type=
"text"
class=
"form-control"
placeholder=
""
></label>
<div
class=
"pannel"
>
<div
class=
"panel-heading"
>
<h4>
限购商品排序
</h4>
</div>
<div
class=
"panel-body"
>
<div
class=
"row"
>
<div
class=
"col-md-3"
>
<label>
是否热门:
</label>
<label
class=
"radio-inline"
><input
type=
"radio"
name=
"hotFlag"
value=
"1"
>
是
</label>
<label
class=
"radio-inline"
><input
type=
"radio"
name=
"hotFlag"
value=
"0"
>
否
</label>
<input
type=
"hidden"
value=
"{{hotFlag}}"
id=
"hotFlag"
for=
"radio"
>
</div>
<div
class=
"col-md-3 height60"
>
<label>
热门发售排序:
</label>
<label><input
id=
"orderBy"
value=
"{{orderBy}}"
type=
"text"
class=
"form-control"
placeholder=
""
></label>
<p>
(提示:数字越大越靠前)
</p>
</div>
<div
class=
"col-md-3"
>
<label>
未发售排序:
</label>
<label><input
id=
"notSaleOrderBy"
value=
"{{notSaleOrderBy}}"
type=
"text"
class=
"form-control"
placeholder=
""
></label>
</div>
</div>
</div>
</div>
</div>
</div>
<div
class=
"pannel"
>
<div
class=
"panel-heading"
>
<h4>
限量详情内容
</h4>
</div>
<div
id=
"baseTable"
></div>
<input
type=
"hidden"
value=
"{{attachment
}}"
id=
"attachm
ent"
/>
<input
type=
"hidden"
value=
"{{attachment
Content}}"
id=
"attachmentCont
ent"
/>
<div
class=
"row"
>
<div
class=
"col-md-8"
></div>
<div
class=
"col-md-4"
>
<div
class=
"col-md-12"
>
<button
class=
"btn btn-info mr5"
id=
"textDialog"
>
文本
</button>
<button
class=
"btn btn-info mr5"
id=
"picDialog"
>
图片
</button>
<button
class=
"btn btn-info mr5"
id=
"videoDialog"
>
视频
</button>
...
...
@@ -97,11 +97,14 @@
</div>
</div>
<div
class=
"pannel"
>
<div
class=
"col-md-10"
></div>
<div
class=
"col-md-2"
>
<input
id=
"limit-add-btn"
class=
"btn btn-success limit-add-btn"
type=
"button"
value=
"保存"
></input>
</div>
</div>
</div>
<input
type=
"hidden"
id=
"id"
value=
"{{id}}"
>
<div
class=
"mt20"
>
<input
id=
"limit-add-btn"
class=
"btn btn-primary limit-add-btn"
type=
"button"
value=
"保存"
></input>
</div>
</form>
{{/ data}}
</div>
...
...
@@ -110,20 +113,20 @@
<script
type=
"text/template"
id=
"picDialogTemp"
>
<
div
class
=
"row"
>
<
div
id
=
"upload-wrapper"
class
=
"col-md-3"
>
<
input
id
=
"
{fileId}"
type
=
"file"
class
=
"btn btn-primary ml10"
value
=
"
"
>
<
input
id
=
"
imgVideo"
type
=
"file"
class
=
"btn btn-primary ml10"
value
=
"{attachUrl}
"
>
<
/div>
<
div
class
=
"col-md-9"
>
<
div
class
=
"row"
>
<
label
class
=
"pull-left control-label height40"
>
{
name
}
链接
<
/label>
<
div
class
=
"pull-left ml10"
>
<
input
class
=
"form-control"
type
=
"text"
placeholder
=
"{name}链接
"
>
<
input
class
=
"form-control"
id
=
"imgVideoText"
type
=
"text"
placeholder
=
"{name}链接"
value
=
"{attachUrl}
"
>
<
/div>
<
/div>
<
div
class
=
"row"
>
<
label
class
=
"pull-left control-label height40"
>
{
name
}
描述
<
/label>
<
div
class
=
"pull-left ml10"
>
<
input
class
=
"form-control"
type
=
"text"
placeholder
=
"{name}描述"
>
<
input
class
=
"form-control"
type
=
"text"
id
=
"attachName"
value
=
"{attachName}"
placeholder
=
"{name}描述"
>
<
/div>
<
/div>
<
/div>
...
...
Please
register
or
login
to post a comment