yingzi 2 years ago
parent
commit
fbe50045f5
2 changed files with 20 additions and 67 deletions
  1. 13 63
      app/api/controller/User.php
  2. 7 4
      library/lib/weixina.php

+ 13 - 63
app/api/controller/User.php

@@ -621,75 +621,25 @@ class User extends BaseController
     public function getWxmpQrcode(Request $request){
         $weixinA = new weixina();
         $data = $weixinA->getUnlimitedQRCode("pages/index/index","a=1");
-        return app('json')->success(["data"=>$data]);
+        if(empty($data)){
+            return app('json')->fail("小程序码获取失败".$weixinA->error);
+        }
+        $base64 = 'data:'.$reponse['contentType'].';base64,'.base64_encode($data['buffer']);
+        
+        
+        
+        return app('json')->success(["data"=>$data,"res"=>\think\facade\Filesystem::disk('resource')]);
     }
     
-    
-    
-    
-    
-    
     /**
-     * 发布圈子
-     * @param Request $request
+     * 
+     * @param type $code
+     * @param type $base64
      */
-    public function upCircle(Request $request){
-        $post = UtilService::getMore([
-            ['id',''],
-            ['title',''],
-            ['content','','empty','请输入动态内容'],
-            ['imgs',[]],
-            ['video',''],
-            ['video_img',''],
-            ['video_time',0],
-            ['pro_id',''],
-        ],$request);
-        
-        $post["status"]=0;
+    public function uploadImageBase64($code,$base64){
         
-        $post["imgs"] = empty($post["imgs"]) ? "" : $post["imgs"];
-        $post["update_time"] = time();
-        if(empty($post["imgs"]) && empty($post["video"])){
-            return app('json')->fail("请至少上传一张主图");
-        }
-        if(!empty($post["imgs"])){
-            $post["video"]="";
-            $post["video_img"]="";
-            $post["video_time"]=0;
-        }
-        if(!empty($post["video"])){
-            $post["imgs"]="";
-            if(empty($post["video_img"])){
-                return app('json')->fail("视频封面错误");
-            }
-            if(empty($post["video_time"]) || (int)$post["video_time"]<=0){
-                return app('json')->fail("视频时长错误");
-            }
-        }
-        if(!empty($post["pro_id"])){
-            $proData = (new Goods)->where("id",$post["pro_id"])->where("status",1)->find();
-            if(empty($proData)){
-                return app('json')->fail("当前商品不可选中");
-            }
-        }else{
-            $post["pro_id"]=0;
-        }
-        $id = $post["id"];
-        unset($post["id"]);
-        $r=0;
-        if(empty($id) || $id=="0"){
-            $post["time"] = time();
-            $post["uid"] = $request->user["uid"];
-            $r = (new UserCircle)->insert($post);
-        }else{
-            $r = (new UserCircle)->where("id",$id)->update($post);
-        }
-        if($r){
-            return app('json')->success("发布成功,等待客服审核。");
-        }else{
-            return app('json')->fail("数据保存失败");
-        }
     }
+
     
     
     /**

+ 7 - 4
library/lib/weixina.php

@@ -128,11 +128,14 @@ class weixina {
             return false;
         }
         $data = json_decode($data,true);
+        if(empty($data) || empty($data["contentType"]) || empty($data["buffer"]) || $data["errcode"]!=0){
+            $this->error="返回参数错误".$res;
+            return false;
+        }
         return $data;
-//        if(empty($data) || empty($data["phone_info"]) || empty($data["phone_info"]["purePhoneNumber"])){
-//            $this->error="返回参数名称错误".$res;
-//            return false;
-//        }
+        
+        
+        
 //        return $data["phone_info"];