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
3d3683e5
Commit
3d3683e5
authored
Oct 16, 2018
by
ZhuChunYang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
681bbb12
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
493 additions
and
226 deletions
+493
-226
ApplicationCategoryController.php
backend/controllers/ApplicationCategoryController.php
+3
-35
ApplicationController.php
backend/controllers/ApplicationController.php
+38
-42
CoinApplication.php
backend/models/coin/CoinApplication.php
+94
-0
CoinApplicationCategoryForm.php
backend/models/coin/CoinApplicationCategoryForm.php
+28
-26
index.php
backend/views/application-category/index.php
+70
-47
add.php
backend/views/application/add.php
+120
-0
index.php
backend/views/application/index.php
+0
-8
list.php
backend/views/application/list.php
+25
-55
CoinAppCate.php
common/models/psources/CoinAppCate.php
+46
-0
CoinApplication.php
common/models/psources/CoinApplication.php
+61
-0
CoinApplicationCategory.php
common/models/psources/CoinApplicationCategory.php
+8
-13
No files found.
backend/controllers/ApplicationCategoryController.php
View file @
3d3683e5
...
...
@@ -24,15 +24,14 @@ class ApplicationCategoryController extends BaseController
$page
=
$request
->
get
(
'page'
,
1
);
$limit
=
$request
->
get
(
'limit'
,
10
);
$name
=
$request
->
get
(
'category_name'
,
''
);
$where
[]
=
[
'pid'
=>
0
];
$where
=
[
];
if
(
$name
){
$where
[]
=
[
'name'
=>
$name
];
}
$data
=
CoinApplicationCategory
::
getList
(
$page
,
$limit
,
$where
);
return
$data
;
}
$items
=
CoinApplicationCategory
::
getItemsByPid
(
0
);
return
$this
->
render
(
'index'
,[
'items'
=>
$items
]);
return
$this
->
render
(
'index'
);
}
/**
...
...
@@ -42,7 +41,7 @@ class ApplicationCategoryController extends BaseController
{
if
(
Yii
::
$app
->
request
->
isPost
)
{
Yii
::
$app
->
response
->
format
=
'json'
;
$fields
=
[
'id'
,
'name'
,
'sort'
,
'icon'
,
'
pid
'
];
$fields
=
[
'id'
,
'name'
,
'sort'
,
'icon'
,
'
banner'
,
'banner_url
'
];
$params
=
$this
->
initParams
(
Yii
::
$app
->
request
->
post
(),
$fields
);
$application_category
=
new
CoinApplicationCategoryForm
();
if
(
$params
[
'id'
]){
//edit
...
...
@@ -75,34 +74,4 @@ class ApplicationCategoryController extends BaseController
return
[
'code'
=>
1
,
'msg'
=>
'failed'
];
}
/**
*子分类列表
*/
public
function
actionSublist
()
{
if
(
Yii
::
$app
->
request
->
isAjax
){
$id
=
Yii
::
$app
->
request
->
get
(
'id'
);
Yii
::
$app
->
response
->
format
=
'json'
;
$request
=
Yii
::
$app
->
request
;
$page
=
$request
->
get
(
'page'
,
1
);
$limit
=
$request
->
get
(
'limit'
,
10
);
$where
[]
=
[
'pid'
=>
$id
];
$data
=
CoinApplicationCategory
::
getList
(
$page
,
$limit
,
$where
);
return
$data
;
}
else
{
$id
=
Yii
::
$app
->
request
->
get
(
'id'
);
if
(
$id
){
$parent_category
=
CoinApplicationCategory
::
getCategoryById
(
$id
);
if
(
$parent_category
){
return
$this
->
render
(
'sublist'
,[
'parent_category'
=>
$parent_category
]);
}
else
{
$this
->
error
(
'id参数不合法'
,
Yii
::
$app
->
request
->
getReferrer
());
}
}
else
{
$this
->
error
(
'id参数不能为空'
,
Yii
::
$app
->
request
->
getReferrer
());
}
}
}
}
\ No newline at end of file
backend/controllers/ApplicationController.php
View file @
3d3683e5
...
...
@@ -6,66 +6,61 @@
* Time: 10:26
*/
namespace
backend\controllers
;
use
common\models\psources\CoinAppCate
;
use
common\models\psources\CoinApplication
;
use
common\models\psources\CoinApplicationCategory
;
use
Yii
;
class
ApplicationController
extends
BaseController
{
public
function
actionIndex
()
/**
* @return array|string|\yii\db\ActiveRecord[]
* 应用列表
*/
public
function
actionList
()
{
if
(
Yii
::
$app
->
request
->
isAjax
)
{
if
(
Yii
::
$app
->
request
->
isAjax
){
$id
=
Yii
::
$app
->
request
->
get
(
'id'
);
Yii
::
$app
->
response
->
format
=
'json'
;
$request
=
Yii
::
$app
->
request
;
$page
=
$request
->
get
(
'page'
,
1
);
$limit
=
$request
->
get
(
'limit'
,
10
);
$name
=
$request
->
get
(
'category_name'
,
''
);
$where
=
[];
if
(
$name
){
$where
[]
=
[
'name'
=>
$name
];
$app_ids
=
CoinAppCate
::
getAppIdByCateId
(
$id
);
$app_items
=
[];
$where
=
[];
if
(
$app_ids
){
$app_items
=
array_column
(
$app_ids
,
'app_id'
);
}
$data
=
CoinApplicationCategory
::
getList
(
$page
,
$limit
,
$where
);
$where
[]
=
[
'in'
,
'id'
,[
$app_items
]];
$data
=
CoinApplication
::
getList
(
$page
,
$limit
,
$where
);
return
$data
;
}
$items
=
CoinApplicationCategory
::
getItemsByPid
(
0
);
return
$this
->
render
(
'index'
,[
'items'
=>
$items
]);
}
}
else
{
$id
=
Yii
::
$app
->
request
->
get
(
'id'
);
if
(
$id
){
$parent_category
=
CoinApplicationCategory
::
getCategoryById
(
$id
);
if
(
$parent_category
){
return
$this
->
render
(
'list'
,[
'parent_category'
=>
$parent_category
]);
}
else
{
$this
->
error
(
'id参数不合法'
,
Yii
::
$app
->
request
->
getReferrer
());
}
/**
* 添加一个application category
*/
public
function
actionAddAndEdit
()
{
if
(
Yii
::
$app
->
request
->
isPost
)
{
Yii
::
$app
->
response
->
format
=
'json'
;
$fields
=
[
'id'
,
'name'
,
'sort'
,
'icon'
,
'pid'
];
$params
=
$this
->
initParams
(
Yii
::
$app
->
request
->
post
(),
$fields
);
$application_category
=
new
CoinApplicationCategoryForm
();
if
(
$params
[
'id'
]){
//edit
$application_category
->
setScenario
(
CoinApplicationCategoryForm
::
SCENARIO_EDIT
);
$application_category
->
load
(
$params
,
''
);
return
$application_category
->
edit
();
}
else
{
$application_category
->
setScenario
(
CoinApplicationCategoryForm
::
SCENARIO_ADD
);
$application_category
->
load
(
$params
,
''
);
return
$application_category
->
add
();
$this
->
error
(
'id参数不能为空'
,
Yii
::
$app
->
request
->
getReferrer
());
}
}
}
/**
* @return array
* @throws \Throwable
* @throws \yii\db\StaleObjectException
*/
public
function
actionDelete
()
public
function
actionAdd
()
{
Yii
::
$app
->
response
->
format
=
'json'
;
$id
=
Yii
::
$app
->
request
->
get
(
'id'
);
if
(
$id
)
{
$application_category
=
new
CoinApplicationCategoryForm
();
return
$application_category
->
del
(
$id
);
if
(
Yii
::
$app
->
request
->
isPost
){
$category_id
=
Yii
::
$app
->
request
->
get
(
'category_id'
);
Yii
::
$app
->
response
->
format
=
'json'
;
$fields
=
[
'name'
,
'sort'
,
'icon'
,
'type'
,
'native_url'
,
'h5_url'
,
'android_url'
,
'ios_url'
,
'app_store_url'
,
'advertise'
,
'description'
,
'redirect_type'
];
$params
=
array_merge
(
Yii
::
$app
->
request
->
post
(),[
'category_id'
=>
$category_id
]);
$params
=
$this
->
initParams
(
$params
,
$fields
);
var_dump
(
$params
);
die
;
}
return
[
'code'
=>
1
,
'msg'
=>
'failed'
]
;
return
$this
->
render
(
'add'
)
;
}
}
\ No newline at end of file
backend/models/coin/CoinApplication.php
0 → 100644
View file @
3d3683e5
<?php
/**
* Created by PhpStorm.
* User: ZCY
* Date: 2018/10/16
* Time: 11:43
*/
namespace
backend\models\coin
;
use
backend\models\BaseForm
;
use
common\models\psources\CoinApplicationCategory
;
class
CoinApplicationCategoryForm
extends
BaseForm
{
const
SCENARIO_ADD
=
'add'
;
const
SCENARIO_EDIT
=
'edit'
;
public
$id
;
public
$name
;
public
$sort
;
public
$icon
;
public
$pid
;
public
$banner
;
public
$banner_url
;
public
function
scenarios
()
{
return
[
self
::
SCENARIO_ADD
=>
[
'name'
,
'sort'
,
'icon'
,
'banner'
,
'banner_url'
],
self
::
SCENARIO_EDIT
=>
[
'id'
,
'name'
,
'sort'
,
'icon'
,
'banner'
,
'banner_url'
],
];
}
public
function
attributeLabels
()
{
return
[
'id'
=>
'ID'
,
'name'
=>
'名称'
,
'icon'
=>
'图标'
,
'sort'
=>
'排序'
,
'banner'
=>
'banner图片'
,
'banner_url'
=>
'banner链接'
];
}
public
function
rules
()
{
return
[
[[
'name'
],
'required'
,
'on'
=>
self
::
SCENARIO_ADD
],
[[
'id'
,
'name'
,
'sort'
],
'required'
,
'on'
=>
self
::
SCENARIO_EDIT
],
[
'sort'
,
'default'
,
'value'
=>
1
],
[
'sort'
,
'integer'
],
[
'icon'
,
'default'
,
'value'
=>
0
],
[
'banner'
,
'default'
,
'value'
=>
0
],
[
'name'
,
'checkName'
],
];
}
public
function
checkName
(
$attribute
,
$params
)
{
$res
=
CoinApplicationCategory
::
find
()
->
where
([
'name'
=>
$this
->
$attribute
])
->
one
();
$scenario
=
$this
->
getScenario
();
if
(
$scenario
==
self
::
SCENARIO_ADD
)
{
if
(
$res
)
{
$this
->
addError
(
$attribute
,
'应用分类名称已存在'
);
}
}
else
if
(
$scenario
==
self
::
SCENARIO_EDIT
)
{
if
(
$res
&&
$res
->
id
!=
$this
->
id
)
{
$this
->
addError
(
$attribute
,
'应用分类名称已存在'
);
}
}
}
/**
* 添加应用
*/
public
function
add
()
{
if
(
$this
->
validate
())
{
$coin_applicate_category
=
new
CoinApplicationCategory
();
$coin_applicate_category
->
setAttributes
(
$this
->
attributes
,
false
);
$coin_applicate_category
->
save
();
return
[
'code'
=>
0
,
'msg'
=>
'应用分类添加成功!'
];
}
else
{
$error
=
self
::
getModelError
(
$this
);
return
[
'code'
=>
1
,
'msg'
=>
$error
];
}
}
}
\ No newline at end of file
backend/models/coin/CoinApplicationCategoryForm.php
View file @
3d3683e5
...
...
@@ -8,25 +8,32 @@
namespace
backend\models\coin
;
use
backend\models\BaseForm
;
use
common\models\psources\CoinApplicationCategory
;
use
common\service\coin\Coin
;
class
CoinApplication
Category
Form
extends
BaseForm
class
CoinApplicationForm
extends
BaseForm
{
const
SCENARIO_ADD
=
'add'
;
const
SCENARIO_EDIT
=
'edit'
;
public
$id
;
public
$name
;
public
$sort
;
public
$icon
;
public
$pid
;
public
$sort
;
public
$type
;
public
$native_url
;
public
$h5_url
;
public
$android_url
;
public
$ios_url
;
public
$app_store_url
;
public
$advertise
;
public
$description
;
public
$image_ids
;
public
$redirect_type
;
public
function
scenarios
()
{
return
[
self
::
SCENARIO_ADD
=>
[
'name'
,
'sort'
,
'icon'
,
'
pid
'
],
self
::
SCENARIO_EDIT
=>
[
'id'
,
'name'
,
'sort'
,
'icon'
,
'
pid
'
],
self
::
SCENARIO_ADD
=>
[
'name'
,
'sort'
,
'icon'
,
'
banner'
,
'banner_url
'
],
self
::
SCENARIO_EDIT
=>
[
'id'
,
'name'
,
'sort'
,
'icon'
,
'
banner'
,
'banner_url
'
],
];
}
...
...
@@ -34,11 +41,19 @@ class CoinApplicationCategoryForm extends BaseForm
public
function
attributeLabels
()
{
return
[
'id'
=>
'ID'
,
'name'
=>
'名称'
,
'icon'
=>
'图标'
,
'sort'
=>
'排序'
,
'pid'
=>
'父级分类ID'
'id'
=>
'ID'
,
'name'
=>
'名称'
,
'icon'
=>
'图标'
,
'sort'
=>
'排序'
,
'type'
=>
'类型'
,
'native_url'
=>
'原生链接'
,
'h5_url'
=>
'h5链接'
,
'android_url'
=>
'安卓链接'
,
'ios_url'
=>
'ios企业版链接'
,
'app_store_url'
=>
'ios商店版链接'
,
'advertise'
=>
'宣传语'
,
'description'
=>
'介绍'
,
'redirect_type'
=>
'跳转方式'
,
];
}
...
...
@@ -50,9 +65,8 @@ class CoinApplicationCategoryForm extends BaseForm
[
'sort'
,
'default'
,
'value'
=>
1
],
[
'sort'
,
'integer'
],
[
'icon'
,
'default'
,
'value'
=>
0
],
[
'
pid'
,
'default'
,
'value'
=>
0
],
[
'
banner'
,
'default'
,
'value'
=>
0
],
[
'name'
,
'checkName'
],
[
'pid'
,
'checkPid'
,
'on'
=>
self
::
SCENARIO_EDIT
],
];
}
...
...
@@ -71,12 +85,6 @@ class CoinApplicationCategoryForm extends BaseForm
}
}
public
function
checkPid
(
$attribute
,
$params
)
{
if
(
$this
->
pid
==
$this
->
id
){
$this
->
addError
(
$attribute
,
'不能设置为自己的子分类'
);
}
}
/**
...
...
@@ -88,7 +96,6 @@ class CoinApplicationCategoryForm extends BaseForm
$coin_applicate_category
=
new
CoinApplicationCategory
();
$coin_applicate_category
->
setAttributes
(
$this
->
attributes
,
false
);
$coin_applicate_category
->
save
();
$items
=
CoinApplicationCategory
::
getItemsByPid
(
0
);
return
[
'code'
=>
0
,
'msg'
=>
'应用分类添加成功!'
];
}
else
{
$error
=
self
::
getModelError
(
$this
);
...
...
@@ -124,12 +131,7 @@ class CoinApplicationCategoryForm extends BaseForm
{
$coin_applicate_category
=
CoinApplicationCategory
::
getCategoryById
(
$id
);
if
(
$coin_applicate_category
){
$hasChild
=
CoinApplicationCategory
::
hasChildCategory
(
$id
);
if
(
$hasChild
){
return
[
'code'
=>
1
,
'msg'
=>
'应用分类存在子分类,不能删除'
];
}
$coin_applicate_category
->
delete
();
$items
=
CoinApplicationCategory
::
getItemsByPid
(
0
);
return
[
'code'
=>
0
,
'msg'
=>
'应用分类删除成功'
];
}
else
{
return
[
'code'
=>
1
,
'msg'
=>
'应用分类不存在'
];
...
...
backend/views/application-category/index.php
View file @
3d3683e5
...
...
@@ -6,6 +6,7 @@
* Time: 17:41
*/
?>
<h4>
应用分类列表
</h4>
<div
class=
"layui-row"
>
<div
class=
"layui-col-md1"
>
...
...
@@ -32,10 +33,9 @@
<!-- 添加页面 -->
<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)"
id=
"form1"
method=
"post"
lay-filter=
"form1"
>
<form
class=
"layui-form"
action=
"javascript:void(0)"
id=
"form1"
method=
"post"
lay-filter=
"form1"
>
<input
type=
"hidden"
name=
"_csrf"
value=
"
<?=
Yii
::
$app
->
request
->
getCsrfToken
()
?>
"
>
<input
type=
"hidden"
name=
"id"
value=
""
>
<input
type=
"hidden"
name=
"pid"
value=
""
>
<div
class=
"layui-form-item layui-form-text"
>
<label
class=
"layui-form-label"
>
名称
</label>
...
...
@@ -67,17 +67,46 @@
</button>
</div>
</div>
<div
class=
"layui-form-item"
>
<div
class=
"layui-inline"
>
<label
class=
"layui-form-label"
>
banner
</label>
<div
class=
"layui-input-block"
>
<img
src=
""
style=
"margin-top: 11px; max-width: 32px; max-height: 32px"
id=
"icon2"
>
</div>
<input
type=
"hidden"
name=
"banner"
value=
""
>
</div>
<div
class=
"layui-inline"
style=
"margin-left: 50px;"
>
<button
type=
"button"
class=
"layui-btn"
id=
"upload2"
style=
""
>
<i
class=
"layui-icon"
>

