Files
yusheng-php/application/api/controller/Theme.php

97 lines
4.3 KiB
PHP
Raw Normal View History

2025-08-07 20:21:47 +08:00
<?php
namespace app\api\controller;
use think\Controller;
use think\Db;
class Theme extends controller
{
public function _initialize()
{
//允许跨域
header('Access-Control-Allow-Origin: *');
}
/*
* 启动页列表
2025-08-12 15:17:17 +08:00
* app背景图片 app_bg
* 首页选中 home_sel
* 首页正常 home_nor
* 广场选中 find_sel
* 广场正常 find_nor
* 消息选中 msg_sel
* 消息正常 msg_nor
* 我的选中 mine_sel
* 我的正常 mine_nor
* 主题色 theme_color
* 按钮文字颜色 btn_text_color
2025-08-07 20:21:47 +08:00
*/
public function get_theme_data()
{
2025-12-30 09:34:36 +08:00
// $reslut = DB::name('vs_theme')->field('theme_color,file_url,auxiliary_color')
// ->where(['delete_time' => 0 ,'is_active' => 1,'begin_time' => ['<',time()],'end_time' => ['>',time()]])->order('id desc')->find();
//
// if($reslut){
// $url = $reslut['file_url'];
// $reslut['btn_text_color'] = $reslut['auxiliary_color'];
// $reslut['app_bg'] = get_system_config_value('web_site').'/static/theme/'.$url.'/app_bg.png';
// $reslut['home_sel'] = get_system_config_value('web_site').'/static/theme/'.$url.'/home_sel.png';
// $reslut['home_nor'] = get_system_config_value('web_site').'/static/theme/'.$url.'/home_nor.png';
// $reslut['find_sel'] = get_system_config_value('web_site').'/static/theme/'.$url.'/find_sel.png';
// $reslut['find_nor'] = get_system_config_value('web_site').'/static/theme/'.$url.'/find_nor.png';
// $reslut['msg_sel'] = get_system_config_value('web_site').'/static/theme/'.$url.'/msg_sel.png';
// $reslut['msg_nor'] = get_system_config_value('web_site').'/static/theme/'.$url.'/msg_nor.png';
// $reslut['mine_sel'] = get_system_config_value('web_site').'/static/theme/'.$url.'/mine_sel.png';
// $reslut['mine_nor'] = get_system_config_value('web_site').'/static/theme/'.$url.'/mine_nor.png';
// }
2025-08-12 15:17:17 +08:00
2025-10-28 18:39:09 +08:00
//版本号
$app_version = request()->header('App-Version');
$system = request()->header('system');
$api_version = 0;
if ($system == 'iOS') {
$api_versions = db::name('version')->where(['type' => 2, 'status' => 1])->order('id', 'desc')->find();
//app的版本和用户使用的当前版本比对
//$api_versions['newversion'] 是数据库当前的版本 也是用户使用的版本
//$app_version 有可能是appstore里面的审核版本 审核版本比用户的版本高
//审核版本给前端返回1
$result = version_compare($api_versions['newversion'],$app_version);
if ($result < 0) {//-1:前面版本小于后面版本,0:相等,1:前面版本大于后面版本
2025-10-28 18:39:09 +08:00
$api_version = 1;
}
}
2025-12-30 09:34:36 +08:00
$reslut = [];
2025-10-28 18:39:09 +08:00
return V(1,'操作成功', $reslut,$api_version);
2025-08-07 20:21:47 +08:00
}
2025-12-30 09:34:36 +08:00
// 节日主题
public function get_festival_theme()
{
$theme = DB::name('vs_theme')->field('theme_name,theme_color,file_url,auxiliary_color')
->where(['delete_time' => 0 ,'is_active' => 1,'begin_time' => ['<=',time()],'end_time' => ['>=',time()]])->order('id desc')->find();
$reslut['is_open'] = 0;
if($theme){
$reslut['theme_name'] = $theme['theme_name'];
$reslut['is_open'] = 1;
}
//版本号
$app_version = request()->header('App-Version');
$system = request()->header('system');
$api_version = 0;
if ($system == 'iOS') {
$api_versions = db::name('version')->where(['type' => 2, 'status' => 1])->order('id', 'desc')->find();
//app的版本和用户使用的当前版本比对
//$api_versions['newversion'] 是数据库当前的版本 也是用户使用的版本
//$app_version 有可能是appstore里面的审核版本 审核版本比用户的版本高
//审核版本给前端返回1
$result = version_compare($api_versions['newversion'],$app_version);
if ($result < 0) {//-1:前面版本小于后面版本,0:相等,1:前面版本大于后面版本
$api_version = 1;
}
}
return V(1,'操作成功', $reslut,$api_version);
2025-12-30 09:34:36 +08:00
}
2025-08-07 20:21:47 +08:00
}