Files
shopxo/application/admin/controller/Appmini.php

327 lines
7.7 KiB
PHP
Raw Normal View History

2020-07-13 21:33:55 +08:00
<?php
// +----------------------------------------------------------------------
// | ShopXO 国内领先企业级B2C免费开源电商系统
// +----------------------------------------------------------------------
2021-03-16 10:34:52 +08:00
// | Copyright (c) 2011~2099 http://shopxo.net All rights reserved.
2020-07-13 21:33:55 +08:00
// +----------------------------------------------------------------------
2021-03-16 10:34:52 +08:00
// | Licensed ( https://opensource.org/licenses/mit-license.php )
2020-07-13 21:33:55 +08:00
// +----------------------------------------------------------------------
// | Author: Devil
// +----------------------------------------------------------------------
namespace app\admin\controller;
use app\service\AppMiniService;
use app\service\ConfigService;
2020-11-21 16:42:35 +08:00
use app\service\StoreService;
2020-07-13 21:33:55 +08:00
/**
* 小程序管理
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2020-07-13
* @desc description
*/
class Appmini extends Common
{
2020-11-21 16:42:35 +08:00
private $params;
2020-07-13 21:33:55 +08:00
private $application_name;
private $old_path;
private $new_path;
2020-11-21 16:42:35 +08:00
private $view_type;
2020-07-13 21:33:55 +08:00
/**
* 构造方法
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2020-07-13
* @desc description
*/
public function __construct()
{
// 调用父类前置方法
parent::__construct();
// 登录校验
$this->IsLogin();
// 权限校验
$this->IsPower();
// 参数
$this->params = $this->data_request;
$this->params['application_name'] = empty($this->data_request['nav_type']) ? 'weixin' : trim($this->data_request['nav_type']);
2020-11-21 16:42:35 +08:00
// 小导航
$this->view_type = input('view_type', 'index');
2020-07-13 21:33:55 +08:00
}
2020-11-21 16:42:35 +08:00
/**
2020-07-13 21:33:55 +08:00
* 列表
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2020-07-13
* @desc description
*/
public function Index()
{
2020-11-21 16:42:35 +08:00
// 公共视图
$this->CurrentViewInit();
2020-12-09 17:26:36 +08:00
switch($this->view_type)
2020-11-21 16:42:35 +08:00
{
2020-12-09 17:26:36 +08:00
// 首页
case 'index' :
// 获取主题列表
$data = AppMiniService::ThemeList($this->params);
$this->assign('data_list', $data);
// 默认主题
$this->assign('theme', AppMiniService::$default_theme);
break;
// 源码包列表
case 'package' :
$this->Package();
break;
2020-11-21 16:42:35 +08:00
}
return $this->fetch($this->view_type);
}
/**
* 小程序包列表页面
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2020-07-13
* @desc description
*/
public function Package()
{
$host = config('shopxo.website_url');
2020-07-13 21:33:55 +08:00
$nav_dev_tips = [
// 微信
2020-08-15 17:58:22 +08:00
'weixin' => [
'msg' => '右上角 -> 详情 -> 不校验合法域名、web-view业务域名、TLS 版本以及 HTTPS 证书(勾选改选项即可进行小程序开发调试)。',
'url' => $host.'weixin.html',
],
2020-07-13 21:33:55 +08:00
// 支付宝
2020-08-15 17:58:22 +08:00
'alipay' => [
'msg' => '右上角 -> 详情 -> 域名信息下 -> 忽略 httpRequest 域名合法性检查(仅限调试时,且支付宝 10.1.35 版本以上)(勾选改选项即可进行小程序开发调试)。',
'url' => $host.'alipay.html',
],
2020-07-13 21:33:55 +08:00
// 百度
2020-08-15 17:58:22 +08:00
'baidu' => [
'msg' => '顶部导航 -> 校验域名(关闭即可)。',
'url' => $host.'baidu.html',
],
// 头条
'toutiao' => [
'msg' => '顶部导航 -> 详情 -> 不校验合法域名、web-view业务域名TLS版本以及HTTPS证书勾选改选项即可进行小程序开发调试。',
'url' => $host.'zijietiaodong.html',
],
2020-07-13 21:33:55 +08:00
// QQ
2020-08-15 17:58:22 +08:00
'qq' => [
'msg' => '顶部导航 -> 详情 -> 不校验合法域名、web-view业务域名TLS版本以及HTTPS证书勾选改选项即可进行小程序开发调试。',
'url' => $host.'qq.html',
],
2020-07-13 21:33:55 +08:00
];
$this->assign('nav_dev_tips', $nav_dev_tips);
// 源码包列表
2020-11-21 16:42:35 +08:00
$ret = AppMiniService::DownloadDataList($this->params);
2020-07-13 21:33:55 +08:00
$this->assign('data_list', $ret['data']);
}
2020-11-21 16:42:35 +08:00
/**
* 公共视图
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2020-11-21
* @desc description
*/
public function CurrentViewInit()
{
// 操作导航类型
$this->assign('nav_type', $this->params['application_name']);
// 操作页面类型
$this->assign('view_type', $this->view_type);
// 应用商店
$this->assign('store_theme_url', StoreService::StoreThemeUrl());
// 小程序平台
$this->assign('common_appmini_type', lang('common_appmini_type'));
// 是否
$this->assign('common_is_text_list', lang('common_is_text_list'));
2020-11-21 19:34:23 +08:00
// 基础导航
$base_nav = [
[
'view_type' => 'index',
'name' => '当前主题',
],
[
'view_type' => 'upload',
'name' => '主题安装',
],
[
'view_type' => 'package',
'name' => '源码包下载',
],
];
$this->assign('base_nav', $base_nav);
2020-11-21 16:42:35 +08:00
}
/**
* 主题上传安装
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2020-11-21
* @desc description
*/
public function ThemeUpload()
{
// 是否ajax
if(!IS_AJAX)
{
return $this->error('非法访问');
}
// 开始处理
return AppMiniService::ThemeUpload($this->params);
}
/**
* 主题切换保存
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @datetime 2018-12-19T00:58:47+0800
*/
public function ThemeSave()
{
$key = AppMiniService::DefaultThemeKey($this->params);
$params[$key] = empty($this->data_request['theme']) ? 'default' : $this->data_request['theme'];
return ConfigService::ConfigSave($params);
}
/**
* 主题打包下载
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @datetime 2018-12-19T00:58:47+0800
*/
public function ThemeDownload()
{
$params = array_merge($this->params, $this->data_request);
$ret = AppMiniService::ThemeDownload($params);
if(isset($ret['code']) && $ret['code'] != 0)
{
$this->assign('msg', $ret['msg']);
return $this->fetch('public/tips_error');
} else {
return $ret;
}
}
/**
* 主题删除
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2020-11-21
* @desc description
*/
public function ThemeDelete()
{
// 是否ajax
if(!IS_AJAX)
{
return $this->error('非法访问');
}
// 开始处理
$params = array_merge($this->params, $this->data_request);
return AppMiniService::ThemeDelete($params);
}
2020-07-13 21:33:55 +08:00
/**
* 配置
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2020-07-13
* @desc description
*/
public function Config()
{
2020-11-21 16:42:35 +08:00
// 公共视图
$this->CurrentViewInit();
2020-07-13 21:33:55 +08:00
// 配置信息
$this->assign('data', ConfigService::ConfigList());
return $this->fetch();
}
/**
* 生成
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2020-07-13
* @desc description
*/
public function Created()
{
// 是否ajax请求
if(!IS_AJAX)
{
$this->error('非法访问');
}
// 开始操作
return AppMiniService::Created($this->params);
}
/**
2020-11-21 16:42:35 +08:00
* 配置保存
2020-07-13 21:33:55 +08:00
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2020-07-13
* @desc description
*/
public function Save()
{
return ConfigService::ConfigSave($_POST);
}
/**
* 删除
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2020-07-13
* @desc description
*/
public function Delete()
{
// 是否ajax请求
if(!IS_AJAX)
{
$this->error('非法访问');
}
// 开始操作
return AppMiniService::Delete($this->params);
}
}
?>