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
5a848615
Commit
5a848615
authored
Jul 25, 2019
by
shajiaiming
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/optimize' into 'master'
Feature/optimize See merge request
!64
parents
7a940eae
ad418f78
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
1030 additions
and
779 deletions
+1030
-779
ApplicationController.php
api/controllers/ApplicationController.php
+38
-3
IndexAsset.php
backend/assets/applicationCategory/IndexAsset.php
+25
-0
ApplicationCategoryController.php
backend/controllers/ApplicationCategoryController.php
+123
-49
ApplicationController.php
backend/controllers/ApplicationController.php
+137
-99
CoinApplicationForm.php
backend/models/coin/CoinApplicationForm.php
+103
-101
add.php
backend/views/application-category/add.php
+131
-0
banner-index.php
backend/views/application-category/banner-index.php
+1
-1
edit.php
backend/views/application-category/edit.php
+126
-0
index.php
backend/views/application-category/index.php
+29
-355
add.php
backend/views/application/add.php
+14
-2
edit.php
backend/views/application/edit.php
+14
-2
list.php
backend/views/application/list.php
+58
-51
index.php
backend/views/coin/index.php
+117
-116
index.js
backend/web/js/application-category/index.js
+109
-0
CoinApplicationCategory.php
common/models/psources/CoinApplicationCategory.php
+5
-0
No files found.
api/controllers/ApplicationController.php
View file @
5a848615
...
...
@@ -31,8 +31,22 @@ class ApplicationController extends BaseController
}
$recommendData
=
ApplicationBusiness
::
getRecommendList
(
$condition
);
foreach
(
$recommendData
as
$j
=>
&
$val
){
$name_arr
=
json_decode
(
$val
[
'name'
],
true
);
$val
[
'name'
]
=
$name_arr
[
$this
->
lang
];
}
$data
[
'recommend'
]
=
$recommendData
;
$cate_app_data
=
ApplicationBusiness
::
getCategoryAppList
(
$condition
);
foreach
(
$cate_app_data
as
$key
=>
&
$val
){
$name
=
json_decode
(
$val
[
'name'
],
true
);
$val
[
'name'
]
=
$name
[
$this
->
lang
];
if
(
!
empty
(
$val
[
'apps'
])){
foreach
(
$val
[
'apps'
]
as
$j
=>
&
$value
){
$name
=
json_decode
(
$value
[
'name'
],
true
);
$value
[
'name'
]
=
$name
[
$this
->
lang
];
}
}
}
$data
[
'cate_app_data'
]
=
$cate_app_data
;
$data
[
'banner'
]
=
ApplicationBusiness
::
getBannerList
(
$condition
);
$result
[
'code'
]
=
0
;
...
...
@@ -48,6 +62,16 @@ class ApplicationController extends BaseController
{
$result
[
'code'
]
=
0
;
$result
[
'data'
]
=
ApplicationBusiness
::
getCategoryAppList
();
foreach
(
$result
[
'data'
]
as
$key
=>
&
$val
){
$name
=
json_decode
(
$val
[
'name'
],
true
);
$val
[
'name'
]
=
$name
[
$this
->
lang
];
if
(
!
empty
(
$val
[
'apps'
])){
foreach
(
$val
[
'apps'
]
as
$j
=>
&
$value
){
$name
=
json_decode
(
$value
[
'name'
],
true
);
$value
[
'name'
]
=
$name
[
$this
->
lang
];
}
}
}
return
$result
;
}
...
...
@@ -59,7 +83,11 @@ class ApplicationController extends BaseController
$request
=
Yii
::
$app
->
request
;
$id
=
$request
->
post
(
'id'
,
0
);
if
(
$id
){
return
ApplicationBusiness
::
appInfo
(
$id
);
$result
=
ApplicationBusiness
::
appInfo
(
$id
);
$data
=
$result
[
'data'
];
$name
=
json_decode
(
$data
[
'name'
],
true
);
$data
[
'name'
]
=
$name
[
$this
->
lang
];
return
[
'code'
=>
0
,
'data'
=>
$data
];
}
else
{
return
[
'code'
=>
1
,
'data'
=>
[],
'msg'
=>
'id不能为空'
];
}
...
...
@@ -126,6 +154,8 @@ class ApplicationController extends BaseController
$icon_Items
=
array_column
(
$appItems
,
'icon'
);
$icon_Infos
=
CoinImage
::
getItemsByIds
(
$icon_Items
);
foreach
(
$appItems
as
&
$value
){
$name
=
json_decode
(
$value
[
'name'
],
true
);
$value
[
'name'
]
=
$name
[
$this
->
lang
];
if
(
$value
[
'icon'
]){
$value
[
'icon'
]
=
$icon_Infos
[
$value
[
'icon'
]][
'base_url'
]
.
$icon_Infos
[
$value
[
'icon'
]][
'file_url'
];
}
else
{
...
...
@@ -138,7 +168,9 @@ class ApplicationController extends BaseController
$cate_id
=
$item
[
'cate_id'
];
$app_id
=
$item
[
'app_id'
];
$cate_app_items
[
$cate_id
][
'cate_id'
]
=
$cate_id
;
$cate_app_items
[
$cate_id
][
'name'
]
=
$item
[
'name'
];
$name_arr
=
json_decode
(
$item
[
'name'
],
true
);
$name
=
$name_arr
[
$this
->
lang
];
$cate_app_items
[
$cate_id
][
'name'
]
=
$name
;
$cate_app_items
[
$cate_id
][
'apps'
][]
=
$appItems
[
$app_id
];
}
foreach
(
$cate_app_items
as
$item
){
...
...
@@ -159,13 +191,16 @@ class ApplicationController extends BaseController
$cate_id
=
$request
->
get
(
'cate_id'
,
''
);
if
(
$cate_id
){
$cate_info
=
CoinApplicationCategory
::
getCategoryById
(
$cate_id
);
$name
=
$cate_info
->
name
[
$this
->
lang
];
$cate_info_data
[
'id'
]
=
$cate_info
->
id
;
$cate_info_data
[
'name'
]
=
$
cate_info
->
name
;
$cate_info_data
[
'name'
]
=
$name
;
$appItems
=
ApplicationBusiness
::
getCateAppInfo
(
0
,[[
'cate_id'
=>
$cate_id
]]);
if
(
$appItems
){
$appItems
=
array_shift
(
$appItems
);
foreach
(
$appItems
as
&
$value
){
$value
[
'app_user_num'
]
=
ApplicationBusiness
::
getAppUserNum
(
$value
[
'app_id'
]);
$name_arr
=
json_decode
(
$value
[
'name'
],
true
);
$value
[
'name'
]
=
$name_arr
[
$this
->
lang
];
}
$cate_info_data
[
'apps'
]
=
$appItems
;
return
[
'code'
=>
0
,
'data'
=>
$cate_info_data
];
...
...
backend/assets/applicationCategory/IndexAsset.php
0 → 100644
View file @
5a848615
<?php
/**
* Created By Sublime Text 3
*
* @authors rlgy <rlgyzhcn@qq.com>
* @date 2018-09-07 17:41:04
*/
namespace
backend\assets\applicationCategory
;
use
yii\web\AssetBundle
;
use
yii\web\View
;
class
IndexAsset
extends
AssetBundle
{
public
$sourcePath
=
'@backend/web/js/application-category'
;
public
$js
=
[
'index.js'
,
];
public
$jsOptions
=
[
'position'
=>
View
::
POS_END
,
];
}
\ No newline at end of file
backend/controllers/ApplicationCategoryController.php
View file @
5a848615
...
...
@@ -11,6 +11,7 @@ namespace backend\controllers;
use
backend\models\coin\CoinApplicationCategoryForm
;
use
common\models\psources\CoinApplicationCategory
;
use
common\models\psources\CoinBanner
;
use
common\models\psources\CoinImage
;
use
Yii
;
...
...
@@ -27,19 +28,22 @@ class ApplicationCategoryController extends BaseController
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
(
'category_name'
,
''
);
$page
=
$request
->
get
(
'page'
,
1
);
$limit
=
$request
->
get
(
'limit'
,
10
);
$name
=
$request
->
get
(
'category_name'
,
''
);
$where
=
[];
if
(
1
!==
$user_platform_id
)
{
if
(
1
!==
$user_platform_id
)
{
$where
[]
=
[
'platform_id'
=>
$user_platform_id
];
}
if
(
$name
)
{
if
(
$name
)
{
$where
[]
=
[
'name'
=>
$name
];
}
$data
=
CoinApplicationCategory
::
getList
(
$page
,
$limit
,
$where
);
foreach
(
$data
[
'data'
]
as
$key
=>
&
$val
){
$data
=
CoinApplicationCategory
::
getList
(
$page
,
$limit
,
$where
);
foreach
(
$data
[
'data'
]
as
&
$val
)
{
$val
[
'name'
]
=
str_replace
(
'en-US'
,
'en'
,
$val
[
'name'
]);
$val
[
'name'
]
=
str_replace
(
'zh-CN'
,
'zh'
,
$val
[
'name'
]);
}
foreach
(
$data
[
'data'
]
as
$key
=>
&
$val
)
{
$val
[
'coin_name'
]
=
isset
(
$val
[
'platform'
][
'name'
])
?
$val
[
'platform'
][
'name'
]
:
''
;
}
...
...
@@ -55,26 +59,96 @@ class ApplicationCategoryController extends BaseController
{
if
(
Yii
::
$app
->
request
->
isPost
)
{
Yii
::
$app
->
response
->
format
=
'json'
;
$fields
=
[
'id'
,
'name'
,
'sort'
,
'icon'
,
'banner'
,
'banner_url'
];
$fields
=
[
'id'
,
'name'
,
'sort'
,
'icon'
,
'banner'
,
'banner_url'
];
$params
=
$this
->
initParams
(
Yii
::
$app
->
request
->
post
(),
$fields
);
$application_category
=
new
CoinApplicationCategoryForm
();
if
(
$params
[
'id'
])
{
//edit
if
(
$params
[
'id'
])
{
//edit
$category
=
CoinApplicationCategory
::
getCategoryById
(
$params
[
'id'
]);
$params
[
'platform_id'
]
=
$category
->
platform_id
;
$application_category
->
setScenario
(
CoinApplicationCategoryForm
::
SCENARIO_EDIT
);
$application_category
->
load
(
$params
,
''
);
$application_category
->
load
(
$params
,
''
);
return
$application_category
->
edit
();
}
else
{
}
else
{
$params
[
'platform_id'
]
=
Yii
::
$app
->
user
->
identity
->
platform_id
;
$application_category
->
setScenario
(
CoinApplicationCategoryForm
::
SCENARIO_ADD
);
$application_category
->
load
(
$params
,
''
);
$application_category
->
load
(
$params
,
''
);
return
$application_category
->
add
();
}
}
}
public
function
actionAdd
()
{
$model
=
new
CoinApplicationCategoryForm
();
$model
->
setScenario
(
CoinApplicationCategoryForm
::
SCENARIO_ADD
);
if
(
Yii
::
$app
->
request
->
isPost
)
{
$fields
=
[
'id'
,
'name'
,
'sort'
,
'icon'
,
'banner'
,
'banner_url'
];
$params
=
$this
->
initParams
(
Yii
::
$app
->
request
->
post
(),
$fields
);
$params
[
'platform_id'
]
=
Yii
::
$app
->
user
->
identity
->
platform_id
;
$lang
=
[
'zh-CN'
,
'en-US'
,
'ja'
];
$name_arr
=
$params
[
'name'
];
$name
=
[];
foreach
(
$name_arr
as
$key
=>
$val
)
{
$name
[
$lang
[
$key
]]
=
$val
;
}
unset
(
$params
[
'name'
]);
$params
[
'name'
]
=
$name
;
$model
->
load
(
$params
,
''
);
$result
=
$model
->
add
();
if
(
0
===
$result
[
'code'
])
{
$this
->
success
(
'添加成功'
,
'/admin/application-category/index'
);
}
}
return
$this
->
render
(
'add'
,
[
'model'
=>
$model
]);
}
public
function
actionEdit
()
{
if
(
Yii
::
$app
->
request
->
isPost
)
{
Yii
::
$app
->
response
->
format
=
'json'
;
$fields
=
[
'id'
,
'name'
,
'sort'
,
'icon'
,
'banner'
,
'banner_url'
];
$params
=
$this
->
initParams
(
Yii
::
$app
->
request
->
post
(),
$fields
);
$application_category
=
new
CoinApplicationCategoryForm
();
$category
=
CoinApplicationCategory
::
getCategoryById
(
$params
[
'id'
]);
$params
[
'platform_id'
]
=
$category
->
platform_id
;
$application_category
->
setScenario
(
CoinApplicationCategoryForm
::
SCENARIO_EDIT
);
$lang
=
[
'zh-CN'
,
'en-US'
,
'ja'
];
$name_arr
=
$params
[
'name'
];
$name
=
[];
foreach
(
$name_arr
as
$key
=>
$val
)
{
$name
[
$lang
[
$key
]]
=
$val
;
}
unset
(
$params
[
'name'
]);
$params
[
'name'
]
=
$name
;
$application_category
->
load
(
$params
,
''
);
return
$application_category
->
edit
();
}
$id
=
Yii
::
$app
->
request
->
get
(
'id'
,
null
);
$coin
=
CoinApplicationCategory
::
getAppCategory
(
$id
);
$icon_model
=
CoinImage
::
findOne
(
$coin
[
'icon'
]);
$banner_model
=
CoinImage
::
findOne
(
$coin
[
'banner'
]);
$coin
[
'icon_url'
]
=
empty
(
$icon_model
)
?
''
:
$icon_model
->
base_url
.
$icon_model
->
file_url
;
$coin
[
'banner_image_url'
]
=
empty
(
$banner_model
)
?
''
:
$banner_model
->
base_url
.
$banner_model
->
file_url
;
$name_arr
=
json_decode
(
$coin
[
'name'
],
true
);
$coin
[
'name_ja'
]
=
isset
(
$name_arr
[
'ja'
])
?
$name_arr
[
'ja'
]
:
''
;
$coin
[
'name_zh'
]
=
isset
(
$name_arr
[
'zh-CN'
])
?
$name_arr
[
'zh-CN'
]
:
''
;
$coin
[
'name_en'
]
=
isset
(
$name_arr
[
'en-US'
])
?
$name_arr
[
'en-US'
]
:
''
;
$this
->
layout
=
false
;
return
$this
->
render
(
'edit'
,
[
'model'
=>
$coin
]);
}
/**
* @return array
* @throws \Throwable
...
...
@@ -102,18 +176,18 @@ class ApplicationCategoryController extends BaseController
if
(
Yii
::
$app
->
request
->
isAjax
)
{
Yii
::
$app
->
response
->
format
=
'json'
;
$request
=
Yii
::
$app
->
request
;
$id
=
$request
->
get
(
'id'
,
''
);
$sort
=
$request
->
get
(
'sort'
,
1
);
if
(
$id
)
{
$id
=
$request
->
get
(
'id'
,
''
);
$sort
=
$request
->
get
(
'sort'
,
1
);
if
(
$id
)
{
$category
=
CoinApplicationCategory
::
getCategoryById
(
$id
);
if
(
!
$category
)
{
return
[
'code'
=>
1
,
'msg'
=>
'分类不存在,不能设置排序'
];
if
(
!
$category
)
{
return
[
'code'
=>
1
,
'msg'
=>
'分类不存在,不能设置排序'
];
}
$category
->
sort
=
$sort
;
$category
->
sort
=
$sort
;
$category
->
save
();
return
[
'code'
=>
0
,
'msg'
=>
'分类排序设置成功'
];
}
else
{
return
[
'code'
=>
1
,
'msg'
=>
'分类排序设置失败'
];
return
[
'code'
=>
0
,
'msg'
=>
'分类排序设置成功'
];
}
else
{
return
[
'code'
=>
1
,
'msg'
=>
'分类排序设置失败'
];
}
}
}
...
...
@@ -124,26 +198,26 @@ class ApplicationCategoryController extends BaseController
*/
public
function
actionBannerIndex
()
{
if
(
Yii
::
$app
->
request
->
isAjax
)
{
if
(
Yii
::
$app
->
request
->
isAjax
)
{
$id
=
Yii
::
$app
->
request
->
get
(
'id'
);
Yii
::
$app
->
response
->
format
=
'json'
;
$applicate_category
=
CoinApplicationCategory
::
getCategoryById
(
$id
);
if
(
$applicate_category
)
{
if
(
$applicate_category
)
{
$data
=
CoinBanner
::
getBannerInfoByIds
(
$applicate_category
->
h5_banner
);
}
else
{
$data
=
[
'code'
=>
0
,
'data'
=>
[]];
}
else
{
$data
=
[
'code'
=>
0
,
'data'
=>
[]];
}
return
$data
;
}
else
{
}
else
{
$id
=
Yii
::
$app
->
request
->
get
(
'id'
);
if
(
$id
)
{
if
(
$id
)
{
$applicate_category
=
CoinApplicationCategory
::
getCategoryById
(
$id
);
if
(
$applicate_category
)
{
return
$this
->
render
(
'banner-index'
,[
'applicate_category'
=>
$applicate_category
]);
}
else
{
if
(
$applicate_category
)
{
return
$this
->
render
(
'banner-index'
,
[
'applicate_category'
=>
$applicate_category
]);
}
else
{
$this
->
error
(
'id参数不合法'
,
Yii
::
$app
->
request
->
getReferrer
());
}
}
else
{
}
else
{
$this
->
error
(
'id参数不能为空'
,
Yii
::
$app
->
request
->
getReferrer
());
}
}
...
...
@@ -155,16 +229,16 @@ class ApplicationCategoryController extends BaseController
*/
public
function
actionAddBanner
()
{
if
(
Yii
::
$app
->
request
->
isPost
)
{
if
(
Yii
::
$app
->
request
->
isPost
)
{
Yii
::
$app
->
response
->
format
=
'json'
;
$id
=
Yii
::
$app
->
request
->
post
(
'applicate_category_id'
,
0
);
$image_id
=
Yii
::
$app
->
request
->
post
(
'image'
,
0
);
$banner_url
=
Yii
::
$app
->
request
->
post
(
'banner_url'
,
0
);
if
(
$id
&&
$image_id
)
{
$id
=
Yii
::
$app
->
request
->
post
(
'applicate_category_id'
,
0
);
$image_id
=
Yii
::
$app
->
request
->
post
(
'image'
,
0
);
$banner_url
=
Yii
::
$app
->
request
->
post
(
'banner_url'
,
0
);
if
(
$id
&&
$image_id
)
{
$coin_applicate_category_form
=
new
CoinApplicationCategoryForm
();
return
$coin_applicate_category_form
->
addBanner
(
$id
,
$image_id
,
$banner_url
);
}
else
{
return
[
'code'
=>
1
,
'msg'
=>
'banner添加失败'
];
return
$coin_applicate_category_form
->
addBanner
(
$id
,
$image_id
,
$banner_url
);
}
else
{
return
[
'code'
=>
1
,
'msg'
=>
'banner添加失败'
];
}
}
}
...
...
@@ -180,7 +254,7 @@ class ApplicationCategoryController extends BaseController
$applicate_category_id
=
Yii
::
$app
->
request
->
get
(
'applicate_category_id'
);
if
(
$id
&&
$applicate_category_id
)
{
$coin_applicateion_category_form
=
new
CoinApplicationCategoryForm
();
return
$coin_applicateion_category_form
->
delBanner
(
$id
,
$applicate_category_id
);
return
$coin_applicateion_category_form
->
delBanner
(
$id
,
$applicate_category_id
);
}
return
[
'code'
=>
1
,
'msg'
=>
'failed'
];
}
...
...
@@ -194,18 +268,18 @@ class ApplicationCategoryController extends BaseController
if
(
Yii
::
$app
->
request
->
isAjax
)
{
Yii
::
$app
->
response
->
format
=
'json'
;
$request
=
Yii
::
$app
->
request
;
$id
=
$request
->
get
(
'id'
,
''
);
$enable
=
$request
->
get
(
'enable'
,
1
);
if
(
$id
)
{
$id
=
$request
->
get
(
'id'
,
''
);
$enable
=
$request
->
get
(
'enable'
,
1
);
if
(
$id
)
{
$category
=
CoinApplicationCategory
::
getCategoryById
(
$id
);
if
(
!
$category
)
{
return
[
'code'
=>
1
,
'msg'
=>
'分类不存在,不能设置启用状态'
];
if
(
!
$category
)
{
return
[
'code'
=>
1
,
'msg'
=>
'分类不存在,不能设置启用状态'
];
}
$category
->
enable
=
$enable
;
$category
->
save
();
return
[
'code'
=>
0
,
'msg'
=>
'分类使用状态设置成功'
];
}
else
{
return
[
'code'
=>
1
,
'msg'
=>
'分类使用状态设置失败'
];
return
[
'code'
=>
0
,
'msg'
=>
'分类使用状态设置成功'
];
}
else
{
return
[
'code'
=>
1
,
'msg'
=>
'分类使用状态设置失败'
];
}
}
}
...
...
backend/controllers/ApplicationController.php
View file @
5a848615
...
...
@@ -5,13 +5,16 @@
* Date: 2018/10/15
* Time: 10:26
*/
namespace
backend\controllers
;
use
backend\models\coin\CoinApplicationForm
;
use
common\models\psources\CoinAppCate
;
use
common\models\psources\CoinApplication
;
use
common\models\psources\CoinApplicationCategory
;
use
common\models\psources\CoinImage
;
use
Yii
;
class
ApplicationController
extends
BaseController
{
/**
...
...
@@ -20,28 +23,32 @@ class ApplicationController extends BaseController
*/
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
);
$data
=
CoinApplication
::
getListByCategory
(
$page
,
$limit
,
$id
);
$page
=
$request
->
get
(
'page'
,
1
);
$limit
=
$request
->
get
(
'limit'
,
10
);
$data
=
CoinApplication
::
getListByCategory
(
$page
,
$limit
,
$id
);
foreach
(
$data
[
'data'
]
as
&
$val
){
$val
[
'name'
]
=
str_replace
(
'en-US'
,
'en'
,
$val
[
'name'
]);
$val
[
'name'
]
=
str_replace
(
'zh-CN'
,
'zh'
,
$val
[
'name'
]);
}
return
$data
;
}
else
{
}
else
{
$id
=
Yii
::
$app
->
request
->
get
(
'id'
);
if
(
$id
)
{
if
(
$id
)
{
$parent_category
=
CoinApplicationCategory
::
getCategoryById
(
$id
);
$platform_id
=
Yii
::
$app
->
user
->
identity
->
platform_id
;
$condition
=
[
'platform_id'
=>
$platform_id
];
$cate_items
=
CoinApplicationCategory
::
getCateItemsArray
(
$condition
);
if
(
$parent_category
)
{
return
$this
->
render
(
'list'
,
[
'parent_category'
=>
$parent_category
,
'cate_items'
=>
$cate_items
]);
}
else
{
if
(
$parent_category
)
{
return
$this
->
render
(
'list'
,
[
'parent_category'
=>
$parent_category
,
'cate_items'
=>
$cate_items
]);
}
else
{
$this
->
error
(
'id参数不合法'
,
Yii
::
$app
->
request
->
getReferrer
());
}
}
else
{
}
else
{
$this
->
error
(
'id参数不能为空'
,
Yii
::
$app
->
request
->
getReferrer
());
}
}
...
...
@@ -53,21 +60,33 @@ class ApplicationController extends BaseController
*/
public
function
actionAdd
()
{
if
(
Yii
::
$app
->
request
->
isPost
)
{
if
(
Yii
::
$app
->
request
->
isPost
)
{
Yii
::
$app
->
response
->
format
=
'json'
;
$category_id
=
Yii
::
$app
->
request
->
get
(
'category_id'
);
$fields
=
[
'category_id'
,
'h5_icon'
,
'official_url'
,
'introduce_image'
,
'show_width'
,
'show_height'
,
'open_type'
,
'open_type_app'
,
'platform_type'
,
'name'
,
'sort'
,
'icon'
,
'type'
,
'native_url'
,
'native_login_url'
,
'h5_url'
,
'android_url'
,
'ios_url'
,
'app_store_url'
,
'advertise'
,
'description'
,
'redirect_type'
,
'platform_id'
];
$fields
=
[
'category_id'
,
'h5_icon'
,
'official_url'
,
'introduce_image'
,
'show_width'
,
'show_height'
,
'open_type'
,
'open_type_app'
,
'platform_type'
,
'name'
,
'sort'
,
'icon'
,
'type'
,
'native_url'
,
'native_login_url'
,
'h5_url'
,
'android_url'
,
'ios_url'
,
'app_store_url'
,
'advertise'
,
'description'
,
'redirect_type'
,
'platform_id'
];
$data
=
Yii
::
$app
->
request
->
post
();
$data
[
'open_type_app'
]
=
(
0
==
$data
[
'open_type_app'
])
?
1
:
$data
[
'open_type_app'
];
$params
=
array_merge
(
$data
,[
'category_id'
=>
$category_id
,
'platform_id'
=>
Yii
::
$app
->
user
->
identity
->
platform_id
]);
$lang
=
[
'zh-CN'
,
'en-US'
,
'ja'
];
$name_arr
=
$data
[
'name'
];
$name
=
[];
foreach
(
$name_arr
as
$key
=>
$val
){
$name
[
$lang
[
$key
]]
=
$val
;
}
unset
(
$data
[
'name'
]);
$data
[
'name'
]
=
$name
;
$data
[
'open_type_app'
]
=
(
0
==
$data
[
'open_type_app'
])
?
1
:
$data
[
'open_type_app'
];
$params
=
array_merge
(
$data
,
[
'category_id'
=>
$category_id
,
'platform_id'
=>
Yii
::
$app
->
user
->
identity
->
platform_id
]);
$params
=
$this
->
initParams
(
$params
,
$fields
);
$coin_applicateion_form
=
new
CoinApplicationForm
();
$coin_applicateion_form
->
setScenario
(
CoinApplicationForm
::
SCENARIO_ADD
);
$coin_applicateion_form
->
load
(
$params
,
''
);
$coin_applicateion_form
->
load
(
$params
,
''
);
$result
=
$coin_applicateion_form
->
add
();
if
(
$result
[
'code'
]
==
0
)
{
$this
->
success
(
'添加成功'
,
'/admin/application/list?id='
.
$category_id
);
}
else
{
if
(
$result
[
'code'
]
==
0
)
{
$this
->
success
(
'添加成功'
,
'/admin/application/list?id='
.
$category_id
);
}
else
{
$this
->
error
(
$result
[
'msg'
],
Yii
::
$app
->
request
->
getReferrer
());
}
}
...
...
@@ -82,55 +101,74 @@ class ApplicationController extends BaseController
{
if
(
Yii
::
$app
->
request
->
isPost
)
{
Yii
::
$app
->
response
->
format
=
'json'
;
$fields
=
[
'category_id'
,
'id'
,
'h5_icon'
,
'official_url'
,
'introduce_image'
,
'show_width'
,
'show_height'
,
'open_type'
,
'open_type_app'
,
'platform_type'
,
'name'
,
'sort'
,
'icon'
,
'type'
,
'native_url'
,
'native_login_url'
,
'h5_url'
,
'android_url'
,
'ios_url'
,
'app_store_url'
,
'advertise'
,
'description'
,
'redirect_type'
,
'platform_id'
];
$fields
=
[
'category_id'
,
'id'
,
'h5_icon'
,
'official_url'
,
'introduce_image'
,
'show_width'
,
'show_height'
,
'open_type'
,
'open_type_app'
,
'platform_type'
,
'name'
,
'sort'
,
'icon'
,
'type'
,
'native_url'
,
'native_login_url'
,
'h5_url'
,
'android_url'
,
'ios_url'
,
'app_store_url'
,
'advertise'
,
'description'
,
'redirect_type'
,
'platform_id'
];
$data
=
Yii
::
$app
->
request
->
post
();
$data
[
'open_type_app'
]
=
(
0
==
$data
[
'open_type_app'
])
?
1
:
$data
[
'open_type_app'
];
$params
=
array_merge
(
$data
,[
'platform_id'
=>
Yii
::
$app
->
user
->
identity
->
platform_id
]);
$lang
=
[
'zh-CN'
,
'en-US'
,
'ja'
];
$name_arr
=
$data
[
'name'
];
$name
=
[];
foreach
(
$name_arr
as
$key
=>
$val
){
$name
[
$lang
[
$key
]]
=
$val
;
}
unset
(
$data
[
'name'
]);
$data
[
'name'
]
=
$name
;
$data
[
'open_type_app'
]
=
(
0
==
$data
[
'open_type_app'
])
?
1
:
$data
[
'open_type_app'
];
#var_dump($data);exit;
$params
=
array_merge
(
$data
,
[
'platform_id'
=>
Yii
::
$app
->
user
->
identity
->
platform_id
]);
$params
=
$this
->
initParams
(
$params
,
$fields
);
$coin_applicateion_form
=
new
CoinApplicationForm
();
$coin_applicateion_form
->
setScenario
(
CoinApplicationForm
::
SCENARIO_EDIT
);
$coin_applicateion_form
->
load
(
$params
,
''
);
$coin_applicateion_form
->
load
(
$params
,
''
);
return
$coin_applicateion_form
->
edit
();
}
elseif
(
Yii
::
$app
->
request
->
isGet
)
{
$id
=
Yii
::
$app
->
request
->
get
(
'id'
,
null
);
$category_id
=
Yii
::
$app
->
request
->
get
(
'category_id'
,
null
);
if
(
$id
)
{
$applicate
=
CoinApplication
::
getApplicateById
(
$id
);
$applicate
=
CoinApplication
::
getApplicateById
(
$id
);
$coin_ids
=
[];
if
(
$applicate
[
'icon'
])
{
if
(
$applicate
[
'icon'
])
{
$coin_ids
[]
=
$applicate
[
'icon'
];
}
if
(
$applicate
[
'h5_icon'
])
{
if
(
$applicate
[
'h5_icon'
])
{
$coin_ids
[]
=
$applicate
[
'h5_icon'
];
}
if
(
$applicate
[
'introduce_image'
])
{
if
(
$applicate
[
'introduce_image'
])
{
$coin_ids
[]
=
$applicate
[
'introduce_image'
];
}
if
(
$coin_ids
)
{
if
(
$coin_ids
)
{
$coin_items
=
CoinImage
::
getItemsByIds
(
$coin_ids
);
}
$app_cate
=
CoinAppCate
::
getAppCate
(
$category_id
,
$id
);
if
(
$applicate
[
'icon'
])
{
$app_cate
=
CoinAppCate
::
getAppCate
(
$category_id
,
$id
);
if
(
$applicate
[
'icon'
])
{
$icon_info
=
$coin_items
[
$applicate
[
'icon'
]];
$applicate
[
'icon_url'
]
=
$icon_info
[
'base_url'
]
.
$icon_info
[
'file_url'
];
}
else
{
$applicate
[
'icon_url'
]
=
""
;
$applicate
[
'icon_url'
]
=
$icon_info
[
'base_url'
]
.
$icon_info
[
'file_url'
];
}
else
{
$applicate
[
'icon_url'
]
=
""
;
}
if
(
$applicate
[
'h5_icon'
])
{
if
(
$applicate
[
'h5_icon'
])
{
$icon_info
=
$coin_items
[
$applicate
[
'h5_icon'
]];
$applicate
[
'h5_icon_url'
]
=
$icon_info
[
'base_url'
]
.
$icon_info
[
'file_url'
];
}
else
{
$applicate
[
'h5_icon_url'
]
=
""
;
$applicate
[
'h5_icon_url'
]
=
$icon_info
[
'base_url'
]
.
$icon_info
[
'file_url'
];
}
else
{
$applicate
[
'h5_icon_url'
]
=
""
;
}
if
(
$applicate
[
'introduce_image'
])
{
if
(
$applicate
[
'introduce_image'
])
{
$icon_info
=
$coin_items
[
$applicate
[
'introduce_image'
]];
$applicate
[
'introduce_image_url'
]
=
$icon_info
[
'base_url'
]
.
$icon_info
[
'file_url'
];
}
else
{
$applicate
[
'introduce_image_url'
]
=
""
;
$applicate
[
'introduce_image_url'
]
=
$icon_info
[
'base_url'
]
.
$icon_info
[
'file_url'
];
}
else
{
$applicate
[
'introduce_image_url'
]
=
""
;
}
$applicate
[
'sort'
]
=
$app_cate
->
sort
;
$name_arr
=
json_decode
(
$applicate
[
'name'
],
true
);
$applicate
[
'name_ja'
]
=
$name_arr
[
'ja'
];
$applicate
[
'name_en'
]
=
$name_arr
[
'en-US'
];
$applicate
[
'name_zh'
]
=
$name_arr
[
'zh-CN'
];
$this
->
layout
=
false
;
return
$this
->
render
(
'edit'
,
[
'item'
=>
$applicate
,
'category_id'
=>
$category_id
]);
return
$this
->
render
(
'edit'
,
[
'item'
=>
$applicate
,
'category_id'
=>
$category_id
]);
}
}
}
...
...
@@ -149,7 +187,7 @@ class ApplicationController extends BaseController
$category_id
=
Yii
::
$app
->
request
->
get
(
'category_id'
);
if
(
$id
&&
$category_id
)
{
$coin_applicateion_form
=
new
CoinApplicationForm
();
return
$coin_applicateion_form
->
del
(
$id
,
$category_id
);
return
$coin_applicateion_form
->
del
(
$id
,
$category_id
);
}
return
[
'code'
=>
1
,
'msg'
=>
'failed'
];
}
...
...
@@ -160,13 +198,13 @@ class ApplicationController extends BaseController
*/
public
function
actionAddCategory
()
{
if
(
Yii
::
$app
->
request
->
isPost
)
{
if
(
Yii
::
$app
->
request
->
isPost
)
{
Yii
::
$app
->
response
->
format
=
'json'
;
$cate_id
=
Yii
::
$app
->
request
->
post
(
'cate_id'
);
$app_id
=
Yii
::
$app
->
request
->
post
(
'app_id'
);
$sort
=
Yii
::
$app
->
request
->
post
(
'sort'
,
0
);
$cate_id
=
Yii
::
$app
->
request
->
post
(
'cate_id'
);
$app_id
=
Yii
::
$app
->
request
->
post
(
'app_id'
);
$sort
=
Yii
::
$app
->
request
->
post
(
'sort'
,
0
);
$coin_applicateion_form
=
new
CoinApplicationForm
();
return
$coin_applicateion_form
->
addCategory
(
$app_id
,
$cate_id
,
$sort
);
return
$coin_applicateion_form
->
addCategory
(
$app_id
,
$cate_id
,
$sort
);
}
}
...
...
@@ -176,34 +214,34 @@ class ApplicationController extends BaseController
*/
public
function
actionImageIndex
()
{
if
(
Yii
::
$app
->
request
->
isAjax
)
{
if
(
Yii
::
$app
->
request
->
isAjax
)
{
$id
=
Yii
::
$app
->
request
->
get
(
'id'
);
$image_category
=
Yii
::
$app
->
request
->
get
(
'image_category'
,
1
);
$image_category
=
Yii
::
$app
->
request
->
get
(
'image_category'
,
1
);
Yii
::
$app
->
response
->
format
=
'json'
;
$applicate
=
CoinApplication
::
getApplicate
(
$id
);
if
(
$applicate
)
{
if
(
$image_category
==
1
)
{
if
(
$applicate
)
{
if
(
$image_category
==
1
)
{
$data
=
CoinImage
::
getItemsByImageIds
(
$applicate
->
image_ids
);
}
else
if
(
$image_category
==
2
)
{
}
else
if
(
$image_category
==
2
)
{
$data
=
CoinImage
::
getItemsByImageIds
(
$applicate
->
h5_image_ids
);
}
else
{
$data
=
[
'code'
=>
0
,
'data'
=>
[]];
}
else
{
$data
=
[
'code'
=>
0
,
'data'
=>
[]];
}
}
else
{
$data
=
[
'code'
=>
0
,
'data'
=>
[]];
}
else
{
$data
=
[
'code'
=>
0
,
'data'
=>
[]];
}
return
$data
;
}
else
{
}
else
{
$id
=
Yii
::
$app
->
request
->
get
(
'id'
);
if
(
$id
)
{
if
(
$id
)
{
$applicate
=
CoinApplication
::
getApplicate
(
$id
);
if
(
$applicate
)
{
return
$this
->
render
(
'image-index'
,[
'applicate'
=>
$applicate
]);
}
else
{
if
(
$applicate
)
{
return
$this
->
render
(
'image-index'
,
[
'applicate'
=>
$applicate
]);
}
else
{
$this
->
error
(
'id参数不合法'
,
Yii
::
$app
->
request
->
getReferrer
());
}
}
else
{
}
else
{
$this
->
error
(
'id参数不能为空'
,
Yii
::
$app
->
request
->
getReferrer
());
}
}
...
...
@@ -215,16 +253,16 @@ class ApplicationController extends BaseController
*/
public
function
actionAddImage
()
{
if
(
Yii
::
$app
->
request
->
isPost
)
{
if
(
Yii
::
$app
->
request
->
isPost
)
{
Yii
::
$app
->
response
->
format
=
'json'
;
$id
=
Yii
::
$app
->
request
->
post
(
'applicate_id'
,
0
);
$image_id
=
Yii
::
$app
->
request
->
post
(
'image'
,
0
);
$image_category
=
Yii
::
$app
->
request
->
post
(
'image_category'
,
1
);
if
(
$id
&&
$image_id
)
{
$id
=
Yii
::
$app
->
request
->
post
(
'applicate_id'
,
0
);
$image_id
=
Yii
::
$app
->
request
->
post
(
'image'
,
0
);
$image_category
=
Yii
::
$app
->
request
->
post
(
'image_category'
,
1
);
if
(
$id
&&
$image_id
)
{
$coin_applicate_form
=
new
CoinApplicationForm
();
return
$coin_applicate_form
->
addImage
(
$id
,
$image_id
,
$image_category
);
}
else
{
return
[
'code'
=>
1
,
'msg'
=>
'图片添加失败'
];
return
$coin_applicate_form
->
addImage
(
$id
,
$image_id
,
$image_category
);
}
else
{
return
[
'code'
=>
1
,
'msg'
=>
'图片添加失败'
];
}
}
}
...
...
@@ -238,10 +276,10 @@ class ApplicationController extends BaseController
Yii
::
$app
->
response
->
format
=
'json'
;
$id
=
Yii
::
$app
->
request
->
get
(
'id'
);
$applicate_id
=
Yii
::
$app
->
request
->
get
(
'applicate_id'
);
$image_category
=
Yii
::
$app
->
request
->
get
(
'image_category'
,
1
);
$image_category
=
Yii
::
$app
->
request
->
get
(
'image_category'
,
1
);
if
(
$id
&&
$applicate_id
)
{
$coin_applicateion_form
=
new
CoinApplicationForm
();
return
$coin_applicateion_form
->
delImage
(
$id
,
$applicate_id
,
$image_category
);
return
$coin_applicateion_form
->
delImage
(
$id
,
$applicate_id
,
$image_category
);
}
return
[
'code'
=>
1
,
'msg'
=>
'failed'
];
}
...
...
@@ -255,19 +293,19 @@ class ApplicationController extends BaseController
if
(
Yii
::
$app
->
request
->
isAjax
)
{
Yii
::
$app
->
response
->
format
=
'json'
;
$request
=
Yii
::
$app
->
request
;
$id
=
$request
->
get
(
'id'
,
''
);
$category_id
=
$request
->
get
(
'category_id'
,
''
);
$sort
=
$request
->
get
(
'sort'
,
1
);
if
(
$id
&&
$category_id
)
{
$app_cate
=
CoinAppCate
::
getAppCate
(
$category_id
,
$id
);
if
(
!
$app_cate
)
{
return
[
'code'
=>
1
,
'msg'
=>
'应用不存在,不能设置排序'
];
$id
=
$request
->
get
(
'id'
,
''
);
$category_id
=
$request
->
get
(
'category_id'
,
''
);
$sort
=
$request
->
get
(
'sort'
,
1
);
if
(
$id
&&
$category_id
)
{
$app_cate
=
CoinAppCate
::
getAppCate
(
$category_id
,
$id
);
if
(
!
$app_cate
)
{
return
[
'code'
=>
1
,
'msg'
=>
'应用不存在,不能设置排序'
];
}
$app_cate
->
sort
=
$sort
;
$app_cate
->
sort
=
$sort
;
$app_cate
->
save
();
return
[
'code'
=>
0
,
'msg'
=>
'应用排序设置成功'
];
}
else
{
return
[
'code'
=>
1
,
'msg'
=>
'应用排序设置失败'
];
return
[
'code'
=>
0
,
'msg'
=>
'应用排序设置成功'
];
}
else
{
return
[
'code'
=>
1
,
'msg'
=>
'应用排序设置失败'
];
}
}
}
...
...
@@ -281,18 +319,18 @@ class ApplicationController extends BaseController
if
(
Yii
::
$app
->
request
->
isAjax
)
{
Yii
::
$app
->
response
->
format
=
'json'
;
$request
=
Yii
::
$app
->
request
;
$id
=
$request
->
get
(
'id'
,
''
);
$enable
=
$request
->
get
(
'enable'
,
1
);
if
(
$id
)
{
$id
=
$request
->
get
(
'id'
,
''
);
$enable
=
$request
->
get
(
'enable'
,
1
);
if
(
$id
)
{
$applicate
=
CoinApplication
::
getApplicate
(
$id
);
if
(
!
$applicate
)
{
return
[
'code'
=>
1
,
'msg'
=>
'应用不存在,不能设置启用状态'
];
if
(
!
$applicate
)
{
return
[
'code'
=>
1
,
'msg'
=>
'应用不存在,不能设置启用状态'
];
}
$applicate
->
enable
=
$enable
;
$applicate
->
save
();
return
[
'code'
=>
0
,
'msg'
=>
'应用使用状态设置成功'
];
}
else
{
return
[
'code'
=>
1
,
'msg'
=>
'应用使用状态设置失败'
];
return
[
'code'
=>
0
,
'msg'
=>
'应用使用状态设置成功'
];
}
else
{
return
[
'code'
=>
1
,
'msg'
=>
'应用使用状态设置失败'
];
}
}
}
...
...
@@ -306,18 +344,18 @@ class ApplicationController extends BaseController
if
(
Yii
::
$app
->
request
->
isAjax
)
{
Yii
::
$app
->
response
->
format
=
'json'
;
$request
=
Yii
::
$app
->
request
;
$id
=
$request
->
get
(
'app_id'
,
''
);
$h5_image_showtype
=
$request
->
get
(
'h5_image_showtype'
,
1
);
if
(
$id
)
{
$id
=
$request
->
get
(
'app_id'
,
''
);
$h5_image_showtype
=
$request
->
get
(
'h5_image_showtype'
,
1
);
if
(
$id
)
{
$applicate
=
CoinApplication
::
getApplicate
(
$id
);
if
(
!
$applicate
)
{
return
[
'code'
=>
1
,
'msg'
=>
'应用不存在'
];
if
(
!
$applicate
)
{
return
[
'code'
=>
1
,
'msg'
=>
'应用不存在'
];
}
$applicate
->
h5_image_showtype
=
$h5_image_showtype
;
$applicate
->
save
();
return
[
'code'
=>
0
,
'msg'
=>
'显示尺寸设置成功'
];
}
else
{
return
[
'code'
=>
1
,
'msg'
=>
'显示尺寸设置失败'
];
return
[
'code'
=>
0
,
'msg'
=>
'显示尺寸设置成功'
];
}
else
{
return
[
'code'
=>
1
,
'msg'
=>
'显示尺寸设置失败'
];
}
}
}
...
...
backend/models/coin/CoinApplicationForm.php
View file @
5a848615
...
...
@@ -5,6 +5,7 @@
* Date: 2018/10/12
* Time: 19:10
*/
namespace
backend\models\coin
;
use
backend\models\BaseForm
;
...
...
@@ -12,6 +13,7 @@ use common\models\psources\CoinAppCate;
use
common\models\psources\CoinApplicateRecommend
;
use
common\models\psources\CoinApplication
;
use
Yii
;
class
CoinApplicationForm
extends
BaseForm
{
const
SCENARIO_ADD
=
'add'
;
...
...
@@ -46,8 +48,8 @@ class CoinApplicationForm extends BaseForm
public
function
scenarios
()
{
return
[
self
::
SCENARIO_ADD
=>
[
'category_id'
,
'name'
,
'h5_icon'
,
'official_url'
,
'introduce_image'
,
'show_width'
,
'show_height'
,
'open_type'
,
'open_type_app'
,
'platform_type'
,
'sort'
,
'icon'
,
'type'
,
'native_url'
,
'native_login_url'
,
'h5_url'
,
'android_url'
,
'ios_url'
,
'app_store_url'
,
'advertise'
,
'description'
,
'redirect_type'
,
'platform_id'
],
self
::
SCENARIO_EDIT
=>
[
'category_id'
,
'id'
,
'h5_icon'
,
'official_url'
,
'introduce_image'
,
'show_width'
,
'show_height'
,
'open_type'
,
'open_type_app'
,
'platform_type'
,
'name'
,
'sort'
,
'icon'
,
'type'
,
'native_url'
,
'native_login_url'
,
'h5_url'
,
'android_url'
,
'ios_url'
,
'app_store_url'
,
'advertise'
,
'description'
,
'redirect_type'
,
'platform_id'
],
self
::
SCENARIO_ADD
=>
[
'category_id'
,
'name'
,
'h5_icon'
,
'official_url'
,
'introduce_image'
,
'show_width'
,
'show_height'
,
'open_type'
,
'open_type_app'
,
'platform_type'
,
'sort'
,
'icon'
,
'type'
,
'native_url'
,
'native_login_url'
,
'h5_url'
,
'android_url'
,
'ios_url'
,
'app_store_url'
,
'advertise'
,
'description'
,
'redirect_type'
,
'platform_id'
],
self
::
SCENARIO_EDIT
=>
[
'category_id'
,
'id'
,
'h5_icon'
,
'official_url'
,
'introduce_image'
,
'show_width'
,
'show_height'
,
'open_type'
,
'open_type_app'
,
'platform_type'
,
'name'
,
'sort'
,
'icon'
,
'type'
,
'native_url'
,
'native_login_url'
,
'h5_url'
,
'android_url'
,
'ios_url'
,
'app_store_url'
,
'advertise'
,
'description'
,
'redirect_type'
,
'platform_id'
],
];
}
...
...
@@ -55,42 +57,42 @@ class CoinApplicationForm extends BaseForm
public
function
attributeLabels
()
{
return
[
'id'
=>
'ID'
,
'category_id'
=>
'分类ID'
,
'name'
=>
'名称'
,
'icon'
=>
'图标'
,
'h5_icon'
=>
'h5图标'
,
'official_url'
=>
'官方链接'
,
'introduce_image'
=>
'介绍图'
,
'sort'
=>
'排序'
,
'type'
=>
'类型'
,
'native_url'
=>
'原生链接'
,
'native_login_url'
=>
'原生登录链接'
,
'h5_url'
=>
'h5链接'
,
'android_url'
=>
'安卓链接'
,
'ios_url'
=>
'ios企业版链接'
,
'app_store_url'
=>
'ios商店版链接'
,
'advertise'
=>
'宣传语'
,
'description'
=>
'介绍'
,
'redirect_type'
=>
'跳转方式'
,
'show_width'
=>
'显示宽度'
,
'show_height'
=>
'显示高度'
,
'open_type'
=>
'H5打开方式 PC版'
,
'open_type_app'
=>
'H5打开方式 APP版'
,
'platform_type'
=>
'所属平台'
,
'platform_id'
=>
'平台Id'
'id'
=>
'ID'
,
'category_id'
=>
'分类ID'
,
'name'
=>
'名称'
,
'icon'
=>
'图标'
,
'h5_icon'
=>
'h5图标'
,
'official_url'
=>
'官方链接'
,
'introduce_image'
=>
'介绍图'
,
'sort'
=>
'排序'
,
'type'
=>
'类型'
,
'native_url'
=>
'原生链接'
,
'native_login_url'
=>
'原生登录链接'
,
'h5_url'
=>
'h5链接'
,
'android_url'
=>
'安卓链接'
,
'ios_url'
=>
'ios企业版链接'
,
'app_store_url'
=>
'ios商店版链接'
,
'advertise'
=>
'宣传语'
,
'description'
=>
'介绍'
,
'redirect_type'
=>
'跳转方式'
,
'show_width'
=>
'显示宽度'
,
'show_height'
=>
'显示高度'
,
'open_type'
=>
'H5打开方式 PC版'
,
'open_type_app'
=>
'H5打开方式 APP版'
,
'platform_type'
=>
'所属平台'
,
'platform_id'
=>
'平台Id'
];
}
public
function
rules
()
{
return
[
[[
'
name'
,
'
category_id'
],
'required'
,
'on'
=>
self
::
SCENARIO_ADD
],
[[
'category_id'
],
'required'
,
'on'
=>
self
::
SCENARIO_ADD
],
[
'sort'
,
'default'
,
'value'
=>
1
],
[
'sort'
,
'integer'
],
[
'icon'
,
'default'
,
'value'
=>
0
],
[
'advertise'
,
'string'
,
'length'
=>
[
0
,
20
]],
[
'description'
,
'string'
,
'length'
=>
[
0
,
500
]],
[
'advertise'
,
'string'
,
'length'
=>
[
0
,
20
]],
[
'description'
,
'string'
,
'length'
=>
[
0
,
500
]],
[
'type'
,
'default'
,
'value'
=>
1
],
[
'redirect_type'
,
'default'
,
'value'
=>
1
],
[
'show_height'
,
'default'
,
'value'
=>
0
],
...
...
@@ -102,14 +104,14 @@ class CoinApplicationForm extends BaseForm
public
function
checkName
(
$attribute
,
$params
)
{
$res
=
CoinApplication
::
find
()
->
where
([
'name'
=>
$this
->
$attribute
])
->
one
();
$scenario
=
$this
->
getScenario
();
if
(
$scenario
==
self
::
SCENARIO_ADD
)
{
if
(
$res
)
{
$this
->
addError
(
$attribute
,
'应用名称已存在'
);
$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
,
'应用名称已存在'
);
}
else
if
(
$scenario
==
self
::
SCENARIO_EDIT
)
{
if
(
$res
&&
$res
->
id
!=
$this
->
id
)
{
$this
->
addError
(
$attribute
,
'应用名称已存在'
);
}
}
}
...
...
@@ -119,13 +121,13 @@ class CoinApplicationForm extends BaseForm
*/
public
function
add
()
{
if
(
$this
->
validate
())
{
if
(
$this
->
validate
())
{
$tr
=
CoinApplication
::
getDb
()
->
beginTransaction
();
try
{
try
{
$coin_applicate
=
new
CoinApplication
();
$coin_applicate
->
setAttributes
(
$this
->
attributes
,
false
);
$coin_applicate
->
setAttributes
(
$this
->
attributes
,
false
);
$res
=
$coin_applicate
->
save
();
if
(
$res
)
{
if
(
$res
)
{
$coin_app_cate
=
new
CoinAppCate
();
$coin_app_cate
->
app_id
=
$coin_applicate
->
id
;
$coin_app_cate
->
cate_id
=
$this
->
category_id
;
...
...
@@ -133,15 +135,15 @@ class CoinApplicationForm extends BaseForm
$coin_app_cate
->
save
();
$tr
->
commit
();
}
return
[
'code'
=>
0
,
'msg'
=>
'应用添加成功!'
];
}
catch
(
\Exception
$e
)
{
return
[
'code'
=>
0
,
'msg'
=>
'应用添加成功!'
];
}
catch
(
\Exception
$e
)
{
$tr
->
rollBack
();
return
[
'code'
=>
1
,
'msg'
=>
$e
->
getMessage
()];
return
[
'code'
=>
1
,
'msg'
=>
$e
->
getMessage
()];
}
}
else
{
}
else
{
$error
=
self
::
getModelError
(
$this
);
return
[
'code'
=>
1
,
'msg'
=>
$error
];
return
[
'code'
=>
1
,
'msg'
=>
$error
];
}
}
...
...
@@ -150,29 +152,29 @@ class CoinApplicationForm extends BaseForm
*/
public
function
edit
()
{
if
(
$this
->
validate
())
{
if
(
$this
->
validate
())
{
$tr
=
CoinApplication
::
getDb
()
->
beginTransaction
();
try
{
try
{
$coin_applicate
=
CoinApplication
::
getApplicate
(
$this
->
id
);
if
(
$coin_applicate
)
{
if
(
$coin_applicate
)
{
$image_ids
=
$coin_applicate
->
image_ids
;
$coin_applicate
->
setAttributes
(
$this
->
attributes
,
false
);
$coin_applicate
->
setAttributes
(
$this
->
attributes
,
false
);
$coin_applicate
->
image_ids
=
$image_ids
;
$coin_applicate
->
save
();
CoinApplicateRecommend
::
updateName
(
$this
->
id
,
2
,
$this
->
name
);
//更新首页推荐name
CoinAppCate
::
updateSort
(
$this
->
category_id
,
$this
->
id
,
$this
->
sort
);
CoinApplicateRecommend
::
updateName
(
$this
->
id
,
2
,
$this
->
name
);
//更新首页推荐name
CoinAppCate
::
updateSort
(
$this
->
category_id
,
$this
->
id
,
$this
->
sort
);
$tr
->
commit
();
return
[
'code'
=>
0
,
'msg'
=>
'应用修改成功!'
];
}
else
{
return
[
'code'
=>
1
,
'msg'
=>
'应用不存在'
];
return
[
'code'
=>
0
,
'msg'
=>
'应用修改成功!'
];
}
else
{
return
[
'code'
=>
1
,
'msg'
=>
'应用不存在'
];
}
}
catch
(
\Exception
$e
)
{
}
catch
(
\Exception
$e
)
{
$tr
->
rollBack
();
return
[
'code'
=>
1
,
'msg'
=>
$e
->
getMessage
()];
return
[
'code'
=>
1
,
'msg'
=>
$e
->
getMessage
()];
}
}
else
{
}
else
{
$error
=
self
::
getModelError
(
$this
);
return
[
'code'
=>
1
,
'msg'
=>
$error
];
return
[
'code'
=>
1
,
'msg'
=>
$error
];
}
}
...
...
@@ -180,27 +182,27 @@ class CoinApplicationForm extends BaseForm
* @param $id
* 删除应用
*/
public
function
del
(
$id
,
$category_id
)
public
function
del
(
$id
,
$category_id
)
{
$coin_app_cate
=
CoinAppCate
::
getAppCate
(
$category_id
,
$id
);
if
(
$coin_app_cate
)
{
$coin_app_cate
=
CoinAppCate
::
getAppCate
(
$category_id
,
$id
);
if
(
$coin_app_cate
)
{
$tr
=
CoinApplication
::
getDb
()
->
beginTransaction
();
try
{
try
{
$cate_count
=
CoinAppCate
::
getCateCountByAppId
(
$id
);
if
(
$cate_count
==
1
)
{
$applicate
=
CoinApplication
::
getApplicate
(
$id
);
$applicate
->
delete
();
CoinApplicateRecommend
::
del
(
$id
,
2
);
//删除首页推荐
if
(
$cate_count
==
1
)
{
$applicate
=
CoinApplication
::
getApplicate
(
$id
);
$applicate
->
delete
();
CoinApplicateRecommend
::
del
(
$id
,
2
);
//删除首页推荐
}
$coin_app_cate
->
delete
();
$tr
->
commit
();
return
[
'code'
=>
0
,
'msg'
=>
'应用分类删除成功'
];
}
catch
(
\Exception
$e
)
{
return
[
'code'
=>
1
,
'msg'
=>
$e
->
getMessage
()];
return
[
'code'
=>
0
,
'msg'
=>
'应用分类删除成功'
];
}
catch
(
\Exception
$e
)
{
return
[
'code'
=>
1
,
'msg'
=>
$e
->
getMessage
()];
}
}
else
{
return
[
'code'
=>
1
,
'msg'
=>
'应用分类不存在'
];
}
else
{
return
[
'code'
=>
1
,
'msg'
=>
'应用分类不存在'
];
}
}
...
...
@@ -209,68 +211,68 @@ class CoinApplicationForm extends BaseForm
* @param $id
* 添加所属分类
*/
public
function
addCategory
(
$id
,
$category_id
,
$sort
)
public
function
addCategory
(
$id
,
$category_id
,
$sort
)
{
$coin_app_cate
=
CoinAppCate
::
getAppCate
(
$category_id
,
$id
);
if
(
$coin_app_cate
)
{
return
[
'code'
=>
1
,
'msg'
=>
'应用已属于该分类,不能再添加'
];
}
else
{
$coin_app_cate
=
CoinAppCate
::
getAppCate
(
$category_id
,
$id
);
if
(
$coin_app_cate
)
{
return
[
'code'
=>
1
,
'msg'
=>
'应用已属于该分类,不能再添加'
];
}
else
{
$coin_app_cate
=
new
CoinAppCate
();
$coin_app_cate
->
app_id
=
$id
;
$coin_app_cate
->
cate_id
=
$category_id
;
$coin_app_cate
->
sort
=
$sort
;
$coin_app_cate
->
save
();
return
[
'code'
=>
0
,
'msg'
=>
'应用所属分类添加成功'
];
return
[
'code'
=>
0
,
'msg'
=>
'应用所属分类添加成功'
];
}
}
public
function
addImage
(
$id
,
$image_id
,
$image_category
)
public
function
addImage
(
$id
,
$image_id
,
$image_category
)
{
$coin_applicate
=
CoinApplication
::
getApplicate
(
$id
);
if
(
$coin_applicate
)
{
if
(
$image_category
==
1
)
{
//app图片
if
(
$coin_applicate
)
{
if
(
$image_category
==
1
)
{
//app图片
$image_ids_field
=
'image_ids'
;
}
else
if
(
$image_category
==
2
)
{
//h5图片
}
else
if
(
$image_category
==
2
)
{
//h5图片
$image_ids_field
=
'h5_image_ids'
;
}
$image_ids
=
$coin_applicate
->
$image_ids_field
;
if
(
$image_ids
)
{
$image_items
=
explode
(
','
,
$image_ids
);
array_push
(
$image_items
,
$image_id
);
$image_ids
=
implode
(
","
,
$image_items
);
}
else
{
if
(
$image_ids
)
{
$image_items
=
explode
(
','
,
$image_ids
);
array_push
(
$image_items
,
$image_id
);
$image_ids
=
implode
(
","
,
$image_items
);
}
else
{
$image_ids
=
$image_id
;
}
$coin_applicate
->
$image_ids_field
=
$image_ids
;
$coin_applicate
->
save
();
return
[
'code'
=>
0
,
'msg'
=>
'图片添加成功'
];
}
else
{
return
[
'code'
=>
1
,
'msg'
=>
'应用不存在'
];
return
[
'code'
=>
0
,
'msg'
=>
'图片添加成功'
];
}
else
{
return
[
'code'
=>
1
,
'msg'
=>
'应用不存在'
];
}
}
public
function
delImage
(
$image_id
,
$id
,
$image_category
)
public
function
delImage
(
$image_id
,
$id
,
$image_category
)
{
$coin_applicate
=
CoinApplication
::
getApplicate
(
$id
);
if
(
$coin_applicate
)
{
if
(
$image_category
==
1
)
{
//app图片
if
(
$coin_applicate
)
{
if
(
$image_category
==
1
)
{
//app图片
$image_ids_field
=
'image_ids'
;
}
else
if
(
$image_category
==
2
)
{
//h5图片
}
else
if
(
$image_category
==
2
)
{
//h5图片
$image_ids_field
=
'h5_image_ids'
;
}
$image_ids
=
$coin_applicate
->
$image_ids_field
;
$image_items
=
explode
(
','
,
$image_ids
);
$image_items
=
array_diff
(
$image_items
,[
$image_id
]);
if
(
$image_items
)
{
$image_ids
=
implode
(
","
,
$image_items
);
}
else
{
$image_items
=
explode
(
','
,
$image_ids
);
$image_items
=
array_diff
(
$image_items
,
[
$image_id
]);
if
(
$image_items
)
{
$image_ids
=
implode
(
","
,
$image_items
);
}
else
{
$image_ids
=
''
;
}
$coin_applicate
->
$image_ids_field
=
$image_ids
;
$coin_applicate
->
save
();
return
[
'code'
=>
0
,
'msg'
=>
'图片删除成功'
];
}
else
{
return
[
'code'
=>
1
,
'msg'
=>
'应用不存在'
];
return
[
'code'
=>
0
,
'msg'
=>
'图片删除成功'
];
}
else
{
return
[
'code'
=>
1
,
'msg'
=>
'应用不存在'
];
}
}
...
...
backend/views/application-category/add.php
0 → 100644
View file @
5a848615
<?php
/**
* Created by PhpStorm.
* User: rlgyzhcn
* Date: 18-5-31
* Time: 下午6:23
*/
?>
<h4>
添加应用分类
</h4>
<style>
.layui-form-label
{
width
:
100px
;
}
</style>
<div
class=
"layui-row"
style=
"padding: 5px;"
>
<div
class=
"layui-col-md12"
>
<form
class=
"layui-form"
method=
"post"
action=
""
id=
"application-category-edit"
>
<input
name=
"_csrf"
type=
"hidden"
value=
"
<?=
Yii
::
$app
->
request
->
getCsrfToken
()
?>
"
>
<input
name=
"id"
type=
"hidden"
value=
""
>
<div
class=
"layui-inline"
>
<label
class=
"layui-form-label"
>
中文名
</label>
<div
class=
"layui-input-block"
style=
"width: 250px"
>
<input
class=
"layui-input"
name=
"name[]"
required
lay-verify=
"required"
placeholder=
""
autocomplete=
"off"
value=
""
class=
"layui-input"
>
</div>
</div>
<div
class=
"layui-inline"
>
<label
class=
"layui-form-label"
>
英文名
</label>
<div
class=
"layui-input-block"
style=
"width: 250px"
>
<input
class=
"layui-input"
name=
"name[]"
value=
""
>
</div>
</div>
<div
class=
"layui-inline"
>
<label
class=
"layui-form-label"
>
日文名
</label>
<div
class=
"layui-input-block"
style=
"width: 250px"
>
<input
class=
"layui-input"
name=
"name[]"
value=
""
>
</div>
</div>
<div
class=
"layui-form-item layui-form-text"
>
<label
class=
"layui-form-label"
>
排序
</label>
<div
class=
"layui-input-block"
style=
"width: 250px"
>
<input
type=
"text"
name=
"sort"
required
lay-verify=
"required"
placeholder=
""
autocomplete=
"off"
value=
""
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>
<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"
style=
"width: 500px"
>
<input
type=
"text"
name=
"banner_url"
required
lay-verify=
"required"
placeholder=
""
autocomplete=
"off"
class=
"layui-input"
value=
""
>
</div>
</div>
<div
class=
"layui-form-item"
>
<button
class=
"layui-btn"
>
提交
</button>
</div>
</form>
</div>
</div>
<script>
var
laydate
=
layui
.
laydate
;
laydate
.
render
({
elem
:
"#time1"
});
//图片上传
var
uploader
=
layui
.
upload
;
$_csrf
=
$
(
"input[name='_csrf']"
).
val
();
uploader
.
render
({
elem
:
"#upload1"
,
url
:
'/admin/image/upload'
,
data
:
{
_csrf
:
$_csrf
},
done
:
function
(
res
)
{
if
(
res
.
code
==
0
){
$
(
"input[name='icon']"
).
val
(
res
.
data
.
image_id
);
$
(
"#icon1"
).
attr
(
'src'
,
res
.
data
.
image_src
);
}
},
error
:
function
(
res
)
{
}
});
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
)
{
}
});
//form render
var
form
=
layui
.
form
;
form
.
render
();
</script>
backend/views/application-category/banner-index.php
View file @
5a848615
...
...
@@ -11,7 +11,7 @@
width
:
100px
;
}
</style>
<h4>
所属分类---
<?=
$applicate_category
->
name
?>
</h4>
<h4>
所属分类---
<?=
$applicate_category
->
name
[
"zh-CN"
]
?>
</h4>
<div
class=
"layui-row"
style=
"padding: 5px;"
>
<div
class=
"layui-tab layui-tab-card"
>
<ul
class=
"layui-tab-title"
>
...
...
backend/views/application-category/edit.php
0 → 100644
View file @
5a848615
<?php
/**
* Created by PhpStorm.
* User: rlgyzhcn
* Date: 18-5-31
* Time: 下午6:23
*/
?>
<style>
.layui-form-label
{
width
:
100px
;
}
</style>
<div
class=
"layui-row"
style=
"padding: 5px;"
>
<div
class=
"layui-col-md12"
>
<form
class=
"layui-form"
method=
"post"
action=
""
id=
"application-category-edit"
>
<input
name=
"_csrf"
type=
"hidden"
value=
"
<?=
Yii
::
$app
->
request
->
getCsrfToken
()
?>
"
>
<input
name=
"id"
type=
"hidden"
value=
"
<?=
$model
[
'id'
]
?>
"
>
<div
class=
"layui-inline"
>
<label
class=
"layui-form-label"
>
中文名
</label>
<div
class=
"layui-input-block"
style=
"width: 250px"
>
<input
class=
"layui-input"
name=
"name[]"
value=
"
<?=
$model
[
'name_zh'
]
?>
"
>
</div>
</div>
<div
class=
"layui-inline"
>
<label
class=
"layui-form-label"
>
英文名
</label>
<div
class=
"layui-input-block"
style=
"width: 250px"
>
<input
class=
"layui-input"
name=
"name[]"
value=
"
<?=
$model
[
'name_en'
]
?>
"
>
</div>
</div>
<div
class=
"layui-inline"
>
<label
class=
"layui-form-label"
>
日文名
</label>
<div
class=
"layui-input-block"
style=
"width: 250px"
>
<input
class=
"layui-input"
name=
"name[]"
value=
"
<?=
$model
[
'name_ja'
]
?>
"
>
</div>
</div>
<div
class=
"layui-form-item layui-form-text"
>
<label
class=
"layui-form-label"
>
排序
</label>
<div
class=
"layui-input-block"
style=
"width: 250px"
>
<input
type=
"text"
name=
"sort"
required
lay-verify=
"required"
placeholder=
""
autocomplete=
"off"
value=
"
<?=
$model
[
'sort'
]
?>
"
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=
"
<?=
$model
[
'icon_url'
]
?>
"
style=
"margin-top: 11px; max-width: 32px; max-height: 32px"
id=
"icon1"
>
</div>
<input
type=
"hidden"
name=
"icon"
value=
"
<?=
$model
[
'icon'
]
?>
"
>
</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"
>
<div
class=
"layui-inline"
>
<label
class=
"layui-form-label"
>
banner
</label>
<div
class=
"layui-input-block"
>
<img
src=
"
<?=
$model
[
'banner_image_url'
]
?>
"
style=
"margin-top: 11px; max-width: 32px; max-height: 32px"
id=
"icon2"
>
</div>
<input
type=
"hidden"
name=
"banner"
value=
"
<?=
$model
[
'banner'
]
?>
"
>
</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"
value=
"
<?=
$model
[
'banner_url'
]
?>
"
>
</div>
</div>
</form>
</div>
</div>
<script>
var
laydate
=
layui
.
laydate
;
laydate
.
render
({
elem
:
"#time1"
});
//图片上传
var
uploader
=
layui
.
upload
;
$_csrf
=
$
(
"input[name='_csrf']"
).
val
();
uploader
.
render
({
elem
:
"#upload1"
,
url
:
'/admin/image/upload'
,
data
:
{
_csrf
:
$_csrf
},
done
:
function
(
res
)
{
if
(
res
.
code
==
0
){
$
(
"input[name='icon']"
).
val
(
res
.
data
.
image_id
);
$
(
"#icon1"
).
attr
(
'src'
,
res
.
data
.
image_src
);
}
},
error
:
function
(
res
)
{
}
});
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
)
{
}
});
//form render
var
form
=
layui
.
form
;
form
.
render
();
</script>
backend/views/application-category/index.php
View file @
5a848615
<?php
/**
* Created by PhpStorm.
* User:
ZCY
* Date:
2018/10/1
1
* Time:
17:41
* User:
rlgyzhcn
* Date:
18-5-3
1
* Time:
上午9:59
*/
?>
use
backend\assets\applicationCategory\IndexAsset
;
IndexAsset
::
register
(
$this
);
?>
<style>
.layui-table-tips-c
{
padding
:
0px
;
}
</style>
<h4>
应用分类列表
</h4>
<div
class=
"layui-row"
>
<div
class=
"layui-col-md1"
>
<a
href=
"/admin/application-category/add"
>
<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>
</a>
</div>
</div>
<div
class=
"layui-
col-md10
"
>
<div
class=
"layui-
row
"
>
<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"
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=
""
>
<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>
<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 lay-event="edit">-->
<!-- <button class="layui-btn layui-btn-sm"><i class="layui-icon"></i></button>-->
<!-- </a>-->
<!-- <a lay-event="delete">-->
<!-- <button class="layui-btn layui-btn-sm layui-btn-danger"><i class="layui-icon"></i></button>-->
<!-- </a>-->
<!--</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-primary layui-btn-xs"
href
=
"/admin/application/list?id={{d.id}}"
>
应用列表
<
/a>
<
a
class
=
"layui-btn layui-btn-normal layui-btn-xs"
href
=
"/admin/application-category/banner-index?id={{d.id}}"
>
banner
图管理
<
/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/list?id={{d.id}}"
>
应用列表
<
/a>
<
a
class
=
"layui-btn layui-btn-normal layui-btn-xs"
href
=
"/admin/application-category/banner-index?id={{d.id}}"
>
banner
图管理
<
/a>
</script>
<script
type=
"text/html"
id=
"recommendTpl"
>
<
input
type
=
"checkbox"
name
=
"isrecommend"
value
=
"{{d.id}}"
lay
-
skin
=
"switch"
lay
-
text
=
"是|否"
lay
-
filter
=
"recommendDemo"
{{
d
.
isrecommend
==
1
?
'checked'
:
''
}}
>
...
...
@@ -115,267 +53,4 @@
<script
type=
"text/html"
id=
"enableTpl"
>
<
input
type
=
"checkbox"
name
=
"isenable"
value
=
"{{d.id}}"
lay
-
skin
=
"switch"
lay
-
text
=
"启用|禁用"
lay
-
filter
=
"enableDemo"
{{
d
.
enable
==
1
?
'checked'
:
''
}}
>
</script>
<script
type=
"text/javascript"
>
var
table
=
layui
.
table
;
table
.
render
({
elem
:
'#table1'
,
page
:
true
,
limit
:
10
,
skin
:
'row'
,
url
:
'/admin/application-category/index'
,
cols
:
[[
{
field
:
'id'
,
title
:
'ID'
},
{
field
:
'name'
,
title
:
'名称'
,
},
{
field
:
'coin_name'
,
title
:
'钱包'
,
},
{
field
:
'app_count'
,
title
:
'应用'
,
},
{
field
:
'icon_url'
,
title
:
'图标'
,
templet
:
'#iconTpl'
},
{
field
:
'sort'
,
title
:
'排序'
,
edit
:
'text'
},
{
field
:
'banner'
,
title
:
'banner'
,
templet
:
'#bannerTpl'
},
{
title
:
'操作'
,
templet
:
'#operationTpl'
,
width
:
300
},
{
title
:
'首页推荐'
,
field
:
'isrecommend'
,
templet
:
'#recommendTpl'
,
width
:
100
},
{
title
:
'状态'
,
field
:
'enable'
,
templet
:
'#enableTpl'
,
width
:
100
},
]],
});
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
:
'800px'
,
type
:
1
,
content
:
$
(
"#_form"
),
btn
:
[
'保存'
,
'取消'
],
success
:
function
()
{
form
.
val
(
"form1"
,
{
id
:
data
.
id
,
name
:
data
.
name
,
icon
:
data
.
icon
,
sort
:
data
.
sort
,
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
)
{
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/application-category/delete'
,
{
id
:
data
.
id
},
function
(
rev
)
{
layer
.
msg
(
rev
.
msg
);
if
(
0
==
rev
.
code
)
{
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
:
'800px'
,
type
:
1
,
content
:
$
(
"#_form"
),
btn
:
[
'保存'
,
'取消'
],
success
:
function
()
{
clearForm
();
},
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'
);
}
});
})
//图片上传
var
uploader
=
layui
.
upload
;
$_csrf
=
$
(
"input[name='_csrf']"
).
val
();
uploader
.
render
({
elem
:
"#upload1"
,
url
:
'/admin/image/upload'
,
data
:
{
_csrf
:
$_csrf
},
done
:
function
(
res
)
{
if
(
res
.
code
==
0
){
$
(
"input[name='icon']"
).
val
(
res
.
data
.
image_id
);
$
(
"#icon1"
).
attr
(
'src'
,
res
.
data
.
image_src
);
}
},
error
:
function
(
res
)
{
}
});
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
:
''
,
banner
:
''
,
banner_url
:
''
});
$
(
"#icon1"
).
attr
(
'src'
,
''
);
$
(
"#icon2"
).
attr
(
'src'
,
''
);
}
form
.
on
(
'switch(recommendDemo)'
,
function
(
obj
){
//layer.tips(this.value + ' ' + this.name + ':'+ obj.elem.checked, obj.othis);return;
if
(
obj
.
elem
.
checked
){
$
.
get
(
'/admin/applicate-recommend/add'
,
{
id
:
this
.
value
,
type
:
1
},
function
(
rev
)
{
layer
.
msg
(
rev
.
msg
);
if
(
0
==
rev
.
code
)
{
}
else
{
}
});
}
else
{
$
.
get
(
'/admin/applicate-recommend/delete'
,
{
id
:
this
.
value
,
type
:
1
},
function
(
rev
)
{
layer
.
msg
(
rev
.
msg
);
if
(
0
==
rev
.
code
)
{
}
else
{
}
});
}
});
form
.
on
(
'switch(enableDemo)'
,
function
(
obj
){
var
enable
=
1
;
if
(
obj
.
elem
.
checked
){
enable
=
1
}
else
{
enable
=
0
;
}
$
.
get
(
'/admin/application-category/set-enable'
,
{
id
:
this
.
value
,
enable
:
enable
},
function
(
rev
)
{
layer
.
msg
(
rev
.
msg
);
if
(
0
==
rev
.
code
)
{
}
else
{
}
});
});
//监听单元格编辑
table
.
on
(
'edit(table1)'
,
function
(
obj
){
var
value
=
obj
.
value
;
//得到修改后的值
var
data
=
obj
.
data
;
//得到所在行所有键值
$
.
get
(
'/admin/application-category/set-sort'
,
{
id
:
data
.
id
,
sort
:
value
},
function
(
rev
)
{
layer
.
msg
(
rev
.
msg
);
if
(
0
==
rev
.
code
)
{
table
.
reload
(
'table1'
,{});
}
else
{
}
});
});
</script>
\ No newline at end of file
backend/views/application/add.php
View file @
5a848615
...
...
@@ -46,9 +46,21 @@
</div>
</div>
<div
class=
"layui-form-item"
>
<label
class=
"layui-form-label"
>
应用名称
</label>
<label
class=
"layui-form-label"
>
中文名
</label>
<div
class=
"layui-input-block"
>
<input
class=
"layui-input"
name=
"name"
value=
""
lay-verify=
"required"
>
<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=
"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=
"name[]"
value=
""
lay-verify=
"required"
>
</div>
</div>
<div
class=
"layui-form-item"
>
...
...
backend/views/application/edit.php
View file @
5a848615
...
...
@@ -48,9 +48,21 @@
</div>
</div>
<div
class=
"layui-form-item"
>
<label
class=
"layui-form-label"
>
应用名称
</label>
<label
class=
"layui-form-label"
>
中文名
</label>
<div
class=
"layui-input-block"
>
<input
class=
"layui-input"
name=
"name"
value=
"
<?=
$item
[
'name'
]
?>
"
lay-verify=
"required"
>
<input
class=
"layui-input"
name=
"name[]"
value=
"
<?=
$item
[
'name_zh'
]
?>
"
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=
"name[]"
value=
"
<?=
$item
[
'name_en'
]
?>
"
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=
"name[]"
value=
"
<?=
$item
[
'name_ja'
]
?>
"
lay-verify=
"required"
>
</div>
</div>
<div
class=
"layui-form-item"
>
...
...
backend/views/application/list.php
View file @
5a848615
...
...
@@ -11,7 +11,7 @@
width
:
100px
;
}
</style>
<h4>
所属分类---
<?=
$parent_category
->
name
?>
</h4>
<h4>
所属分类---
<?=
$parent_category
->
name
[
"zh-CN"
]
?>
</h4>
<div
class=
"layui-row"
style=
"padding: 5px;"
>
<div
class=
"layui-col-md1"
>
<a
href=
"/admin/application/add?category_id=
<?=
$parent_category
->
id
?>
"
>
...
...
@@ -27,7 +27,7 @@
<!-- 添加页面 -->
<div
class=
"layui-row"
style=
"display: none;padding: 5px;"
id=
"_form"
>
<div
class=
"layui-col-xs6 layui-col-sm6 layui-col-md11"
>
<form
class=
"layui-form"
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
id=
"app_id"
name=
"app_id"
type=
"hidden"
value=
""
>
<div
class=
"layui-form-item"
>
...
...
@@ -58,13 +58,15 @@
<
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-normal layui-btn-xs"
lay
-
event
=
"add_category"
>
添加所属分类
<
/a>
<
a
class
=
"layui-btn layui-btn-primary layui-btn-xs"
href
=
"/admin/application/image-index?id={{d.id}}"
>
详情图管理
<
/a>
<
a
class
=
"layui-btn layui-btn-primary layui-btn-xs"
href
=
"/admin/application/image-index?id={{d.id}}"
>
详情图管理
<
/a>
</script>
<script
type=
"text/html"
id=
"recommendTpl"
>
<
input
type
=
"checkbox"
name
=
"isrecommend"
value
=
"{{d.id}}"
lay
-
skin
=
"switch"
lay
-
text
=
"是|否"
lay
-
filter
=
"recommendDemo"
{{
d
.
isrecommend
==
1
?
'checked'
:
''
}}
>
<
input
type
=
"checkbox"
name
=
"isrecommend"
value
=
"{{d.id}}"
lay
-
skin
=
"switch"
lay
-
text
=
"是|否"
lay
-
filter
=
"recommendDemo"
{{
d
.
isrecommend
==
1
?
'checked'
:
''
}}
>
</script>
<script
type=
"text/html"
id=
"enableTpl"
>
<
input
type
=
"checkbox"
name
=
"isenable"
value
=
"{{d.id}}"
lay
-
skin
=
"switch"
lay
-
text
=
"启用|禁用"
lay
-
filter
=
"enableDemo"
{{
d
.
enable
==
1
?
'checked'
:
''
}}
>
<
input
type
=
"checkbox"
name
=
"isenable"
value
=
"{{d.id}}"
lay
-
skin
=
"switch"
lay
-
text
=
"启用|禁用"
lay
-
filter
=
"enableDemo"
{{
d
.
enable
==
1
?
'checked'
:
''
}}
>
</script>
<script
type=
"text/javascript"
>
var
form
=
layui
.
form
;
...
...
@@ -75,7 +77,7 @@
elem
:
'#table1'
,
page
:
true
,
limit
:
10
,
url
:
'/admin/application/list?id='
+
category_id
,
url
:
'/admin/application/list?id='
+
category_id
,
cols
:
[[
{
field
:
'id'
,
...
...
@@ -84,6 +86,11 @@
{
field
:
'name'
,
title
:
'名称'
,
templet
:
function
(
data
)
{
var
name
=
JSON
.
parse
(
data
.
name
);
console
.
log
(
typeof
(
data
.
name
),
name
.
zh
);
return
name
.
zh
}
},
{
...
...
@@ -94,26 +101,26 @@
{
field
:
'sort'
,
title
:
'排序'
,
edit
:
'text'
edit
:
'text'
},
{
field
:
'has_h5'
,
title
:
'h5'
,
templet
:
function
(
d
)
{
if
(
d
.
has_h5
)
{
return
"有"
;
}
else
{
return
"无"
;
}
templet
:
function
(
d
)
{
if
(
d
.
has_h5
)
{
return
"有"
;
}
else
{
return
"无"
;
}
}
},
{
field
:
'has_android'
,
title
:
'安卓'
,
templet
:
function
(
d
)
{
if
(
d
.
has_android
)
{
templet
:
function
(
d
)
{
if
(
d
.
has_android
)
{
return
"有"
;
}
else
{
}
else
{
return
"无"
;
}
}
...
...
@@ -121,14 +128,14 @@
{
field
:
'has_ios'
,
title
:
'ios'
,
templet
:
function
(
d
)
{
if
(
d
.
has_ios
===
3
)
{
templet
:
function
(
d
)
{
if
(
d
.
has_ios
===
3
)
{
return
"企业版/商店版"
;
}
else
if
(
d
.
has_ios
===
2
)
{
}
else
if
(
d
.
has_ios
===
2
)
{
return
"商店版"
;
}
else
if
(
d
.
has_ios
===
1
)
{
}
else
if
(
d
.
has_ios
===
1
)
{
return
"企业版"
;
}
else
{
}
else
{
return
"无"
;
}
}
...
...
@@ -153,15 +160,15 @@
]],
});
table
.
on
(
'tool(table1)'
,
function
(
obj
)
{
table
.
on
(
'tool(table1)'
,
function
(
obj
)
{
var
data
=
obj
.
data
;
var
event
=
obj
.
event
;
if
(
event
===
'edit'
)
{
$
.
get
(
'/admin/application/edit'
,
{
id
:
data
.
id
,
category_id
:
category_id
},
function
(
str
)
{
$
.
get
(
'/admin/application/edit'
,
{
id
:
data
.
id
,
category_id
:
category_id
},
function
(
str
)
{
var
editIndex
=
layer
.
open
({
type
:
1
,
title
:
'编辑: '
+
data
.
name
,
area
:
[
'625px'
,
'800px'
],
area
:
[
'625px'
,
'800px'
],
content
:
str
,
btn
:
[
'保存'
,
'取消'
],
btn1
:
function
()
{
...
...
@@ -182,31 +189,31 @@
});
}
else
if
(
'del'
===
event
)
{
var
index
=
layer
.
confirm
(
"确认删除?"
,
{
icon
:
3
,
title
:
'删除'
},
function
()
{
$
.
get
(
'/admin/application/delete'
,
{
id
:
data
.
id
,
category_id
:
category_id
},
function
(
rev
)
{
$
.
get
(
'/admin/application/delete'
,
{
id
:
data
.
id
,
category_id
:
category_id
},
function
(
rev
)
{
layer
.
msg
(
rev
.
msg
);
if
(
0
==
rev
.
code
)
{
table
.
reload
(
'table1'
,{
page
:
{
curr
:
1
}
if
(
0
==
rev
.
code
)
{
table
.
reload
(
'table1'
,
{
page
:
{
curr
:
1
}
});
}
});
});
}
else
if
(
'add_category'
===
event
)
{
}
else
if
(
'add_category'
===
event
)
{
$
(
"#app_id"
).
val
(
data
.
id
);
var
index
=
layer
.
open
({
title
:
'添加应用分类'
,
area
:
[
'500px'
,
'400px'
],
area
:
[
'500px'
,
'400px'
],
type
:
1
,
content
:
$
(
"#_form"
),
btn
:
[
'保存'
,
'取消'
],
success
:
function
()
{
success
:
function
()
{
form
.
val
(
"form1"
,
{
cate_id
:
0
,
sort
:
''
,
});
},
btn1
:
function
()
{
$
.
post
(
'/admin/application/add-category'
,
$
(
"#form1"
).
serialize
(),
function
(
rev
)
{
btn1
:
function
()
{
$
.
post
(
'/admin/application/add-category'
,
$
(
"#form1"
).
serialize
(),
function
(
rev
)
{
layer
.
msg
(
rev
.
msg
);
if
(
0
==
rev
.
code
)
{
layer
.
close
(
index
);
...
...
@@ -214,63 +221,63 @@
}
});
},
btn2
:
function
()
{
btn2
:
function
()
{
layer
.
close
(
index
);
$
(
"#_form"
).
css
(
'display'
,
'none'
);
},
cancel
:
function
()
{
cancel
:
function
()
{
layer
.
close
(
index
);
$
(
"#_form"
).
css
(
'display'
,
'none'
);
}
});
}
});
form
.
on
(
'switch(recommendDemo)'
,
function
(
obj
)
{
form
.
on
(
'switch(recommendDemo)'
,
function
(
obj
)
{
//layer.tips(this.value + ' ' + this.name + ':'+ obj.elem.checked, obj.othis);return;
if
(
obj
.
elem
.
checked
)
{
$
.
get
(
'/admin/applicate-recommend/add'
,
{
id
:
this
.
value
,
type
:
2
},
function
(
rev
)
{
if
(
obj
.
elem
.
checked
)
{
$
.
get
(
'/admin/applicate-recommend/add'
,
{
id
:
this
.
value
,
type
:
2
},
function
(
rev
)
{
layer
.
msg
(
rev
.
msg
);
if
(
0
==
rev
.
code
)
{
}
else
{
}
else
{
}
});
}
else
{
$
.
get
(
'/admin/applicate-recommend/delete'
,
{
id
:
this
.
value
,
type
:
2
},
function
(
rev
)
{
}
else
{
$
.
get
(
'/admin/applicate-recommend/delete'
,
{
id
:
this
.
value
,
type
:
2
},
function
(
rev
)
{
layer
.
msg
(
rev
.
msg
);
if
(
0
==
rev
.
code
)
{
}
else
{
}
else
{
}
});
}
});
form
.
on
(
'switch(enableDemo)'
,
function
(
obj
)
{
form
.
on
(
'switch(enableDemo)'
,
function
(
obj
)
{
var
enable
=
1
;
if
(
obj
.
elem
.
checked
)
{
if
(
obj
.
elem
.
checked
)
{
enable
=
1
}
else
{
}
else
{
enable
=
0
;
}
$
.
get
(
'/admin/application/set-enable'
,
{
id
:
this
.
value
,
enable
:
enable
},
function
(
rev
)
{
$
.
get
(
'/admin/application/set-enable'
,
{
id
:
this
.
value
,
enable
:
enable
},
function
(
rev
)
{
layer
.
msg
(
rev
.
msg
);
if
(
0
==
rev
.
code
)
{
}
else
{
}
else
{
}
});
});
//监听单元格编辑
table
.
on
(
'edit(table1)'
,
function
(
obj
)
{
table
.
on
(
'edit(table1)'
,
function
(
obj
)
{
var
value
=
obj
.
value
;
//得到修改后的值
var
data
=
obj
.
data
;
//得到所在行所有键值
$
.
get
(
'/admin/application/set-sort'
,
{
id
:
data
.
id
,
category_id
:
category_id
,
sort
:
value
},
function
(
rev
)
{
$
.
get
(
'/admin/application/set-sort'
,
{
id
:
data
.
id
,
category_id
:
category_id
,
sort
:
value
},
function
(
rev
)
{
layer
.
msg
(
rev
.
msg
);
if
(
0
==
rev
.
code
)
{
table
.
reload
(
'table1'
,{});
}
else
{
table
.
reload
(
'table1'
,
{});
}
else
{
}
});
...
...
backend/views/coin/index.php
View file @
5a848615
<?php
/**
* Created by PhpStorm.
* User: rlgyzhcn
* Date: 18-5-31
* Time: 上午9:59
*/
use
backend\assets\coin\IndexAsset
;
IndexAsset
::
register
(
$this
);
?>
<style>
.layui-table-tips-c
{
padding
:
0px
;
}
</style>
<h4>
币种列表
</h4>
<div
class=
"layui-row"
>
<div
class=
"layui-col-md1"
>
<a
href=
"/admin/coin/add"
>
<button
class=
"layui-btn layui-btn-default"
id=
"add"
>
添加币种
</button>
</a>
</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: 100px;"
>
币种名称
</label>
<div
class=
"layui-input-inline"
>
<input
class=
"layui-input"
name=
"name"
>
</div>
</div>
<div
class=
"layui-inline"
>
<label
class=
"layui-form-label"
style=
"margin-bottom: 0; width: 100px;"
>
平台
</label>
<div
class=
"layui-input-inline"
>
<select
name=
"platform"
>
<option
value=
""
>
全部
</option>
<?php
foreach
(
$platforms
as
$platform
)
:
?>
<option
value=
"
<?=
$platform
?>
"
>
<?=
$platform
?>
</option>
<?php
endforeach
;
?>
</select>
</div>
</div>
<div
class=
"layui-inline"
>
<label
class=
"layui-form-label"
style=
"margin-bottom: 0; width: 100px;"
>
类型
</label>
<div
class=
"layui-input-inline"
>
<select
name=
"chain"
>
<option
value=
""
>
全部
</option>
<?php
foreach
(
$chains
as
$chain
)
:
?>
<option
value=
"
<?=
$chain
?>
"
>
<?=
$chain
?>
</option>
<?php
endforeach
;
?>
</select>
</div>
</div>
<div
class=
"layui-inline"
>
<label
class=
"layui-form-label"
style=
"margin-bottom: 0; width: 100px;"
>
推介币种
</label>
<div
class=
"layui-input-inline"
>
<select
name=
"recommend"
>
<option
value=
""
>
全部
</option>
<option
value=
"0"
>
否
</option>
<option
value=
"1"
>
是
</option>
</select>
</div>
</div>
<div
class=
"layui-inline"
>
<button
class=
"layui-btn"
lay-submit
lay-filter=
"form1"
>
搜索
</button>
</div>
</form>
</div>
</div>
<div
class=
"layui-row"
>
<table
class=
"layui-table"
id=
"table1"
lay-filter=
"table1"
></table>
</div>
<script
type=
"text/html"
id=
"iconTpl"
>
<
a
href
=
"{{d.icon}}"
target
=
"_blank"
><
img
src
=
"{{d.icon}}"
style
=
"max-width: 32px; max-height: 32px;"
/><
/a
>
</script>
<script
type=
"text/html"
id=
"officialTpl"
>
{{
#
if
(
d
.
official
){
}}
{{
#
layui
.
each
(
d
.
official
.
split
(
';'
),
function
(
index
,
item
){
}}
{{
#
if
(
item
){
}}
<
a
href
=
"{{ item }}"
class
=
"layui-table-link"
target
=
"_blank"
>
官网
{{
#
if
(
index
){
}}{{
index
}}{{
#
}
}}
<
/a
>
{{
#
}
}}
{{
#
});
}}
{{
#
}
else
{
}}
-
{{
#
}
}}
</script>
<script
type=
"text/html"
id=
"paperTpl"
>
{{
#
if
(
d
.
paper
){
}}
<
a
href
=
"{{d.paper}}"
class
=
"layui-table-link"
target
=
"_blank"
>
白皮书
<
/a
>
{{
#
}
else
{
}}
-
{{
#
}
}}
</script>
<script
type=
"text/html"
id=
"operationTpl"
>
<
a
lay
-
event
=
"edit"
>
<
button
class
=
"layui-btn layui-btn-sm"
><
i
class
=
"layui-icon"
>&
#
xe642
;
<
/i></
button
>
<
/a
>
<
a
lay
-
event
=
"delete"
>
<
button
class
=
"layui-btn layui-btn-sm layui-btn-danger"
><
i
class
=
"layui-icon"
>&
#
xe640
;
<
/i></
button
>
<
/a
>
</script>
<script
type=
"text/html"
id=
"exchangeTpl"
>
{{
d
.
exchange
}}
家
</script>
<script
type=
"text/html"
id=
"recommendTpl"
>
{{
#
if
(
d
.
recommend
==
0
){
}}
否
{{
#
}
else
if
(
d
.
recommend
==
1
){
}}
首页推荐
{{
#
}
else
{
}}
次页推荐
{{
#
}
}}
<?php
/**
* Created by PhpStorm.
* User: rlgyzhcn
* Date: 18-5-31
* Time: 上午9:59
*/
use
backend\assets\coin\IndexAsset
;
IndexAsset
::
register
(
$this
);
?>
<style>
.layui-table-tips-c
{
padding
:
0px
;
}
</style>
<h4>
币种列表
</h4>
<div
class=
"layui-row"
>
<div
class=
"layui-col-md1"
>
<a
href=
"/admin/coin/add"
>
<button
class=
"layui-btn layui-btn-default"
id=
"add"
>
添加币种
</button>
</a>
</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: 100px;"
>
币种名称
</label>
<div
class=
"layui-input-inline"
>
<input
class=
"layui-input"
name=
"name"
>
</div>
</div>
<div
class=
"layui-inline"
>
<label
class=
"layui-form-label"
style=
"margin-bottom: 0; width: 100px;"
>
平台
</label>
<div
class=
"layui-input-inline"
>
<select
name=
"platform"
>
<option
value=
""
>
全部
</option>
<?php
foreach
(
$platforms
as
$platform
)
:
?>
<option
value=
"
<?=
$platform
?>
"
>
<?=
$platform
?>
</option>
<?php
endforeach
;
?>
</select>
</div>
</div>
<div
class=
"layui-inline"
>
<label
class=
"layui-form-label"
style=
"margin-bottom: 0; width: 100px;"
>
类型
</label>
<div
class=
"layui-input-inline"
>
<select
name=
"chain"
>
<option
value=
""
>
全部
</option>
<?php
foreach
(
$chains
as
$chain
)
:
?>
<option
value=
"
<?=
$chain
?>
"
>
<?=
$chain
?>
</option>
<?php
endforeach
;
?>
</select>
</div>
</div>
<div
class=
"layui-inline"
>
<label
class=
"layui-form-label"
style=
"margin-bottom: 0; width: 100px;"
>
推介币种
</label>
<div
class=
"layui-input-inline"
>
<select
name=
"recommend"
>
<option
value=
""
>
全部
</option>
<option
value=
"0"
>
否
</option>
<option
value=
"1"
>
是
</option>
</select>
</div>
</div>
<div
class=
"layui-inline"
>
<button
class=
"layui-btn"
lay-submit
lay-filter=
"form1"
>
搜索
</button>
</div>
</form>
</div>
</div>
<div
class=
"layui-row"
>
<table
class=
"layui-table"
id=
"table1"
lay-filter=
"table1"
></table>
</div>
<script
type=
"text/html"
id=
"iconTpl"
>
<
a
href
=
"{{d.icon}}"
target
=
"_blank"
><
img
src
=
"{{d.icon}}"
style
=
"max-width: 32px; max-height: 32px;"
/><
/a>
</script>
<script
type=
"text/html"
id=
"officialTpl"
>
{{
#
if
(
d
.
official
){
}}
{{
#
layui
.
each
(
d
.
official
.
split
(
';'
),
function
(
index
,
item
){
}}
{{
#
if
(
item
){
}}
<
a
href
=
"{{ item }}"
class
=
"layui-table-link"
target
=
"_blank"
>
官网
{{
#
if
(
index
){
}}{{
index
}}{{
#
}
}}
<
/a>
{{
#
}
}}
{{
#
});
}}
{{
#
}
else
{
}}
-
{{
#
}
}}
</script>
<script
type=
"text/html"
id=
"paperTpl"
>
{{
#
if
(
d
.
paper
){
}}
<
a
href
=
"{{d.paper}}"
class
=
"layui-table-link"
target
=
"_blank"
>
白皮书
<
/a>
{{
#
}
else
{
}}
-
{{
#
}
}}
</script>
<script
type=
"text/html"
id=
"operationTpl"
>
<
a
lay
-
event
=
"edit"
>
<
button
class
=
"layui-btn layui-btn-sm"
><
i
class
=
"layui-icon"
>&
#
xe642
;
<
/i></
button
>
<
/a>
<
a
lay
-
event
=
"delete"
>
<
button
class
=
"layui-btn layui-btn-sm layui-btn-danger"
><
i
class
=
"layui-icon"
>&
#
xe640
;
<
/i></
button
>
<
/a>
</script>
<script
type=
"text/html"
id=
"exchangeTpl"
>
{{
d
.
exchange
}}
家
</script>
<script
type=
"text/html"
id=
"recommendTpl"
>
{{
#
if
(
d
.
recommend
==
0
){
}}
否
{{
#
}
else
if
(
d
.
recommend
==
1
){
}}
首页推荐
{{
#
}
else
{
}}
次页推荐
{{
#
}
}}
</script>
\ No newline at end of file
backend/web/js/application-category/index.js
0 → 100644
View file @
5a848615
/**
* @author rlgyzhcn@qq.com
*/
var
table
=
layui
.
table
;
var
form
=
layui
.
form
;
var
layer
=
layui
.
layer
;
form
.
render
();
var
tableIns
=
table
.
render
({
elem
:
"#table1"
,
url
:
'/admin/application-category/index'
,
limit
:
10
,
page
:
1
,
loading
:
true
,
cols
:
[[
{
field
:
'coin_name'
,
title
:
'名称'
,
templet
:
function
(
data
)
{
var
name
=
JSON
.
parse
(
data
.
name
);
console
.
log
(
typeof
(
data
.
name
),
name
.
zh
);
return
name
.
zh
}
},
{
field
:
'icon_url'
,
title
:
'图标'
,
templet
:
'#iconTpl'
},
{
field
:
'isrecommend'
,
title
:
'首页推荐'
,
templet
:
'#recommendTpl'
,
width
:
100
},
{
field
:
'enable'
,
title
:
'状态'
,
templet
:
'#enableTpl'
,
width
:
100
},
{
field
:
'id'
,
title
:
'操作'
,
templet
:
'#operationTpl'
}
]],
});
form
.
on
(
'submit(form1)'
,
function
(
data
)
{
table
.
reload
(
"table1"
,
{
where
:
data
.
field
,
page
:
{
curr
:
1
},
});
return
false
;
});
//监听单元格事件
table
.
on
(
'tool(table1)'
,
function
(
obj
)
{
var
data
=
obj
.
data
;
if
(
'del'
===
obj
.
event
)
{
var
index
=
layer
.
confirm
(
"确认删除?"
,
{
icon
:
3
,
title
:
'删除'
},
function
()
{
$
.
get
(
'/admin/application-category/delete'
,
{
id
:
data
.
id
},
function
(
rev
)
{
layer
.
msg
(
rev
.
msg
);
if
(
0
==
rev
.
code
)
{
table
.
reload
(
'table1'
,
{
page
:
{
curr
:
1
}
});
}
});
});
}
else
if
(
obj
.
event
==
'edit'
)
{
$
.
get
(
'/admin/application-category/edit'
,
{
id
:
data
.
id
},
function
(
str
)
{
var
editIndex
=
layer
.
open
({
type
:
1
,
title
:
'编辑: '
+
data
.
name
,
area
:
'625px'
,
content
:
str
,
btn
:
[
'保存'
,
'取消'
],
btn1
:
function
()
{
// console.log();
$
.
post
(
'/admin/application-category/edit'
,
$
(
"#application-category-edit"
).
serialize
(),
function
(
rev
)
{
layer
.
msg
(
rev
.
msg
);
if
(
rev
.
code
==
0
)
{
table
.
reload
(
"table1"
,
{
where
:
data
.
field
,
});
layer
.
close
(
editIndex
);
}
});
}
});
});
}
});
form
.
on
(
'switch(recommendDemo)'
,
function
(
obj
)
{
//layer.tips(this.value + ' ' + this.name + ':'+ obj.elem.checked, obj.othis);return;
if
(
obj
.
elem
.
checked
)
{
$
.
get
(
'/admin/applicate-recommend/add'
,
{
id
:
this
.
value
,
type
:
1
},
function
(
rev
)
{
layer
.
msg
(
rev
.
msg
);
if
(
0
==
rev
.
code
)
{
}
else
{
}
});
}
else
{
$
.
get
(
'/admin/applicate-recommend/delete'
,
{
id
:
this
.
value
,
type
:
1
},
function
(
rev
)
{
layer
.
msg
(
rev
.
msg
);
if
(
0
==
rev
.
code
)
{
}
else
{
}
});
}
});
form
.
on
(
'switch(enableDemo)'
,
function
(
obj
)
{
var
enable
=
1
;
if
(
obj
.
elem
.
checked
)
{
enable
=
1
}
else
{
enable
=
0
;
}
$
.
get
(
'/admin/application-category/set-enable'
,
{
id
:
this
.
value
,
enable
:
enable
},
function
(
rev
)
{
layer
.
msg
(
rev
.
msg
);
if
(
0
==
rev
.
code
)
{
}
else
{
}
});
});
\ No newline at end of file
common/models/psources/CoinApplicationCategory.php
View file @
5a848615
...
...
@@ -92,6 +92,11 @@ class CoinApplicationCategory extends BaseActiveRecord
return
self
::
find
()
->
where
([
'id'
=>
$id
])
->
one
();
}
public
static
function
getAppCategory
(
$id
)
{
return
self
::
find
()
->
where
([
'id'
=>
$id
])
->
asArray
()
->
one
();
}
public
static
function
getCateItemsArray
(
$condition
=
[])
{
return
self
::
find
()
->
where
(
$condition
)
->
asArray
()
->
all
();
...
...
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