乐趣区

关于php:在线音乐网站网站开发项目-第一篇

从明天开始,我开始记录我最近开发的音乐网站我的项目的过程,从前台到后盾等,程序采纳了 PHP+mysql 开发的,这种模式大家也比拟相熟的。

首页

public function index()

{

// 幻灯片

$slider = Db::name(‘slider’)->where(‘status’,’1′)->order(‘level asc,create_time desc’)->limit(8)->select();

// 查问热门标签

$hitstag = Db::name(‘tags’)->order(‘hits desc’)->where(‘status’,’1′)->limit(22)->select();

// 歌单

$song_sheet = Db::name(‘song_sheet’)

->alias(‘sh’)

->field(‘sh.*,se.down_url’)

->join(‘server se’,’sh.server=se.id’,’LEFT’)

->where(‘is_rec’,’1′)

->order(‘create_time desc’)

->limit(10)

->select();

// 新歌首发

$new_song = Db::name(“songs”)

->alias(‘so’)

->field(‘so.id,so.name,so.artist_name,so.cover_url,so.create_time,so.likes,so.listens,so.play_time,se.down_url,m.uid,m.avatar,m.route_name,se2.down_url as mdown_url’)

->join(‘server se’,’so.server=se.id’,”LEFT”)

->join(‘member m’,’so.up_uid=m.uid’,’LEFT’)

->join(‘server se2′,’se2.id=m.server’,’LEFT’)

->where(‘so.status’,’1′)

->order(‘so.id desc’)

->limit(12)

->select();

// 热门歌手

$hits_singer = Db::name(‘singer’)

->alias(‘si’)

->field(‘si.id,si.name,si.pic,se.down_url’)

->join(‘server se’,’si.server=se.id’,”LEFT”)

->order(‘si.hits desc’)

->limit(6)

->select();

if(empty(Request::get(‘isajax’))){

return view(”,[

‘headernav’ => ‘index’,//nav

‘slider’ => $slider,// 幻灯片

‘hitstag’ => $hitstag,// 热门标签

‘song_sheet’ => $song_sheet,// 歌单

‘new_song’ => $new_song,// 新歌首发

‘hits_singer’ => $hits_singer,// 热门歌手

‘json_data’ => ”,// 页面信息

]);

}else{

// $a = [

// ‘site_title’=>’Feed’,// 以后页面地址

// ‘theme_url’=>’/themes/default’,// 模板地址

// ‘page_name’=>’feed’,// 页面名称

// ‘description’=>’Description’,// 形容

// ‘keyword’=>”,// 关键词

// ‘url’=>’/feed’,// 门路

// ‘classes’=>”,

// ‘scroll’=>false,// 是否滚动

// ‘ajax_url’=>’feed’,// 异步申请地址

// ];

$page_msg = [

‘site_title’=>’ 音乐都 ’,

‘theme_url’=>’/themes/default’,

‘page_name’=>request()->action(),

‘description’=>’Description’,

‘keyword’=>”,

‘url’=> “http://song.{$this->Web_url}” .request()->url(),

‘classes’=>”,

‘scroll’=>false,

‘ajax_url’=>request()->action(),

];

$page_msg = str_replace(‘”‘,”"”,json_encode($page_msg));

$json_data = ‘<input type=”hidden”‘ . ‘ value=”‘ . $page_msg . ‘” id=”json-data”>’;

return view(‘index_content’,[

‘headernav’ => ‘index’,//nav

‘slider’ => $slider,// 幻灯片

‘hitstag’ => $hitstag,// 热门标签

‘song_sheet’ => $song_sheet,// 歌单

‘new_song’ => $new_song,// 新歌首发

‘hits_singer’ => $hits_singer,// 热门歌手

‘json_data’ => $json_data,// 页面信息

]);

}

}

页面信息

public function goPro(){

if(empty(Request::get(‘isajax’))){

return view(”,[

‘json_data’ => ”,// 页面信息

]);

}else{

$page_msg = [

‘site_title’=>’Go Pro’,

‘theme_url’=>”,

‘page_name’=>request()->action(),

‘description’=> ‘Go Pro’,

‘keyword’=>”,

‘url’=> “http://my.” . $this->Web_url . url(‘Collection/myPlaylists’),

‘classes’=>”,

‘scroll’=>false,

‘ajax_url’=>”,

];

$page_msg = str_replace(‘”‘,”&quot;”,json_encode($page_msg));

$json_data = ‘<input type=”hidden”‘ . ‘ value=”‘ . $page_msg . ‘” id=”json-data”>’;

return view(‘index/go_pro_content’,[

‘json_data’ => $json_data,// 页面信息

]);

}

}

}

加载更多歌曲

public function loadsongs()

{

echo 111;return;

// 幻灯片

$slider = Db::name(‘slider’)->where(‘status’,’1′)->order(‘level asc,create_time desc’)->limit(8)->select();

// 查问热门标签

$hitstag = Db::name(‘tags’)->order(‘hits desc’)->where(‘status’,’1′)->limit(22)->select();

// 歌单

$song_sheet = Db::name(‘song_sheet’)

->alias(‘sh’)

->field(‘sh.*,se.down_url’)

->join(‘server se’,’sh.server=se.id’,’LEFT’)

->where(‘is_rec’,’1′)

->order(‘create_time desc’)

->limit(10)

->select();

// 新歌首发

$new_song = Db::name(“songs”)

->alias(‘so’)

->field(‘so.id,so.name,so.artist_name,so.cover_url,so.create_time,so.likes,so.listens,so.play_time,se.down_url,m.uid,m.avatar,m.route_name,se2.down_url as mdown_url’)

->join(‘server se’,’so.server=se.id’,”LEFT”)

->join(‘member m’,’so.up_uid=m.uid’,’LEFT’)

->join(‘server se2′,’se2.id=m.server’,’LEFT’)

->where(‘so.status’,’1′)

->order(‘so.id desc’)

->limit(12)

->select();

// 热门歌手

$hits_singer = Db::name(‘singer’)

->alias(‘si’)

->field(‘si.id,si.name,si.pic,se.down_url’)

->join(‘server se’,’si.server=se.id’,”LEFT”)

->order(‘si.hits desc’)

->limit(6)

->select();

return view(”,[

‘headernav’ => ‘index’,//nav

‘slider’ => $slider,// 幻灯片

‘hitstag’ => $hitstag,// 热门标签

‘song_sheet’ => $song_sheet,// 歌单

‘new_song’ => $new_song,// 新歌首发

‘hits_singer’ =>$hits_singer,// 热门歌手

]);

}

}

退出移动版