Browse Source

feat():授权

geek 4 years ago
parent
commit
b450828a7d
1 changed files with 21 additions and 21 deletions
  1. 21 21
      application/index/controller/Index.php

+ 21 - 21
application/index/controller/Index.php

@@ -25,32 +25,32 @@ class Index {
             throw new ApiException('渠道id不为空');
         }
         $data = CommonService::getSetData($channelId);
-        $info = (new UserModel())::where(['unionid' => Session::get('wxId'), 'channel_id' => $channelId])->find();
+        $info = (new UserModel())::where(['unionid' => Session::get('wxId'), 'channel_id' => $channelId])
+            ->order(['id' => 'desc'])->find();
         if (empty(Session::get('wxId')) || empty($info)){
             header("Location:".CommonService::getAuthUrl($channelId));
             die();
         }
-        $model = new VisitorModel();
-        $visitorInfo = $model::where(['unionid' => Session::get('wxId')])->find();
-        var_dump($visitorInfo);
+//        $model = new VisitorModel();
+//        $visitorInfo = $model::where(['unionid' => Session::get('wxId')])->find();
+
+//        if (empty($visitorInfo)) {
+//            $model->insertGetId([
+//                'visitorId' => $visitorId,
+//                'unionid' => Session::get('wxId'),
+//            ]);
+//        } else {
+//            $visitorId = $visitorInfo['visitorId'];
+//        }
+        $params = [
+            'id'     => $info['channel_id'],
+            'userid' => $info['unionid'],
+            'name'   => $info['nickName'],
+            'avatar' => $info['avatar'],
+            'key'    => $info['key']
+        ];
+        header('Location:http://mudu.tv/activity.php?a=userAssign&'.http_build_query($params));
         die();
-        if (empty($visitorInfo)) {
-            $model->insertGetId([
-                'visitorId' => $visitorId,
-                'unionid' => Session::get('wxId'),
-            ]);
-        } else {
-            $visitorId = $visitorInfo['visitorId'];
-        }
-        //        $params = [
-//            'id'     => $info['channel_id'],
-//            'userid' => $info['unionid'],
-//            'name'   => $info['nickName'],
-//            'avatar' => $info['avatar'],
-//            'key'    => $info['key']
-//        ];
-//        header('Location:http://mudu.tv/activity.php?a=userAssign&'.http_build_query($params));
-//        die();
         //增加客户自己的验证逻辑,例如登录,关注,付费,填手机号等
         $key = md5($visitorId.$data['channel_auth_code']);
         if(strpos($notifyUrl,'?') !== false){//url参数处理,将key加到url参数中