| 
					
				 | 
			
			
				@@ -18,7 +18,7 @@ class Code 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         $param['param'] = Dever::input('send');
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         $filename = Dever::input('filename');
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         $param['width'] = Dever::input('width', 200);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        $param['is_hyaline'] = true;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $param['is_hyaline'] = false;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         $param['env_version'] = 'release';
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         $update = Dever::input('update', 2);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -50,19 +50,43 @@ class Code 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             $filename = md5($param['param']);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        $wechat = new Wechat($project, 'wechat_applet');
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $where['project_id'] = $project;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $where['filename'] = $filename;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $where['path'] = $param['path'];
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $where['send'] = $param['param'];
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        $code = Dever::db('wechat_applet/code')->find($where);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (!$code) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            $update = 1;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } elseif ($update == 2) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return $code['file'] . '?v=' . time();
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if ($update == 1) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            $wechat = new Wechat($project, 'wechat_applet');
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        $data = $wechat->curl('code', $param, true);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            $data = $wechat->curl('code', $param, true);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if ($data) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            $upload = Dever::load('upload/save')->copy('content,' . $data, 1, false, '', 'png', $filename);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if (isset($upload['url'])) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                return $upload['url'] . '?v=' . time();
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if ($data) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                $upload = Dever::load('upload/save')->copy('content,' . $data, 1, false, '', 'png', $filename);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (isset($upload['url'])) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    $where['file'] = $upload['url'];
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    $where['width'] = $param['width'];
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    $where['env'] = $param['env_version'];
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    if ($code) {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        $where['where_id'] = $code['id'];
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        Dever::db('wechat_applet/code')->update($where);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } else {
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        Dever::db('wechat_applet/code')->insert($where);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    return $upload['url'] . '?v=' . time();
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return false;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        /*
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         $file = Dever::pathDay('upload/applet/code', false) . $project . '_' . md5($param['path'] . '_' . $param['param'] . '_' . $param['width']) . '.jpg';
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if (!is_file($file) || $update == 1) {
 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -83,5 +107,6 @@ class Code 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         $file = Dever::pic($file);
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return $file;
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        */
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     }
 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 |