2023-07-15 10:16:32 +08:00
|
|
|
|
<?php
|
|
|
|
|
// +----------------------------------------------------------------------
|
|
|
|
|
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
|
|
|
|
// +----------------------------------------------------------------------
|
|
|
|
|
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
|
|
|
|
// | 开源版本可自由商用,可去除界面版权logo
|
|
|
|
|
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
|
|
|
|
// | github下载:https://github.com/likeshop-github/likeadmin
|
|
|
|
|
// | 访问官网:https://www.likeadmin.cn
|
|
|
|
|
// | likeadmin团队 版权所有 拥有最终解释权
|
|
|
|
|
// +----------------------------------------------------------------------
|
|
|
|
|
// | author: likeadminTeam
|
|
|
|
|
// +----------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
namespace app\api\logic;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
use app\common\logic\BaseLogic;
|
2023-08-31 14:41:35 +08:00
|
|
|
|
use app\common\model\AppUpdate;
|
2023-07-15 10:16:32 +08:00
|
|
|
|
use app\common\model\article\Article;
|
|
|
|
|
use app\common\model\decorate\DecoratePage;
|
|
|
|
|
use app\common\model\decorate\DecorateTabbar;
|
2023-08-26 18:19:46 +08:00
|
|
|
|
use app\common\model\user\UserMenu;
|
|
|
|
|
use app\common\model\user\UserRole;
|
2023-07-15 10:16:32 +08:00
|
|
|
|
use app\common\service\ConfigService;
|
|
|
|
|
use app\common\service\FileService;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* index
|
|
|
|
|
* Class IndexLogic
|
|
|
|
|
* @package app\api\logic
|
|
|
|
|
*/
|
|
|
|
|
class IndexLogic extends BaseLogic
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @notes 首页数据
|
|
|
|
|
* @return array
|
|
|
|
|
* @throws \think\db\exception\DataNotFoundException
|
|
|
|
|
* @throws \think\db\exception\DbException
|
|
|
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
|
|
|
* @author 段誉
|
|
|
|
|
* @date 2022/9/21 19:15
|
|
|
|
|
*/
|
|
|
|
|
public static function getIndexData()
|
|
|
|
|
{
|
|
|
|
|
// 装修配置
|
|
|
|
|
$decoratePage = DecoratePage::findOrEmpty(1);
|
|
|
|
|
|
|
|
|
|
// 首页文章
|
|
|
|
|
$field = [
|
|
|
|
|
'id', 'title', 'desc', 'abstract', 'image',
|
|
|
|
|
'author', 'click_actual', 'click_virtual', 'create_time'
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
$article = Article::field($field)
|
|
|
|
|
->where(['is_show' => 1])
|
|
|
|
|
->order(['id' => 'desc'])
|
|
|
|
|
->limit(20)->append(['click'])
|
|
|
|
|
->hidden(['click_actual', 'click_virtual'])
|
|
|
|
|
->select()->toArray();
|
|
|
|
|
|
|
|
|
|
return [
|
|
|
|
|
'page' => $decoratePage,
|
|
|
|
|
'article' => $article
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @notes 获取政策协议
|
|
|
|
|
* @param string $type
|
|
|
|
|
* @return array
|
|
|
|
|
* @author 段誉
|
|
|
|
|
* @date 2022/9/20 20:00
|
|
|
|
|
*/
|
|
|
|
|
public static function getPolicyByType(string $type)
|
|
|
|
|
{
|
|
|
|
|
return [
|
|
|
|
|
'title' => ConfigService::get('agreement', $type . '_title', ''),
|
|
|
|
|
'content' => ConfigService::get('agreement', $type . '_content', ''),
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @notes 装修信息
|
|
|
|
|
* @param $id
|
|
|
|
|
* @return array
|
|
|
|
|
* @author 段誉
|
|
|
|
|
* @date 2022/9/21 18:37
|
|
|
|
|
*/
|
|
|
|
|
public static function getDecorate($id)
|
|
|
|
|
{
|
|
|
|
|
return DecoratePage::field(['type', 'name', 'data'])
|
|
|
|
|
->findOrEmpty($id)->toArray();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @notes 获取配置
|
|
|
|
|
* @return array
|
|
|
|
|
* @throws \think\db\exception\DataNotFoundException
|
|
|
|
|
* @throws \think\db\exception\DbException
|
|
|
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
|
|
|
* @author 段誉
|
|
|
|
|
* @date 2022/9/21 19:38
|
|
|
|
|
*/
|
2023-08-31 14:41:35 +08:00
|
|
|
|
public static function getConfigData($group_id = 1)
|
2023-07-15 10:16:32 +08:00
|
|
|
|
{
|
2023-08-31 14:41:35 +08:00
|
|
|
|
if ($group_id == null) {
|
|
|
|
|
$group_id = 1;
|
2023-08-26 18:19:46 +08:00
|
|
|
|
}
|
2023-08-31 14:41:35 +08:00
|
|
|
|
$group_find = UserRole::where('id', $group_id)->find();
|
|
|
|
|
$menu = [];
|
|
|
|
|
if ($group_find) {
|
|
|
|
|
$select = UserMenu::where('id', 'in', $group_find['menu_arr'])->field('id,pid,name,icon,sort,paths')->order('sort', 'desc')->limit(100)->select()->toArray();
|
|
|
|
|
$arr = [];
|
|
|
|
|
foreach ($select as $k => $v) {
|
|
|
|
|
if ($v['pid'] == 0) {
|
|
|
|
|
$arr[] = $v;
|
2023-08-26 18:19:46 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2023-08-31 14:41:35 +08:00
|
|
|
|
foreach ($arr as $k => $v) {
|
|
|
|
|
foreach ($select as $kk => $vv) {
|
|
|
|
|
if ($v['id'] == $vv['pid']) {
|
|
|
|
|
$arr[$k]['children'][] = $vv;
|
2023-08-26 18:19:46 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-08-31 14:41:35 +08:00
|
|
|
|
$menu = $arr;
|
2023-08-26 18:19:46 +08:00
|
|
|
|
}
|
2023-07-15 10:16:32 +08:00
|
|
|
|
// 底部导航
|
|
|
|
|
$tabbar = DecorateTabbar::getTabbarLists();
|
|
|
|
|
// 导航颜色
|
|
|
|
|
$style = ConfigService::get('tabbar', 'style', config('project.decorate.tabbar_style'));
|
|
|
|
|
// 登录配置
|
|
|
|
|
$loginConfig = [
|
|
|
|
|
// 登录方式
|
|
|
|
|
'login_way' => ConfigService::get('login', 'login_way', config('project.login.login_way')),
|
|
|
|
|
// 注册强制绑定手机
|
|
|
|
|
'coerce_mobile' => ConfigService::get('login', 'coerce_mobile', config('project.login.coerce_mobile')),
|
|
|
|
|
// 政策协议
|
|
|
|
|
'login_agreement' => ConfigService::get('login', 'login_agreement', config('project.login.login_agreement')),
|
|
|
|
|
// 第三方登录 开关
|
2023-08-26 18:19:46 +08:00
|
|
|
|
// 'third_auth' => ConfigService::get('login', 'third_auth', config('project.login.third_auth')),
|
2023-07-15 10:16:32 +08:00
|
|
|
|
// 微信授权登录
|
|
|
|
|
'wechat_auth' => ConfigService::get('login', 'wechat_auth', config('project.login.wechat_auth')),
|
|
|
|
|
// qq授权登录
|
2023-08-26 18:19:46 +08:00
|
|
|
|
// 'qq_auth' => ConfigService::get('login', 'qq_auth', config('project.login.qq_auth')),
|
2023-07-15 10:16:32 +08:00
|
|
|
|
];
|
|
|
|
|
// 网址信息
|
|
|
|
|
$website = [
|
|
|
|
|
'shop_name' => ConfigService::get('website', 'shop_name'),
|
|
|
|
|
'shop_logo' => FileService::getFileUrl(ConfigService::get('website', 'shop_logo')),
|
|
|
|
|
];
|
2023-08-31 14:41:35 +08:00
|
|
|
|
$versionInfo = [];
|
|
|
|
|
$version='1.0.0';
|
|
|
|
|
if(self::isAndroid()){
|
|
|
|
|
$versionInfo=AppUpdate::where('type',2)->order('id','desc')->find();
|
|
|
|
|
}elseif(self::isIOS()){
|
|
|
|
|
$versionInfo=AppUpdate::where('type',1)->order('id','desc')->find();
|
|
|
|
|
}
|
|
|
|
|
if($versionInfo){
|
|
|
|
|
$version=$versionInfo['version'];
|
|
|
|
|
}
|
2023-07-15 10:16:32 +08:00
|
|
|
|
return [
|
|
|
|
|
'domain' => FileService::getFileUrl(),
|
|
|
|
|
'style' => $style,
|
|
|
|
|
'tabbar' => $tabbar,
|
2023-08-26 18:19:46 +08:00
|
|
|
|
'menu' => $menu,
|
2023-07-15 10:16:32 +08:00
|
|
|
|
'login' => $loginConfig,
|
|
|
|
|
'website' => $website,
|
2023-08-31 14:41:35 +08:00
|
|
|
|
'version' => $version,
|
|
|
|
|
'version_info' => $versionInfo,
|
2023-07-15 10:16:32 +08:00
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-31 14:41:35 +08:00
|
|
|
|
public static function isAndroid()
|
|
|
|
|
{
|
|
|
|
|
$userAgent = $_SERVER['HTTP_USER_AGENT'];
|
|
|
|
|
return strpos($userAgent, 'Android') !== false;
|
|
|
|
|
}
|
2023-08-31 11:21:56 +08:00
|
|
|
|
|
2023-08-31 14:41:35 +08:00
|
|
|
|
public static function isIOS()
|
|
|
|
|
{
|
|
|
|
|
$userAgent = $_SERVER['HTTP_USER_AGENT'];
|
|
|
|
|
return strpos($userAgent, 'iPhone') !== false;
|
|
|
|
|
}
|
2023-08-31 11:21:56 +08:00
|
|
|
|
}
|