You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
441 lines
15 KiB
441 lines
15 KiB
<?php
|
|
|
|
namespace app\project\controller\admin;
|
|
|
|
|
|
use app\fire\model\FireCarousel;
|
|
use app\fire\model\FireCarouselText;
|
|
use app\project\model\ProjectConfig;
|
|
use app\project\model\ProjectConfigAdvertise;
|
|
use app\project\model\ProjectConfigApp;
|
|
use app\project\model\ProjectConfigH5;
|
|
use app\project\model\ProjectConfigMessage;
|
|
use app\project\model\ProjectConfigMpweixin;
|
|
use app\project\model\ProjectConfigUser;
|
|
use app\project\model\ProjectConfigInfo;
|
|
use app\project\model\ProjectMessageRecord;
|
|
use app\project\model\ProjectQuestion;
|
|
use app\project\model\ProjectQuestionConfig;
|
|
use think\facade\View;
|
|
|
|
class Project extends Base
|
|
{
|
|
public function config()
|
|
{
|
|
$param = input();
|
|
$project_config_model = new ProjectConfig();
|
|
$project_config_user_model = new ProjectConfigUser();
|
|
$project_config_h5_model = new ProjectConfigH5();
|
|
$project_config_app_model = new ProjectConfigApp();
|
|
$project_config_advertise_model = new ProjectConfigAdvertise();
|
|
$project_config_info_model = new ProjectConfigInfo();
|
|
$project_config_mpweixin_model = new ProjectConfigMpweixin();
|
|
$carousel_model = new FireCarousel();
|
|
|
|
if (request()->isPost()) {
|
|
switch ($param['r']) {
|
|
case 'about':
|
|
//关于我们
|
|
$param['uid'] = UID;
|
|
$res = $project_config_model->dataUpdate($param);
|
|
if ($res === false) {
|
|
return sendErrorMessage();
|
|
}
|
|
return sendSuccessMessage();
|
|
break;
|
|
case 'project':
|
|
$param['uid'] = UID;
|
|
$res = $project_config_info_model->dataUpdate($param);
|
|
if (!$res) {
|
|
return sendErrorMessage();
|
|
}
|
|
return sendSuccessMessage();
|
|
break;
|
|
// 微信小程序
|
|
case 'mpweixin':
|
|
$param['uid'] = UID;
|
|
$res = $project_config_mpweixin_model->dataUpdate($param);
|
|
if (!$res) {
|
|
return sendErrorMessage();
|
|
}
|
|
return sendSuccessMessage();
|
|
break;
|
|
case 'user':
|
|
$param['uid'] = UID;
|
|
$res = $project_config_user_model->dataUpdate($param);
|
|
if (!$res) {
|
|
return sendErrorMessage();
|
|
}
|
|
return sendSuccessMessage();
|
|
break;
|
|
case 'web':
|
|
$param['uid'] = UID;
|
|
$res = $project_config_h5_model->dataUpdate($param);
|
|
if (!$res) {
|
|
return sendErrorMessage();
|
|
}
|
|
return sendSuccessMessage();
|
|
break;
|
|
case 'app':
|
|
$param['uid'] = UID;
|
|
$res = $project_config_app_model->dataUpdate($param);
|
|
if (!$res) {
|
|
return sendErrorMessage();
|
|
}
|
|
return sendSuccessMessage();
|
|
break;
|
|
case 'advertise':
|
|
$param['uid'] = UID;
|
|
$res = $project_config_advertise_model->dataUpdate($param);
|
|
if (!$res) {
|
|
return sendErrorMessage();
|
|
}
|
|
return sendSuccessMessage();
|
|
break;
|
|
case 'carousel':
|
|
//轮播图
|
|
$carousel = [];
|
|
foreach ($param['carousel_image'] as $k_1 => $value) {
|
|
$carousel[] = [
|
|
'uid' => UID,
|
|
'image' => $value,
|
|
'link_url' => $param['carousel_link_url'][$k_1],
|
|
'id' => $param['carousel_id'][$k_1],
|
|
];
|
|
}
|
|
$res = $carousel_model->dataUpdateByAll($carousel);
|
|
if ($res === false) {
|
|
return sendErrorMessage();
|
|
}
|
|
return sendSuccessMessage();
|
|
break;
|
|
default:
|
|
|
|
}
|
|
} else {
|
|
switch ($param['r']) {
|
|
case 'about':
|
|
$data = $project_config_model->getOneData(['uid' => UID]);
|
|
View::assign('data', $data);
|
|
break;
|
|
case 'project':
|
|
$config_data = $project_config_info_model->getOneData(['uid' => UID]);
|
|
View::assign('data', $config_data);
|
|
break;
|
|
case 'mpweixin':
|
|
$config_data = $project_config_mpweixin_model->getOneData(['uid' => UID]);
|
|
View::assign('data', $config_data);
|
|
break;
|
|
case 'user':
|
|
$config_data = $project_config_user_model->getOneData(['uid' => UID]);
|
|
View::assign('data', $config_data);
|
|
break;
|
|
case 'web':
|
|
$config_data = $project_config_h5_model->getOneData(['uid' => UID]);
|
|
View::assign('data', $config_data);
|
|
break;
|
|
case 'app':
|
|
$config_data = $project_config_app_model->getOneData(['uid' => UID]);
|
|
View::assign('data', $config_data);
|
|
break;
|
|
case 'advertise':
|
|
$config_data = $project_config_advertise_model->getOneData(['uid' => UID]);
|
|
View::assign('data', $config_data);
|
|
break;
|
|
case 'carousel':
|
|
$carousel = $carousel_model->getAllData(['uid' => UID], 'id,image,link_url', 'id asc')->toArray();
|
|
|
|
$count = 5 - count($carousel);
|
|
|
|
if ($count > 0) {
|
|
for ($i = 0; $i <= $count; $i++) {
|
|
$temp = array(
|
|
'id' => "",
|
|
'image' => "",
|
|
'link_url' => ""
|
|
);
|
|
array_push($carousel, $temp);
|
|
}
|
|
}
|
|
View::assign('carousel', $carousel);
|
|
break;
|
|
default:
|
|
|
|
}
|
|
View::assign('r', $param['r']);
|
|
return View::fetch();
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
* 短信设置
|
|
*/
|
|
public function message()
|
|
{
|
|
$search = input('get.');
|
|
autoSearch(['keyword'], $search);
|
|
$message_record_model = new ProjectMessageRecord();
|
|
$where [] = ['uid', '=', UID];
|
|
if ($search['keyword']) {
|
|
$where[] = ['remark', 'like', '%' . $search['keyword'] . '%'];
|
|
}
|
|
$page = array_key_exists("page", $search) ? (string)$search['page'] : "1";
|
|
$dataList = $message_record_model->getDataList($where, $page, "*", "id desc");
|
|
|
|
View::assign('dataList', $dataList);
|
|
View::assign('search', $search);
|
|
|
|
return View::fetch();
|
|
}
|
|
|
|
/**
|
|
* 短信设置
|
|
*/
|
|
public function messageconfig()
|
|
{
|
|
$message_config_model = new ProjectConfigMessage();
|
|
if (request()->isPost()) {
|
|
$data = input('post.');
|
|
$data['uid'] = UID;
|
|
$data['is_limit'] = array_key_exists('is_limit', $data) ? $data['is_limit'] : 0;
|
|
$res = $message_config_model->dataUpdate($data);
|
|
if ($res === false) {
|
|
return sendErrorMessage();
|
|
}
|
|
return sendSuccessMessage();
|
|
} else {
|
|
$id = input('param.id', 0);
|
|
$data = $message_config_model->getOneData(['uid' => UID]);
|
|
View::assign('data', $data);
|
|
return View::fetch('messageconfig');
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 增加短信次数
|
|
*/
|
|
public function messageincrease()
|
|
{
|
|
$message_config_model = new ProjectConfigMessage();
|
|
if (request()->isPost()) {
|
|
$data = input('post.');
|
|
$data['uid'] = UID;
|
|
$res = $message_config_model->messageNumberUpdate($data['number'], $data['remark'], 1);
|
|
if ($res === false) {
|
|
return sendErrorMessage();
|
|
}
|
|
return sendSuccessMessage();
|
|
} else {
|
|
$id = input('param.id', 0);
|
|
$data = $message_config_model->getOneData(['id' => $id]);
|
|
View::assign('data', $data);
|
|
return View::fetch('messageincrease');
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 减少短信次数
|
|
*/
|
|
public function messagereduce()
|
|
{
|
|
$message_config_model = new ProjectConfigMessage();
|
|
if (request()->isPost()) {
|
|
$data = input('post.');
|
|
$data['uid'] = UID;
|
|
$res = $message_config_model->messageNumberUpdate($data['number'], $data['remark'], 2);
|
|
if ($res === false) {
|
|
return sendErrorMessage();
|
|
}
|
|
return sendSuccessMessage();
|
|
} else {
|
|
$id = input('param.id', 0);
|
|
$data = $message_config_model->getOneData(['id' => $id]);
|
|
View::assign('data', $data);
|
|
return View::fetch('messagereduce');
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 常见问题基础设置
|
|
* @return array|mixed|string
|
|
*/
|
|
public function questionConfig()
|
|
{
|
|
$question_config_model = new ProjectQuestionConfig();
|
|
if (request()->isPost()) {
|
|
$data = input('post.');
|
|
$data['uid'] = UID;
|
|
$carousel = [];
|
|
foreach ($data['carousel_img_path'] as $k_1 => $value) {
|
|
$carousel[] = [
|
|
'img_path' => $value,
|
|
'url' => $data['carousel_url'][$k_1]
|
|
];
|
|
}
|
|
$data['carousel'] = $carousel;
|
|
|
|
$res = $question_config_model->dataUpdate($data);
|
|
if ($res === false) {
|
|
return sendErrorMessage();
|
|
}
|
|
return sendSuccessMessage();
|
|
} else {
|
|
$data = $question_config_model->getOneData(array('uid' => UID));
|
|
View::assign('data', $data);
|
|
return View::fetch('questionconfig');
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 常见问题列表
|
|
* @return array|mixed|string
|
|
*/
|
|
public function question()
|
|
{
|
|
$search = input('get.');
|
|
autoSearch(['time', 'keyword', 'category_id'], $search);
|
|
View::assign('search', $search);
|
|
$where = [
|
|
['uid', '=', UID],
|
|
];
|
|
if ($search['time']) {
|
|
$time = explode('-', $search['time']);
|
|
$where[] = ['create_time', 'between time', [$time[0], $time[1]]];
|
|
}
|
|
if ($search['keyword']) {
|
|
$where[] = ['title', 'like', '%' . $search['keyword'] . '%'];
|
|
}
|
|
if ($search['category_id'] != "") {
|
|
$where[] = ['create_time', '=', $search['category_id']];
|
|
}
|
|
|
|
$page = array_key_exists("page", $search) ? (string)$search['page'] : "1";
|
|
|
|
$question_model = new ProjectQuestion();
|
|
$dataList = $question_model
|
|
->where($where)->order('id asc')
|
|
->paginate(['list_rows' => 50, 'page' => $page], false)->each(function ($item, $key) {
|
|
return $item;
|
|
});
|
|
|
|
View::assign('dataList', $dataList);
|
|
$attach = [
|
|
'total_html' => [['问题总数', $dataList->total()]]
|
|
];
|
|
View::assign('attach', $attach);
|
|
|
|
return View::fetch();
|
|
}
|
|
|
|
/**
|
|
* 常见问题添加
|
|
* @return array|mixed|string
|
|
*/
|
|
public function questionAdd()
|
|
{
|
|
$question_model = new ProjectQuestion();
|
|
if (request()->isPost()) {
|
|
$data = input('post.');
|
|
$data['uid'] = UID;
|
|
$data['is_publish'] = array_key_exists('is_publish', $data) ? $data['is_publish'] : 0;
|
|
$data['publish_time'] = time();
|
|
$res = $question_model->dataUpdate($data);
|
|
if ($res === false) {
|
|
return sendErrorMessage();
|
|
}
|
|
return sendSuccessMessage();
|
|
} else {
|
|
$id = input('param.id', 0);
|
|
$data = $question_model->getOneData(['id' => $id]);
|
|
View::assign('data', $data);
|
|
return View::fetch('questionadd');
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 常见问题修改
|
|
* @return array|mixed|string
|
|
*/
|
|
public function questionUpdate()
|
|
{
|
|
return $this->questionAdd();
|
|
}
|
|
|
|
/**
|
|
* 富文本列表
|
|
* @return array|mixed|string
|
|
*/
|
|
public function text()
|
|
{
|
|
$search = input('get.');
|
|
autoSearch(['time', 'keyword', 'category_id'], $search);
|
|
View::assign('search', $search);
|
|
$where = [
|
|
['uid','=',UID],
|
|
];
|
|
if ($search['time']) {
|
|
$time = explode('-', $search['time']);
|
|
$where[] = ['create_time','between time',[$time[0], $time[1]]];
|
|
}
|
|
if ($search['keyword']) {
|
|
$where[] = ['title','like','%' . $search['keyword'] . '%'];
|
|
}
|
|
if ($search['category_id'] != "") {
|
|
$where[] = ['create_time','=',$search['category_id']];
|
|
}
|
|
|
|
$page = array_key_exists("page", $search) ? (string)$search['page'] : "1";
|
|
|
|
$text_model = new FireCarouselText();
|
|
|
|
$dataList = $text_model
|
|
->where($where)->order('id asc')
|
|
->paginate(['list_rows' => 50, 'page' => $page], false)->each(function ($item, $key) {
|
|
return $item;
|
|
});
|
|
|
|
View::assign('dataList', $dataList);
|
|
$attach = [
|
|
'total_html' => [['富文本总数', $dataList->total()]]
|
|
];
|
|
View::assign('attach', $attach);
|
|
|
|
return View::fetch();
|
|
}
|
|
|
|
/**
|
|
* 富文本添加
|
|
* @return array|mixed|string
|
|
*/
|
|
public function textAdd()
|
|
{
|
|
$text_model = new FireCarouselText();
|
|
if (request()->isPost()) {
|
|
$data = input('post.');
|
|
$data['uid'] = UID;
|
|
$data['is_publish'] = array_key_exists('is_publish', $data) ? $data['is_publish'] : 0;
|
|
$data['publish_time'] = time();
|
|
$res = $text_model->dataUpdate($data);
|
|
if ($res === false) {
|
|
return sendErrorMessage();
|
|
}
|
|
return sendSuccessMessage();
|
|
} else {
|
|
$id = input('param.id', 0);
|
|
$data = $text_model->getOneData(['id' => $id]);
|
|
View::assign('data', $data);
|
|
return View::fetch('textadd');
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 富文本修改
|
|
* @return array|mixed|string
|
|
*/
|
|
public function textUpdate()
|
|
{
|
|
return $this->textAdd();
|
|
}
|
|
|
|
} |