yingzi 2 年之前
父节点
当前提交
6e116c2916
共有 4 个文件被更改,包括 116 次插入1 次删除
  1. 10 0
      app/api/controller/User.php
  2. 4 0
      app/api/route/user.php
  3. 1 1
      library/lib/expInfo.php
  4. 101 0
      library/lib/weixina.php

+ 10 - 0
app/api/controller/User.php

@@ -614,6 +614,16 @@ class User extends BaseController
         return app('json')->success("设置成功");
     }
     
+    /**
+     * 获取小程序码
+     * @param Request $request
+     */
+    public function getWxmpQrcode(Request $request){
+        $weixinA = new weixina();
+        $data = $weixinA->getUnlimitedQRCode("pages/index/index","a=1");
+        return app('json')->success(["data"=>$data]);
+    }
+    
     
     
     

+ 4 - 0
app/api/route/user.php

@@ -35,6 +35,10 @@ Route::group('user', function () {
     Route::rule('getUserCardInfo', 'User/getUserCardInfo');
     //绑定手机号
     Route::rule('bindMobile', 'User/bindMobile');
+    //获取小程序码
+    Route::rule('getWxmpQrcode', 'User/getWxmpQrcode');
+    
+    
     
     
     

+ 1 - 1
library/lib/expInfo.php

@@ -14,7 +14,7 @@ namespace library\lib;
 class  expInfo {
     //host
     private $host = "https://ali-deliver.showapi.com/";
-    private $appcode = '9c5ae0c97ea941f9bc07aa4a2cb6969a';
+    private $appcode = '9c5ae0cea941f9b7aa4a2cb6969a';
 
 
     /**

+ 101 - 0
library/lib/weixina.php

@@ -89,6 +89,102 @@ class weixina {
         }
         return $data["phone_info"];
     }
+    
+    
+    /**
+     * 获取小程序码
+     * @param type $path
+     * @param type $width
+     */
+    public function getQRCode($path,$width){
+        
+    }
+    
+    /**
+     * 获取不限制的小程序码
+     * @param type $page 页面
+     * @param type $scene 携带参数
+     * @param type $width 宽度
+     * @return bool
+     */
+    public function getUnlimitedQRCode($page,$scene,$width=430){
+        $accessData = $this->getAccessToken();
+        if(empty($accessData) || empty($accessData["access_token"])){
+            return false;
+        }
+        $access_token = $accessData["access_token"];
+        $url = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?"
+            ."access_token=".$access_token;
+        $postData = json_encode(array(
+            "page"=>$page,
+            "scene"=>$scene,
+            "width"=>$width,//默认430
+            "auto_color"=>true,//自动配置线条颜色
+            "is_hyaline" => false,//是否透明底色
+        ));
+        $data = $this->Post($postData,$url);
+        return $data;
+//        $res = $data;
+//        if(empty($data)){
+//            return false;
+//        }
+//        $data = json_decode($data,true);
+//        if(empty($data) || empty($data["phone_info"]) || empty($data["phone_info"]["purePhoneNumber"])){
+//            $this->error="返回参数名称错误".$res;
+//            return false;
+//        }
+//        return $data["phone_info"];
+        
+        
+        
+        
+        
+        
+        
+        
+//        $key = md5($this->appid.$parms['path'].$parms['params']);
+//        $imgsrc = Factory::cache('default')->hget($this->pathAndWxacodeunlimitKey, $key);
+//        if(!empty($imgsrc)){
+//            return ResultWrapper::success($imgsrc);
+//        }
+//
+//        $apiUrl = 'https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token='.$access_token;
+//
+//        $postData = [
+//            'scene'      => $parms['params'],
+//            'page'       => $parms['path'],
+//            'width'      => 430,
+//            'auto_color' => true,
+//        ];
+//
+//        $reponse =  request($apiUrl, json_encode($postData));
+//        if($reponse['httpcode'] != 200){
+//            return ResultWrapper::fail('请求外部系统接口报错', ErrorCode::$apiNotResult);
+//        }else{
+//            if(!is_object($reponse['content'])){
+//                $base64   = 'data:'.$reponse['content_type'].';base64,'.base64_encode($reponse['content']);
+//                $upload = Factory::baseImg();
+//                $upload->move($base64);
+//                $imgsrc = $upload->getSaveName();
+//                Factory::cache('default')->hset($this->pathAndWxacodeunlimitKey, $key, $imgsrc);
+//                return ResultWrapper::success($imgsrc);
+//            }
+//            $reponseData = json_decode($reponse['content'], true);
+//            if( isset($reponseData['errcode']) ){
+//                return ResultWrapper::fail($reponseData['errmsg'], $reponseData['errcode']);
+//            }
+//        }
+    }
+    
+    /**
+     * 获取小程序二维码
+     * @param type $path
+     * @param type $width
+     */
+    public function createQRCode($path,$width){
+        
+    }
+    
     /**
      * 新版获取接口调用凭证
      * @return type
@@ -106,6 +202,11 @@ class weixina {
     }
     
     
+   
+    
+    
+    
+