Selaa lähdekoodia

添加控制器方法:更新头像(actionUpdateAvatar)

shizhongqi 1 vuosi sitten
vanhempi
commit
c922dab90f
2 muutettua tiedostoa jossa 29 lisäystä ja 1 poistoa
  1. 0 1
      app-ghs/controllers/MainController.php
  2. 29 0
      app-ghs/controllers/ShopController.php

+ 0 - 1
app-ghs/controllers/MainController.php

@@ -224,7 +224,6 @@ class MainController extends BaseController
     //我的 ssh 2021.1.30
     public function actionMy()
     {
-
         $lookMoney = ShopAdminClass::lookMoneyPower($this->shopAdmin, $this->shop);
 
         $shop = $this->shop ?? null;

+ 29 - 0
app-ghs/controllers/ShopController.php

@@ -175,6 +175,35 @@ class ShopController extends BaseController
         util::complete();
     }
 
+    public function actionUpdateAvatar()
+    {
+        $post = Yii::$app->request->post();
+        $shopId = $post['shopId'];
+        if ($post['shopId'] != $this->shopId or $this->mainId == 0) {
+            util::fail('不是您的门店');
+        }
+        $avatar = $post['avatar'];
+        if ($avatar == '') {
+            util::fail('头像地址不能为空');
+        }
+
+        $shop = ShopClass::getById($shopId, true);
+        $shop->avatar = $avatar;
+        $shop->save();
+
+        $ptStyle = $shop['ptStyle'] ?? dict::getDict('ptStyle', 'hd');
+        $update = ['avatar'=>$avatar];
+        $where = ['mainId' => $this->mainId];
+        if ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
+            GhsClass::updateByCondition($where, $update);
+        } else {
+            util::fail('门店头像更新失败,平台类型错误');
+        }
+
+        $shopImg = Yii::$app->params['ghsImgHost'] . $shop->avatar . "?x-oss-process=image/resize,m_fill,h_700,w_700";
+        util::success(['shopImg' => $shopImg], '门店头像更新成功');
+    }
+
     //添加门店 ssh 2021.1.14
     public function actionAdd()
     {