| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510 |
- <?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;
- /**
- * Pc端 控制器
- */
- class Pc extends BaseShop
- {
- private $pc_model;
- protected $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',
- ];
- public function __construct()
- {
- $this->pc_model = new PcModel();
- parent::__construct();
- }
- /**
- * 网站部署
- */
- public function deploy()
- {
- $refresh_time = 0;
- $path = 'web/refresh.log';
- if (file_exists($path)) {
- $refresh_time = file_get_contents($path);
- }
- $this->assign('refresh_time', $refresh_time);
- $config_model = new Config();
- $config = $config_model->getPcDomainName($this->site_id);
- if ($config[ 'data' ][ 'value' ][ 'deploy_way' ] == 'separate') {
- $root_url = $config[ 'data' ][ 'value' ][ 'domain_name_pc' ];
- } else {
- $root_url = __ROOT__;
- }
- $this->assign('config', $config[ 'data' ][ 'value' ]);
- $this->assign("roots_url", $root_url);
- $this->assign("root_url", __ROOT__);
- return $this->fetch('addon/pc/shop/view/pc/deploy.html');
- }
- /**
- * 设置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()->isAjax()) {
- $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);
- $float_layer = $float_layer[ 'data' ][ 'value' ];
- $this->assign("float_layer", $float_layer);
- return $this->fetch('pc/float_layer');
- }
- }
- /**
- * 导航设置
- * @return mixed
- */
- public function navList()
- {
- if (request()->isAjax()) {
- $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()->isAjax()) {
- $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()->isAjax()) {
- $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()->isAjax()) {
- $id = input('id', 0);
- $model = new PcModel();
- return $model->deleteNav([ [ 'id', '=', $id ], [ 'site_id', '=', $this->site_id ] ]);
- }
- }
- /**
- * 修改排序
- */
- public function modifySort()
- {
- if (request()->isAjax()) {
- $sort = input('sort', 0);
- $id = input('id', 0);
- $model = new PcModel();
- return $model->modifyNavSort($sort, $id);
- }
- }
- public function modifyNavIsShow()
- {
- if (request()->isAjax()) {
- $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()->isAjax()) {
- $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()->isAjax()) {
- $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()->isAjax()) {
- $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()->isAjax()) {
- $id = input('id', 0);
- $model = new PcModel();
- return $model->deleteLink([ [ 'id', '=', $id ], [ 'site_id', '=', $this->site_id ] ]);
- }
- }
- /**
- * 修改排序
- */
- public function modifyLinkSort()
- {
- if (request()->isAjax()) {
- $sort = input('sort', 0);
- $id = input('id', 0);
- return $this->pc_model->modifyLinkSort($sort, $id);
- }
- }
- /**
- * 首页楼层
- * @return array|mixed
- */
- public function floor()
- {
- if (request()->isAjax()) {
- $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()->isAjax()) {
- $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()->isAjax()) {
- $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()->isAjax()) {
- $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', [], $this->replace);
- }
- }
- /**
- * PC端首页分类设置
- * @return array|mixed
- */
- public function category()
- {
- $config_model = new Config();
- if (request()->isAjax()) {
- $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');
- }
- }
- }
|