初始上传
This commit is contained in:
336
addon/pc/shop/controller/Adv.php
Executable file
336
addon/pc/shop/controller/Adv.php
Executable file
@@ -0,0 +1,336 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
|
||||
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\pc\shop\controller;
|
||||
|
||||
use app\model\web\Adv as AdvModel;
|
||||
use app\model\web\AdvPosition;
|
||||
use addon\pc\model\Pc as PcModel;
|
||||
use app\shop\controller\BaseShop;
|
||||
|
||||
|
||||
/**
|
||||
* 广告管理
|
||||
*/
|
||||
class Adv extends BaseShop
|
||||
{
|
||||
|
||||
/**
|
||||
* 广告位管理
|
||||
* @return mixed
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$adv_position = new AdvPosition();
|
||||
if (request()->isJson()) {
|
||||
$page = input('page', 1);
|
||||
$page_size = input('page_size', PAGE_LIST_ROWS);
|
||||
$search_text = input('search_text', '');
|
||||
$type = input('type', '');//位置类型 1 电脑端 2 手机端
|
||||
|
||||
$condition = [
|
||||
[ 'site_id', '=', $this->site_id ],
|
||||
[ 'type', '=', 1 ]
|
||||
];
|
||||
if (!empty($search_text)) {
|
||||
$condition[] = [ 'ap_name', 'like', '%' . $search_text . '%' ];
|
||||
}
|
||||
if ($type !== '') {
|
||||
$condition[] = [ 'type', '=', $type ];
|
||||
}
|
||||
return $adv_position->getAdvPositionPageList($condition, $page, $page_size);
|
||||
} else {
|
||||
|
||||
return $this->fetch('adv/index');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加广告位
|
||||
*/
|
||||
public function addPosition()
|
||||
{
|
||||
$adv_position = new AdvPosition();
|
||||
if (request()->isJson()) {
|
||||
$data = [
|
||||
'ap_name' => input('ap_name', ''),
|
||||
'keyword' => input('keyword', ''),
|
||||
'ap_intro' => input('ap_intro', ''),
|
||||
'ap_height' => input('ap_height', 0),
|
||||
'ap_width' => input('ap_width', 0),
|
||||
'default_content' => input('default_content', ''),
|
||||
'ap_background_color' => input('ap_background_color', ''),
|
||||
'type' => input('type', 1),
|
||||
'site_id' => $this->site_id,
|
||||
'state' => input('state', 0),
|
||||
];
|
||||
return $adv_position->addAdvPosition($data);
|
||||
} else {
|
||||
return $this->fetch('adv/add_position');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑广告位
|
||||
*/
|
||||
public function editPosition()
|
||||
{
|
||||
$adv_position = new AdvPosition();
|
||||
$ap_id = input('ap_id', 0);
|
||||
if (request()->isJson()) {
|
||||
$data = [
|
||||
'ap_name' => input('ap_name', ''),
|
||||
'keyword' => input('keyword', ''),
|
||||
'ap_intro' => input('ap_intro', ''),
|
||||
'ap_height' => input('ap_height', 0),
|
||||
'ap_width' => input('ap_width', 0),
|
||||
'default_content' => input('default_content', ''),
|
||||
'ap_background_color' => input('ap_background_color', ''),
|
||||
'state' => input('state', 0),
|
||||
];
|
||||
return $adv_position->editAdvPosition($data, [ [ 'ap_id', '=', $ap_id ], [ 'site_id', '=', $this->site_id ] ]);
|
||||
} else {
|
||||
$ap_info = $adv_position->getAdvPositionInfo([ [ 'ap_id', '=', $ap_id ], [ 'site_id', '=', $this->site_id ] ]);
|
||||
$this->assign('info', $ap_info[ 'data' ]);
|
||||
return $this->fetch('adv/edit_position');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改广告位字段
|
||||
*/
|
||||
public function editPositionField()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$adv_position = new AdvPosition();
|
||||
$type = input('type', '');
|
||||
$value = input('value', 0);
|
||||
$ap_id = input('ap_id', 0);
|
||||
$data = [
|
||||
$type => $value
|
||||
];
|
||||
return $adv_position->editAdvPosition($data, [ [ 'ap_id', '=', $ap_id ] ]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除广告位
|
||||
*/
|
||||
public function deletePosition()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$ap_ids = input('ap_ids', 0);
|
||||
$adv_position = new AdvPosition();
|
||||
return $adv_position->deleteAdvPosition([ [ 'ap_id', 'in', $ap_ids ], [ 'site_id', '=', $this->site_id ] ], $ap_ids);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 广告列表
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
$adv = new AdvModel();
|
||||
$adv_position = new AdvPosition();
|
||||
$ap_id = input('ap_id', '');
|
||||
if (request()->isJson()) {
|
||||
$page = input('page', 1);
|
||||
$page_size = input('page_size', PAGE_LIST_ROWS);
|
||||
$search_text = input('search_text', '');
|
||||
$ap_id = input('ap_id', '');
|
||||
//查询所有手机端广告位
|
||||
$conditions[] = [ 'type', '=', 1 ];
|
||||
$positions = $adv_position->getAdvPositionList($conditions);
|
||||
$positions_ids = array_column($positions[ 'data' ], 'ap_id');
|
||||
$condition = [
|
||||
[ 'a.site_id', '=', $this->site_id ],
|
||||
[ 'a.ap_id', 'in', $positions_ids ]
|
||||
];
|
||||
if (!empty($search_text)) {
|
||||
$condition[] = [ 'a.adv_title', 'like', '%' . $search_text . '%' ];
|
||||
}
|
||||
if ($ap_id !== '') {
|
||||
$condition[] = [ 'a.ap_id', '=', $ap_id ];
|
||||
}
|
||||
|
||||
//排序
|
||||
$order = input('order', 'slide_sort');
|
||||
$sort = input('sort', 'desc');
|
||||
if ($order == 'slide_sort') {
|
||||
$order_by = 'a.' . $order . ' ' . $sort;
|
||||
} else {
|
||||
$order_by = 'a.' . $order . ' ' . $sort . ',a.slide_sort desc';
|
||||
}
|
||||
|
||||
return $adv->getAdvPageList($condition, $page, $page_size, $order_by);
|
||||
} else {
|
||||
$this->assign('ap_id', $ap_id);
|
||||
|
||||
|
||||
$adv_position = new AdvPosition();
|
||||
$adv_position_list = $adv_position->getAdvPositionList([ [ 'site_id', '=', $this->site_id ], [ 'type', '=', 1 ] ], 'ap_id,ap_name');
|
||||
$this->assign('adv_position', $adv_position_list[ 'data' ]);
|
||||
|
||||
return $this->fetch('adv/lists');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加广告
|
||||
*/
|
||||
public function addAdv()
|
||||
{
|
||||
$adv = new AdvModel();
|
||||
if (request()->isJson()) {
|
||||
$data = [
|
||||
'ap_id' => input('ap_id', 0),
|
||||
'adv_title' => input('adv_title', ''),
|
||||
'adv_url' => input('adv_url', ''),
|
||||
'adv_image' => input('adv_image', ''),
|
||||
'slide_sort' => input('slide_sort', 0),
|
||||
'price' => input('price', 0),
|
||||
'background' => input('background', ''),
|
||||
'state' => input('state', 0),
|
||||
'site_id' => $this->site_id
|
||||
];
|
||||
return $adv->addAdv($data);
|
||||
} else {
|
||||
$pc_model = new PcModel();
|
||||
$pc_link = $pc_model->getLink();
|
||||
$this->assign('pc_link', $pc_link);
|
||||
|
||||
$adv_position = new AdvPosition();
|
||||
$adv_position_list = $adv_position->getAdvPositionList([
|
||||
[ 'site_id', '=', $this->site_id ],
|
||||
[ 'type', '=', 1 ],
|
||||
]);
|
||||
$this->assign('adv_position_list', $adv_position_list[ 'data' ]);
|
||||
|
||||
$ap_id = input('ap_id', 0);
|
||||
$this->assign('ap_id', $ap_id);
|
||||
return $this->fetch('adv/add_adv');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑广告
|
||||
*/
|
||||
public function editAdv()
|
||||
{
|
||||
$adv_id = input('adv_id', '');
|
||||
$adv = new AdvModel();
|
||||
if (request()->isJson()) {
|
||||
$data = [
|
||||
'ap_id' => input('ap_id', 0),
|
||||
'adv_title' => input('adv_title', ''),
|
||||
'adv_url' => input('adv_url', ''),
|
||||
'adv_image' => input('adv_image', ''),
|
||||
'slide_sort' => input('slide_sort', 0),
|
||||
'price' => input('price', 0),
|
||||
'background' => input('background', ''),
|
||||
'state' => input('state', 0),
|
||||
];
|
||||
return $adv->editAdv($data, [ [ 'adv_id', '=', $adv_id ], [ 'site_id', '=', $this->site_id ] ]);
|
||||
} else {
|
||||
$pc_model = new PcModel();
|
||||
$pc_link = $pc_model->getLink();
|
||||
$this->assign('pc_link', $pc_link);
|
||||
|
||||
$adv_position = new AdvPosition();
|
||||
$adv_position_list = $adv_position->getAdvPositionList([
|
||||
[ 'site_id', '=', $this->site_id ],
|
||||
[ 'type', '=', 1 ],
|
||||
]);
|
||||
$this->assign('adv_position_list', $adv_position_list[ 'data' ]);
|
||||
$adv_info = $adv->getAdvInfo($adv_id);
|
||||
//得出推荐宽高
|
||||
foreach ($adv_position_list[ 'data' ] as $k => $v) {
|
||||
if ($v[ 'ap_id' ] == $adv_info[ 'data' ][ 'ap_id' ]) {
|
||||
$adv_info[ 'data' ][ 'ap_width' ] = $v[ 'ap_width' ];
|
||||
$adv_info[ 'data' ][ 'ap_height' ] = $v[ 'ap_height' ];
|
||||
}
|
||||
}
|
||||
$this->assign('adv_info', $adv_info[ 'data' ]);
|
||||
// 得到当前广告图类型
|
||||
$type = 2;// 1 pc、2 wap
|
||||
foreach ($adv_position_list[ 'data' ] as $k => $v) {
|
||||
if ($v[ 'ap_id' ] == $adv_info[ 'data' ][ 'ap_id' ]) {
|
||||
$type = $v[ 'type' ];
|
||||
break;
|
||||
}
|
||||
}
|
||||
$this->assign('type', $type);
|
||||
|
||||
$ap_id = input('ap_id', 0);
|
||||
$this->assign('ap_id', $ap_id);
|
||||
|
||||
return $this->fetch('adv/edit_adv');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改广告字段
|
||||
*/
|
||||
public function editAdvField()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$adv = new AdvModel();
|
||||
$type = input('type', '');
|
||||
$value = input('value', '');
|
||||
$adv_id = input('adv_id', '');
|
||||
$data = [
|
||||
$type => $value
|
||||
];
|
||||
return $adv->editAdv($data, [ [ 'adv_id', '=', $adv_id ] ]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除广告
|
||||
*/
|
||||
public function deleteAdv()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$adv_ids = input('adv_ids', 0);
|
||||
$adv = new AdvModel();
|
||||
return $adv->deleteAdv([ [ 'adv_id', 'in', $adv_ids ], [ 'site_id', '=', $this->site_id ] ]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改广告位状态
|
||||
* @return array
|
||||
*/
|
||||
public function alterAdvPositionState()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$ap_id = input('ap_id', 0);
|
||||
$state = input('state', 0);
|
||||
$ap_model = new AdvPosition();
|
||||
return $ap_model->editAdvPosition([ 'state' => $state ], [ [ 'ap_id', '=', $ap_id ], [ 'site_id', '=', $this->site_id ] ]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改广告状态
|
||||
* @return array
|
||||
*/
|
||||
public function alterAdvState()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$adv_id = input('adv_id', 0);
|
||||
$state = input('state', 0);
|
||||
$ap_model = new AdvModel();
|
||||
return $ap_model->editAdv([ 'state' => $state ], [ [ 'adv_id', '=', $adv_id ], [ 'site_id', '=', $this->site_id ] ]);
|
||||
}
|
||||
}
|
||||
}
|
||||
508
addon/pc/shop/controller/Pc.php
Executable file
508
addon/pc/shop/controller/Pc.php
Executable file
@@ -0,0 +1,508 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
|
||||
* 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\pc\shop\controller;
|
||||
|
||||
use app\model\goods\GoodsCategory as GoodsCategoryModel;
|
||||
use addon\pc\model\Pc as PcModel;
|
||||
use app\model\web\Config;
|
||||
use app\shop\controller\BaseShop;
|
||||
use think\App;
|
||||
|
||||
/**
|
||||
* Pc端 控制器
|
||||
*/
|
||||
class Pc extends BaseShop
|
||||
{
|
||||
private $pc_model;
|
||||
|
||||
public function __construct(App $app = null)
|
||||
{
|
||||
$this->replace = [
|
||||
'ADDON_PC_CSS' => __ROOT__ . '/addon/pc/shop/view/public/css',
|
||||
'ADDON_PC_JS' => __ROOT__ . '/addon/pc/shop/view/public/js',
|
||||
'ADDON_PC_IMG' => __ROOT__ . '/addon/pc/shop/view/public/img',
|
||||
];
|
||||
$this->pc_model = new PcModel();
|
||||
parent::__construct($app);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取PC端部署信息
|
||||
* @return array
|
||||
*/
|
||||
public function getDeploy()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$config_model = new Config();
|
||||
$config = $config_model->getPcDomainName($this->site_id)[ 'data' ][ 'value' ];
|
||||
if ($config[ 'deploy_way' ] == 'separate') {
|
||||
$root_url = $config[ 'domain_name_pc' ];
|
||||
} else {
|
||||
$root_url = __ROOT__;
|
||||
}
|
||||
|
||||
$res = [
|
||||
'root_url' => __ROOT__,
|
||||
'roots_url' => $root_url,
|
||||
'config' => $config,
|
||||
];
|
||||
return success('', '', $res);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置pc端域名
|
||||
* @return array
|
||||
*/
|
||||
public function pcDomainName()
|
||||
{
|
||||
$config_model = new Config();
|
||||
$domain_name = input("domain", "");
|
||||
$deploy_way = input("deploy_way", "default");
|
||||
|
||||
if ($deploy_way == 'default') $domain_name = __ROOT__ . '/web';
|
||||
|
||||
$result = $config_model->setPcDomainName([
|
||||
'domain_name_pc' => $domain_name,
|
||||
'deploy_way' => $deploy_way
|
||||
]);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 默认部署:无需下载,一键刷新,API接口请求地址为当前域名,编译代码存放到web文件夹中
|
||||
*/
|
||||
public function downloadCsDefault()
|
||||
{
|
||||
$this->pcDomainName();
|
||||
return $this->pc_model->downloadCsDefault();
|
||||
}
|
||||
|
||||
/**
|
||||
* 独立部署:下载编译代码包,参考开发文档进行配置
|
||||
*/
|
||||
public function downloadCsSeparate()
|
||||
{
|
||||
if (strstr(ROOT_URL, 'niuteam.cn') === false) {
|
||||
$domain_name = input("domain", "");
|
||||
$res = $this->pc_model->downloadCsSeparate($domain_name);
|
||||
if ($res[ 'code' ] >= 0) {
|
||||
$config_model = new Config();
|
||||
$result = $config_model->setPcDomainName([
|
||||
'domain_name_pc' => $domain_name,
|
||||
'deploy_way' => 'separate'
|
||||
]);
|
||||
}
|
||||
echo $res[ 'message' ];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 源码下载:下载开源代码包,参考开发文档进行配置,结合业务需求进行二次开发
|
||||
*/
|
||||
public function downloadOs()
|
||||
{
|
||||
if (strstr(ROOT_URL, 'niuteam.cn') === false) {
|
||||
$res = $this->pc_model->downloadOs();
|
||||
echo $res[ 'message' ];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 首页浮层
|
||||
* @return mixed
|
||||
*/
|
||||
public function floatLayer()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$data = [
|
||||
'title' => input("title", ""),
|
||||
'url' => input("url", ""),
|
||||
'is_show' => input("is_show", 0),
|
||||
'number' => input("number", ""),
|
||||
'img_url' => input("img_url", "")
|
||||
];
|
||||
$res = $this->pc_model->setFloatLayer($data, $this->site_id);
|
||||
return $res;
|
||||
} else {
|
||||
$link = $this->pc_model->getLink();
|
||||
$this->assign("link", $link);
|
||||
$float_layer = $this->pc_model->getFloatLayer($this->site_id)[ 'data' ][ 'value' ];
|
||||
$this->assign("float_layer", $float_layer);
|
||||
return $this->fetch('pc/float_layer');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 导航设置
|
||||
* @return mixed
|
||||
*/
|
||||
public function navList()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$page = input('page', 1);
|
||||
$page_size = input('page_size', PAGE_LIST_ROWS);
|
||||
$search_text = input('search_text', '');
|
||||
|
||||
$condition = [
|
||||
[ 'site_id', '=', $this->site_id ]
|
||||
];
|
||||
if (!empty($search_text)) $condition[] = [ 'nav_title', 'like', '%' . $search_text . '%' ];
|
||||
$order = 'create_time desc';
|
||||
|
||||
$model = new PcModel();
|
||||
return $model->getNavPageList($condition, $page, $page_size, $order);
|
||||
} else {
|
||||
return $this->fetch('pc/nav_list');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加导航
|
||||
* @return mixed
|
||||
*/
|
||||
public function addNav()
|
||||
{
|
||||
$model = new PcModel();
|
||||
if (request()->isJson()) {
|
||||
$data = [
|
||||
'nav_title' => input('nav_title', ''),
|
||||
'nav_url' => input('nav_url', ''),
|
||||
'sort' => input('sort', ''),
|
||||
'is_blank' => input('is_blank', ''),
|
||||
'nav_icon' => input('nav_icon', ''),
|
||||
'is_show' => input('is_show', ''),
|
||||
'create_time' => time(),
|
||||
'site_id' => $this->site_id
|
||||
];
|
||||
|
||||
return $model->addNav($data);
|
||||
} else {
|
||||
$link_list = $model->getLink();
|
||||
$this->assign('link', $link_list);
|
||||
|
||||
return $this->fetch('pc/add_nav');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑导航
|
||||
* @return mixed
|
||||
*/
|
||||
public function editNav()
|
||||
{
|
||||
$model = new PcModel();
|
||||
if (request()->isJson()) {
|
||||
$data = [
|
||||
'nav_title' => input('nav_title', ''),
|
||||
'nav_url' => input('nav_url', ''),
|
||||
'sort' => input('sort', ''),
|
||||
'is_blank' => input('is_blank', ''),
|
||||
'nav_icon' => input('nav_icon', ''),
|
||||
'is_show' => input('is_show', ''),
|
||||
'modify_time' => time(),
|
||||
];
|
||||
$id = input('id', 0);
|
||||
$condition = [
|
||||
[ 'id', '=', $id ],
|
||||
[ 'site_id', '=', $this->site_id ]
|
||||
];
|
||||
|
||||
return $model->editNav($data, $condition);
|
||||
} else {
|
||||
$link_list = $model->getLink();
|
||||
$this->assign('link', $link_list);
|
||||
|
||||
$id = input('id', 0);
|
||||
$this->assign('id', $id);
|
||||
|
||||
$nav_info = $model->getNavInfo($id);
|
||||
$this->assign('nav_info', $nav_info[ 'data' ]);
|
||||
|
||||
return $this->fetch('pc/edit_nav');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除导航
|
||||
* @return mixed
|
||||
*/
|
||||
public function deleteNav()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$id = input('id', 0);
|
||||
$model = new PcModel();
|
||||
return $model->deleteNav([ [ 'id', '=', $id ], [ 'site_id', '=', $this->site_id ] ]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改排序
|
||||
*/
|
||||
public function modifySort()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$sort = input('sort', 0);
|
||||
$id = input('id', 0);
|
||||
$model = new PcModel();
|
||||
return $model->modifyNavSort($sort, $id);
|
||||
}
|
||||
}
|
||||
|
||||
public function modifyNavIsShow()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$is_show = input('is_show', 0);
|
||||
$id = input('id', 0);
|
||||
$model = new PcModel();
|
||||
return $model->editNav([ 'is_show' => $is_show ], [ [ 'id', '=', $id ] ]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 友情链接
|
||||
* @return mixed
|
||||
*/
|
||||
public function linklist()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$page = input('page', 1);
|
||||
$page_size = input('page_size', PAGE_LIST_ROWS);
|
||||
$search_text = input('search_text', '');
|
||||
|
||||
$condition = [
|
||||
[ 'site_id', '=', $this->site_id ]
|
||||
];
|
||||
if (!empty($search_text)) $condition[] = [ 'link_title', 'like', '%' . $search_text . '%' ];
|
||||
|
||||
//排序
|
||||
$link_sort = input('order', 'link_sort');
|
||||
$sort = input('sort', 'desc');
|
||||
if ($link_sort == 'link_sort') {
|
||||
$order_by = $link_sort . ' ' . $sort;
|
||||
} else {
|
||||
$order_by = $link_sort . ' ' . $sort . ',link_sort desc';
|
||||
}
|
||||
|
||||
$model = new PcModel();
|
||||
return $model->getLinkPageList($condition, $page, $page_size, $order_by);
|
||||
} else {
|
||||
return $this->fetch('pc/link_list');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加友情链接
|
||||
* @return mixed
|
||||
*/
|
||||
public function addLink()
|
||||
{
|
||||
$model = new PcModel();
|
||||
if (request()->isJson()) {
|
||||
$data = [
|
||||
'link_title' => input('link_title', ''),
|
||||
'link_url' => input('link_url', ''),
|
||||
'link_pic' => input('link_pic', ''),
|
||||
'link_sort' => input('link_sort', ''),
|
||||
'is_blank' => input('is_blank', ''),
|
||||
'is_show' => input('is_show', ''),
|
||||
'site_id' => $this->site_id
|
||||
];
|
||||
|
||||
return $model->addLink($data);
|
||||
} else {
|
||||
return $this->fetch('pc/add_link');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑友情链接
|
||||
* @return mixed
|
||||
*/
|
||||
public function editLink()
|
||||
{
|
||||
$model = new PcModel();
|
||||
if (request()->isJson()) {
|
||||
$data = [
|
||||
'link_title' => input('link_title', ''),
|
||||
'link_url' => input('link_url', ''),
|
||||
'link_pic' => input('link_pic', ''),
|
||||
'link_sort' => input('link_sort', ''),
|
||||
'is_blank' => input('is_blank', ''),
|
||||
'is_show' => input('is_show', ''),
|
||||
];
|
||||
$id = input('id', 0);
|
||||
$condition = [
|
||||
[ 'id', '=', $id ],
|
||||
[ 'site_id', '=', $this->site_id ]
|
||||
];
|
||||
return $model->editLink($data, $condition);
|
||||
} else {
|
||||
|
||||
$id = input('id', 0);
|
||||
$this->assign('id', $id);
|
||||
|
||||
$link_info = $model->getLinkInfo($id);
|
||||
$this->assign('link_info', $link_info[ 'data' ]);
|
||||
|
||||
return $this->fetch('pc/edit_link');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除友情链接
|
||||
* @return mixed
|
||||
*/
|
||||
public function deleteLink()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$id = input('id', 0);
|
||||
$model = new PcModel();
|
||||
return $model->deleteLink([ [ 'id', '=', $id ], [ 'site_id', '=', $this->site_id ] ]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改排序
|
||||
*/
|
||||
public function modifyLinkSort()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$sort = input('sort', 0);
|
||||
$id = input('id', 0);
|
||||
return $this->pc_model->modifyLinkSort($sort, $id);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 首页楼层
|
||||
* @return array|mixed
|
||||
*/
|
||||
public function floor()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$page = input('page', 1);
|
||||
$page_size = input('page_size', PAGE_LIST_ROWS);
|
||||
$search_text = input('search_text', '');
|
||||
$condition = [
|
||||
[ 'pf.site_id', '=', $this->site_id ]
|
||||
];
|
||||
if (!empty($search_text)) $condition[] = [ 'pf.title', 'like', '%' . $search_text . '%' ];
|
||||
$list = $this->pc_model->getFloorPageList($condition, $page, $page_size);
|
||||
return $list;
|
||||
} else {
|
||||
return $this->fetch('pc/floor');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改首页楼层排序
|
||||
*/
|
||||
public function modifyFloorSort()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$sort = input('sort', 0);
|
||||
$id = input('id', 0);
|
||||
$condition = array (
|
||||
[ 'id', '=', $id ],
|
||||
[ 'site_id', '=', $this->site_id ]
|
||||
);
|
||||
$res = $this->pc_model->modifyFloorSort($sort, $condition);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除首页楼层
|
||||
* @return array
|
||||
*/
|
||||
public function deleteFloor()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$id = input('id', 0);
|
||||
$res = $this->pc_model->deleteFloor([ [ 'id', '=', $id ], [ 'site_id', '=', $this->site_id ] ]);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑楼层
|
||||
* @return mixed
|
||||
*/
|
||||
public function editFloor()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$id = input("id", 0);
|
||||
$data = [
|
||||
'block_id' => input("block_id", 0), //楼层模板关联id
|
||||
'title' => input("title", ''), // 楼层标题
|
||||
'value' => input("value", ''),
|
||||
'state' => input("state", 0),// 状态(0:禁用,1:启用)
|
||||
'sort' => input("sort", 0), //排序号
|
||||
'site_id' => $this->site_id
|
||||
];
|
||||
if ($id == 0) {
|
||||
$res = $this->pc_model->addFloor($data);
|
||||
} else {
|
||||
$res = $this->pc_model->editFloor($data, [ [ 'id', '=', $id ], [ 'site_id', '=', $this->site_id ] ]);
|
||||
}
|
||||
return $res;
|
||||
} else {
|
||||
$id = input("id", 0);
|
||||
$this->assign("id", $id);
|
||||
|
||||
if (!empty($id)) {
|
||||
$floor_info = $this->pc_model->getFloorDetail($id, $this->site_id);
|
||||
$floor_info = $floor_info[ 'data' ];
|
||||
$this->assign("floor_info", $floor_info);
|
||||
}
|
||||
|
||||
$floor_block_list = $this->pc_model->getFloorBlockList();
|
||||
$floor_block_list = $floor_block_list[ 'data' ];
|
||||
$this->assign("floor_block_list", $floor_block_list);
|
||||
|
||||
$pc_link = $this->pc_model->getLink();
|
||||
$this->assign("pc_link", $pc_link);
|
||||
|
||||
$goods_category_model = new GoodsCategoryModel();
|
||||
$category_list = $goods_category_model->getCategoryTree([ [ 'site_id', '=', $this->site_id ] ]);
|
||||
$category_list = $category_list[ 'data' ];
|
||||
$this->assign("category_list", $category_list);
|
||||
return $this->fetch('pc/edit_floor');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* PC端首页分类设置
|
||||
* @return array|mixed
|
||||
*/
|
||||
public function category()
|
||||
{
|
||||
$config_model = new Config();
|
||||
if (request()->isJson()) {
|
||||
$data = array (
|
||||
"category" => input("category", "1"),
|
||||
"img" => input("img", "0")
|
||||
);
|
||||
$res = $config_model->setCategoryConfig($data, $this->site_id, $this->app_module);
|
||||
return $res;
|
||||
} else {
|
||||
$config_info = $config_model->getCategoryConfig($this->site_id, $this->app_module);
|
||||
$this->assign('config_info', $config_info[ 'data' ][ 'value' ]);
|
||||
return $this->fetch('pc/category');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user