Просмотр исходного кода

Merge branch 'shizhongqi-avatar'

shish 1 год назад
Родитель
Сommit
96e0a3b882
2 измененных файлов с 30 добавлено и 2 удалено
  1. 0 1
      app-ghs/controllers/MainController.php
  2. 30 1
      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;

+ 30 - 1
app-ghs/controllers/ShopController.php

@@ -175,6 +175,36 @@ 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()
     {
@@ -336,7 +366,6 @@ class ShopController extends BaseController
     //切换门店 lqh 2021.1.31
     public function actionToggleShop()
     {
-
         $mainId = $this->mainId;
         $adminId = $this->adminId;
         if (getenv('YII_ENV') == 'production') {