作者 景龙
1 个管道 的构建 通过 耗费 1 秒

修复音频,增加搜索

... ... @@ -15,6 +15,7 @@ use app\portal\model\MobileCodeModel;
use think\Db;
class CommonController extends HomeBaseController
{
//助通科技网址:http://mix2.zthysms.com/login
private $url = 'http://api.mix2.zthysms.com/v2/sendSmsTp';//短信请求地址
private $username = 'dujiaoxinghy';//用户名
private $password = 'eU3OeYmx';//密码
... ...
... ... @@ -6,6 +6,7 @@
*/
namespace app\portal\controller;
use app\portal\model\CityCategoryModel;
use app\portal\model\UserModel;
use app\portal\validate\UsersValidate;
use cmf\controller\HomeBaseController;
... ... @@ -17,7 +18,7 @@ use think\Config;
class LoginController extends HomeBaseController
{
private $limit = 8;//收藏,搜索分页
//登录页面
public function login(){
return $this->fetch();
... ... @@ -174,7 +175,7 @@ class LoginController extends HomeBaseController
//我的收藏列表
public function myCollection(){
$limit = 8;
$limit = $this->limit;
$uid = cmf_get_current_user_id();
$collectionModel = new CollectionModel();
$res = $collectionModel
... ... @@ -206,6 +207,127 @@ class LoginController extends HomeBaseController
return $this->fetch();
}
//搜索列表
public function searchList(){
$keyword = $this->request->param('keyword');
if(isset($keyword) && !empty($keyword)){
$limit = $this->limit;
$res = Db::name('portal_post')
->alias('p')
->join('city_category c','p.city_id = c.id','LEFT')
->join('portal_category_post c_p','p.id = c_p.post_id','LEFT')
->where('p.post_title','like','%'.$keyword.'%')
->where('c_p.category_id','<>',CityCategoryModel::xqyy)
->where('c_p.category_id','<>',CityCategoryModel::xyhl)
->where('p.delete_time', 0)
->field('p.id,p.post_title,p.post_excerpt,p.post_favorites,c.name city_name')
->order('p.weigh desc')
->paginate($limit,false,['query'=>request()->param()]);
$data = $res->toArray();
$page = $res->render();
$post_ids = array_column($data['data'],'id');
//查找分类名称
$category = Db::name('portal_category_post')
->alias('c_p')
->join('portal_category c','c_p.category_id = c.id','LEFT')
->whereIn('c_p.post_id',$post_ids)
->field('c.id,c_p.post_id,c.name')
->select()
->toArray();
foreach($data['data'] as &$value){
$value['post_title'] = str_replace($keyword,'<span style="color:rgba(9, 255, 142, 1);">'.$keyword.'</span>',$value['post_title']);
foreach($category as $item){
if($value['id'] == $item['post_id']){
$value['category_name'] = $item['name'];
$value['post_url'] = $this->getDetailUrl($item['id']);
}
}
}
//查询总数
$count = Db::name('portal_post')
->alias('p')
->join('portal_category_post c_p','p.id = c_p.post_id','LEFT')
->where('p.post_title','like','%'.$keyword.'%')
->where('c_p.category_id','<>',CityCategoryModel::xqyy)
->where('c_p.category_id','<>',CityCategoryModel::xyhl)
->where('p.delete_time', 0)
->count();
}else{
$count = 0;
$data['data'] = [];
$page = '';
}
$this->assign('count',$count);
$this->assign('res',$data['data']);
$this->assign('page',$page);
return $this->fetch();
}
//获取各个板块详情页位置
public function getDetailUrl($c_id){
$url = '';
switch ($c_id) {
case CityCategoryModel::xqgs:
$url = '/portal/star/getStoryDetail';
break;
case CityCategoryModel::whmj:
$url = '/portal/star/getSceneryDetail';
break;
case CityCategoryModel::yyzx:
$url = '/portal/star/getFoodDetail';
break;
case CityCategoryModel::lsmq:
$url = '/portal/star/getHotelDetail';
break;
case CityCategoryModel::hlst:
$url = '/portal/star/getEcologyDetail';
break;
case CityCategoryModel::blcx:
$url = '/portal/star/getTravelDetail';
break;
case CityCategoryModel::mxft:
$url = '/portal/region/getStarDetail';
break;
case CityCategoryModel::djkb:
$url = '/portal/region/getNewsDetail';
break;
case CityCategoryModel::djrz:
$url = '/portal/region/getNoteDetail';
break;
case CityCategoryModel::tqwl:
$url = '/portal/region/getFutureDetail';
break;
case CityCategoryModel::qlxc:
$url = '/portal/enjoy/getEnjoyDetail';
break;
case CityCategoryModel::sjmy:
$url = '/portal/enjoy/getEnjoyDetail';
break;
case CityCategoryModel::stsy:
$url = '/portal/enjoy/getEnjoyDetail';
break;
case CityCategoryModel::hwtt:
$url = '/portal/enjoy/getEnjoyDetail';
break;
case CityCategoryModel::lylx:
$url = '/portal/scout/getTravelDetail';
break;
case CityCategoryModel::ddfw:
$url = '/portal/scout/getSceneryDetail';
break;
case CityCategoryModel::cysj:
$url = '/portal/scout/getSceneryDetail';
break;
case CityCategoryModel::yjyr:
$url = '/portal/scout/getSceneryDetail';
break;
default:
}
return $url;
}
//第三方微信登录
public function wx_login(){
$config = Config::get('wx_login');
... ...
... ... @@ -8,6 +8,7 @@
<title>星球故事更多</title>
<link rel="stylesheet" href="__TMPL__/public/assets/css/bootstrap4.0.css">
<link rel="stylesheet" href="__TMPL__/public/assets/css/show.css">
<link rel="stylesheet" href="__TMPL__/public/assets/css/audio.css">
</head>
<body>
... ... @@ -36,7 +37,11 @@
</div>
<!-- 进度条 -->
<div class="show_index_progress">
<img src="__TMPL__/public/assets/starImg/aicon_15.png" alt="">
<notempty name="vo.audio">
<audio src="{:cmf_get_file_download_url($vo.audio)}"></audio>
<else/>
<audio src="http://link.hhtjim.com/163/442869240.mp3"></audio>
</notempty>
</div>
</div>
</volist>
... ... @@ -51,6 +56,26 @@
<include file="public@footer"/>
<script src="__TMPL__/public/assets/js/jquery-3.2.1.min.js"></script>
<script src="__TMPL__/public/assets/js/public.js"></script>
<script src="__TMPL__/public/assets/js/k-audio.js"></script>
<script>
$('audio').each(function() {
var a = new kac(this, 800, 40, "https://raw.githubusercontent.com/KIPI-C/k-audio.js/master/22.lrc", true);
a.style("#E1E1E6");
});
// 获取所有audios
var audios = document.getElementsByTagName("audio");
// 暂停函数
function pauseAll() {
var self = this;
[].forEach.call(audios, function(i) {
// 将audios中其他的audio全部暂停
i !== self && i.pause();
})
}
// 给play事件绑定暂停函数
[].forEach.call(audios, function(i) {
i.addEventListener("play", pauseAll.bind(i));
});
</script>
</body>
</html>
\ No newline at end of file
... ...
... ... @@ -8,6 +8,7 @@
<title>星域秀场</title>
<link rel="stylesheet" href="__TMPL__/public/assets/js/swiper4/swiper.min.css">
<link rel="stylesheet" href="__TMPL__/public/assets/css/show.css">
<link rel="stylesheet" href="__TMPL__/public/assets/css/audio.css">
<style>
.slide-image{
width:260px;
... ... @@ -19,55 +20,30 @@
.swiper-button-prev2,.swiper-button-next2{
outline:none;
}
.kc-body {
margin: 0 !important;
}
.kc-lrctable {
width: 0 !important;
}
.kc-playlog,
.kc-pauselog {
width: 30px !important;
height: 30px !important;
margin-top: 10px !important;
}
.kc-rangeloadli {
border-radius: 2px;
background-color: #5B5B6B !important;
}
.kc-rangeli {
border-radius: 2px;
background-color: #CCCCD1 !important;
}
.kc-infbody {
display: none;
}
.kc-soundbody {
display: none;
}
.kc-rangep {
position: absolute !important;
top: -6px !important;
z-index: 11;
width: 14px !important;
height: 14px !important;
background: white;
border: 1px solid rgba(207, 207, 207, 1);
border-radius: 50% !important;
.hl_index{
overflow: hidden;
float: left;
margin-top: 11px;
}
.kc-rangebody {
top: -45% !important;
.hl_index span {
width: 8px;
height: 8px;
float: left;
background: rgba(255, 255, 255, 1);
opacity: 0.6;
display: inline-block;
border-radius: 50%;
margin-right: 6px;
}
.kc-playlog,
.kc-pauselog {
margin-left: 45px !important;
z-index: 99;
.swiper-button-prev2{
margin-right: 6px;
}
.kc-rangebody {
left: 100px !important;
.hl_index .first {
background: #09FF8E;
}
.k-body {
border-radius: 0 !important;
.swiper-button-disabled2 {
background-color: white !important;
}
</style>
</head>
... ... @@ -146,7 +122,11 @@
</div>
<!-- 进度条 -->
<div class="show_index_progress">
<notempty name="vo.audio">
<audio src="{:cmf_get_file_download_url($vo.audio)}"></audio>
<else/>
<audio src="http://link.hhtjim.com/163/442869240.mp3"></audio>
</notempty>
<!--<img src="__TMPL__/public/assets/starImg/aicon_15.png" alt="">-->
</div>
</div>
... ... @@ -156,7 +136,10 @@
<div class="show_swiper2_btn clearfix">
<div class="show_swiper2_btn22">
<div class="swiper-button-prev2"></div>
<div class="swiper-pagination">
<div class="hl_index">
<volist name="res_xqgs" id="vo">
<span></span>
</volist>
</div>
<div class="swiper-button-next2"></div>
... ... @@ -302,13 +285,59 @@
<script src="__TMPL__/public/assets/js/swiper4/swiper.min.js"></script>
<script src="__TMPL__/public/assets/js/public.js"></script>
<script src="__TMPL__/public/assets/js/k-audio.js"></script>
<script src="__TMPL__/public/assets/js/k-color.js"></script>
<script>
var index = 0;
$(window).ready(function() {
if (index == 0) {
$('.swiper-button-prev2').addClass('swiper-button-disabled2');
}
});
// 轮播图
$('.hl_index span:first-child').addClass('first');
$('.swiper-button-next2').click(function() {
index++;
if (index == $('.swiper-container2 .swiper-wrapper .swiper-slide').length) {
index = $('.swiper-container2 .swiper-wrapper .swiper-slide').length - 1
}
$(".swiper-container2 .swiper-wrapper").animate({
"left": -1200 * index
}, 300);
$(".hl_index span").eq(index).css("background-color", "#09FF8E")
.siblings().css("background-color", "#FFFFFF");
if (index == $('.swiper-container2 .swiper-wrapper .swiper-slide').length - 1) {
$('.swiper-button-next2').addClass('swiper-button-disabled2');
$('.swiper-button-prev2').removeClass('swiper-button-disabled2');
} else if (index <= $('.swiper-container2 .swiper-wrapper .swiper-slide').length - 1) {
$('.swiper-button-next2').removeClass('swiper-button-disabled2');
$('.swiper-button-prev2').removeClass('swiper-button-disabled2');
} else {
$('.swiper-button-next2').removeClass('swiper-button-disabled2');
}
});
$(".swiper-button-prev2").click(function() {
if (index == 0) {
index = 0;
} else {
index--;
}
$(".swiper-container2 .swiper-wrapper").animate({
"left": -1200 * index
}, 300);
$(".hl_index span").eq(index).css("background-color", "#09FF8E")
.siblings().css("background-color", "#FFFFFF");
if (index == 0) {
$('.swiper-button-prev2').addClass('swiper-button-disabled2');
$('.swiper-button-next2').removeClass('swiper-button-disabled2');
} else if (index <= $('.swiper-container2 .swiper-wrapper .swiper-slide').length - 1) {
$('.swiper-button-next2').removeClass('swiper-button-disabled2');
$('.swiper-button-prev2').removeClass('swiper-button-disabled2');
} else {
$('.swiper-button-prev2').removeClass('swiper-button-disabled2');
}
});
$('audio').each(function() {
var a = new kac(this, 800, 40, "https://raw.githubusercontent.com/KIPI-C/k-audio.js/master/22.lrc", true);
a.style("#E1E1E6");
// var b = new kac(this, 800, 40, "https://raw.githubusercontent.com/KIPI-C/k-audio.js/master/2U.lrc");
// b.style("#E1E1E6");
});
// 获取所有audios
var audios = document.getElementsByTagName("audio");
... ... @@ -335,19 +364,19 @@
},
});
// 星球故事swiper
var swiper = new Swiper('.swiper-container2', {
slidesPerView: 1,
spaceBetween: 30,
// loop: true,
pagination: {
el: '.swiper-pagination',
clickable: true,
},
navigation: {
nextEl: '.swiper-button-next2',
prevEl: '.swiper-button-prev2',
},
});
// var swiper = new Swiper('.swiper-container2', {
// slidesPerView: 1,
// spaceBetween: 30,
// // loop: true,
// pagination: {
// el: '.swiper-pagination',
// clickable: true,
// },
// navigation: {
// nextEl: '.swiper-button-next2',
// prevEl: '.swiper-button-prev2',
// },
// });
// banner视频
// var video = document.getElementById("video");
... ...
... ... @@ -8,6 +8,7 @@
<title>星球奇境</title>
<link rel="stylesheet" href="__TMPL__/public/assets/js/swiper4/swiper.min.css" />
<link rel="stylesheet" href="__TMPL__/public/assets/css/happy_index.css" />
<link rel="stylesheet" href="__TMPL__/public/assets/css/audio.css">
</head>
<body>
... ... @@ -61,7 +62,12 @@
</div>
<!-- 进度条 -->
<div class="show_index_progress">
<img src="__TMPL__/public/assets/starImg/aicon_15.png" alt="">
<notempty name="res_xqgs.audio">
<audio src="{:cmf_get_file_download_url($res_xqgs.audio)}"></audio>
<else/>
<audio src="http://link.hhtjim.com/163/442869240.mp3"></audio>
</notempty>
</div>
</div>
</div>
... ... @@ -260,7 +266,26 @@
<script src="__TMPL__/public/assets/js/jquery-3.2.1.min.js"></script>
<script src="__TMPL__/public/assets/js/swiper4/swiper.min.js"></script>
<script src="__TMPL__/public/assets/js/public.js"></script>
<script src="__TMPL__/public/assets/js/k-audio.js"></script>
<script>
$('audio').each(function() {
var a = new kac(this, 800, 40, "https://raw.githubusercontent.com/KIPI-C/k-audio.js/master/22.lrc", true);
a.style("#E1E1E6");
});
// 获取所有audios
var audios = document.getElementsByTagName("audio");
// 暂停函数
function pauseAll() {
var self = this;
[].forEach.call(audios, function(i) {
// 将audios中其他的audio全部暂停
i !== self && i.pause();
})
}
// 给play事件绑定暂停函数
[].forEach.call(audios, function(i) {
i.addEventListener("play", pauseAll.bind(i));
});
// swiper
var swiper = new Swiper(".swiper-container", {
slidesPerView: 4,
... ...
.kc-body {
margin: 0 !important;
}
.kc-lrctable {
width: 0 !important;
}
.kc-playlog,
.kc-pauselog {
width: 30px !important;
height: 30px !important;
margin-top: 10px !important;
}
.kc-rangeloadli {
border-radius: 2px;
background-color: #5B5B6B !important;
}
.kc-rangeli {
border-radius: 2px;
background-color: #CCCCD1 !important;
}
.kc-infbody {
display: none;
}
.kc-soundbody {
display: none;
}
.kc-rangep {
position: absolute !important;
top: -6px !important;
z-index: 11;
width: 14px !important;
height: 14px !important;
background: white;
border: 1px solid rgba(207, 207, 207, 1);
border-radius: 50% !important;
}
.kc-rangebody {
top: -45% !important;
}
.kc-playlog,
.kc-pauselog {
margin-left: 45px !important;
z-index: 99;
}
.kc-rangebody {
left: 100px !important;
}
.k-body {
border-radius: 0 !important;
}
.kc-lrctable{
display: none;
}
\ No newline at end of file
... ...
... ... @@ -132,6 +132,12 @@ $(function(){
$('#about_us').click(function(){
window.location.href = '/portal/index/aboutUs';
});
//搜索
$("#keywords").keypress(function (e) {
if (e.which == 13) {
$("#searchForm").submit();//处理事件
}
});
});
//点赞收藏
... ...
... ... @@ -37,10 +37,12 @@
</ul>
</section>
<!-- 搜索框 -->
<form method="GET" action="/portal/login/searchList" id="searchForm">
<section class="home_search">
<i class="search_icon"></i>
<input type="text" placeholder="">
<input type="text" placeholder="" name="keyword" value="{$keyword}" id="keywords">
</section>
</form>
<notempty name="user">
<section class="home_login login_person">
<notempty name="user.avatar">
... ...
... ... @@ -34,6 +34,8 @@ class HomeBaseController extends BaseController
$this->getComment();
$this->is_collection();
$this->is_like();
$keyword = $this->request->param('keyword');
$this->assign('keyword',$keyword);
}
protected function _initializeView()
... ...