HEX
Server: nginx/1.28.1
System: Linux 10-41-63-61 6.8.0-31-generic #31-Ubuntu SMP PREEMPT_DYNAMIC Sat Apr 20 00:40:06 UTC 2024 x86_64
User: www (1001)
PHP: 7.4.33
Disabled: passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv
Upload Files
File: /www/wwwroot/cms.smpolia.com/addons/model/DiyPage.php
<?php
// +----------------------------------------------------------------------
// | Yzncms [ 御宅男工作室 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2018 http://yzncms.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 御宅男 <530765310@qq.com>
// +----------------------------------------------------------------------

// +----------------------------------------------------------------------
// | diy页面设计模型
// +----------------------------------------------------------------------
namespace app\diywap\model;

use think\Model;

class DiyPage extends Model
{
    protected $autoWriteTimestamp = true;
    protected $insert             = ['status' => 1];
    // 追加属性
    protected $append = [
        'url',
    ];

    public function getUrlAttr($value, $data)
    {
        if ($data['page_type'] == '1') {
            $url = 'pages/index/index';
        } else {
            $url = 'pages/custom/index?page_id=' . $data['id'];
        }
        return request()->domain() . '/diywap/#/' . $url;
    }

    /**
     * 新增页面
     * @param $data
     * @return bool
     */
    public function add($data)
    {
        $count = $this->order(['id' => 'desc'])->count();
        if ($count > 0) {
            return $this->save([
                'page_type' => 2,
                'page_name' => json_decode($data, true)['page']['params']['name'],
                'page_data' => $data,
            ]);
        } else {
            return $this->save([
                'page_type' => 1,
                'page_name' => json_decode($data, true)['page']['params']['name'],
                'page_data' => $data,
            ]);
        }
    }

    /**
     * 更新页面
     * @param $data
     * @return bool
     */
    public function edit($data)
    {
        // 保存数据
        return $this->save([
            'page_name' => json_decode($data, true)['page']['params']['name'],
            'page_data' => $data,
        ]) !== false;
    }

    /**
     * 设为默认首页
     * @return int
     */
    public function setHome()
    {
        // 取消原默认首页
        $this->where('page_type', 1)->update(['page_type' => 2]);
        return $this->save(['page_type' => 1]);
    }

    /**
     * 页面标题栏默认数据
     * @return array
     */
    public function getDefaultPage()
    {
        return [
            'name'   => '页面设置',
            'type'   => 'page',
            'params' => [
                'name'       => '页面名称',
                'title'      => '页面标题',
                'shareTitle' => '分享标题',
            ],
            'style'  => [
                'titleTextColor'       => 'black',
                'titleBackgroundColor' => '#ffffff',
            ],
        ];
    }

    /**
     * 获取Url列表
     */
    public function getLinkUrl()
    {
        return [
            'Inlay'    => ['type' => 'Inlay', 'name' => '内置页面'],
            'Wxapp'    => ['type' => 'Wxapp', 'name' => '小程序'],
            'Outside'  => ['type' => 'Outside', 'name' => '外链'],
            'Phone'    => ['type' => 'Phone', 'name' => '拨打电话'],
            'Copy'     => ['type' => 'Copy', 'name' => '复制文本'],
            'Location' => ['type' => 'Location', 'name' => '查看位置'],
        ];
    }

    /**
     * 获取Url列表
     */
    public function getUrlList()
    {
        return $this->where('page_type', 2)->order(['id' => 'desc'])->select();
    }

