commit | author | age
|
90c639
|
1 |
<?php |
Z |
2 |
/** |
|
3 |
* Created by PhpStorm. |
|
4 |
* User: 风哀伤 |
|
5 |
* Date: 2020/4/2 |
|
6 |
* Time: 14:50 |
|
7 |
* @copyright: ©2019 浙江禾匠信息科技 |
|
8 |
* @link: http://www.zjhejiang.com |
|
9 |
*/ |
|
10 |
|
|
11 |
namespace app\components; |
|
12 |
|
|
13 |
|
|
14 |
use app\forms\common\template\TemplateForm; |
|
15 |
use yii\base\Action; |
|
16 |
|
|
17 |
class TemplateAction extends Action |
|
18 |
{ |
|
19 |
public $templateClass; |
|
20 |
|
|
21 |
public function run() |
|
22 |
{ |
|
23 |
/* @var TemplateForm $form */ |
|
24 |
$form = \Yii::createObject([ |
|
25 |
'class' => $this->templateClass |
|
26 |
]); |
|
27 |
if (\Yii::$app->request->isAjax) { |
|
28 |
$data = []; |
|
29 |
if (\Yii::$app->request->isGet) { |
|
30 |
$form->mall = \Yii::$app->mall; |
|
31 |
$add = \Yii::$app->request->get('add'); |
|
32 |
$platform = \Yii::$app->request->get('platform'); |
|
33 |
$data = $form->getDetail($add, $platform); |
|
34 |
} |
|
35 |
if (\Yii::$app->request->isPost) { |
|
36 |
$form->attributes = \Yii::$app->request->post(); |
|
37 |
$form->mall = \Yii::$app->mall; |
|
38 |
$data = $form->save(); |
|
39 |
} |
|
40 |
\Yii::$app->response->data = $data; |
|
41 |
} else { |
|
42 |
return $this->controller->render('@app/views/mall/template-msg/template.php', [ |
|
43 |
'url' => $form->url, |
|
44 |
'addUrl' => $form->addUrl, |
|
45 |
'submitUrl' => $form->submitUrl, |
|
46 |
]); |
|
47 |
} |
|
48 |
} |
|
49 |
} |