| 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
|
|
|
* {
|
| xqd
@@ -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){
|