</i>
上传新图片
</button>
</div>
</div>
<div
class=
"layui-form-item"
>
<label
class=
"layui-form-label"
>
banner链接
</label>
<div
class=
"layui-input-block"
>
<input
type=
"text"
name=
"banner_url"
required
lay-verify=
"required"
placeholder=
""
autocomplete=
"off"
class=
"layui-input"
>
</div>
</div>
</form>
</div>
</div>
<script
type=
"text/html"
id=
"iconTpl"
>
<
img
src
=
"{{d.icon_url}}"
style
=
"max-width: 32px; max-height: 32px;"
/>
</script>
<script
type=
"text/html"
id=
"bannerTpl"
>
{{
#
if
(
d
.
banner
>
0
){
}}
有
{{
#
}
else
{
}}
无
{{
#
}
}}
</script>
<script
type=
"text/html"
id=
"operationTpl"
>
<
a
class
=
"layui-btn layui-btn-normal layui-btn-xs"
lay
-
event
=
"add"
>
添加子分类
<
/a>
<
a
class
=
"layui-btn layui-btn-xs"
lay
-
event
=
"edit"
>
编辑
<
/a>
<
a
class
=
"layui-btn layui-btn-danger layui-btn-xs"
lay
-
event
=
"del"
>
删除
<
/a>
<
a
class
=
"layui-btn layui-btn-primary layui-btn-xs"
href
=
"/admin/application
-category/sublist?id={{d.id}}"
>
管理
<
/a>
<
a
class
=
"layui-btn layui-btn-primary layui-btn-xs"
href
=
"/admin/application
/list?id={{d.id}}"
>
应用列表
<
/a>
</script>
<script
type=
"text/javascript"
>
...
...
@@ -107,6 +136,11 @@
title
:
'排序'
},
{
field
:
'banner'
,
title
:
'banner'
,
templet
:
'#bannerTpl'
},
{
title
:
'操作'
,
templet
:
'#operationTpl'
},
...
...
@@ -118,8 +152,15 @@
},
{
field
:
'pid'
,
title
:
'所属父级'
,
field
:
'banner_url'
,
title
:
'banner链接'
,
hide
:
true
,
width
:
50
},
{
field
:
'banner_image_url'
,
title
:
'banner图片链接'
,
hide
:
true
,
width
:
50
...
...
@@ -136,7 +177,7 @@
if
(
event
===
'edit'
)
{
var
index
=
layer
.
open
({
title
:
'编辑应用分类'
,
area
:
'
5
00px'
,
area
:
'
8
00px'
,
type
:
1
,
content
:
$
(
"#_form"
),
btn
:
[
'保存'
,
'取消'
],
...
...
@@ -146,9 +187,11 @@
name
:
data
.
name
,
icon
:
data
.
icon
,
sort
:
data
.
sort
,
pid
:
data
.
pid
,
banner
:
data
.
banner
,
banner_url
:
data
.
banner_url
});
$
(
"#icon1"
).
attr
(
'src'
,
data
.
icon_url
);
$
(
"#icon2"
).
attr
(
'src'
,
data
.
banner_image_url
);
},
btn1
:
function
()
{
$
.
post
(
'/admin/application-category/add-and-edit'
,
$
(
"#form1"
).
serialize
(),
function
(
rev
)
{
...
...
@@ -184,43 +227,6 @@
}
});
});
}
else
if
(
'add'
===
event
){
var
index
=
layer
.
open
({
title
:
'添加应用分类'
,
area
:
'500px'
,
type
:
1
,
content
:
$
(
"#_form"
),
btn
:
[
'保存'
,
'取消'
],
success
:
function
()
{
clearForm
();
form
.
val
(
"form1"
,
{
pid
:
data
.
id
,
});
},
btn1
:
function
()
{
$
.
post
(
'/admin/application-category/add-and-edit'
,
$
(
"#form1"
).
serialize
(),
function
(
rev
)
{
layer
.
msg
(
rev
.
msg
);
if
(
0
==
rev
.
code
)
{
layer
.
close
(
index
);
$
(
"#_form"
).
css
(
'display'
,
'none'
);
clearForm
();
table
.
reload
(
'table1'
,
{
page
:
{
curr
:
1
}
});
}
});
},
btn2
:
function
()
{
layer
.
close
(
index
);
$
(
"#_form"
).
css
(
'display'
,
'none'
);
},
cancel
:
function
()
{
layer
.
close
(
index
);
$
(
"#_form"
).
css
(
'display'
,
'none'
);
}
});
}
});
form
.
on
(
'submit(search)'
,
function
(
obj
)
{
...
...
@@ -234,7 +240,7 @@
$
(
'#add'
).
click
(
function
()
{
var
index
=
layer
.
open
({
title
:
'添加应用分类'
,
area
:
'
5
00px'
,
area
:
'
8
00px'
,
type
:
1
,
content
:
$
(
"#_form"
),
btn
:
[
'保存'
,
'取消'
],
...
...
@@ -284,15 +290,32 @@
}
});
uploader
.
render
({
elem
:
"#upload2"
,
url
:
'/admin/image/upload'
,
data
:
{
_csrf
:
$_csrf
,
image_type
:
2
},
done
:
function
(
res
)
{
if
(
res
.
code
==
0
){
$
(
"input[name='banner']"
).
val
(
res
.
data
.
image_id
);
$
(
"#icon2"
).
attr
(
'src'
,
res
.
data
.
image_src
);
}
},
error
:
function
(
res
)
{
}
});
function
clearForm
(){
form
.
val
(
"form1"
,
{
id
:
''
,
name
:
''
,
icon
:
''
,
sort
:
''
,
pid
:
0
,
banner
:
''
,
banner_url
:
''
});
$
(
"#icon1"
).
attr
(
'src'
,
''
);
$
(
"#icon2"
).
attr
(
'src'
,
''
);
}
...
...
backend/views/application/add.php
0 → 100644
View file @
3d3683e5
<?php
/**
* Created by PhpStorm.
* User: ZCY
* Date: 2018/10/15
* Time: 21:01
*/
?>
<div
class=
"layui-row"
style=
"padding: 5px;"
>
<div
class=
"layui-col-md6"
>
<form
class=
"layui-form"
method=
"post"
action=
""
>
<input
name=
"_csrf"
type=
"hidden"
value=
"
<?=
Yii
::
$app
->
request
->
getCsrfToken
()
?>
"
>
<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>
<div
class=
"layui-form-item"
>
<label
class=
"layui-form-label"
>
应用名称
</label>
<div
class=
"layui-input-block"
>
<input
class=
"layui-input"
name=
"name"
value=
""
lay-verify=
"required"
>
</div>
</div>
<div
class=
"layui-form-item"
>
<label
class=
"layui-form-label"
>
应用排序
</label>
<div
class=
"layui-input-block"
>
<input
class=
"layui-input"
name=
"sort"
value=
""
>
</div>
</div>
<div
class=
"layui-form-item"
>
<label
class=
"layui-form-label"
>
类型
</label>
<div
class=
"layui-input-block"
>
<select
name=
"type"
>
<option
value=
"1"
>
非原生页面
</option>
<option
value=
"2"
>
原生页面
</option>
</select>
</div>
</div>
<div
class=
"layui-form-item"
>
<label
class=
"layui-form-label"
>
原生链接
</label>
<div
class=
"layui-input-block"
>
<input
class=
"layui-input"
name=
"native_url"
value=
""
>
</div>
</div>
<div
class=
"layui-form-item"
>
<label
class=
"layui-form-label"
>
h5链接
</label>
<div
class=
"layui-input-block"
>
<input
class=
"layui-input"
name=
"h5_url"
value=
""
>
</div>
</div>
<div
class=
"layui-form-item"
>
<label
class=
"layui-form-label"
>
安卓链接
</label>
<div
class=
"layui-input-block"
>
<input
class=
"layui-input"
name=
"android_url"
value=
""
>
</div>
</div>
<div
class=
"layui-form-item"
>
<label
class=
"layui-form-label"
>
ios企业版链接
</label>
<div
class=
"layui-input-block"
>
<input
class=
"layui-input"
name=
"ios_url"
value=
""
>
</div>
</div>
<div
class=
"layui-form-item"
>
<label
class=
"layui-form-label"
>
ios商业版链接
</label>
<div
class=
"layui-input-block"
>
<input
class=
"layui-input"
name=
"app_store_url"
value=
""
>
</div>
</div>
<div
class=
"layui-form-item"
>
<label
class=
"layui-form-label"
>
众筹价格
</label>
<div
class=
"layui-input-block"
>
<input
class=
"layui-input"
name=
""
placeholder=
"¥"
value=
""
>
</div>
</div>
<div
class=
"layui-form-item"
>
<label
class=
"layui-form-label"
>
宣传语
</label>
<div
class=
"layui-input-block"
>
<input
type=
"text"
class=
"layui-input"
name=
"advertise"
value=
""
>
</div>
</div>
<div
class=
"layui-form-item"
>
<label
class=
"layui-form-label"
>
应用介绍
</label>
<div
class=
"layui-input-block"
>
<textarea
class=
"layui-textarea"
name=
"description"
></textarea>
</div>
</div>
<div
class=
"layui-form-item"
>
<label
class=
"layui-form-label"
>
跳转方式
</label>
<div
class=
"layui-input-block"
>
<select
name=
"redirect_type"
>
<option
value=
"1"
>
跳转应用详情
</option>
<option
value=
"2"
>
直接跳转h5
</option>
</select>
</div>
</div>
<div
class=
"layui-form-item"
>
<button
class=
"layui-btn"
>
提交
</button>
</div>
</form>
</div>
</div>
<script>
//form render
var
form
=
layui
.
form
;
form
.
render
();
</script>
\ No newline at end of file
backend/views/application/index.php
deleted
100644 → 0
View file @
681bbb12
<?php
/**
* Created by PhpStorm.
* User: ZCY
* Date: 2018/10/15
* Time: 10:48
*/
\ No newline at end of file
backend/views/application
-category/sub
list.php
→
backend/views/application
/
list.php
View file @
3d3683e5
...
...
@@ -7,68 +7,34 @@
*/
?>
<h4>
所属分类---
<?=
$parent_category
->
name
?>
</h4>
<div
class=
"layui-row"
style=
"padding: 5px;"
>
<div
class=
"layui-col-md1"
>
<a
href=
"/admin/application/add?category_id=
<?=
$parent_category
->
id
?>
"
>
<button
class=
"layui-btn layui-btn-default"
id=
"add"
>
添加应用
</button>
</a>
</div>
</div>
<div
class=
"layui-col-md8"
>
<table
class=
"layui-table"
id=
"table1"
lay-filter=
"table1"
></table>
</div>
<input
type=
"hidden"
id=
"parent_id"
name=
"parent_id"
value=
"
<?=
$parent_category
->
id
?>
"
>
<!-- 添加页面 -->
<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)"
id=
"form1"
method=
"post"
lay-filter=
"form1"
>
<input
type=
"hidden"
name=
"_csrf"
value=
"
<?=
Yii
::
$app
->
request
->
getCsrfToken
()
?>
"
>
<input
type=
"hidden"
name=
"id"
value=
""
>
<input
type=
"hidden"
name=
"pid"
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=
"iconTpl"
>
<
img
src
=
"{{d.icon_url}}"
style
=
"max-width: 32px; max-height: 32px;"
/>
</script>
<script
type=
"text/html"
id=
"operationTpl"
>
<
a
class
=
"layui-btn layui-btn-xs"
lay
-
event
=
"edit"
>
编辑
<
/a>
<
a
class
=
"layui-btn layui-btn-danger layui-btn-xs"
lay
-
event
=
"del"
>
删除
<
/a>
<
a
class
=
"layui-btn layui-btn-xs"
lay
-
event
=
"edit"
>
编辑
<
/a>
<
a
class
=
"layui-btn layui-btn-danger layui-btn-xs"
lay
-
event
=
"del"
>
删除
<
/a>
</script>
<script
type=
"text/javascript"
>
var
table
=
layui
.
table
;
var
pid
=
$
(
"#parent_id"
).
val
();
console
.
log
(
pid
);
var
category_id
=
$
(
"#parent_id"
).
val
();
table
.
render
({
elem
:
'#table1'
,
page
:
true
,
limit
:
10
,
url
:
'/admin/application
-category/sublist?id='
+
p
id
,
url
:
'/admin/application
/list?id='
+
category_
id
,
cols
:
[[
{
field
:
'id'
,
...
...
@@ -89,6 +55,18 @@
title
:
'排序'
},
{
field
:
'h5_url'
,
title
:
'h5'
},
{
field
:
'安卓'
,
title
:
'android_url'
},
{
field
:
'ios'
,
title
:
'ios_url'
},
{
title
:
'操作'
,
templet
:
'#operationTpl'
},
...
...
@@ -99,13 +77,6 @@
width
:
50
},
{
field
:
'pid'
,
title
:
'所属父级'
,
hide
:
true
,
width
:
50
},
]],
});
...
...
@@ -128,7 +99,6 @@
name
:
data
.
name
,
icon
:
data
.
icon
,
sort
:
data
.
sort
,
pid
:
data
.
pid
,
});
$
(
"#icon1"
).
attr
(
'src'
,
data
.
icon_url
);
},
...
...
common/models/psources/CoinAppCate.php
0 → 100644
View file @
3d3683e5
<?php
/**
* Created by PhpStorm.
* User: ZCY
* Date: 2018/10/16
* Time: 11:25
*/
namespace
common\models\psources
;
use
common\core\BaseActiveRecord
;
use
Yii
;
class
CoinAppCate
extends
BaseActiveRecord
{
public
static
function
getDb
()
{
return
Yii
::
$app
->
get
(
'p_sources'
);
}
public
static
function
tableName
()
{
return
'{{%coin_app_cate}}'
;
}
public
function
beforeSave
(
$instert
)
{
if
(
parent
::
beforeSave
(
$instert
))
{
if
(
$this
->
isNewRecord
)
{
$this
->
create_time
=
Yii
::
$app
->
formatter
->
asTimestamp
(
'now'
);
}
else
{
$this
->
update_time
=
Yii
::
$app
->
formatter
->
asTimestamp
(
'now'
);
}
return
true
;
}
else
{
return
false
;
}
}
public
static
function
getAppIdByCateId
(
$cate_id
)
{
return
self
::
find
()
->
where
([
'cate_id'
=>
$cate_id
])
->
asArray
()
->
all
();
}
}
\ No newline at end of file
common/models/psources/CoinApplication.php
0 → 100644
View file @
3d3683e5
<?php
/**
* Created by PhpStorm.
* User: ZCY
* Date: 2018/10/15
* Time: 20:41
*/
namespace
common\models\psources
;
use
common\core\BaseActiveRecord
;
use
Yii
;
class
CoinApplication
extends
BaseActiveRecord
{
public
static
function
getDb
()
{
return
Yii
::
$app
->
get
(
'p_sources'
);
}
public
static
function
tableName
()
{
return
'{{%coin_application}}'
;
}
public
function
beforeSave
(
$instert
)
{
if
(
parent
::
beforeSave
(
$instert
))
{
if
(
$this
->
isNewRecord
)
{
$this
->
create_time
=
Yii
::
$app
->
formatter
->
asTimestamp
(
'now'
);
}
else
{
$this
->
update_time
=
Yii
::
$app
->
formatter
->
asTimestamp
(
'now'
);
}
return
true
;
}
else
{
return
false
;
}
}
public
static
function
getList
(
$page
=
1
,
$limit
=
10
,
$condition
=
[],
$order_by
=
[
'sort'
=>
SORT_ASC
],
$select
=
[])
{
$query
=
self
::
find
();
foreach
(
$condition
as
$item
){
$query
=
$query
->
andWhere
(
$item
);
}
$count
=
$query
->
count
();
$data
=
$query
->
offset
((
$page
-
1
)
*
10
)
->
limit
(
$limit
)
->
orderby
(
$order_by
);
$data
=
$data
->
asArray
()
->
all
();
$icon_Items
=
array_column
(
$data
,
'icon'
);
$icon_Infos
=
CoinImage
::
getItemsByIds
(
$icon_Items
);
foreach
(
$data
as
$key
=>
&
$value
){
if
(
$value
[
'icon'
]){
$value
[
'icon_url'
]
=
$icon_Infos
[
$value
[
'icon'
]][
'base_url'
]
.
$icon_Infos
[
$value
[
'icon'
]][
'file_url'
];
}
else
{
$value
[
'icon_url'
]
=
''
;
}
}
return
[
'count'
=>
$count
,
'data'
=>
$data
,
'code'
=>
0
];
}
}
\ No newline at end of file
common/models/psources/CoinApplicationCategory.php
View file @
3d3683e5
...
...
@@ -54,14 +54,20 @@ class CoinApplicationCategory extends BaseActiveRecord
$data
=
$query
->
offset
((
$page
-
1
)
*
10
)
->
limit
(
$limit
)
->
orderby
(
$order_by
);
$data
=
$data
->
asArray
()
->
all
();
$icon_Items
=
array_column
(
$data
,
'icon'
);
$icon_Infos
=
CoinImage
::
getItemsByIds
(
$icon_Items
);
$banner_Items
=
array_column
(
$data
,
'banner'
);
$image_Items
=
array_merge
(
$icon_Items
,
$banner_Items
);
$icon_Infos
=
CoinImage
::
getItemsByIds
(
$image_Items
);
foreach
(
$data
as
$key
=>
&
$value
){
if
(
$value
[
'icon'
]){
$value
[
'icon_url'
]
=
$icon_Infos
[
$value
[
'icon'
]][
'base_url'
]
.
$icon_Infos
[
$value
[
'icon'
]][
'file_url'
];
}
else
{
$value
[
'icon_url'
]
=
''
;
}
if
(
$value
[
'banner'
]){
$value
[
'banner_image_url'
]
=
$icon_Infos
[
$value
[
'banner'
]][
'base_url'
]
.
$icon_Infos
[
$value
[
'banner'
]][
'file_url'
];
}
else
{
$value
[
'banner_image_url'
]
=
''
;
}
}
return
[
'count'
=>
$count
,
'data'
=>
$data
,
'code'
=>
0
];
}
...
...
@@ -74,15 +80,4 @@ class CoinApplicationCategory extends BaseActiveRecord
return
self
::
find
()
->
where
([
'id'
=>
$id
])
->
one
();
}
public
static
function
getItemsByPid
(
$pid
)
{
$data
=
self
::
find
()
->
where
([
'pid'
=>
$pid
])
->
asArray
()
->
all
();
$items
=
array_column
(
$data
,
'name'
,
'id'
);
return
$items
;
}
public
static
function
hasChildCategory
(
$pid
)
{
return
self
::
find
()
->
where
([
'pid'
=>
$pid
])
->
count
();
}
}
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