request->get(); // 验证 $res = Yii::$app->services->validate->validate($params,[ [['id'], 'safe'], [['id', 'goods_id'], 'integer'], [['template'], 'string'], ]); if($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage()); $where[] = ['=', 'mall_id', $this->mall_id]; $where[] = ['=', 'status', StatusEnum::ENABLED]; if (isset($params['template'])) { $where[] = ['=', 'template', $params['template']]; if ($params['template'] == DiyEnum::HOME_PAGE) { $where[] = ['=', 'is_home_page', StatusEnum::ENABLED]; } } else { $where[] = ['=', 'id', $params['id']]; } if($params['template'] == DiyEnum::GOODS_DETAIL){ $data = GoodsDecorationTemplate::getGoodsDecoration($this->mall_id, $params['goods_id'] ?? 0); }else if ($params['template'] == 'store_steward'){ $data = \addons\StoreSteward\common\models\AddonsStoreDiyPage::getOne([ ['mall_id' => $this->mall_id], ['status' => StatusEnum::ENABLED], ['id' => $params['id']], ], true, [], '', 'id,title,content,is_show_bottom_nav'); }else { // 获取装修页面内容 $data = DiyPage::getOne($where, true, [], '', 'id,title,content,is_show_bottom_nav'); $data['is_expire'] = Mall::getIsExpired($this->mall_id); } // 小程序配置替换修改 if (!empty($data['content'])) { $platform = str_replace('-', '_', $this->platform); $data['content'] = str_replace([ "{$platform}_appid", "{$platform}_app_path", ], [ 'appid', 'app_path' ], $data['content']); // 如果非支付宝的情况下需要将支付宝入群按钮移除 } // 获取商城有效的插件 // $valid_addons = MallAddons::getValidAddons($this->mall_id); // $data['valid_addons'] = $valid_addons; //浏览 $event = new ViewsEvent($this->mall_id); $event_data['mall_id'] =$this->mall_id; $event_data['user_id'] =$this->user_id??0; $event_data['goods_id'] = $params['goods_id']??0; \Yii::$app->services->events->dispatch($event, $event_data, $event->listeners); return $this->success('',$data); } /** * 根据标识获取对应组件的内容 * @Author: lun * @DateTime: 2021/11/2 0002 14:23 * @Copyright: copyright (c) 2021 广东七件事集团 */ public function actionGetComponentsData() { $params = Yii::$app->request->post('form'); $list = Json::decode($params, true); if (empty($list)) return $this->error('请求数据为空'); // 获取数据 $user_id = $this->user_id > 0 ? $this->user_id : 0; $data = DiyComponentsData::getCompentsData($this->mall_id, $list, $user_id); return $this->success('操作成功',$data); } }