152 lines
4.8 KiB
PHP
152 lines
4.8 KiB
PHP
<?php
|
|
|
|
/** ZJMall商城系统 - 团队十年电商经验汇集巨献!
|
|
* =========================================================
|
|
* Copy right 2022-2032 四川正今科技有限公司, 保留所有权利。
|
|
* ----------------------------------------------
|
|
* 官方网址: https://www.zjphp.com
|
|
* 这不是自由软件!未经允许不得用于商业目或程序代码摘取及修改。
|
|
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布传播。
|
|
* 唯一发布渠道官方颁发授权证书,无纸质授权凭证书视为侵权行为。
|
|
* =========================================================
|
|
*/
|
|
|
|
namespace addon\article\shop\controller;
|
|
|
|
|
|
use addon\fenxiao\model\FenxiaoOrder;
|
|
use app\model\newModel\common\CaChe;
|
|
use app\model\newModel\Config;
|
|
use addon\article\model\Article;
|
|
use addon\article\model\ArticleCategory;
|
|
use app\shop\controller\NewBaseShop;
|
|
use think\facade\Log;
|
|
|
|
class Index extends NewBaseShop{
|
|
|
|
public function __construct(){
|
|
parent::__construct();
|
|
// 输出菜单
|
|
$this->forthMenu();
|
|
// 实例化默认模型
|
|
$this->thisDefaultModel = new Article();
|
|
|
|
}
|
|
/**
|
|
* Common: 文章列表
|
|
* Author: wu-hui
|
|
* Time: 2022/10/18 15:28
|
|
* @return array|mixed
|
|
* @throws \think\db\exception\DbException
|
|
*/
|
|
public function index(){
|
|
if (request()->isAjax()) {
|
|
$params = input('');
|
|
// 缓存名称
|
|
$cacheTag = CaChe::tag($params);
|
|
$list = CaChe::get('article_list',$cacheTag);
|
|
if($list){
|
|
// 存在缓存时的处理
|
|
$list = json_decode($list,TRUE);
|
|
}else{
|
|
$list = $this->thisDefaultModel->getList();
|
|
// 记录缓存
|
|
CaChe::set('article_list',json_encode($list,JSON_UNESCAPED_UNICODE),$cacheTag);
|
|
}
|
|
|
|
return $list;
|
|
}
|
|
|
|
return $this->fetch('article/index');
|
|
}
|
|
/**
|
|
* Common: 添加编辑文章信息
|
|
* Author: wu-hui
|
|
* Time: 2022/10/14 15:44
|
|
* @return array|mixed
|
|
* @throws \think\db\exception\DataNotFoundException
|
|
* @throws \think\db\exception\DbException
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
*/
|
|
public function editInfo(){
|
|
if(request()->isAjax()) return parent::editInfo();
|
|
|
|
parent::editInfo();
|
|
// 获取分类
|
|
$field = ['category_id', 'category_name'];
|
|
$categoryList = (new ArticleCategory())
|
|
->field($field)
|
|
->where('site_id',$this->site_id)
|
|
->order('create_time','DESC')
|
|
->select();
|
|
if($categoryList) $categoryList = $categoryList->toArray();
|
|
$this->assign('category_list',$categoryList ?? []);
|
|
|
|
return $this->fetch('article/edit');
|
|
}
|
|
/**
|
|
* Common: 装修 —— 文章选择器
|
|
* Author: wu-hui
|
|
* Time: 2022/10/17 15:18
|
|
* @return array|mixed
|
|
* @throws \think\db\exception\DataNotFoundException
|
|
* @throws \think\db\exception\DbException
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
*/
|
|
public function selectInfo(){
|
|
if (request()->isAjax()) {
|
|
// 获取已选择列表
|
|
return parent::index();
|
|
}
|
|
else {
|
|
//已经选择的商品sku数据
|
|
$ids = (string)trim(input('ids'));
|
|
$this->assign('ids', $ids);
|
|
// 获取已选择列表
|
|
if(strlen($ids) > 0){
|
|
$result = parent::index();;
|
|
$this->assign('article_list', $result['data']['list']);
|
|
}else{
|
|
$this->assign('article_list', []);
|
|
}
|
|
|
|
return $this->fetch("article/select");
|
|
}
|
|
}
|
|
/**
|
|
* Common: 文章基本设置
|
|
* Author: wu-hui
|
|
* Time: 2022/10/21 14:18
|
|
* @return array|mixed
|
|
* @throws \think\db\exception\DataNotFoundException
|
|
* @throws \think\db\exception\DbException
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
*/
|
|
public function set(){
|
|
$key = 'ARTICLE_SETTING';
|
|
$configModel = new Config();
|
|
if (request()->isAjax()) {
|
|
// 参数获取
|
|
$info = input('info',[]);
|
|
$params = [
|
|
'site_id' => $this->site_id,
|
|
'app_module' => 'shop',
|
|
'config_key' => $key,
|
|
'value' => json_encode($info,JSON_UNESCAPED_UNICODE),
|
|
'config_desc' => '文章基本设置',
|
|
'is_use' => 1,
|
|
];
|
|
|
|
return $configModel->setConfigInfo($params);
|
|
}
|
|
else {
|
|
$info = $configModel->getConfigInfo($key);
|
|
$this->assign('info',$info);
|
|
|
|
return $this->fetch('article/set');
|
|
}
|
|
}
|
|
|
|
|
|
|
|
} |