    /**
     * 页面diy元素默认数据
     * @return array
     */
    public function getDefaultItems()
    {
        $url = request()->domain() . config('public_url');
        return [
            'title'    => [
                'name'   => '标题组',
                'type'   => 'title',
                'params' => [
                    'textStyle'     => 'textStyle1', //线条风格
                    'lineColor'     => "#434343", //线条颜色
                    'zhutitle'      => '主标题', //主标题
                    'zhutitlecolor' => '#434343', //主标题颜色
                    'zhutitlesize'  => 20, //主标题字体大小
                    'futitle'       => '副标题描述', //副标题
                    'futitlecolor'  => '#838383', //副标题颜色
                    'futitlesize'   => 14, //副标题字体大小
                ],
                'style'  => [
                    'marginLeft' => 20,
                    'paddingTop' => 10,
                    'background' => '#ffffff',
                ],
            ],
            'navBar'   => [
                'name'  => '导航组',
                'type'  => 'navBar',
                'style' => ['background' => '#ffffff', 'borderradius' => 0, 'rowsNum' => '4', 'paddingTop' => 10],
                'data'  => [
                    [
                        'imgUrl' => $url . 'static/modules/diywap/images/menu.png',
                        'link'   => null,
                        'text'   => '按钮文字1',
                        'color'  => '#666666',
                    ],
                    [
                        'imgUrl' => $url . 'static/modules/diywap/images/menu.png',
                        'link'   => null,
                        'text'   => '按钮文字2',
                        'color'  => '#666666',
                    ],
                    [
                        'imgUrl' => $url . 'static/modules/diywap/images/menu.png',
                        'link'   => null,
                        'text'   => '按钮文字3',
                        'color'  => '#666666',
                    ],
                    [
                        'imgUrl' => $url . 'static/modules/diywap/images/menu.png',
                        'link'   => null,
                        'text'   => '按钮文字4',
                        'color'  => '#666666',
                    ],
                    [
                        'imgUrl' => $url . 'static/modules/diywap/images/menu.png',
                        'link'   => null,
                        'text'   => '按钮文字5',
                        'color'  => '#666666',
                    ],
                    [
                        'imgUrl' => $url . 'static/modules/diywap/images/menu.png',
                        'link'   => null,
                        'text'   => '按钮文字6',
                        'color'  => '#666666',
                    ],
                    [
                        'imgUrl' => $url . 'static/modules/diywap/images/menu.png',
                        'link'   => null,
                        'text'   => '按钮文字7',
                        'color'  => '#666666',
                    ],
                    [
                        'imgUrl' => $url . 'static/modules/diywap/images/menu.png',
                        'link'   => null,
                        'text'   => '按钮文字8',
                        'color'  => '#666666',
                    ],
                ],
            ],
            'video'    => [
                'name'   => '视频组',
                'type'   => 'video',
                'params' => [
                    'videoUrl' => '',
                    'poster'   => $url . 'static/modules/diywap/images/video_poster.png',
                    'autoplay' => 0,
                ],
                'style'  => [
                    'paddingTop'  => 0,
                    'paddingLeft' => 0,
                    'height'      => 190,
                ],
            ],
            'notice'   => [
                'name'   => '系统公告',
                'type'   => 'notice',
                'params' => [
                    'text'       => '这里是一条自定义公告的标题', // 公告内容
                    'link'       => null, // 链接
                    'showIcon'   => true, // 是否显示图标
                    'scrollable' => true, // 是否滚动
                ],
                'style'  => [
                    'paddingTop' => 0,
                    'background' => '#fffbe8',
                    'textColor'  => '#de8c17',
                ],
            ],
            'banner'   => [
                'name'   => '图片轮播',
                'type'   => 'banner',
                'style'  => [
                    'btnColor' => '#ffffff',
                    'btnShape' => 'round',
                ],
                'params' => [
                    'interval' => 3000,
                    'autoplay' => 1,
                ],
                'data'   => [
                    [
                        'imgUrl' => $url . 'static/modules/diywap/images/banner.png',
                        'link'   => null,
                    ],
                    [
                        'imgUrl' => $url . 'static/modules/diywap/images/banner.png',
                        'link'   => null,
                    ],
                ],
            ],
            'window'   => [
                'name'    => '图片魔方',
                'type'    => 'window',
                'style'   => [
                    'paddingTop'  => 0,
                    'paddingLeft' => 0,
                    'background'  => '#ffffff',
                    'layout'      => 2, // 布局方式: -1橱窗
                ],
                'data'    => [
                    [
                        'imgUrl' => $url . 'static/modules/diywap/images/01.jpg',
                        'link'   => null,
                    ],
                    [
                        'imgUrl' => $url . 'static/modules/diywap/images/02.jpg',
                        'link'   => null,
                    ],
                    [
                        'imgUrl' => $url . 'static/modules/diywap/images/03.jpg',
                        'link'   => null,
                    ],
                    [
                        'imgUrl' => $url . 'static/modules/diywap/images/04.jpg',
                        'link'   => null,
                    ],
                ],
                'dataNum' => 4,
            ],
            'richText' => [
                'name'   => '富文本',
                'type'   => 'richText',
                'params' => [
                    'content' => '<p>这里是文本的内容</p>',
                ],
                'style'  => [
                    'paddingTop'  => 0,
                    'paddingLeft' => 0,
                    'background'  => '#ffffff',
                ],
            ],
            'blank'    => [
                'name'  => '辅助空白',
                'type'  => 'blank',
                'style' => [
                    'height'     => 20,
                    'background' => '#ffffff',
                ],
            ],
            'guide'    => [
                'name'  => '辅助线',
                'type'  => 'guide',
                'style' => [
                    'background' => '#ffffff',
                    'lineStyle'  => 'solid',
                    'lineHeight' => 1,
                    'lineColor'  => "#000000",
                    'paddingTop' => 10,
                ],
            ],
            'service'  => [
                'name'   => '在线客服',
                'type'   => 'service',
                'params' => [
                    'type'  => 'chat', // '客服类型' => chat在线聊天,phone拨打电话 link 链接
                    'image' => $url . 'static/modules/diywap/images/service.png',
                    'tel'   => '', // 电话号码
                    'link'  => null,
                ],
                'style'  => [
                    'right'   => 1,
                    'bottom'  => 10,
                    'opacity' => 100,
                ],
            ],
            'map'      => [
                'name'   => '地图',
                'type'   => 'map',
                'params' => [
                    'imgUrl'    => $url . 'static/modules/diywap/images/map.jpg',
                    'iconPath'  => $url . 'static/modules/diywap/images/location.png',
                    'height'    => 250,
                    'latitude'  => 31.330907,
                    'longitude' => 120.610467,
                ],
                'style'  => [
                    'paddingTop'  => 10,
                    'paddingLeft' => 10,
                    'background'  => '#ffffff',
                ],
            ],
            'webview'  => [
                'name'   => 'webview',
                'type'   => 'webview',
                'params' => [
                    'url' => 'http://www.baidu.com/',
                ],
            ],
            'music'    => [
                'name'   => '音乐',
                'type'   => 'music',
                'params' => [
                    'ImgUrl'   => $url . 'static/modules/diywap/images/music.png',
                    'musicUrl' => 'https://bjetxgzv.cdn.bspapp.com/VKCEYUGU-hello-uniapp/2cc220e0-c27a-11ea-9dfb-6da8e309e0d8.mp3',
                ],
                'style'  => [
                    'right'   => 1,
                    'top'     => 4,
                    'opacity' => 100,
                ],
            ],
            'form'     => [
                'name'   => '表单',
                'type'   => 'form',
                'params' => [
                    'id' => 0,
                ],
                'style'  => [
                    'labelPosition' => 'left',
                    'paddingLeft'   => 20,
                    'paddingTop'    => 10,
                    'background'    => '#ffffff',
                ],
            ],
        ];
    }
}