jh-admin/app/api/controller/Diyview.php

147 lines
5.7 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
/**
* SaaSMall商城系统 - 团队十年电商经验汇集巨献!
* =========================================================
* Copy right 2023-2033 成都SAAS云科技有限公司, 保留所有权利。
* ----------------------------------------------
* 官方网址: https://www.gobuysaas.com
* =========================================================
*/
namespace app\api\controller;
use app\model\diy\Template;
use app\model\web\DiyView as DiyViewModel;
/**
* 自定义模板
* @package app\api\controller
*/
class Diyview extends BaseApi
{
/**
* 基础信息
*/
public function info()
{
$id = isset($this->params['id']) ? $this->params['id'] : 0;
$name = isset($this->params['name']) ? $this->params['name'] : '';
if (empty($id) && empty($name)) {
return $this->response($this->error('', 'REQUEST_DIY_ID_NAME'));
}
$this->initStoreData();
// 如果是连锁运营模式,则进入门店页面
if ($name == 'DIY_VIEW_INDEX' && $this->store_data['config']['store_business'] == 'store') {
$name = 'DIY_STORE';
}
$diy_view = new DiyViewModel();
if ($name != 'DIY_VIEW_RANDOM_1688636371') {
$condition = [
['site_id', '=', $this->site_id]
];
}
if (!empty($id)) {
$condition[] = ['id', '=', $id];
} elseif (!empty($name)) {
$condition[] = ['name', '=', $name];
$condition[] = ['is_default', '=', 1];
}
$info = $diy_view->getSiteDiyViewDetail($condition);
if (!empty($info['data'])) {
$diy_view->modifyClick([['id', '=', $info['data']['id']], ['site_id', '=', $this->site_id]]);
}
//增加套餐广告
if (!empty($info['data']) && $name!='DIY_VIEW_MEMBER_INDEX') {
$siteInfo = model('site')
->getInfo([['s.site_id', '=', $this->site_id]], 'ad_image,agent_id,is_ad_show', 's',
[
['site_group sg', 'sg.group_id = s.group_id', 'left']
]);
$version_status = model('applet_release')->getCount([['site_id', '=', $this->site_id], ['version_status', '=', 'AUDITING']]);//审核状态
if ($siteInfo['is_ad_show'] && $siteInfo['ad_image'] != '' && $version_status == 0) {
$info['data']['value'] = json_decode($info['data']['value'], true);
$info['data']['value']['global']['popWindow'] = [
"imageUrl" => $siteInfo['ad_image'],
"count" => 2,
"isFull" => 1,
"autoClose" => 5, //自动关闭时间
"background" => "#165FF1",
"show" => 0,
"link" => [
"name" => "MOBILE",
"title" => "拨打电话18982255122",
"mobile" => "18982255122",
"parent" => "MOBILE"
],
"imgWidth" => "2000",
"imgHeight" => "3422"
];
$info['data']['value'] = json_encode($info['data']['value'], JSON_UNESCAPED_UNICODE);
}
}else if(!empty($info['data']) && $name == 'DIY_VIEW_MEMBER_INDEX'){
$this->checkToken();
$member_id = $this->member_id;
$info['data']['value'] = json_decode($info['data']['value'], true);
foreach($info['data']['value']['value'] as $k => &$val){
if(isset($val['mode']) && $val['mode'] == 'graphic'){
$link = array_column($val['list'],'link');
$list = array_column($link,'name');
if(in_array('REGION_MANAGE',$list)){
$key = array_search('REGION_MANAGE',$list);
if($key && is_null($member_id)){
unset($val['list'][$key]);
}else if($key && !is_null($member_id)){
$manage_id = model('region_manage')->getInfo([ [ 'member_id', '=', $member_id ],['site_id', '=', $this->site_id] ],'id');
if(is_null($manage_id)){
unset($val['list'][$key]);
}
}
}
}
}
$info['data']['value'] = json_encode($info['data']['value'], JSON_UNESCAPED_UNICODE);
}
// 如果是连锁运营模式,标题显示门店名称
// if ($name == 'DIY_STORE' && $this->store_data[ 'config' ][ 'store_business' ] == 'store' && $this->store_data[ 'store_info' ]) {
// $info[ 'data' ][ 'value' ] = json_decode($info[ 'data' ][ 'value' ], true);
// $info[ 'data' ][ 'value' ][ 'global' ][ 'title' ] = $this->store_data[ 'store_info' ][ 'store_name' ];
// $info[ 'data' ][ 'value' ] = json_encode($info[ 'data' ][ 'value' ]);
// }
return $this->response($info);
}
/**
* 平台端底部导航
* @return string
*/
public function bottomNav()
{
$site_id = $this->site_id;
if (empty($site_id)) {
return $this->response($this->error('', 'REQUEST_SITE_ID'));
}
$diy_view = new DiyViewModel();
$info = $diy_view->getBottomNavConfig($site_id);
return $this->response($info);
}
/**
* 风格
*/
public function style()
{
$site_id = $this->site_id;
if (empty($site_id)) {
return $this->response($this->error('', 'REQUEST_SITE_ID'));
}
$diy_view = new DiyViewModel();
$res = $diy_view->getStyleConfig($this->site_id);
return $this->response($res);
}
}