dever 3 years ago
parent
commit
d7f56ec9ac
1 changed files with 22 additions and 1 deletions
  1. 22 1
      src/Code.php

+ 22 - 1
src/Code.php

@@ -16,6 +16,7 @@ class Code
         $project = Dever::input('project');
         $param['path'] = Dever::input('path', 'pages/index/index');
         $param['param'] = Dever::input('send');
+        $filename = Dever::input('filename');
         $param['width'] = Dever::input('width', 200);
         $update = Dever::input('update', 2);
 
@@ -27,16 +28,36 @@ class Code
                 $param['path'] = $send['path'];
             }
             if (isset($send['send'])) {
-                $param['send'] = $send['send'];
+                $param['param'] = $send['send'];
             }
             if (isset($send['width'])) {
                 $param['width'] = $send['width'];
             }
+            if (isset($send['filename'])) {
+                $filename = $send['filename'];
+            }
             if (isset($send['update'])) {
                 $update = $send['update'];
             }
         }
 
+        if (!$filename) {
+            $filename = md5($param['param']);
+        }
+
+        $wechat = new Wechat($project, 'wechat_applet');
+
+        $data = $wechat->curl('code', $param, true);
+
+        if ($data) {
+            $upload = Dever::load('upload/save')->copy('content,' . $data, 1, false, '', 'jpg', $filename);
+            if (isset($upload['url'])) {
+                return $upload['url'];
+            }
+        }
+
+        return false;
+
         $file = Dever::pathDay('upload/applet/code', false) . $project . '_' . md5($param['path'] . '_' . $param['param'] . '_' . $param['width']) . '.jpg';
 
         if (!is_file($file) || $update == 1) {