You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.5 KiB

  1. <?php
  2. namespace backend\modules\wx_public_account\controllers;
  3. use Yii;
  4. use yii\web\Controller;
  5. use yii\filters\VerbFilter;
  6. use backend\modules\wx_public_account\models\ars\WxPublicAccountConfig;
  7. use backend\modules\wx_public_account\logic\PublicAccountManager;
  8. /**
  9. * PublicAccountController manage WeChat public account platform.
  10. */
  11. class PublicAccountController extends Controller
  12. {
  13. /**
  14. * {@inheritdoc}
  15. */
  16. public function behaviors()
  17. {
  18. return [
  19. 'verbs' => [
  20. 'class' => VerbFilter::className(),
  21. 'actions' => [
  22. 'delete' => ['POST'],
  23. ],
  24. ],
  25. ];
  26. }
  27. /**
  28. * Lists all AfterSale models.
  29. * @return mixed
  30. * @throws \yii\web\ServerErrorHttpException
  31. */
  32. public function actionCustomMenu()
  33. {
  34. $wxPublicAccountConfig = WxPublicAccountConfig::find()->one();
  35. if (Yii::$app->request->isPost) {
  36. Yii::$app->response->format = 'json';
  37. $data = Yii::$app->request->post('data');
  38. $res = PublicAccountManager::dealCustomMenuData($data, $wxPublicAccountConfig);
  39. if ($res) {
  40. return ['status' => true];
  41. } else {
  42. return ['status' => false, 'info' => $res['info']];
  43. }
  44. }
  45. return $this->render('custom_menu', [
  46. 'customPageList' => [],
  47. 'data' => $wxPublicAccountConfig->menu_setting ?: '[]'
  48. ]);
  49. }
  50. }