DiyConfig.php 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507
  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 yii\helpers\Json;
  11. class DiyConfig extends \yii\db\ActiveRecord
  12. {
  13. const DIY_CONFIG = [
  14. [
  15. 'name' => '基础组件',
  16. 'sub' => [
  17. [
  18. 'name' => '搜索',
  19. 'type' => 'search',
  20. 'icon' => 'search',
  21. 'param' => [
  22. 'backgroundColorW' => '#eeeeee',
  23. 'backgroundColor' => '#ffffff',
  24. 'borderRadius' => 4,
  25. 'color' => '#b2b2b2',
  26. 'textPosition' => 'left',
  27. 'text' => '搜索'
  28. ]
  29. ],
  30. [
  31. 'name' => '导航图标',
  32. 'type' => 'nav',
  33. 'icon' => 'menu',
  34. 'param' => [
  35. 'backgroundColor' => '#efeff4',
  36. 'count' => 3,
  37. 'col' => 1,
  38. 'list' => [],
  39. 'is_slide' => 1
  40. ]
  41. ],
  42. [
  43. 'name' => '轮播广告',
  44. 'type' => 'banner',
  45. 'icon' => 'block',
  46. 'param' => [
  47. 'bg_color' => '#ffffff',
  48. 'style' => 1,
  49. 'fill' => 1,
  50. 'list' => [],
  51. 'height' => 280
  52. ]
  53. ],
  54. [
  55. 'name' => '公告',
  56. 'type' => 'notice',
  57. 'icon' => 'sound',
  58. 'param' => [
  59. 'bg_color' => '#f67f79',
  60. 'color' => '#ffffff',
  61. 'icon' => '',
  62. 'name' => '公告',
  63. 'content' => ''
  64. ]
  65. ],
  66. [
  67. 'name' => '专题',
  68. 'type' => 'topic',
  69. 'icon' => 'reconciliation',
  70. 'param' => [
  71. 'count' => 1,
  72. 'logo_1' => '',
  73. 'logo_2' => '',
  74. 'heated' => '',
  75. 'style' => 0,
  76. 'list' => [],
  77. 'is_cat' => 0
  78. ]
  79. ],
  80. [
  81. 'name' => '关联连接',
  82. 'type' => 'link',
  83. 'icon' => 'link',
  84. 'param' => [
  85. 'backgroundColor' => '#ffffff',
  86. 'color' => '#353535',
  87. 'name' => '',
  88. 'icon' => '',
  89. 'is_icon' => 1,
  90. 'url' => '',
  91. 'left' => 0,
  92. 'is_jiantou' => 1,
  93. 'page_name' => '',
  94. 'position' => 0
  95. ]
  96. ],
  97. [
  98. 'name' => '图片广告',
  99. 'type' => 'rubik',
  100. 'icon' => 'file-image',
  101. 'param' => [
  102. 'style' => 0,
  103. 'fill' => 1,
  104. 'space' => 0,
  105. 'width' => 4,
  106. 'height' => 4,
  107. 'minHeight' => 360,
  108. 'new_minHeight' => 360,
  109. 'list' => []
  110. ]
  111. ],
  112. [
  113. 'name' => '视频',
  114. 'type' => 'video',
  115. 'icon' => 'video-camera',
  116. 'param' => [
  117. 'url' => '',
  118. 'pic_url' => ''
  119. ]
  120. ],
  121. [
  122. 'name' => '商品',
  123. 'type' => 'goods',
  124. 'icon' => 'wallet',
  125. 'param' => [
  126. 'is_cat' => 0,
  127. 'cat_position' => 0,
  128. 'cat_style' => 0,
  129. 'list' => [],
  130. 'goods_list' => [],
  131. 'list_style' => 0,
  132. 'fill' => 1,
  133. 'per' => 0,
  134. 'style' => 0,
  135. 'name' => 1,
  136. 'price' => 1,
  137. 'old_price' => 1,
  138. 'buy' => 1,
  139. 'buy_list' => [],
  140. 'buy_content' => '',
  141. 'mark' => 0,
  142. 'mark_list' => 4,
  143. 'mark_url' => '',
  144. 'cat_index' => 0,
  145. 'buy_default' => '购买'
  146. ]
  147. ],
  148. [
  149. 'name' => '门店信息',
  150. 'type' => 'shop_info',
  151. 'icon' => 'contacts',
  152. 'param' => [
  153. 'bg_color' => '#ffffff',
  154. 'default_search_text' => '搜索',
  155. 'font_color' => '#ffffff',
  156. 'btn_1_img' => '',
  157. 'btn_1_text' => '',
  158. 'btn_1_page_name' => '',
  159. 'btn_1_url' => '',
  160. 'btn_1_open_type' => '',
  161. 'btn_2_img' => '',
  162. 'btn_2_text' => '',
  163. 'btn_2_page_name' => '',
  164. 'btn_2_url' => '',
  165. 'btn_2_open_type' => '',
  166. ]
  167. ],
  168. [
  169. 'name' => '门店',
  170. 'type' => 'shop',
  171. 'icon' => 'bank',
  172. 'param' => [
  173. 'list' => [],
  174. 'name' => 1,
  175. 'score' => 1,
  176. 'mobile' => 1,
  177. 'distance' => 1
  178. ]
  179. ],
  180. [
  181. 'name' => '超级品牌',
  182. 'type' => 'super_brand',
  183. 'icon' => 'sketch',
  184. 'param' => [
  185. 'name' => '超级品牌周',
  186. 'list' => []
  187. ]
  188. ],
  189. [
  190. 'name' => '附近店铺',
  191. 'type' => 'nearby_mch',
  192. 'icon' => 'shop',
  193. 'param' => [
  194. 'show_num' => 3,
  195. 'show_goods_num' => 6
  196. ]
  197. ],
  198. [
  199. 'name' => '图片活动',
  200. 'type' => 'plate',
  201. 'icon' => 'picture',
  202. 'param' => [
  203. 'list' => [],
  204. 'padding_top' => 0,
  205. 'padding_bottom' => 0
  206. ]
  207. ],
  208. [
  209. 'name' => '快捷导航',
  210. 'type' => 'fast_nav',
  211. 'icon' => 'monitor',
  212. 'param' => [
  213. 'list' => [],
  214. 'padding_top' => 0,
  215. 'padding_bottom' => 0,
  216. 'bg_color' => '#F50A0A'
  217. ]
  218. ],
  219. [
  220. 'name' => '推荐商品',
  221. 'type' => 'recommend_goods',
  222. 'icon' => 'import',
  223. 'param' => [
  224. 'list' => []
  225. ]
  226. ]
  227. ]
  228. ],
  229. [
  230. 'name' => '营销组件',
  231. 'sub' => [
  232. [
  233. 'name' => '优惠券',
  234. 'type' => 'coupon',
  235. 'icon' => 'account-book',
  236. 'param' => [
  237. 'bg' => '',
  238. 'bg_1' => '',
  239. 'color' => '#ffffff'
  240. ]
  241. ],
  242. [
  243. 'name' => '倒计时',
  244. 'type' => 'time',
  245. 'icon' => 'hourglass',
  246. 'param' => [
  247. 'pic_url' => '',
  248. 'url' => '',
  249. 'open_type' => '',
  250. 'start_time' => '',
  251. 'end_time' => '',
  252. 'date_start' => '',
  253. 'date_end' => '',
  254. 'pic_url_1' => ''
  255. ]
  256. ],
  257. [
  258. 'name' => '拼团',
  259. 'type' => 'pintuan',
  260. 'icon' => 'build',
  261. 'param' => [
  262. 'list' => []
  263. ]
  264. ],
  265. [
  266. 'name' => '秒杀',
  267. 'type' => 'miaosha',
  268. 'icon' => 'history',
  269. 'param' => [
  270. 'list' => [],
  271. 'list_style' => 0,
  272. 'fill' => 1,
  273. 'per' => 0,
  274. 'style' => 0,
  275. 'time' => 1,
  276. 'name' => 1,
  277. 'price' => 1,
  278. 'old_price' => 1,
  279. 'buy' => 1,
  280. 'buy_list' => 2,
  281. 'buy_content' => '',
  282. 'mark' => 0,
  283. 'mark_list' => 4,
  284. 'mark_url' => '',
  285. 'buy_default' => '马上秒'
  286. ]
  287. ],
  288. [
  289. 'name' => '预约',
  290. 'type' => 'book',
  291. 'icon' => 'dashboard',
  292. 'param' => [
  293. 'list' => [],
  294. 'list_style' => 0,
  295. 'fill' => 1,
  296. 'per' => 0,
  297. 'style' => 0,
  298. 'name' => 1,
  299. 'price' => 1,
  300. 'buy' => 1,
  301. 'buy_list' => 2,
  302. 'buy_content' => '',
  303. 'mark' => 0,
  304. 'mark_list' => 4,
  305. 'mark_url' => '',
  306. 'buy_default' => '预约'
  307. ]
  308. ],
  309. [
  310. 'name' => '砍价',
  311. 'type' => 'bargain',
  312. 'icon' => 'thunderbolt',
  313. 'param' => [
  314. 'list' => [],
  315. 'list_style' => 0,
  316. 'fill' => 1,
  317. 'per' => 0,
  318. 'style' => 0,
  319. 'time' => 1,
  320. 'name' => 1,
  321. 'price' => 1,
  322. 'old_price' => 1,
  323. 'buy' => 1,
  324. 'buy_list' => 2,
  325. 'buy_content' => '',
  326. 'mark' => 0,
  327. 'mark_list' => 4,
  328. 'mark_url' => '',
  329. 'buy_default' => '去参与'
  330. ]
  331. ],
  332. [
  333. 'name' => '好店推荐',
  334. 'type' => 'mch',
  335. 'icon' => 'trophy',
  336. 'param' => [
  337. 'is_goods' => 0,
  338. 'list' => [],
  339. 'price' => 1
  340. ]
  341. ],
  342. [
  343. 'name' => '积分商城',
  344. 'type' => 'integral',
  345. 'icon' => 'property-safety',
  346. 'param' => [
  347. 'bg_1' => '',
  348. 'color' => '#ffffff',
  349. 'is_coupon' => 1,
  350. 'is_goods' => 1,
  351. 'list' => [],
  352. 'list_style' => 0,
  353. 'fill' => 1,
  354. 'per' => 0,
  355. 'style' => 0,
  356. 'name' => 1,
  357. 'price' => 1,
  358. 'buy' => 1,
  359. 'buy_list' => 2,
  360. 'buy_content' => '',
  361. 'mark' => 0,
  362. 'mark_list' => 0,
  363. 'mark_url' => '',
  364. 'buy_default' => '立即兑换'
  365. ]
  366. ],
  367. [
  368. 'name' => '抽奖',
  369. 'type' => 'lottery',
  370. 'icon' => 'gift',
  371. 'param' => [
  372. 'list' => [],
  373. 'list_style' => 0,
  374. 'fill' => 1,
  375. 'per' => 0,
  376. 'style' => 0,
  377. 'time' => 1,
  378. 'name' => 1,
  379. 'price' => 1,
  380. 'old_price' => 1,
  381. 'buy' => 1,
  382. 'buy_list' => 2,
  383. 'buy_content' => '',
  384. 'mark' => 0,
  385. 'mark_list' => 4,
  386. 'mark_url' => '',
  387. 'buy_default' => '去参与'
  388. ]
  389. ],
  390. [
  391. 'name' => '整点秒杀',
  392. 'type' => 'hourly_miaosha',
  393. 'icon' => 'history',
  394. 'param' => [
  395. 'goods_list' => [],
  396. 'show_num' => 3
  397. ]
  398. ],
  399. [
  400. 'name' => '首页推荐',
  401. 'type' => 'index_recommend',
  402. 'icon' => 'like',
  403. 'param' => [
  404. 'list' => [
  405. [
  406. 'name' => '',
  407. 'title' => '',
  408. 'title_color' => '#ff0000',
  409. 'icon' => '',
  410. 'img_1' => '',
  411. 'img_1_page_name' => '',
  412. 'img_1_url' => '',
  413. 'img_1_open_type' => '',
  414. 'img_2' => '',
  415. 'img_2_page_name' => '',
  416. 'img_2_url' => '',
  417. 'img_2_open_type' => ''
  418. ]
  419. ]
  420. ]
  421. ]
  422. ]
  423. ],
  424. [
  425. 'name' => '其他组件',
  426. 'sub' => [
  427. [
  428. 'name' => '空白占位符',
  429. 'type' => 'line',
  430. 'icon' => 'container',
  431. 'param' => [
  432. 'backgroundColor' => '#eeeeee',
  433. 'height' => 1
  434. ]
  435. ],
  436. [
  437. 'name' => '流量主',
  438. 'type' => 'ad',
  439. 'icon' => 'tags',
  440. 'param' => [
  441. 'id' => ''
  442. ]
  443. ],
  444. [
  445. 'name' => '弹窗广告',
  446. 'type' => 'modal',
  447. 'icon' => 'tablet',
  448. 'param' => [
  449. 'show' => 0,
  450. 'pic_url' => '',
  451. 'url' => '',
  452. 'open_type' => '',
  453. 'status' => 0,
  454. 'pic_width' => 650,
  455. 'pic_height' => 700,
  456. 'list' => []
  457. ]
  458. ],
  459. ]
  460. ],
  461. ];
  462. /**
  463. * 获取diy配置
  464. */
  465. public static function getConfig()
  466. {
  467. return self::DIY_CONFIG;
  468. }
  469. /**
  470. * 获取diy配置
  471. * @param $id
  472. * @return DiyTemplate|array|\yii\db\ActiveRecord[]|null
  473. */
  474. public static function getSetting($id = 0)
  475. {
  476. if ($id) {
  477. $page = DiyTemplate::findOne([
  478. 'id' => $id,
  479. 'store_id' => get_store_id(),
  480. 'is_delete' => 0
  481. ]);
  482. if ($page) {
  483. $page->toArray();
  484. $page['template'] = $page['template'] ? Json::decode($page['template']) : [];
  485. return $page;
  486. } else {
  487. return [];
  488. }
  489. }
  490. $page = DiyTemplate::find()
  491. ->where([
  492. 'store_id' => get_store_id(),
  493. 'is_delete' => 0
  494. ])->orderBy(['id' => SORT_ASC])->asArray()->all();
  495. foreach ($page as &$val) {
  496. $val['template'] = $val['template'] ? Json::decode($page['template']) : [];
  497. }
  498. return $page;
  499. }
  500. }