Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tl_estate
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
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
hujun
tl_estate
Commits
1c2c3f0e
Commit
1c2c3f0e
authored
Dec 19, 2017
by
clone
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
banner模块
parent
0189db8f
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
180 additions
and
54 deletions
+180
-54
AttentionShop.php
application/api/controller/AttentionShop.php
+3
-0
config.php
application/config.php
+1
-0
Banner.php
application/index/controller/Banner.php
+46
-16
BannerModel.php
application/model/BannerModel.php
+18
-13
route.php
application/route.php
+8
-0
banner.js
public/resource/js/banner.js
+94
-13
banner_template_tpl.html
public/resource/template/banner_template_tpl.html
+10
-12
No files found.
application/api/controller/AttentionShop.php
View file @
1c2c3f0e
...
...
@@ -5,6 +5,7 @@ namespace app\api\controller;
use
app\api\extend\Basic
;
use
app\model\AttentionModel
;
use
think\Request
;
use
app\model\HouseImgs
;
/**
* Created by PhpStorm.
...
...
@@ -17,11 +18,13 @@ class AttentionShop extends Basic
{
protected
$attentionModel
;
protected
$dbImg
;
public
function
__construct
(
$request
=
null
)
{
parent
::
__construct
(
$request
);
$this
->
attentionModel
=
new
AttentionModel
();
$this
->
dbImg
=
new
HouseImgs
();
}
/**
...
...
application/config.php
View file @
1c2c3f0e
...
...
@@ -10,6 +10,7 @@
// +----------------------------------------------------------------------
define
(
'IMG_PATH'
,
'https://admin.tonglianjituan.com/houseImg/'
);
define
(
'LOCAL_IMG_HOST'
,
'/resource/lib/Attachments/'
);
return
[
// +----------------------------------------------------------------------
// | 应用设置
...
...
application/index/controller/Banner.php
View file @
1c2c3f0e
...
...
@@ -32,7 +32,8 @@ class Banner extends Basic
return
view
(
"banner/banner"
);
}
public
function
getBannerList
(){
public
function
getBannerList
()
{
$field
=
"id,title,pic_path,url,sort,hits,is_show,up_user,create_time,update_time"
;
$params
[
'is_show'
]
=
array
(
"eq"
,
0
);
$pageNo
=
empty
(
$_POST
[
'pageNo'
])
?
1
:
$_POST
[
'pageNo'
];
...
...
@@ -51,34 +52,62 @@ class Banner extends Basic
*/
public
function
addOrSave
()
{
/* $params = array(
"id" => 2,
"is_show" => 0
);
$msg = isset($params['id']) ? "修改" : "新增";
$result = $this->bannerModel->addOrUpdate($params);
if ($result['code'] == 200) {
return $this->response("200", $msg . "成功", $result["msg"]);
} else {
return $this->response("101", $msg . $result["msg"]);
}*/
/* $params = array(
"id" => 2,
"is_show" => 0
);*/
if
(
isset
(
$_POST
[
"id"
]))
{
$params
[
"id"
]
=
$_POST
[
"id"
];
}
if
(
isset
(
$_POST
[
"title"
]))
{
$params
[
"title"
]
=
$_POST
[
"title"
];
}
if
(
isset
(
$_POST
[
"url"
]))
{
$params
[
"url"
]
=
$_POST
[
"url"
];
}
if
(
isset
(
$_POST
[
"cover_image"
]))
{
$params
[
"cover_image"
]
=
$_POST
[
"cover_image"
];
}
if
(
isset
(
$_POST
[
"sort"
]))
{
$params
[
"sort"
]
=
$_POST
[
"sort"
];
}
if
(
isset
(
$_POST
[
"is_show"
]))
{
$params
[
"is_show"
]
=
$_POST
[
"is_show"
];
}
if
(
empty
(
$params
[
"title"
])
||
empty
(
$params
[
"url"
])
||
empty
(
$params
[
"cover_image"
])
||
empty
(
$params
[
"sort"
]))
{
return
$this
->
response
(
"101"
,
"请提交正确的请求参数"
);
}
if
(
isset
(
$params
[
'id'
]))
{
$msg
=
"修改"
;
}
else
{
$msg
=
"新增"
;
$params
[
"is_show"
]
=
0
;
}
$result
=
$this
->
bannerModel
->
addOrUpdate
(
$params
);
if
(
$result
[
'code'
]
==
200
)
{
return
$this
->
response
(
"200"
,
$msg
.
"成功"
,
$result
[
"msg"
]);
}
else
{
return
$this
->
response
(
"101"
,
$msg
.
$result
[
"msg"
]);
}
}
/**
* 修改是否显示
* @return \think\Response
*/
public
function
upIsShow
()
{
/*
$params = array(
"id" =>
1
,
"is_show" =>
1
$params
=
array
(
"id"
=>
$_POST
[
"id"
]
,
"is_show"
=>
$_POST
[
"is_show"
]
);
$result
=
$this
->
bannerModel
->
upIsShow
(
$params
);
if
(
$result
[
'code'
]
==
200
)
{
return
$this
->
response
(
"200"
,
"update success"
,
$result
[
"msg"
]);
}
else
{
return
$this
->
response
(
"101"
,
"update error"
);
}
*/
}
}
}
\ No newline at end of file
application/model/BannerModel.php
View file @
1c2c3f0e
...
...
@@ -39,8 +39,8 @@ class BannerModel extends Model
if
(
isset
(
$param
[
'title'
]))
{
$arr
[
"title"
]
=
$param
[
'title'
];
}
if
(
isset
(
$param
[
'
pic_path
'
]))
{
$arr
[
"pic_path"
]
=
$param
[
'
pic_path
'
];
if
(
isset
(
$param
[
'
cover_image
'
]))
{
$arr
[
"pic_path"
]
=
$param
[
'
cover_image
'
];
}
if
(
isset
(
$param
[
'url'
]))
{
$arr
[
"url"
]
=
$param
[
'url'
];
...
...
@@ -48,13 +48,13 @@ class BannerModel extends Model
if
(
isset
(
$param
[
'sort'
]))
{
$arr
[
"sort"
]
=
$param
[
'sort'
];
}
if
(
isset
(
$param
[
'
title
'
]))
{
if
(
isset
(
$param
[
'
is_show
'
]))
{
$arr
[
"is_show"
]
=
$param
[
'is_show'
];
}
$saveWhere
=
array
();
if
(
isset
(
$param
[
'id'
]))
{
$result
=
$this
->
db
$result
=
$this
->
where
(
"id="
.
$param
[
'id'
])
->
select
();
if
(
count
(
$result
)
>
0
)
{
...
...
@@ -63,15 +63,19 @@ class BannerModel extends Model
return
[
"code"
=>
"101"
,
"msg"
=>
"数据不存在"
];
}
}
else
{
$arr
[
"create_time"
]
=
date
(
"Y-m-d H:i:s"
,
time
());
$arr
[
"update_time"
]
=
date
(
"Y-m-d H:i:s"
,
time
());
$arr
[
"create_time"
]
=
date
(
"Y-m-d H:i:s"
,
time
());
$arr
[
"update_time"
]
=
date
(
"Y-m-d H:i:s"
,
time
());
}
//todo 暂时未做登陆页
$arr
[
"up_user"
]
=
"admin"
;
Db
::
startTrans
();
try
{
if
(
isset
(
$saveWhere
[
"id"
])){
$id
=
$banner
->
save
(
$arr
,
$saveWhere
);
}
else
{
$id
=
$banner
->
save
(
$arr
);
if
(
isset
(
$saveWhere
[
"id"
]))
{
$id
=
$this
->
save
(
$arr
,
$saveWhere
);
}
else
{
//print_r($arr);exit;
$id
=
$this
->
save
(
$arr
);
}
Db
::
commit
();
return
[
"code"
=>
"200"
,
"msg"
=>
$id
];
...
...
@@ -92,11 +96,11 @@ class BannerModel extends Model
$banner
=
$this
->
db
;
$arr
=
array
(
"is_show"
=>
$param
[
'is_show'
],
"update_time"
=>
date
(
"Y-m-d H:i:s"
,
time
())
"update_time"
=>
date
(
"Y-m-d H:i:s"
,
time
())
);
Db
::
startTrans
();
try
{
$id
=
$
banner
->
save
(
$arr
,[
"id"
=>
$param
[
"id"
]
]);
$id
=
$
this
->
save
(
$arr
,
[
"id"
=>
$param
[
"id"
]
]);
Db
::
commit
();
return
[
"code"
=>
"200"
,
"msg"
=>
$id
];
}
catch
(
\Exception
$e
)
{
...
...
@@ -130,7 +134,8 @@ class BannerModel extends Model
* @param $params
* @return int|string
*/
function
getBannerTotal
(
$params
){
function
getBannerTotal
(
$params
)
{
return
$this
->
db
->
where
(
$params
)
->
count
();
...
...
application/route.php
View file @
1c2c3f0e
...
...
@@ -56,8 +56,16 @@ Route::group('index', [
'consumer_list'
=>
[
'index/member.index/consumer_list'
,
[
'method'
=>
'get'
]
],
'diagram_list'
=>
[
'index/member.index/diagram_list'
,
[
'method'
=>
'get'
]
],
'entrust_list'
=>
[
'index/member.index/entrust_list'
,
[
'method'
=>
'get'
]
],
//banner模块
'banner'
=>
[
'index/banner/index'
,
[
'method'
=>
'get'
]
],
'bannerList'
=>
[
'index/banner/getBannerList'
,
[
'method'
=>
'post'
]
],
'addOrSave'
=>
[
'index/banner/addOrSave'
,
[
'method'
=>
'post'
]
],
'upIsShow'
=>
[
'index/banner/upIsShow'
,
[
'method'
=>
'post'
]
],
'usersList'
=>
[
'index/member/getUserList'
,[
'method'
=>
'get'
]],
'users_list'
=>
[
'index/member/index'
]
]);
...
...
public/resource/js/banner.js
View file @
1c2c3f0e
...
...
@@ -5,7 +5,7 @@ define (['doT', 'text!temp/banner_template_tpl.html', 'ckfinder', 'ckfinderStart
var
banner
=
{
pageNo
:
1
,
/*第几页*/
pageSize
:
15
,
/*每页显示多少条*/
datas
:
""
,
init
:
function
()
{
//初始化dot
$
(
"body"
).
append
(
template
);
...
...
@@ -18,10 +18,53 @@ define (['doT', 'text!temp/banner_template_tpl.html', 'ckfinder', 'ckfinderStart
BrowseServer
(
'cover_image'
);
});
$
(
'#modal-add-do'
).
on
(
'show.bs.modal'
,
function
()
{
$
(
"#editor_modal_title"
).
html
(
"编辑广告"
);
});
$
(
"#save_banner"
).
click
(
function
()
{
banner
.
addBanner
();
var
params
=
{};
params
.
title
=
$
(
"#title"
).
val
();
params
.
url
=
$
(
"#url"
).
val
();
params
.
cover_image
=
$
(
"#cover_image"
).
val
();
params
.
sort
=
$
(
"#sort"
).
val
();
if
(
!
params
.
title
||
params
.
title
==
null
)
{
alert
(
"banner名称不能为空"
);
return
false
;
}
if
(
!
params
.
url
||
params
.
url
==
null
)
{
alert
(
"url不能为空"
);
return
false
;
}
if
(
!
params
.
cover_image
||
params
.
cover_image
==
null
)
{
alert
(
"banner图片不能为空"
);
return
false
;
}
if
(
!
params
.
sort
||
params
.
sort
==
null
)
{
alert
(
"banner排序不能为空"
);
return
false
;
}
if
(
$
(
"#id"
).
val
())
{
params
.
id
=
$
(
"#id"
).
val
();
}
banner
.
addOrUpdateBanner
(
params
);
});
$
(
"#confirm_delete"
).
click
(
function
(){
var
params
=
{};
params
.
id
=
$
(
"#delete_id"
).
val
();
params
.
is_show
=
1
;
banner
.
deleteBanner
(
params
);
});
/* $(document).delegate(".modal_editor", "click", function () {
console.log(11111111);
});*/
},
/*获取banner list*/
getBannerList
:
function
(
pageNo
)
{
...
...
@@ -32,7 +75,7 @@ define (['doT', 'text!temp/banner_template_tpl.html', 'ckfinder', 'ckfinderStart
params
.
pageSize
=
banner
.
pageSize
;
$
.
ajax
({
url
:
'/index/bannerList'
,
url
:
'/
admin.php/
index/bannerList'
,
type
:
'POST'
,
async
:
true
,
data
:
params
,
...
...
@@ -54,20 +97,58 @@ define (['doT', 'text!temp/banner_template_tpl.html', 'ckfinder', 'ckfinderStart
}
})
})
;
},
addBanner
:
function
()
{
var
params
=
{};
params
.
title
=
$
(
"#title"
).
val
();
params
.
intro
=
$
(
"#intro"
).
val
();
params
.
url
=
$
(
"#url"
).
val
();
params
.
cover_image
=
$
(
"#cover_image"
).
val
();
params
.
sort
=
$
(
"#sort"
).
val
();
if
(
empty
(
params
.
title
))
{
addOrUpdateBanner
:
function
(
params
)
{
$
.
ajax
({
url
:
'/admin.php/index/addOrSave'
,
type
:
'POST'
,
async
:
true
,
data
:
params
,
dataType
:
'json'
,
success
:
function
(
data
)
{
$
(
"#modal-add-do"
).
modal
(
'hide'
);
if
(
data
.
code
==
"101"
)
{
alert
(
data
.
msg
);
return
false
;
}
banner
.
getBannerList
(
banner
.
pageNo
);
}
}
});
},
deleteBanner
:
function
(
params
){
$
.
ajax
({
url
:
'/admin.php/index/upIsShow'
,
type
:
'POST'
,
async
:
true
,
data
:
params
,
dataType
:
'json'
,
success
:
function
(
data
)
{
$
(
"#modal-delete"
).
modal
(
'hide'
);
if
(
data
.
code
==
"101"
)
{
alert
(
data
.
msg
);
return
false
;
}
banner
.
getBannerList
(
banner
.
pageNo
);
}
});
}
};
return
banner
});
function
confirms
(
obj
)
{
var
item
=
$
(
obj
).
parents
(
"tr"
).
find
(
"td"
);
$
(
"#id"
).
val
(
$
(
obj
).
attr
(
"data-id"
));
$
(
"#title"
).
val
(
item
.
eq
(
0
).
html
());
$
(
"#url"
).
val
(
item
.
eq
(
2
).
html
());
$
(
"#cover_image"
).
val
(
item
.
eq
(
1
).
find
(
"input"
).
val
());
$
(
"#sort"
).
val
(
item
.
eq
(
3
).
html
());
}
function
delete_banner
(
obj
)
{
$
(
"#delete_id"
).
val
(
$
(
obj
).
attr
(
"data-id"
));
}
public/resource/template/banner_template_tpl.html
View file @
1c2c3f0e
<script
id=
"banner_list_tpl"
type=
"text/template"
>
[
%
if
(
it
)
{
%
]
[
%
for
(
var
item
in
it
){
%
]
<
tr
>
<
tr
>
<
td
>
[
%=
it
[
item
][
"title"
]
%
]
<
/td
>
<
td
>
<
img
src
=
"[%= it[item]['pic_path'] %]"
class
=
"diagram-image"
>
<
input
type
=
"hidden"
value
=
'[%= it[item]["pic_path"] %]'
>
<
img
src
=
'/resource/lib/Attachments/[%= it[item]["pic_path"] %]'
class
=
"diagram-image"
>
<
/td
>
<
td
>
[
%=
it
[
item
][
"url"
]
%
]
<
/td
>
<
td
>
[
%=
it
[
item
][
"sort"
]
%
]
<
/td
>
<
td
>
[
%=
it
[
item
][
"hits"
]
%
]
<
/td
>
<
td
>
[
%=
it
[
item
][
"up_user"
]
%
]
<
/td
>
<
td
>
<
a
class
=
"btn1 btn-success "
href
=
"#modal-
do"
data
-
toggle
=
"modal"
>
<
a
class
=
"btn1 btn-success "
href
=
"#modal-
add-do"
data
-
toggle
=
"modal"
onclick
=
"confirms(this)"
data
-
id
=
"[%= it[item]['id'] %]"
>
编辑
<
/a
>
<
a
class
=
"btn1 btn-danger "
href
=
"#modal-delete"
data
-
toggle
=
"modal"
>
<
a
class
=
"btn1 btn-danger "
href
=
"#modal-delete"
data
-
toggle
=
"modal"
onclick
=
"delete_banner(this)"
data
-
id
=
"[%= it[item]['id'] %]"
>
删除
<
/a
>
<
/td
>
...
...
@@ -42,13 +43,14 @@
</div>
<div
class=
"modal-body"
>
<div
class=
"modal-body"
>
<input
type=
"hidden"
value=
""
id=
"delete_id"
/>
确认删除吗?
</div>
</div>
<div
class=
"modal-footer"
>
<button
type=
"button"
class=
"btn btn-default"
data-dismiss=
"modal"
>
关闭
</button>
<button
type=
"button"
class=
"btn btn-primary"
>
<button
type=
"button"
class=
"btn btn-primary"
id=
"confirm_delete"
>
删除
</button>
</div>
...
...
@@ -63,22 +65,18 @@
<div
class=
"modal-header"
>
<button
type=
"button"
class=
"close"
data-dismiss=
"modal"
aria-label=
"Close"
><span
aria-hidden=
"true"
>
×
</span>
</button>
<h4
class=
"modal-title"
>
新增广告
</h4>
<h4
class=
"modal-title"
id=
"editor_modal_title"
>
新增广告
</h4>
</div>
<div
class=
"modal-body"
>
<form
class=
"form-horizontal"
>
<div
class=
"form-group"
>
<label
class=
"col-sm-3 control-label"
>
标题:
</label>
<div
class=
"col-sm-9"
>
<input
type=
"hidden"
value=
""
id=
"id"
/>
<input
type=
"text"
class=
"form-control btn6"
name=
"title"
id=
"title"
placeholder=
"请输入标题"
>
</div>
</div>
<div
class=
"form-group"
>
<label
class=
"col-sm-3 control-label"
>
备注:
</label>
<div
class=
"col-sm-9"
>
<input
type=
"text"
class=
"form-control btn6"
name=
"title"
id=
"intro"
placeholder=
"请输入备注"
>
</div>
</div>
<div
class=
"form-group"
>
<label
class=
"col-sm-3 control-label"
>
链接:
</label>
<div
class=
"col-sm-9"
>
...
...
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