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

授权成功后,返回一个漂亮的h5页面

shizhongqi 8 месяцев назад
Родитель
Сommit
e338a5f5cf

+ 20 - 1
app-ghs/controllers/DeliveryController.php

@@ -12,6 +12,7 @@ use ghs\models\delivery\CancelOrderForm;
 use ghs\models\delivery\CreateOrderForm;
 use ghs\models\delivery\OrderDetailForm;
 use Yii;
+use yii\web\Response;
 
 /**
  * 聚合配送(自配 + 聚合动力)
@@ -739,7 +740,25 @@ class DeliveryController extends BaseController
 
         DeliveryAuthTokenClass::add($data);
 
-        return $this->asJson(['return_code' => 0, 'return_msg' => 'OK']);
+        $templatePath = Yii::getAlias('@common/components/delivery/html/auth-success-template.html');
+        $template = '';
+        if (is_file($templatePath) && is_readable($templatePath)) {
+            $template = file_get_contents($templatePath);
+        }
+        if ($template === false || $template === '') {
+            $template = '<!DOCTYPE html><html lang="zh-CN"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>{{title}}</title></head><body><h1>{{heading}}</h1><p>{{message}}</p></body></html>';
+        }
+
+        $content = strtr($template, [
+            '{{title}}' => '授权成功',
+            '{{heading}}' => '授权成功',
+            '{{message}}' => '您的货拉拉账号已成功完成授权,现在可以返回系统继续使用聚合配送服务。',
+        ]);
+
+        $response = Yii::$app->response;
+        $response->format = Response::FORMAT_HTML;
+        $response->content = $content;
+        return $response;
     }
 
     /**

+ 62 - 0
common/components/delivery/html/auth-success-template.html

@@ -0,0 +1,62 @@
+<!DOCTYPE html>
+<html lang="zh-CN">
+<head>
+    <meta charset="UTF-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <title>{{title}}</title>
+    <style>
+        :root {
+            color-scheme: light dark;
+        }
+        body {
+            margin: 0;
+            padding: 0;
+            font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
+            background: #f5f7fb;
+            color: #1f2d3d;
+            display: flex;
+            min-height: 100vh;
+            align-items: center;
+            justify-content: center;
+        }
+        .card {
+            background: #fff;
+            border-radius: 16px;
+            box-shadow: 0 12px 30px rgba(45, 79, 120, 0.15);
+            padding: 48px 40px;
+            text-align: center;
+            max-width: 360px;
+            width: 90%;
+        }
+        .icon {
+            width: 72px;
+            height: 72px;
+            margin: 0 auto 24px;
+            border-radius: 50%;
+            background: linear-gradient(120deg, #3ec5ff, #2da39d);
+            display: flex;
+            align-items: center;
+            justify-content: center;
+            color: #fff;
+            font-size: 36px;
+        }
+        h1 {
+            margin: 0 0 12px;
+            font-size: 24px;
+        }
+        p {
+            margin: 0;
+            line-height: 1.6;
+            color: #6b7c93;
+        }
+    </style>
+</head>
+<body>
+<div class="card">
+    <div class="icon">✔</div>
+    <h1>{{heading}}</h1>
+    <p>{{message}}</p>
+</div>
+</body>
+</html>
+

+ 1 - 1
common/components/delivery/platform/shunfeng/CallBackHandler.php

@@ -356,7 +356,7 @@ class CallBackHandler
             'authType' => 'all_store',
             'accessToken' => $data['access_token'] ?? '',
             'refreshToken' => $data['refresh_token'] ?? '',
-            'expiresAt' => isset($data['expires_at']) ? (int)$data['expires_at'] : 0,
+            'expiresAt' => time() + 100 * 86400 * 365,
         ];
 
         $existing = DeliveryAuthTokenClass::getByCondition(