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
18ddc65b
Commit
18ddc65b
authored
Nov 12, 2018
by
ZhuChunYang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
46d148d8
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
99 additions
and
21 deletions
+99
-21
ApplicationController.php
backend/controllers/ApplicationController.php
+12
-3
CoinApplicationForm.php
backend/models/coin/CoinApplicationForm.php
+16
-6
image-index.php
backend/views/application/image-index.php
+71
-12
No files found.
backend/controllers/ApplicationController.php
View file @
18ddc65b
...
...
@@ -164,10 +164,17 @@ class ApplicationController extends BaseController
{
if
(
Yii
::
$app
->
request
->
isAjax
){
$id
=
Yii
::
$app
->
request
->
get
(
'id'
);
$image_category
=
Yii
::
$app
->
request
->
get
(
'image_category'
,
1
);
Yii
::
$app
->
response
->
format
=
'json'
;
$applicate
=
CoinApplication
::
getApplicate
(
$id
);
if
(
$applicate
){
$data
=
CoinImage
::
getItemsByImageIds
(
$applicate
->
image_ids
);
if
(
$image_category
==
1
){
$data
=
CoinImage
::
getItemsByImageIds
(
$applicate
->
image_ids
);
}
else
if
(
$image_category
==
2
){
$data
=
CoinImage
::
getItemsByImageIds
(
$applicate
->
h5_image_ids
);
}
else
{
$data
=
[
'code'
=>
0
,
'data'
=>
[]];
}
}
else
{
$data
=
[
'code'
=>
0
,
'data'
=>
[]];
}
...
...
@@ -194,9 +201,10 @@ class ApplicationController extends BaseController
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
){
$coin_applicate_form
=
new
CoinApplicationForm
();
return
$coin_applicate_form
->
addImage
(
$id
,
$image_id
);
return
$coin_applicate_form
->
addImage
(
$id
,
$image_id
,
$image_category
);
}
else
{
return
[
'code'
=>
1
,
'msg'
=>
'图片添加失败'
];
}
...
...
@@ -208,9 +216,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
);
if
(
$id
&&
$applicate_id
)
{
$coin_applicateion_form
=
new
CoinApplicationForm
();
return
$coin_applicateion_form
->
delImage
(
$id
,
$applicate_id
);
return
$coin_applicateion_form
->
delImage
(
$id
,
$applicate_id
,
$image_category
);
}
return
[
'code'
=>
1
,
'msg'
=>
'failed'
];
}
...
...
backend/models/coin/CoinApplicationForm.php
View file @
18ddc65b
...
...
@@ -210,11 +210,16 @@ class CoinApplicationForm extends BaseForm
}
}
public
function
addImage
(
$id
,
$image_id
)
public
function
addImage
(
$id
,
$image_id
,
$image_category
)
{
$coin_applicate
=
CoinApplication
::
getApplicate
(
$id
);
if
(
$coin_applicate
){
$image_ids
=
$coin_applicate
->
image_ids
;
if
(
$image_category
==
1
){
//app图片
$image_ids_field
=
'image_ids'
;
}
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
);
...
...
@@ -222,7 +227,7 @@ class CoinApplicationForm extends BaseForm
}
else
{
$image_ids
=
$image_id
;
}
$coin_applicate
->
image_ids
=
$image_ids
;
$coin_applicate
->
$image_ids_field
=
$image_ids
;
$coin_applicate
->
save
();
return
[
'code'
=>
0
,
'msg'
=>
'图片添加成功'
];
}
else
{
...
...
@@ -230,11 +235,16 @@ class CoinApplicationForm extends BaseForm
}
}
public
function
delImage
(
$image_id
,
$id
)
public
function
delImage
(
$image_id
,
$id
,
$image_category
)
{
$coin_applicate
=
CoinApplication
::
getApplicate
(
$id
);
if
(
$coin_applicate
){
$image_ids
=
$coin_applicate
->
image_ids
;
if
(
$image_category
==
1
){
//app图片
$image_ids_field
=
'image_ids'
;
}
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
){
...
...
@@ -242,7 +252,7 @@ class CoinApplicationForm extends BaseForm
}
else
{
$image_ids
=
''
;
}
$coin_applicate
->
image_ids
=
$image_ids
;
$coin_applicate
->
$image_ids_field
=
$image_ids
;
$coin_applicate
->
save
();
return
[
'code'
=>
0
,
'msg'
=>
'图片删除成功'
];
}
else
{
...
...
backend/views/application/image-index.php
View file @
18ddc65b
...
...
@@ -13,20 +13,30 @@
</style>
<h4>
所属应用---
<?=
$applicate
->
name
?>
</h4>
<div
class=
"layui-row"
style=
"padding: 5px;"
>
<div
class=
"layui-col-md1"
>
<button
class=
"layui-btn layui-btn-default"
id=
"add"
>
添加应用图片
</button>
<div
class=
"layui-tab layui-tab-card"
>
<ul
class=
"layui-tab-title"
>
<li
class=
"layui-this"
>
APP应用
</li>
<li>
H5应用
</li>
</ul>
<div
class=
"layui-tab-content"
>
<div
class=
"layui-tab-item layui-show"
>
<button
class=
"layui-btn layui-btn-default add_image"
image_category=
"1"
>
添加APP图片
</button>
<table
class=
"layui-table"
id=
"table1"
lay-filter=
"table1"
></table>
</div>
<div
class=
"layui-tab-item"
>
<button
class=
"layui-btn layui-btn-default add_image"
image_category=
"2"
>
添加H5图片
</button>
<table
class=
"layui-table"
id=
"table2"
lay-filter=
"table2"
></table>
</div>
</div>
</div>
</div>
<div
class=
"layui-col-md10"
>
<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
id=
"applicate_id"
name=
"applicate_id"
type=
"hidden"
value=
"
<?=
$applicate
->
id
?>
"
>
<input
id=
"image_category"
name=
"image_category"
type=
"hidden"
value=
""
>
<div
class=
"layui-form-item"
>
<div
class=
"layui-inline"
>
<label
class=
"layui-form-label"
>
图标
</label>
...
...
@@ -58,7 +68,7 @@
var
applicate_id
=
$
(
"#applicate_id"
).
val
();
table
.
render
({
elem
:
'#table1'
,
url
:
'/admin/application/image-index?id='
+
applicate_id
,
url
:
'/admin/application/image-index?id='
+
applicate_id
+
"&image_category=1"
,
cols
:
[[
{
field
:
'id'
,
...
...
@@ -78,13 +88,34 @@
},
]],
});
table
.
render
({
elem
:
'#table2'
,
url
:
'/admin/application/image-index?id='
+
applicate_id
+
"&image_category=2"
,
cols
:
[[
{
field
:
'id'
,
title
:
'图片ID'
},
{
field
:
'image_url'
,
title
:
'图片链接'
,
templet
:
function
(
d
){
return
"<a href='"
+
d
.
image_url
+
"' target='_blank'>"
+
d
.
image_url
+
"</a>"
;
}
},
{
title
:
'操作'
,
templet
:
'#operationTpl'
,
width
:
300
},
]],
});
table
.
on
(
'tool(table1)'
,
function
(
obj
)
{
var
data
=
obj
.
data
;
var
event
=
obj
.
event
;
if
(
event
===
'del'
)
{
var
index
=
layer
.
confirm
(
"确认删除?"
,
{
icon
:
3
,
title
:
'删除'
},
function
()
{
$
.
get
(
'/admin/application/delete-image'
,
{
id
:
data
.
id
,
applicate_id
:
applicate_id
},
function
(
rev
)
{
$
.
get
(
'/admin/application/delete-image'
,
{
id
:
data
.
id
,
applicate_id
:
applicate_id
,
image_category
:
1
},
function
(
rev
)
{
layer
.
msg
(
rev
.
msg
);
if
(
0
==
rev
.
code
)
{
table
.
reload
(
'table1'
);
...
...
@@ -93,8 +124,24 @@
});
}
});
table
.
on
(
'tool(table2)'
,
function
(
obj
)
{
var
data
=
obj
.
data
;
var
event
=
obj
.
event
;
if
(
event
===
'del'
)
{
var
index
=
layer
.
confirm
(
"确认删除?"
,
{
icon
:
3
,
title
:
'删除'
},
function
()
{
$
.
get
(
'/admin/application/delete-image'
,
{
id
:
data
.
id
,
applicate_id
:
applicate_id
,
image_category
:
2
},
function
(
rev
)
{
layer
.
msg
(
rev
.
msg
);
if
(
0
==
rev
.
code
)
{
table
.
reload
(
'table2'
);
}
});
});
}
});
$
(
'#add'
).
click
(
function
()
{
$
(
'.add_image'
).
click
(
function
()
{
var
image_category
=
$
(
this
).
attr
(
'image_category'
);
$
(
'#image_category'
).
val
(
image_category
);
var
index
=
layer
.
open
({
title
:
'添加图片'
,
area
:
'800px'
,
...
...
@@ -110,7 +157,7 @@
if
(
0
==
rev
.
code
)
{
layer
.
close
(
index
);
$
(
"#_form"
).
css
(
'display'
,
'none'
);
table
.
reload
(
'table
1'
);
table
.
reload
(
'table
'
+
image_category
);
}
});
},
...
...
@@ -132,7 +179,17 @@
uploader
.
render
({
elem
:
"#upload1"
,
url
:
'/admin/image/upload'
,
data
:
{
_csrf
:
$_csrf
,
image_type
:
3
},
before
:
function
(
input
){
var
data
=
{};
var
image_category
=
$
(
'#image_category'
).
val
();
data
.
_csrf
=
$_csrf
;
if
(
image_category
==
1
){
data
.
image_type
=
3
;
}
else
if
(
image_category
==
2
){
data
.
image_type
=
6
;;
}
this
.
data
=
data
;
},
done
:
function
(
res
)
{
if
(
res
.
code
==
0
){
$
(
"input[name='image']"
).
val
(
res
.
data
.
image_id
);
...
...
@@ -149,4 +206,5 @@
});
$
(
"#image1"
).
attr
(
'src'
,
''
);
}
</script>
\ No newline at end of file
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