dyjh 6 роки тому
батько
коміт
a87bd5d4a7

+ 31 - 3
app/Http/Controllers/Api/V1/AlbumController.php

xqd xqd
@@ -1111,7 +1111,9 @@ class AlbumController extends Controller
      * @apiPermission none
      * @apiVersion 0.1.0
      * @apiParam {int}    [store_id]  商户id 模拟值为0
-     * @apiParam {string}    [phone]  电话号码
+     * @apiParam {string}    [code]  code
+     * @apiParam {string}    [iv]  偏移量
+     * @apiParam {string}    [encrypted]  加密参数
      * @apiSuccessExample {json} Success-Response:
      * HTTP/1.1 200 OK
      * {
@@ -1139,14 +1141,40 @@ class AlbumController extends Controller
         if(!$userAuth) return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '未登录!');
         $validator = Validator::make($request->all(), [
             'store_id' => 'required',
-            'phone' => 'required',
+            'code' => 'required',
+            'iv' => 'required',
+            'encrypted' => 'required',
         ],[
             'store_id.required'=>'缺少商户参数',
-            'phone.required'=>'缺少号码参数',
+            'code.required'=>'缺少code参数',
+            'iv.required'=>'缺少偏移量参数',
+            'encrypted.required'=>'缺少加密参数',
         ]);
         if ($validator->fails()) {
             return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '传入参数不正确!', $validator->messages());
         }
+        $config = [
+            'app_id' => $this->wechat_app->xyx_id,
+            'secret' => $this->wechat_app->xyx_secret,
+
+            // 下面为可选项
+            // 指定 API 调用返回结果的类型:array(default)/collection/object/raw/自定义类名
+            'response_type' => 'array',
+
+
+        ];
+
+        $app = Factory::miniProgram($config);
+        $res = $app->auth->session($request->input('code'));
+        // dd($res);
+        if (!$res || empty($res['openid'])) {
+            return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '获取用户OpenId失败!', $validator->messages());
+        }
+
+        $session_key = $res['session_key'];
+        $pc = new WXBizDataCrypt($this->wechat_app->app_id, $session_key);
+        $errCode = $pc->decryptData($request->input('encrypted'), $request->input('iv'), $data);
+dd($errCode);
         $update['phone'] = $request->input('phone');
         $res = $userAuth->save($update);
         if($res){

+ 16 - 2
public/apidoc/api_data.js

xqd
@@ -681,8 +681,22 @@ define({ "api": [
             "group": "Parameter",
             "type": "string",
             "optional": true,
-            "field": "phone",
-            "description": "<p>电话号码</p>"
+            "field": "code",
+            "description": "<p>code</p>"
+          },
+          {
+            "group": "Parameter",
+            "type": "string",
+            "optional": true,
+            "field": "iv",
+            "description": "<p>偏移量</p>"
+          },
+          {
+            "group": "Parameter",
+            "type": "string",
+            "optional": true,
+            "field": "encrypted",
+            "description": "<p>加密参数</p>"
           }
         ]
       }

+ 16 - 2
public/apidoc/api_data.json

xqd
@@ -681,8 +681,22 @@
             "group": "Parameter",
             "type": "string",
             "optional": true,
-            "field": "phone",
-            "description": "<p>电话号码</p>"
+            "field": "code",
+            "description": "<p>code</p>"
+          },
+          {
+            "group": "Parameter",
+            "type": "string",
+            "optional": true,
+            "field": "iv",
+            "description": "<p>偏移量</p>"
+          },
+          {
+            "group": "Parameter",
+            "type": "string",
+            "optional": true,
+            "field": "encrypted",
+            "description": "<p>加密参数</p>"
           }
         ]
       }

+ 1 - 1
public/apidoc/api_project.js

xqd
@@ -9,7 +9,7 @@ define({
   "apidoc": "0.3.0",
   "generator": {
     "name": "apidoc",
-    "time": "2018-11-12T09:13:10.984Z",
+    "time": "2018-11-13T02:54:43.910Z",
     "url": "http://apidocjs.com",
     "version": "0.17.6"
   }

+ 1 - 1
public/apidoc/api_project.json

xqd
@@ -9,7 +9,7 @@
   "apidoc": "0.3.0",
   "generator": {
     "name": "apidoc",
-    "time": "2018-11-12T09:13:10.984Z",
+    "time": "2018-11-13T02:54:43.910Z",
     "url": "http://apidocjs.com",
     "version": "0.17.6"
   }