118 lines
2.6 KiB
PHP
118 lines
2.6 KiB
PHP
<?php
|
|
|
|
namespace app\admin\model\page;
|
|
|
|
use think\Model;
|
|
|
|
|
|
class Navigation extends Model
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
// 表名
|
|
protected $name = 'page_navigation';
|
|
|
|
// 自动写入时间戳字段
|
|
protected $autoWriteTimestamp = 'integer';
|
|
|
|
// 定义时间戳字段名
|
|
protected $createTime = 'createtime';
|
|
protected $updateTime = 'updatetime';
|
|
protected $deleteTime = false;
|
|
|
|
// 追加属性
|
|
protected $append = [
|
|
'status_text'
|
|
];
|
|
|
|
|
|
|
|
public function getStatusList()
|
|
{
|
|
return ['11' => __('Status 11')];
|
|
}
|
|
|
|
|
|
public function getStatusTextAttr($value, $data)
|
|
{
|
|
$value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
|
|
$list = $this->getStatusList();
|
|
return isset($list[$value]) ? $list[$value] : '';
|
|
}
|
|
|
|
|
|
/**
|
|
* 转换数据结构
|
|
* @param $params
|
|
* @param $type
|
|
* @return mixed
|
|
*/
|
|
public function paramsStructure($params,$type = 'encode')
|
|
{
|
|
if($type=='encode'){
|
|
if(isset($params['config'])){
|
|
$params['config'] = json_encode($params['config']);
|
|
}
|
|
if(isset($params['platform'])){
|
|
$params['platform'] = $this->arrToStr($params['platform']);
|
|
}
|
|
if(isset($params['take_page'])){
|
|
$params['take_page'] = $this->arrToStr($params['take_page']);
|
|
}
|
|
}else{
|
|
if(isset($params['config'])){
|
|
$params['config'] = json_decode($params['config'],true);
|
|
}
|
|
if(isset($params['platform'])){
|
|
$params['platform'] = $this->strToArr($params['platform']);
|
|
}
|
|
if(isset($params['take_page'])){
|
|
$params['take_page'] = $this->strToArr($params['take_page']);
|
|
}
|
|
}
|
|
return $params;
|
|
}
|
|
|
|
public function getPlatformList(){
|
|
return [
|
|
'h5'=>__('Platform h5'),
|
|
'wx'=>__('Platform wx')
|
|
];
|
|
}
|
|
|
|
public function getTakePageList(){
|
|
return [
|
|
'index'=>__('TakePage index'),
|
|
'user'=>__('TakePage user'),
|
|
'other'=>__('TakePage other')
|
|
];
|
|
}
|
|
|
|
public function arrToStr($arr){
|
|
if(empty($arr)){
|
|
return "";
|
|
}
|
|
|
|
foreach ($arr as &$item){
|
|
$item = "|".$item."|";
|
|
}
|
|
$arr = implode(",",$arr);
|
|
|
|
return $arr;
|
|
}
|
|
|
|
public function strToArr($str){
|
|
if(empty($str)){
|
|
return [];
|
|
}
|
|
$str = str_replace("|","",$str);
|
|
$arr = explode(",",$str);
|
|
return $arr;
|
|
}
|
|
|
|
|
|
}
|