Files
amb_wechatapp/application/api/model/app/pc/Page.php
T

64 lines
1.2 KiB
PHP

<?php
namespace app\api\model\app\pc;
use think\Model;
/**
* PC页面装修
*/
class Page extends Model
{
// 表名
protected $name = 'app_pc_page';
/**
* 获取主页
* @return false
*/
public function getIndexData(){
$data = self::where([
'is_index'=>1,
'status'=>1
])->find();
if($data){
return $data;
}
return false;
}
/**
* 获取页面数据
* @param $id
* @return false
*/
public function getPageData($id){
$where = [
'status'=>1
];
if($id){
$where['id'] = $id;
$data = self::where($where)->find();
if(!$data){
$data = $this->getIndexData();
}
}else{
$data = $this->getIndexData();
}
if(!$data){
return false;
}
//之前的变量名疏忽写错了,暂时这样
$data['compontents'] = $data['components'];
$data = (new \app\common\model\page\Decorate())->parseData($data,'pc');
$data['components'] = $data['compontents'];
unset($data['compontents']);
return $data;
}
}