| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199 |
- <?php
- /**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
- namespace app\models\common\diy;
- use app\models\DiyPage;
- use app\models\DiyTemplate;
- use app\models\MchDiyTemplate;
- use yii\helpers\Json;
- class MchDiyConfig extends \yii\db\ActiveRecord
- {
- const DIY_CONFIG = [
- [
- 'name' => '基础组件',
- 'sub' => [
- [
- 'name' => '搜索',
- 'type' => 'search',
- 'icon' => 'search',
- 'param' => [
- 'backgroundColorW' => '#eeeeee',
- 'backgroundColor' => '#ffffff',
- 'borderRadius' => 4,
- 'color' => '#b2b2b2',
- 'textPosition' => 'left',
- 'text' => '搜索'
- ]
- ],
- [
- 'name' => '导航图标',
- 'type' => 'nav',
- 'icon' => 'menu',
- 'param' => [
- 'backgroundColor' => '#efeff4',
- 'count' => 3,
- 'col' => 1,
- 'list' => [],
- 'is_slide' => 1
- ]
- ],
- [
- 'name' => '轮播广告',
- 'type' => 'banner',
- 'icon' => 'block',
- 'param' => [
- 'bg_color' => '#ffffff',
- 'style' => 1,
- 'fill' => 1,
- 'list' => [],
- 'height' => 280
- ]
- ],
- [
- 'name' => '公告',
- 'type' => 'notice',
- 'icon' => 'sound',
- 'param' => [
- 'bg_color' => '#f67f79',
- 'color' => '#ffffff',
- 'icon' => '',
- 'name' => '公告',
- 'content' => ''
- ]
- ],
- [
- 'name' => '关联连接',
- 'type' => 'link',
- 'icon' => 'link',
- 'param' => [
- 'backgroundColor' => '#ffffff',
- 'color' => '#353535',
- 'name' => '',
- 'icon' => '',
- 'is_icon' => 1,
- 'url' => '',
- 'left' => 0,
- 'is_jiantou' => 1,
- 'page_name' => '',
- 'position' => 0
- ]
- ],
- [
- 'name' => '图片广告',
- 'type' => 'rubik',
- 'icon' => 'file-image',
- 'param' => [
- 'style' => 0,
- 'fill' => 1,
- 'space' => 0,
- 'width' => 4,
- 'height' => 4,
- 'minHeight' => 360,
- 'new_minHeight' => 360,
- 'list' => []
- ]
- ],
- [
- 'name' => '视频',
- 'type' => 'video',
- 'icon' => 'video-camera',
- 'param' => [
- 'url' => '',
- 'pic_url' => ''
- ]
- ],
- [
- 'name' => '商品',
- 'type' => 'goods',
- 'icon' => 'wallet',
- 'param' => [
- 'is_cat' => 0,
- 'cat_position' => 0,
- 'cat_style' => 0,
- 'list' => [],
- 'goods_list' => [],
- 'list_style' => 0,
- 'fill' => 1,
- 'per' => 0,
- 'style' => 0,
- 'name' => 1,
- 'price' => 1,
- 'old_price' => 1,
- 'buy' => 1,
- 'buy_list' => [],
- 'buy_content' => '',
- 'mark' => 0,
- 'mark_list' => 4,
- 'mark_url' => '',
- 'cat_index' => 0,
- 'buy_default' => '购买'
- ]
- ],
- ]
- ],
- [
- 'name' => '其他组件',
- 'sub' => [
- [
- 'name' => '空白占位符',
- 'type' => 'line',
- 'icon' => 'container',
- 'param' => [
- 'backgroundColor' => '#eeeeee',
- 'height' => 1
- ]
- ]
- ]
- ],
- ];
- /**
- * 获取diy配置
- */
- public static function getConfig()
- {
- return self::DIY_CONFIG;
- }
- /**
- * 获取diy配置
- * @param $id
- * @return DiyTemplate|array|\yii\db\ActiveRecord[]|null
- */
- public static function getSetting($id = 0)
- {
- if ($id) {
- $page = MchDiyTemplate::findOne([
- 'id' => $id,
- 'store_id' => get_store_id(),
- 'is_delete' => 0,
- 'mch_id' => get_mch_id()
- ]);
- if ($page) {
- $page->toArray();
- $page['template'] = $page['template'] ? Json::decode($page['template']) : [];
- return $page;
- } else {
- return [];
- }
- }
- $page = MchDiyTemplate::find()
- ->where([
- 'store_id' => get_store_id(),
- 'is_delete' => 0,
- 'mch_id' => get_mch_id()
- ])->orderBy(['id' => SORT_ASC])->asArray()->all();
- foreach ($page as &$val) {
- $val['template'] = $val['template'] ? Json::decode($page['template']) : [];
- }
- return $page;
- }
- }
|