181 lines
5.6 KiB
PHP
181 lines
5.6 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @author Any
|
|
* @description KISS
|
|
* @date 2020-11-23
|
|
* @version 1.0.0
|
|
*
|
|
* _____LOG_____
|
|
*
|
|
*/
|
|
namespace app\modules\admin\controllers;
|
|
|
|
use app\modules\admin\behaviors\LoginBehavior;
|
|
use app\modules\admin\models\wechat\WechatAppForm;
|
|
use app\modules\admin\models\wechat\WechatOfficalAccountForm;
|
|
use app\modules\admin\models\wechat\WechatAppTplMsgForm;
|
|
use app\modules\admin\models\wechat\WechatOfficalAccountTplMsgForm;
|
|
use app\modules\admin\models\SlideEditForm;
|
|
use app\modules\admin\models\SlideListForm;
|
|
use app\modules\admin\models\SlideActionForm;
|
|
use app\models\wechat\WechatApp;
|
|
use app\models\wechat\WechatOfficalAccount;
|
|
use app\models\wechat\WechatAppTplMsg;
|
|
use app\models\wechat\WechatOfficalAccountTplMsg;
|
|
use app\models\Banner;
|
|
use app\models\PickLinkForm;
|
|
|
|
|
|
|
|
class WechatController extends Controller
|
|
{
|
|
public $ids = [
|
|
12,13,14,15,16,17,18,19,20,21,22,23,24,25
|
|
];
|
|
public function behaviors()
|
|
{
|
|
return array_merge(parent::behaviors(), [
|
|
'login' => [
|
|
'class' => LoginBehavior::className(),
|
|
],
|
|
]);
|
|
}
|
|
|
|
public function actionMp()
|
|
{
|
|
$this->wechat_app = $this->wechat_app == null ? new WechatApp() : $this->wechat_app;
|
|
if(\Yii::$app->request->isPost){
|
|
$form = new WechatAppForm();
|
|
$form->attributes = \Yii::$app->request->post();
|
|
$form->cx_mch_id = $this->cx_mch_id;
|
|
$form->model = $this->wechat_app;
|
|
$data = $form->save();
|
|
return $this->responseHandler($data);
|
|
}
|
|
return $this->render('mp',[
|
|
'model' => $this->wechat_app
|
|
]);
|
|
}
|
|
|
|
public function actionMpTplMsg()
|
|
{
|
|
$form = new WechatAppTplMsgForm();
|
|
if(\Yii::$app->request->isPost){
|
|
$form->attributes = \Yii::$app->request->post();
|
|
$form->cx_mch_id = $this->cx_mch_id;
|
|
$data = $form->save();
|
|
return $this->responseHandler($data);
|
|
}
|
|
$form->cx_mch_id = $this->cx_mch_id;
|
|
$list = $form->search();
|
|
return $this->render('mp-tpl-msg',[
|
|
'list' => $list
|
|
]);
|
|
}
|
|
|
|
public function actionMpSlide()
|
|
{
|
|
$form = new SlideListForm();
|
|
$form->attributes = \Yii::$app->request->get();
|
|
$form->zone_id = Banner::ZONE_ID_WXAPP_INDEX;
|
|
$form->cx_mch_id = $this->cx_mch_id;
|
|
$data = $form->search($this->ids,'not in');
|
|
return $this->render('mp-slide', $data);
|
|
}
|
|
public function actionMpSlideT()
|
|
{
|
|
$form = new SlideListForm();
|
|
$form->attributes = \Yii::$app->request->get();
|
|
$form->zone_id = Banner::ZONE_ID_WXAPP_INDEX;
|
|
$form->cx_mch_id = $this->cx_mch_id;
|
|
$data = $form->search($this->ids,'in');
|
|
return $this->render('mp-slide-t', $data);
|
|
}
|
|
|
|
public function actionMpSlideEdit($id = 0)
|
|
{
|
|
$zone_id = Banner::ZONE_ID_WXAPP_INDEX;
|
|
$model = Banner::findOne([
|
|
'id' => $id,
|
|
'cx_mch_id' => $this->cx_mch_id,
|
|
'zone_id' => $zone_id,
|
|
'is_delete' => 0
|
|
]);
|
|
if($model == null){
|
|
$model = new Banner();
|
|
}
|
|
if(\Yii::$app->request->isPost){
|
|
$media = \Yii::$app->request->post('media',0);
|
|
$form = new SlideEditForm();
|
|
if($media == Banner::MEDIA_IMG){
|
|
$form->scenario = 'img';
|
|
}
|
|
if($media == Banner::MEDIA_VIDEO){
|
|
$form->scenario = 'video';
|
|
}
|
|
$form->attributes = \Yii::$app->request->post();
|
|
$form->cx_mch_id = $this->cx_mch_id;
|
|
$form->zone_id = $zone_id;
|
|
$form->model = $model;
|
|
$form->user_id = \Yii::$app->admin->identity->user_id;
|
|
$data = $form->save();
|
|
return $this->responseHandler($data);
|
|
}
|
|
$return_url = \Yii::$app->request->referrer;
|
|
$is = false;
|
|
if(in_array($id,$this->ids)){
|
|
$is = true;
|
|
}
|
|
return $this->render('mp-slide-edit', [
|
|
'model' => $model,
|
|
'return_url' => $return_url,
|
|
'links' => (new PickLinkForm())->getPickLink(),
|
|
'is' => $is,
|
|
'id' => $id,
|
|
]);
|
|
}
|
|
|
|
public function actionMpSlideShow()
|
|
{
|
|
if(!\Yii::$app->request->isPost){
|
|
$data = $this->invaildRequest();
|
|
return $this->responseHandler($data);
|
|
}
|
|
$form = new SlideActionForm();
|
|
$form->attributes = \Yii::$app->request->post();
|
|
$form->cx_mch_id = $this->cx_mch_id;
|
|
$form->zone_id = Banner::ZONE_ID_WXAPP_INDEX;
|
|
$data = $form->show();
|
|
return $this->responseHandler($data);
|
|
}
|
|
|
|
public function actionMpSlideHide()
|
|
{
|
|
if(!\Yii::$app->request->isPost){
|
|
$data = $this->invaildRequest();
|
|
return $this->responseHandler($data);
|
|
}
|
|
$form = new SlideActionForm();
|
|
$form->attributes = \Yii::$app->request->post();
|
|
$form->cx_mch_id = $this->cx_mch_id;
|
|
$form->zone_id = Banner::ZONE_ID_WXAPP_INDEX;
|
|
$data = $form->hide();
|
|
return $this->responseHandler($data);
|
|
}
|
|
|
|
public function actionMpSlideDel()
|
|
{
|
|
if(!\Yii::$app->request->isPost){
|
|
$data = $this->invaildRequest();
|
|
return $this->responseHandler($data);
|
|
}
|
|
$form = new SlideActionForm();
|
|
$form->attributes = \Yii::$app->request->post();
|
|
$form->cx_mch_id = $this->cx_mch_id;
|
|
$form->zone_id = Banner::ZONE_ID_WXAPP_INDEX;
|
|
$data = $form->delete();
|
|
return $this->responseHandler($data);
|
|
}
|
|
|
|
} |