[ 'class' => LoginBehavior::className(), ], ]); } public function actionUserProtocol() { $form = new PageForm(); $form->cx_mch_id = $this->cx_mch_id; $form->key = "_page_user_protocol_"; if(\Yii::$app->request->isPost){ $form->scenario = 'edit'; $form->attributes = \Yii::$app->request->post(); $data = $form->save(); return $this->responseHandler($data); } $data = $form->search(); return $this->render('page',[ 'data' => $data, 'title' => '用户协议', 'post_api' => \Yii::$app->urlManager->createUrl(['/admin/page/user-protocol']) ]); } public function actionPrivacyProtocol() { $form = new PageForm(); $form->cx_mch_id = $this->cx_mch_id; $form->key = "_page_privacy_protocol_"; if(\Yii::$app->request->isPost){ $form->scenario = 'edit'; $form->attributes = \Yii::$app->request->post(); $data = $form->save(); return $this->responseHandler($data); } $data = $form->search(); return $this->render('page',[ 'data' => $data, 'title' => '隐私协议', 'post_api' => \Yii::$app->urlManager->createUrl(['/admin/page/privacy-protocol']) ]); } public function actionAboutUs() { $form = new PageForm(); $form->cx_mch_id = $this->cx_mch_id; $form->key = "_page_about_us_"; if(\Yii::$app->request->isPost){ $form->scenario = 'edit'; $form->attributes = \Yii::$app->request->post(); $data = $form->save(); return $this->responseHandler($data); } $data = $form->search(); return $this->render('page',[ 'data' => $data, 'title' => '关于我们', 'post_api' => \Yii::$app->urlManager->createUrl(['/admin/page/about-us']) ]); } public function actionIntegralRuleIntro() { $form = new PageForm(); $form->cx_mch_id = $this->cx_mch_id; $form->key = "_page_integral_rule_intro_"; if(\Yii::$app->request->isPost){ $form->scenario = 'edit'; $form->attributes = \Yii::$app->request->post(); $data = $form->save(); return $this->responseHandler($data); } $data = $form->search(); return $this->render('page',[ 'data' => $data, 'title' => '积分规则介绍', 'post_api' => \Yii::$app->urlManager->createUrl(['/admin/page/integral-rule-intro']) ]); } public function actionProjectIntroduction() { $form = new PageForm(); $form->cx_mch_id = $this->cx_mch_id; $form->key = "_page_project_introduction_"; if(\Yii::$app->request->isPost){ $form->scenario = 'edit'; $form->attributes = \Yii::$app->request->post(); $data = $form->save(); return $this->responseHandler($data); } $data = $form->search(); return $this->render('page',[ 'data' => $data, 'title' => '项目介绍', 'post_api' => \Yii::$app->urlManager->createUrl(['/admin/page/project-introduction']) ]); } /** * @ Author : Lw * @ CreateTime : 2022-11-04 * @ Info : mqtt设置 */ public function actionMqttConfig(){ $redis_name = "api:cxaibc:mqtt:config"; if(\Yii::$app->request->isPost){ \Yii::$app->redis->set($redis_name,\Yii::$app->request->post('content')); return $this->responseHandler(['code'=>0,'msg'=>'保存成功']); } $data = \Yii::$app->redis->get($redis_name); if(!empty($data)){ $data = json_decode($data,true); }else{ $data = [ 'mqtt_server' => '', 'mqtt_port' => '', 'mqtt_user' => '', 'mqtt_pass' => '', ]; } return $this->render('mqtt-setting',[ 'data' => $data, 'title' => 'mqtt设置', 'post_api' => \Yii::$app->urlManager->createUrl(['/admin/page/mqtt-config']) ]); } /** * @ Author : Lw * @ CreateTime : 2022-11-04 * @ Info : 测试mqtt链接 */ public function actionMqttTestConnect(){ try{ $server = \Yii::$app->request->get('mqtt_server'); $port = \Yii::$app->request->get('mqtt_port'); $clientId = md5(microtime(true)); $username = \Yii::$app->request->get('mqtt_user'); $password = \Yii::$app->request->get('mqtt_pass'); $mqtt = new MqttClient($server, $port, $clientId); $mqtt->connect($username,$password); return $this->responseHandler(['code'=>0,'msg'=>"链接成功"]); }catch (\Exception $e){ return $this->responseHandler(['code'=>1,'msg'=>"链接失败"]); } } //操作视频 public function actionHandleVideo() { $redis_name = "cxaibc:api:actionHandleVideo_v1"; $form = new PageForm(); $form->cx_mch_id = $this->cx_mch_id; $form->key = strtoupper('_page_handle_video_'); if(\Yii::$app->request->isPost){ $form->scenario = 'edit'; $form->attributes = \Yii::$app->request->post(); $data = $form->save(); return $this->responseHandler($data); } $get = \Yii::$app->redis->get($redis_name); $data = $form->search(); return $this->render('video',[ 'data' => $data, 'title' => '上传操作视频', 'is_open' => empty($get)?"":"checked=''", 'post_api' => \Yii::$app->urlManager->createUrl(['/admin/page/handle-video']) ]); } }