Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
token
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wallet
token
Commits
f990e95f
Commit
f990e95f
authored
Oct 12, 2018
by
ZhuChunYang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
29aac451
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
367 additions
and
0 deletions
+367
-0
ApplicationCategoryController.php
backend/controllers/ApplicationCategoryController.php
+107
-0
index.php
backend/views/application-category/index.php
+215
-0
CoinApplicationCategory.php
common/models/psources/CoinApplicationCategory.php
+45
-0
No files found.
backend/controllers/ApplicationCategoryController.php
0 → 100644
View file @
f990e95f
<?php
/**
* Created by PhpStorm.
* User: ZCY
* Date: 2018/10/11
* Time: 16:55
*/
namespace
backend\controllers
;
use
common\models\psources\CoinApplicationCategory
;
use
Yii
;
use
yii\web\UploadedFile
;
class
ApplicationCategoryController
extends
BaseController
{
public
function
actionIndex
()
{
if
(
Yii
::
$app
->
request
->
isAjax
)
{
Yii
::
$app
->
response
->
format
=
'json'
;
$request
=
Yii
::
$app
->
request
;
$page
=
$request
->
get
(
'page'
,
1
);
$limit
=
$request
->
get
(
'limit'
,
10
);
$name
=
$request
->
get
(
'name'
,
''
);
$where
=
[];
if
(
$name
){
$where
[]
=
[
'name'
=>
$name
];
}
$data
=
CoinApplicationCategory
::
getList
(
$page
,
$limit
,
$where
);
return
$data
;
}
return
$this
->
render
(
'index'
);
}
/**
* 添加一个application category
*/
public
function
actionAdd
()
{
if
(
Yii
::
$app
->
request
->
isPost
)
{
Yii
::
$app
->
response
->
format
=
'json'
;
if
(
$id
=
Yii
::
$app
->
request
->
post
(
'id'
))
{
$model
=
AppVersion
::
findOne
(
$id
);
$model
->
scenario
=
AppVersion
::
APP_UPDATE
;
}
else
{
$model
=
new
AppVersion
();
$model
->
scenario
=
AppVersion
::
APP_ADD
;
}
$post
=
array_filter
(
Yii
::
$app
->
request
->
post
(),
function
(
$item
)
{
return
$item
;
});
if
(
$model
->
load
(
$post
)
&&
$model
->
validate
())
{
if
(
!
isset
(
$post
[
'id'
]))
{
$model
->
created_at
=
date
(
'Y-m-d H:i:s'
);
}
$model
->
updated_at
=
date
(
'Y-m-d H:i:s'
);
//更新日志使用json array
if
(
isset
(
$post
[
'log'
]))
{
$log_str
=
$post
[
'log'
];
$log_arr
=
explode
(
"
\n
"
,
$log_str
);
$model
->
log
=
$log_arr
;
}
$model
->
save
(
false
);
return
[
'code'
=>
0
,
'msg'
=>
'succeed'
];
}
$errors
=
$model
->
errors
;
foreach
(
$errors
as
$error
)
{
return
[
'code'
=>
1
,
'msg'
=>
$error
[
0
]];
}
}
}
/**
* @return array
* @throws \Throwable
* @throws \yii\db\StaleObjectException
*/
public
function
actionDelete
()
{
Yii
::
$app
->
response
->
format
=
'json'
;
$id
=
Yii
::
$app
->
request
->
get
(
'id'
);
if
(
$id
)
{
$model
=
AppVersion
::
findOne
(
$id
);
if
(
$model
)
{
$model
->
delete
();
return
[
'code'
=>
0
,
'msg'
=>
'succeed'
];
}
}
return
[
'code'
=>
1
,
'msg'
=>
'failed'
];
}
public
function
actionUpload
()
{
Yii
::
$app
->
response
->
format
=
'json'
;
try
{
$apk
=
UploadedFile
::
getInstanceByName
(
'apk'
);
$filepath
=
Yii
::
$app
->
uploader
->
upload
(
$apk
);
return
[
'code'
=>
0
,
'msg'
=>
'succeed'
,
'path'
=>
$filepath
];
}
catch
(
\Exception
$e
)
{
return
[
'code'
=>
$e
->
getCode
(),
'msg'
=>
$e
->
getMessage
()];
}
}
}
\ No newline at end of file
backend/views/application-category/index.php
0 → 100644
View file @
f990e95f
<?php
/**
* Created by PhpStorm.
* User: ZCY
* Date: 2018/10/11
* Time: 17:41
*/
?>
<h4>
应用分类列表
</h4>
<div
class=
"layui-row"
>
<div
class=
"layui-col-md1"
>
<button
class=
"layui-btn layui-btn-default"
id=
"add"
>
添加应用分类
</button>
</div>
<div
class=
"layui-col-md8"
>
<form
class=
"layui-form"
method=
"get"
action=
""
>
<div
class=
"layui-inline"
>
<label
class=
"layui-form-label"
style=
"margin-bottom: 0; width: 120px;"
>
应用分类名称
</label>
<div
class=
"layui-input-inline"
>
<input
class=
"layui-input"
name=
"category_name"
>
</div>
</div>
<div
class=
"layui-inline"
>
<button
class=
"layui-btn"
lay-submit
lay-filter=
"search"
>
搜索
</button>
</div>
</form>
</div>
</div>
<div
class=
"layui-col-md8"
>
<table
class=
"layui-table"
id=
"table1"
lay-filter=
"table1"
></table>
</div>
<!-- 添加页面 -->
<div
class=
"layui-row add"
style=
"display: none;padding: 5px;"
id=
"_form"
>
<div
class=
"layui-col-xs6 layui-col-sm6 layui-col-md11"
>
<form
class=
"layui-form form_add"
action=
"javascript:void(0)"
method=
"post"
lay-filter=
"form1"
>
<input
type=
"hidden"
name=
"_csrf"
value=
"
<?=
Yii
::
$app
->
request
->
getCsrfToken
()
?>
"
>
<input
type=
"hidden"
name=
"id"
value=
""
>
<div
class=
"layui-form-item layui-form-text"
>
<label
class=
"layui-form-label"
>
名称
</label>
<div
class=
"layui-input-block"
>
<input
type=
"text"
name=
"name"
required
lay-verify=
"required"
placeholder=
""
autocomplete=
"off"
class=
"layui-input"
>
</div>
</div>
<div
class=
"layui-form-item layui-form-text"
>
<label
class=
"layui-form-label"
>
排序
</label>
<div
class=
"layui-input-block"
>
<input
type=
"text"
name=
"sort"
required
lay-verify=
"required"
placeholder=
""
autocomplete=
"off"
class=
"layui-input"
>
</div>
</div>
<div
class=
"layui-form-item"
>
<div
class=
"layui-inline"
>
<label
class=
"layui-form-label"
>
图标
</label>
<div
class=
"layui-input-block"
>
<img
src=
""
style=
"margin-top: 11px; max-width: 32px; max-height: 32px"
id=
"icon1"
>
</div>
<input
type=
"hidden"
name=
"icon"
value=
""
>
</div>
<div
class=
"layui-inline"
style=
"margin-left: 50px;"
>
<button
type=
"button"
class=
"layui-btn"
id=
"upload1"
style=
""
>
<i
class=
"layui-icon"
>

