AddShopDiyView.php 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. <?php
  2. /**
  3. * Niushop商城系统 - 团队十年电商经验汇集巨献!
  4. * =========================================================
  5. * Copy right 2019-2029 山西牛酷信息科技有限公司, 保留所有权利。
  6. * ----------------------------------------------
  7. * 官方网址: https://www.niushop.com.cn
  8. * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
  9. * 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
  10. * =========================================================
  11. */
  12. // +---------------------------------------------------------------------+
  13. // | NiuCloud | [ WE CAN DO IT JUST NiuCloud ]  |
  14. // +---------------------------------------------------------------------+
  15. // | Copy right 2019-2029 www.niucloud.com  |
  16. // +---------------------------------------------------------------------+
  17. // | Author | NiuCloud <niucloud@outlook.com>  |
  18. // +---------------------------------------------------------------------+
  19. // | Repository | https://github.com/niucloud/framework.git  |
  20. // +---------------------------------------------------------------------+
  21. declare (strict_types = 1);
  22. namespace app\event;
  23. use app\model\web\DiyView as DiyViewModel;
  24. /**
  25. * 增加默认自定义数据:网站主页、底部导航
  26. */
  27. class AddShopDiyView
  28. {
  29. public function handle($param)
  30. {
  31. if (!empty($param['site_id'])) {
  32. $diy_view_model = new DiyViewModel();
  33. $page = $diy_view_model->getPage();
  34. $index_value = json_encode([
  35. "global" => [
  36. "title" => "店铺主页",
  37. "openBottomNav" => false,
  38. "bgColor" => "#ffffff",
  39. "bgUrl" => ""
  40. ],
  41. "value" => [
  42. [
  43. "addon_name" => "",
  44. "type" => "IMAGE_ADS",
  45. "name" => "图片广告",
  46. "controller" => "ImageAds",
  47. "selectedTemplate" => "carousel-posters",
  48. "imageClearance" => 0,
  49. "height" => 0,
  50. "list" => [
  51. [
  52. "imageUrl" => "upload/default/diy_view/posters.png",
  53. "title" => "",
  54. "link" => []
  55. ]
  56. ]
  57. ],
  58. [
  59. "addon_name" => "",
  60. "type" => "SHOP_INFO",
  61. "name" => "店铺信息",
  62. "controller" => "ShopInfo",
  63. "color" => "#0a020a"
  64. ],
  65. [
  66. "addon_name" => "",
  67. "type" => "SHOP_SEARCH",
  68. "name" => "店内搜索",
  69. "controller" => "ShopSearch"
  70. ],
  71. [
  72. "height" => 10,
  73. "backgroundColor" => "#f4f4f4",
  74. "addon_name" => "",
  75. "type" => "HORZ_BLANK",
  76. "name" => "辅助空白",
  77. "controller" => "HorzBlank"
  78. ],
  79. [
  80. "sources" => "default",
  81. "skuId" => "",
  82. "categoryId" => 0,
  83. "goodsCount" => 12,
  84. "addon_name" => "",
  85. "type" => "GOODS_LIST",
  86. "name" => "商品列表",
  87. "controller" => "GoodsList"
  88. ],
  89. [
  90. "height" => 10,
  91. "backgroundColor" => "#f4f4f4",
  92. "addon_name" => "",
  93. "type" => "HORZ_BLANK",
  94. "name" => "辅助空白",
  95. "controller" => "HorzBlank"
  96. ],
  97. [
  98. "addon_name" => "",
  99. "type" => "SHOP_STORE",
  100. "name" => "门店",
  101. "controller" => "ShopStore"
  102. ],
  103. ]
  104. ]);
  105. $goods_category_value = json_encode([
  106. "global" => [
  107. "title" => "商品分类",
  108. "openBottomNav" => false,
  109. "bgColor" => "#ffffff",
  110. "bgUrl" => ""
  111. ],
  112. "value" => [
  113. [
  114. "addon_name" => "",
  115. "type" => "GOODS_CATEGORY",
  116. "name" => "商品分类",
  117. "controller" => "GoodsCategory",
  118. "level" => 2,
  119. "template" => 2
  120. ]
  121. ]
  122. ]);
  123. // 网站主页
  124. $data = [ [
  125. 'site_id' => $param['site_id'],
  126. 'title' => '店铺主页',
  127. 'name' => $page['shop']['index']['name'],
  128. 'type' => $page['shop']['port'],
  129. 'value' => $index_value
  130. ], [
  131. 'site_id' => $param['site_id'],
  132. 'title' => '商品分类',
  133. 'name' => $page['shop']['goods_category']['name'],
  134. 'type' => $page['shop']['port'],
  135. 'value' => $goods_category_value
  136. ] ];
  137. $res = $diy_view_model->addSiteDiyViewList($data);
  138. // 底部导航
  139. $value = json_encode([
  140. "type" => 1,
  141. "list" => [
  142. [
  143. "iconPath" => "upload/default/diy_view/bottom/shop_index.png",
  144. "selectedIconPath" => "upload/default/diy_view/bottom/shop_index_selected.png",
  145. "text" => "首页",
  146. "link" => [
  147. "addon_name" => "",
  148. "addon_title" => null,
  149. "name" => "SHOP_INDEX",
  150. "title" => "店铺首页",
  151. "web_url" => "",
  152. "wap_url" => "/otherpages/shop/index/index",
  153. "icon" => "",
  154. "addon_icon" => null,
  155. "selected" => false
  156. ]
  157. ],
  158. [
  159. "iconPath" => "upload/default/diy_view/bottom/shop_category.png",
  160. "selectedIconPath" => "upload/default/diy_view/bottom/shop_category_selected.png",
  161. "text" => "分类",
  162. "link" => [
  163. "addon_name" => "",
  164. "addon_title" => null,
  165. "name" => "SHOP_CATEGORY",
  166. "title" => "店铺商品分类",
  167. "web_url" => "",
  168. "wap_url" => "/otherpages/shop/category/category",
  169. "icon" => "",
  170. "addon_icon" => null,
  171. "selected" => false
  172. ]
  173. ],
  174. [
  175. "iconPath" => "upload/default/diy_view/bottom/shop_list.png",
  176. "selectedIconPath" => "upload/default/diy_view/bottom/shop_list_selected.png",
  177. "text" => "宝贝",
  178. "link" => [
  179. "addon_name" => "",
  180. "addon_title" => null,
  181. "name" => "SHOP_LIST",
  182. "title" => "店铺商品列表",
  183. "web_url" => "",
  184. "wap_url" => "/otherpages/shop/list/list",
  185. "icon" => "",
  186. "addon_icon" => null,
  187. "selected" => false
  188. ]
  189. ],
  190. [
  191. "iconPath" => "upload/default/diy_view/bottom/shop_introduce.png",
  192. "selectedIconPath" => "upload/default/diy_view/bottom/shop_introduce_selected.png",
  193. "text" => "介绍",
  194. "link" => [
  195. "addon_name" => "",
  196. "addon_title" => null,
  197. "name" => "SHOP_INTRODUCE",
  198. "title" => "店铺介绍",
  199. "web_url" => "",
  200. "wap_url" => "/otherpages/shop/introduce/introduce",
  201. "icon" => "",
  202. "addon_icon" => null,
  203. "selected" => false
  204. ]
  205. ]
  206. ],
  207. "backgroundColor" => "#ffffff",
  208. "textColor" => "#333333",
  209. "textHoverColor" => "#ff0036",
  210. "bulge" => false
  211. ]);
  212. $res = $diy_view_model->setShopBottomNavConfig($value, $param['site_id']);
  213. return $res;
  214. }
  215. }
  216. }