MchDiyConfig.php 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. <?php
  2. /**
  3. * 重庆赤晓店信息科技有限公司
  4. * https://www.chixiaodian.com
  5. * Copyright (c) 2023 赤店商城 All rights reserved.
  6. */
  7. namespace app\models\common\diy;
  8. use app\models\DiyPage;
  9. use app\models\DiyTemplate;
  10. use app\models\MchDiyTemplate;
  11. use yii\helpers\Json;
  12. class MchDiyConfig extends \yii\db\ActiveRecord
  13. {
  14. const DIY_CONFIG = [
  15. [
  16. 'name' => '基础组件',
  17. 'sub' => [
  18. [
  19. 'name' => '搜索',
  20. 'type' => 'search',
  21. 'icon' => 'search',
  22. 'param' => [
  23. 'backgroundColorW' => '#eeeeee',
  24. 'backgroundColor' => '#ffffff',
  25. 'borderRadius' => 4,
  26. 'color' => '#b2b2b2',
  27. 'textPosition' => 'left',
  28. 'text' => '搜索'
  29. ]
  30. ],
  31. [
  32. 'name' => '导航图标',
  33. 'type' => 'nav',
  34. 'icon' => 'menu',
  35. 'param' => [
  36. 'backgroundColor' => '#efeff4',
  37. 'count' => 3,
  38. 'col' => 1,
  39. 'list' => [],
  40. 'is_slide' => 1
  41. ]
  42. ],
  43. [
  44. 'name' => '轮播广告',
  45. 'type' => 'banner',
  46. 'icon' => 'block',
  47. 'param' => [
  48. 'bg_color' => '#ffffff',
  49. 'style' => 1,
  50. 'fill' => 1,
  51. 'list' => [],
  52. 'height' => 280
  53. ]
  54. ],
  55. [
  56. 'name' => '公告',
  57. 'type' => 'notice',
  58. 'icon' => 'sound',
  59. 'param' => [
  60. 'bg_color' => '#f67f79',
  61. 'color' => '#ffffff',
  62. 'icon' => '',
  63. 'name' => '公告',
  64. 'content' => ''
  65. ]
  66. ],
  67. [
  68. 'name' => '关联连接',
  69. 'type' => 'link',
  70. 'icon' => 'link',
  71. 'param' => [
  72. 'backgroundColor' => '#ffffff',
  73. 'color' => '#353535',
  74. 'name' => '',
  75. 'icon' => '',
  76. 'is_icon' => 1,
  77. 'url' => '',
  78. 'left' => 0,
  79. 'is_jiantou' => 1,
  80. 'page_name' => '',
  81. 'position' => 0
  82. ]
  83. ],
  84. [
  85. 'name' => '图片广告',
  86. 'type' => 'rubik',
  87. 'icon' => 'file-image',
  88. 'param' => [
  89. 'style' => 0,
  90. 'fill' => 1,
  91. 'space' => 0,
  92. 'width' => 4,
  93. 'height' => 4,
  94. 'minHeight' => 360,
  95. 'new_minHeight' => 360,
  96. 'list' => []
  97. ]
  98. ],
  99. [
  100. 'name' => '视频',
  101. 'type' => 'video',
  102. 'icon' => 'video-camera',
  103. 'param' => [
  104. 'url' => '',
  105. 'pic_url' => ''
  106. ]
  107. ],
  108. [
  109. 'name' => '商品',
  110. 'type' => 'goods',
  111. 'icon' => 'wallet',
  112. 'param' => [
  113. 'is_cat' => 0,
  114. 'cat_position' => 0,
  115. 'cat_style' => 0,
  116. 'list' => [],
  117. 'goods_list' => [],
  118. 'list_style' => 0,
  119. 'fill' => 1,
  120. 'per' => 0,
  121. 'style' => 0,
  122. 'name' => 1,
  123. 'price' => 1,
  124. 'old_price' => 1,
  125. 'buy' => 1,
  126. 'buy_list' => [],
  127. 'buy_content' => '',
  128. 'mark' => 0,
  129. 'mark_list' => 4,
  130. 'mark_url' => '',
  131. 'cat_index' => 0,
  132. 'buy_default' => '购买'
  133. ]
  134. ],
  135. ]
  136. ],
  137. [
  138. 'name' => '其他组件',
  139. 'sub' => [
  140. [
  141. 'name' => '空白占位符',
  142. 'type' => 'line',
  143. 'icon' => 'container',
  144. 'param' => [
  145. 'backgroundColor' => '#eeeeee',
  146. 'height' => 1
  147. ]
  148. ]
  149. ]
  150. ],
  151. ];
  152. /**
  153. * 获取diy配置
  154. */
  155. public static function getConfig()
  156. {
  157. return self::DIY_CONFIG;
  158. }
  159. /**
  160. * 获取diy配置
  161. * @param $id
  162. * @return DiyTemplate|array|\yii\db\ActiveRecord[]|null
  163. */
  164. public static function getSetting($id = 0)
  165. {
  166. if ($id) {
  167. $page = MchDiyTemplate::findOne([
  168. 'id' => $id,
  169. 'store_id' => get_store_id(),
  170. 'is_delete' => 0,
  171. 'mch_id' => get_mch_id()
  172. ]);
  173. if ($page) {
  174. $page->toArray();
  175. $page['template'] = $page['template'] ? Json::decode($page['template']) : [];
  176. return $page;
  177. } else {
  178. return [];
  179. }
  180. }
  181. $page = MchDiyTemplate::find()
  182. ->where([
  183. 'store_id' => get_store_id(),
  184. 'is_delete' => 0,
  185. 'mch_id' => get_mch_id()
  186. ])->orderBy(['id' => SORT_ASC])->asArray()->all();
  187. foreach ($page as &$val) {
  188. $val['template'] = $val['template'] ? Json::decode($page['template']) : [];
  189. }
  190. return $page;
  191. }
  192. }