Toggle navigation
This project
Loading...
Sign in
najixian
/
xt_dc_admin
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Download as
Email Patches
Plain Diff
Browse Files
Commit
aa58c8eaf407bfa2270787f895a7a8fb607f51d7
Authored by
u123231312
2018-09-05 17:50:53 +0800
1 parent
7ea8e226
build: skipped
PC端管理安卓包
Changes
6
Builds
0
Inline
Side-by-side
Showing
6 changed files
with
219 additions
and
6 deletions
application/admin/controller/Template.php
application/admin/controller/UpFiles.php
application/admin/lang/zh-cn.php
application/admin/view/template/android.html
application/admin/view/template/android_upload.html
public/static/plugins/layui/lay/modules/upload.js
application/admin/controller/Template.php
View file @
aa58c8e
...
...
@@ -12,13 +12,11 @@ class Template extends Common{
$this
->
viewSuffix
=
config
(
'template.view_suffix'
);
$viewPath
=
$viewPath
?
$viewPath
:
'view'
;
$this
->
filepath
=
Env
::
get
(
'app_path'
)
.
strtolower
(
config
(
'default_module'
))
.
'/'
.
$viewPath
.
'/'
;
$this
->
publicpath
=
'static/
home
/'
;
$this
->
publicpath
=
'static/
android
/'
;
$this
->
assign
(
'viewSuffix'
,
$this
->
viewSuffix
);
}
public
function
index
(){
//$path = $this->publicpath.'images/'.input('folder').'/';
if
(
$_SERVER
[
'REMOTE_ADDR'
]
==
"127.0.0.1"
)
$path
=
"/Applications/XAMPP/xamppfiles/htdocs/dashboard/images/"
;
else
...
...
@@ -366,4 +364,63 @@ class Template extends Common{
}
}
//安卓包管理
public
function
android
(){
if
(
Request
::
isAjax
()){
$list
=
db
(
'android'
)
->
select
();
foreach
(
$list
as
$key
=>
$value
)
{
$list
[
$key
][
'cdate'
]
=
date
(
"Y-m-d H:i:s"
,
$value
[
'cdate'
]);
}
$this
->
assign
(
'title'
,
'安卓包管理'
);
$result
=
[
'code'
=>
0
,
'msg'
=>
'获取成功!'
,
'data'
=>
$list
,
'rel'
=>
1
];
return
$result
;
}
return
view
();
}
//上传
public
function
androidUpload
(){
if
(
request
()
->
isPost
()){
//构建数组
$data
=
Request
::
except
(
'file'
);
if
(
empty
(
$data
[
'pic'
])){
$result
[
'code'
]
=
0
;
$result
[
'msg'
]
=
'请确保文件已经上传成功!'
;
$result
[
'url'
]
=
url
(
'uploadFile'
);
return
$result
;
}
$data
=
array
(
'name'
=>
$data
[
'name'
],
'version'
=>
$data
[
'version'
],
'file_url'
=>
$data
[
'pic'
],
'content'
=>
$data
[
'content'
],
'cdate'
=>
time
(),
);
db
(
'android'
)
->
insert
(
$data
);
$result
[
'code'
]
=
1
;
$result
[
'msg'
]
=
'OK!'
;
$result
[
'url'
]
=
url
(
'android'
);
return
$result
;
}
$this
->
assign
(
'title'
,
'安卓包管理'
);
return
$this
->
fetch
();
}
//删除文件
public
function
androidDel
(){
if
(
Request
::
isAjax
()){
$data
=
Request
::
except
(
'file'
);
$arr
=
db
(
'android'
)
->
where
(
'id'
,
$data
[
'id'
])
->
delete
();
if
(
$arr
==
1
){
$result
[
'code'
]
=
1
;
$result
[
'msg'
]
=
'删除成功!'
;
}
else
{
$result
[
'code'
]
=
0
;
$result
[
'msg'
]
=
'请求错误!'
;
}
return
$result
;
}
return
view
();
}
}
\ No newline at end of file
...
...
application/admin/controller/UpFiles.php
View file @
aa58c8e
...
...
@@ -107,12 +107,11 @@ class UpFiles extends Common
// 获取表单上传文件 例如上传了001.jpg
$file
=
request
()
->
file
(
$fileKey
[
'0'
]);
// 移动到框架应用根目录/public/uploads/ 目录下
$info
=
$file
->
validate
([
'ext'
=>
'zip,rar,pdf,swf,ppt,psd,ttf,txt,xls,doc,docx'
])
->
move
(
'uploads'
);
$info
=
$file
->
validate
([
'ext'
=>
'
apk,
zip,rar,pdf,swf,ppt,psd,ttf,txt,xls,doc,docx'
])
->
move
(
'uploads'
);
if
(
$info
){
$result
[
'code'
]
=
0
;
$result
[
'info'
]
=
'文件上传成功!'
;
$path
=
str_replace
(
'\\'
,
'/'
,
$info
->
getSaveName
());
$result
[
'url'
]
=
'/uploads/'
.
$path
;
$result
[
'ext'
]
=
$info
->
getExtension
();
$result
[
'size'
]
=
byte_format
(
$info
->
getSize
(),
2
);
...
...
application/admin/lang/zh-cn.php
View file @
aa58c8e
...
...
@@ -43,6 +43,7 @@ return [
'no'
=>
'否'
,
'edit'
=>
'编辑'
,
'del'
=>
'删除'
,
'dow'
=>
'下载'
,
'add'
=>
'添加'
,
'list'
=>
'列表'
,
'field'
=>
'字段'
,
...
...
application/admin/view/template/android.html
0 → 100644
View file @
aa58c8e
{include file="common/head"/}
<div
class=
"admin-main fadeInUp animated"
>
<fieldset
class=
"layui-elem-field layui-field-title"
>
<legend>
{$title}
</legend>
</fieldset>
<div
class=
"layui-field-box"
>
<blockquote
class=
"layui-elem-quote"
>
<a
href=
"{:url('android')}"
class=
"layui-btn layui-btn-sm layui-btn-danger"
>
<i
class=
"fa fa-file-image-o"
></i>
下载包
</a>
<a
href=
"{:url('androidUpload')}"
class=
"layui-btn layui-btn-sm"
>
<i
class=
"fa fa-file-image-o"
></i>
上传包
</a>
</blockquote>
<table
class=
"layui-table"
id=
"list"
lay-filter=
"list"
></table>
</div>
</div>
{include file="common/foot"/}
<script
type=
"text/html"
id=
"barDemo"
>
<
a
class
=
"layui-btn layui-btn-xs"
href
=
"{{d.file_url}}"
lay
-
event
=
"dow"
>
{:
lang
(
'dow'
)}
<
/a
>
<
a
class
=
"layui-btn layui-btn-danger layui-btn-xs"
lay
-
event
=
"del"
>
{:
lang
(
'del'
)}
<
/a
>
</script>
<script>
layui
.
use
([
'table'
,
'form'
],
function
()
{
var
table
=
layui
.
table
,
form
=
layui
.
form
,
$
=
layui
.
jquery
;
var
tableIn
=
table
.
render
({
elem
:
'#list'
,
url
:
'{:url("android")}'
,
method
:
'post'
,
cols
:
[[
{
field
:
'id'
,
title
:
'主键ID'
,
width
:
80
,
fixed
:
true
}
,{
field
:
'name'
,
title
:
'名称'
,
width
:
100
,
fixed
:
true
}
,{
field
:
'version'
,
title
:
'版本号'
,
width
:
100
}
,{
field
:
'file_url'
,
title
:
'文件地址'
,
width
:
450
}
,{
field
:
'cdate'
,
title
:
'上传日期'
,
width
:
180
}
,{
width
:
160
,
title
:
'操作'
,
align
:
'center'
,
toolbar
:
'#barDemo'
}
]]
});
//删除
table
.
on
(
'tool(list)'
,
function
(
obj
){
var
data
=
obj
.
data
;
if
(
obj
.
event
===
'del'
){
layer
.
confirm
(
'{:lang("Are you sure you want to delete it")}'
,
function
(
index
){
$
.
post
(
"{:url('androidDel')}"
,{
id
:
data
.
id
},
function
(
res
){
if
(
res
.
code
==
1
){
layer
.
msg
(
res
.
msg
,{
time
:
1000
,
icon
:
1
});
obj
.
del
();
}
else
{
layer
.
msg
(
res
.
msg
,{
time
:
1000
,
icon
:
2
});
}
});
layer
.
close
(
index
);
});
}
});
});
</script>
</body>
</html>
\ No newline at end of file
...
...
application/admin/view/template/android_upload.html
0 → 100644
View file @
aa58c8e
{include file="common/head"/}
<div
class=
"admin-main layui-anim layui-anim-upbit"
ng-app=
"hd"
ng-controller=
"ctrl"
>
<fieldset
class=
"layui-elem-field layui-field-title"
>
<legend>
{$title}
</legend>
</fieldset>
<blockquote
class=
"layui-elem-quote"
>
<a
href=
"{:url('android')}"
class=
"layui-btn layui-btn-sm"
>
<i
class=
"fa fa-file-image-o"
></i>
下载包
</a>
<a
href=
"{:url('androidUpload')}"
class=
"layui-btn layui-btn-sm layui-btn-danger"
>
<i
class=
"fa fa-file-image-o"
></i>
上传包
</a>
</blockquote>
<form
class=
"layui-form layui-form-pane"
>
<div
class=
"layui-form-item"
>
<label
class=
"layui-form-label"
>
包名
</label>
<div
class=
"layui-input-4"
>
<input
type=
"text"
name=
"name"
ng-model=
"field.name"
lay-verify=
"required"
placeholder=
"{:lang('pleaseEnter')}包名"
class=
"layui-input"
>
</div>
</div>
<div
class=
"layui-form-item"
>
<label
class=
"layui-form-label"
>
版本号
</label>
<div
class=
"layui-input-4"
>
<input
type=
"text"
name=
"version"
ng-model=
"field.version"
lay-verify=
"required"
placeholder=
"{:lang('pleaseEnter')}版本号"
class=
"layui-input"
>
</div>
</div>
<div
class=
"layui-form-item"
>
<label
class=
"layui-form-label"
>
文件
</label>
<input
type=
"hidden"
name=
"pic"
id=
"pic"
value=
""
>
<div
class=
"layui-input-block"
>
<div
class=
"layui-upload"
>
<button
type=
"button"
class=
"layui-btn layui-btn-primary"
id=
"adBtn"
><i
class=
"icon icon-upload3"
></i>
点击上传
</button>
</div>
</div>
</div>
<div
class=
"layui-form-item layui-form-text"
>
<label
class=
"layui-form-label"
>
更新内容
</label>
<div
class=
"layui-input-block"
>
<textarea
ng-model=
"field.content"
placeholder=
"请输入更新内容"
name=
"content"
class=
"layui-textarea"
></textarea>
</div>
</div>
<div
class=
"layui-form-item"
>
<div
class=
"layui-input-block"
>
<button
type=
"button"
class=
"layui-btn"
lay-submit=
""
lay-filter=
"submit"
>
{:lang('submit')}
</button>
</div>
</div>
</form>
</div>
{include file="common/foot"/}
<script
src=
"/static/common/js/angular.min.js"
></script>
<script>
var
m
=
angular
.
module
(
'hd'
,[]);
m
.
controller
(
'ctrl'
,[
'$scope'
,
function
(
$scope
)
{
$scope
.
field
=
{
type_id
:
''
,
name
:
''
,
url
:
''
,
open
:
1
,
sort
:
50
,
pic
:
''
,
content
:
''
};
layui
.
use
([
'form'
,
'layer'
,
'upload'
],
function
()
{
var
form
=
layui
.
form
,
$
=
layui
.
jquery
,
upload
=
layui
.
upload
;
if
(
$scope
.
field
.
pic
){
adPic
.
src
=
$scope
.
field
.
pic
;
}
form
.
on
(
'submit(submit)'
,
function
(
data
)
{
// 提交到方法 默认为本身
var
loading
=
layer
.
load
(
1
,
{
shade
:
[
0.1
,
'#fff'
]});
$
.
post
(
"{:url('androidUpload')}"
,
data
.
field
,
function
(
res
)
{
layer
.
close
(
loading
);
if
(
res
.
code
>
0
)
{
layer
.
msg
(
res
.
msg
,
{
time
:
1800
,
icon
:
1
},
function
()
{
location
.
href
=
res
.
url
;
});
}
else
{
layer
.
msg
(
res
.
msg
,
{
time
:
1800
,
icon
:
2
});
}
});
});
//文件上传
var
uploadInst
=
upload
.
render
({
elem
:
'#adBtn'
,
url
:
'{:url("UpFiles/file")}'
,
before
:
function
(
obj
){
//预读本地文件示例,不支持ie8
obj
.
preview
(
function
(
index
,
file
,
result
){
});
},
done
:
function
(
res
){
if
(
res
.
code
==
0
){
$
(
'#pic'
).
val
(
res
.
url
);
return
layer
.
msg
(
'上传成功'
);
}
else
{
//如果上传失败
return
layer
.
msg
(
'上传失败'
);
}
}
});
});
}]);
</script>
\ No newline at end of file
...
...
public/static/plugins/layui/lay/modules/upload.js
View file @
aa58c8e
...
...
@@ -242,7 +242,7 @@ function(e) {
default
:
if
(
layui
.
each
(
v
,
function
(
e
,
i
)
{
RegExp
(
"\\w\\.("
+
(
h
||
"mp4|jpg|png|gif|bmp|jpeg$"
)
+
")"
,
"i"
).
test
(
escape
(
i
))
||
(
n
=
!
0
)
RegExp
(
"\\w\\.("
+
(
h
||
"
apk|
mp4|jpg|png|gif|bmp|jpeg$"
)
+
")"
,
"i"
).
test
(
escape
(
i
))
||
(
n
=
!
0
)
}),
n
)
return
o
.
msg
(
"选择的图片中包含不支持的格式"
),
r
.
value
=
""
}
...
...
Please
register
or
login
to post a comment