</i>
上传新图片
</button>
</div>
</div>
</form>
</div>
</div>
<script
type=
"text/html"
id=
"operationTpl"
>
<
button
class
=
"layui-btn layui-btn-sm"
lay
-
event
=
"edit"
><
i
class
=
"layui-icon"
>&
#
xe642
;
<
/i></
button
>
<
button
class
=
"layui-btn layui-btn-sm layui-btn-danger"
lay
-
event
=
"del"
><
i
class
=
"layui-icon"
>&
#
xe640
;
<
/i></
button
>
</script>
<script
type=
"text/javascript"
>
var
table
=
layui
.
table
;
table
.
render
({
elem
:
'#table1'
,
page
:
true
,
limit
:
10
,
url
:
'/admin/application-category/index'
,
cols
:
[[
{
field
:
'id'
,
title
:
'ID'
},
{
field
:
'name'
,
title
:
'名称'
,
},
{
field
:
'icon'
,
title
:
'图标'
},
{
field
:
'sort'
,
title
:
'排序'
},
{
title
:
'操作'
,
templet
:
'#operationTpl'
},
]]
});
var
form
=
layui
.
form
;
form
.
render
();
table
.
on
(
'tool(table1)'
,
function
(
obj
)
{
var
event
=
obj
.
event
;
var
data
=
obj
.
data
;
if
(
event
===
'edit'
)
{
var
index
=
layer
.
open
({
title
:
'编辑应用分类'
,
area
:
'500px'
,
type
:
1
,
content
:
$
(
"#_form"
),
btn
:
[
'保存'
,
'取消'
],
success
:
function
()
{
form
.
val
(
"form1"
,
{
id
:
data
.
id
,
name
:
data
.
name
,
icon
:
data
.
icon
,
sort
:
data
.
sort
,
});
},
btn1
:
function
()
{
$
.
get
(
'/admin/coin-recommend/add'
,
$
(
"#form1"
).
serialize
(),
function
(
rev
)
{
layer
.
msg
(
rev
.
msg
);
if
(
0
==
rev
.
code
)
{
layer
.
close
(
index
);
$
(
"#_form"
).
css
(
'display'
,
'none'
);
table
.
reload
(
'table1'
,
{
page
:
{
curr
:
1
}
});
}
});
},
btn2
:
function
()
{
layer
.
close
(
index
);
$
(
"#_form"
).
css
(
'display'
,
'none'
);
},
cancel
:
function
()
{
layer
.
close
(
index
);
$
(
"#_form"
).
css
(
'display'
,
'none'
);
}
});
}
else
if
(
'del'
===
event
)
{
var
index
=
layer
.
confirm
(
"确认删除?"
,
{
icon
:
3
,
title
:
'删除'
},
function
()
{
$
.
get
(
'/admin/coin-recommend/del'
,
{
id
:
data
.
id
},
function
(
rev
)
{
layer
.
msg
(
rev
.
msg
);
if
(
0
==
rev
.
code
)
{
// layer.close(index);
table
.
reload
(
'table1'
,{
page
:{
curr
:
1
}
});
}
});
});
}
});
form
.
on
(
'submit(search)'
,
function
(
obj
)
{
console
.
log
(
obj
.
field
);
table
.
reload
(
"table1"
,
{
where
:
obj
.
field
,
page
:
{
curr
:
1
}
});
return
false
;
});
$
(
'#add'
).
click
(
function
()
{
var
index
=
layer
.
open
({
title
:
'添加应用分类'
,
area
:
'500px'
,
type
:
1
,
content
:
$
(
"#_form"
),
btn
:
[
'保存'
,
'取消'
],
success
:
function
()
{
form
.
val
(
"form1"
,
{
id
:
""
,
name
:
""
,
icon
:
""
,
sort
:
""
,
});
},
btn1
:
function
()
{
$
.
get
(
'/admin/coin-recommend/add'
,
$
(
"#form1"
).
serialize
(),
function
(
rev
)
{
layer
.
msg
(
rev
.
msg
);
if
(
0
==
rev
.
code
)
{
layer
.
close
(
index
);
$
(
"#_form"
).
css
(
'display'
,
'none'
);
table
.
reload
(
'table1'
,
{
page
:
{
curr
:
1
}
});
}
});
},
btn2
:
function
()
{
layer
.
close
(
index
);
$
(
"#_form"
).
css
(
'display'
,
'none'
);
},
cancel
:
function
()
{
layer
.
close
(
index
);
$
(
"#_form"
).
css
(
'display'
,
'none'
);
}
});
})
</script>
\ No newline at end of file
common/models/psources/CoinApplicationCategory.php
0 → 100644
View file @
f990e95f
<?php
/**
* Created by PhpStorm.
* User: ZCY
* Date: 2018/10/11
* Time: 18:49
*/
namespace
common\models\psources
;
use
common\core\BaseActiveRecord
;
use
Yii
;
class
CoinApplicationCategory
extends
BaseActiveRecord
{
public
static
function
getDb
()
{
return
Yii
::
$app
->
get
(
'p_sources'
);
}
public
static
function
tableName
()
{
return
'{{%coin_application_category}}'
;
}
/**
* 获取应用分类列表
*
* @param integer $page [description]
* @param integer $limit [description]
* @param array $condition [description]
* @param array $order_by [description]
* @return [type] [description]
*/
public
static
function
getList
(
$page
=
1
,
$limit
=
10
,
$condition
=
[],
$order_by
=
[
'sort'
=>
SORT_ASC
],
$select
=
[])
{
$query
=
self
::
find
();
if
(
!
empty
(
$condition
))
{
$query
=
$query
->
where
(
$condition
);
}
$count
=
$query
->
count
();
$data
=
$query
->
offset
((
$page
-
1
)
*
10
)
->
limit
(
$limit
)
->
orderby
(
$order_by
);
$data
=
$data
->
asArray
()
->
all
();
return
[
'count'
=>
$count
,
'data'
=>
$data
,
'code'
=>
0
];
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment