作者 开飞机的舒克

条形码识别问题

... ... @@ -3,6 +3,8 @@
namespace app\api\controller;
use app\common\controller\Api;
use app\common\controller\Resource;
mb_internal_encoding("UTF-8");
/**
* 示例接口
... ... @@ -67,6 +69,10 @@ class Demo extends Api
*/
public function test3()
{
$id = 97;
$res = str_pad($id,8,"0",STR_PAD_LEFT);
$data = Resource::StudyBar($res);
$this->success($data);
}
}
... ...
... ... @@ -2,19 +2,16 @@
namespace app\common\controller;
use Qiniu\Auth;
use tinymeng\code\Generate;
class Resource
{
/**
* 生成条形码
* @param $res
* @return false|string
*/
public static function StudyBar($res){
$generate = Generate::bar();
$file_path = $generate->create($res,true,true,4,40);
$file_path = $generate->create($res,false,true);
$file_path = substr($file_path,strripos($file_path,"public")+6);
return $file_path;
}
... ...
... ... @@ -32,7 +32,7 @@
"ext-bcmath": "*",
"txthinking/mailer": "^2.0",
"phpoffice/phpexcel": "^1.8",
"tinymeng/code": "dev-master"
"tinymeng/code": "^2.0"
},
"config": {
"preferred-install": "dist",
... ...
... ... @@ -1063,8 +1063,8 @@
},
{
"name": "overtrue/wechat",
"version": "4.7.0",
"version_normalized": "4.7.0.0",
"version": "4.8.0",
"version_normalized": "4.8.0.0",
"source": {
"type": "git",
"url": "https://github.com/w7corp/easywechat.git",
... ... @@ -1131,7 +1131,7 @@
],
"support": {
"issues": "https://github.com/w7corp/easywechat/issues",
"source": "https://github.com/w7corp/easywechat/tree/4.7.0"
"source": "https://github.com/w7corp/easywechat/tree/4.8.0"
},
"funding": [
{
... ... @@ -2966,8 +2966,8 @@
},
{
"name": "tinymeng/code",
"version": "dev-master",
"version_normalized": "dev-master",
"version": "v2.0.1",
"version_normalized": "2.0.1.0",
"source": {
"type": "git",
"url": "https://github.com/majiameng/phpQrCode.git",
... ... @@ -2984,7 +2984,6 @@
"tinymeng/tools": "^1.0.7"
},
"time": "2020-03-28T10:11:51+00:00",
"default-branch": true,
"type": "library",
"installation-source": "dist",
"autoload": {
... ...
... ... @@ -3,7 +3,7 @@
'name' => 'karsonzhang/fastadmin',
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => '3adf148ca4f5939e55dd606e8cb9b4c4545de89b',
'reference' => '11dcb6c44732b8867d69444db4589246a6fe0f66',
'type' => 'project',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
... ... @@ -58,7 +58,7 @@
'karsonzhang/fastadmin' => array(
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => '3adf148ca4f5939e55dd606e8cb9b4c4545de89b',
'reference' => '11dcb6c44732b8867d69444db4589246a6fe0f66',
'type' => 'project',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
... ... @@ -146,8 +146,8 @@
'dev_requirement' => false,
),
'overtrue/wechat' => array(
'pretty_version' => '4.7.0',
'version' => '4.7.0.0',
'pretty_version' => '4.8.0',
'version' => '4.8.0.0',
'reference' => '4accb0627803ffb6e45d2988898a0293d2a48e68',
'type' => 'library',
'install_path' => __DIR__ . '/../overtrue/wechat',
... ... @@ -443,14 +443,12 @@
'dev_requirement' => false,
),
'tinymeng/code' => array(
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'pretty_version' => 'v2.0.1',
'version' => '2.0.1.0',
'reference' => 'a5a6ba189f18a8e1f826dfa4994e26da5714d8ad',
'type' => 'library',
'install_path' => __DIR__ . '/../tinymeng/code',
'aliases' => array(
0 => '9999999-dev',
),
'aliases' => array(),
'dev_requirement' => false,
),
'tinymeng/tools' => array(
... ...
... ... @@ -53,7 +53,7 @@ class Bar extends Gateway{
mkdir($filePath, 0777, true);
}
$file_name = is_int($data) ? $data : $data;
$file_name = $data;
$filename = $filePath.$file_name.'.png';
$drawing = new BCGDrawing($filename, $colorBack);
$drawing->setBarcode($code);
... ...
... ... @@ -54,9 +54,9 @@ class Qr extends Gateway{
}
if(is_int($data)){
$file_name = 'qr'.date('YmdHis').rand(1111,9999).'.png';
$file_name = 'qr'.$data.'.png';
}else{
$file_name = $data.'.png';
$file_name = 'qr'.date('YmdHis').rand(1111,9999).'.png';
}
$filename = $filePath.$file_name;
QRcode::png($data, $filename, $errorCorrectionLevel, $matrixPointSize, 2);
... ...
... ... @@ -11,7 +11,6 @@ use \tinymeng\tools\Strings;
* @package tinymeng\mailer
*/
define('saveFilePath',dirname(dirname(dirname(dirname(__DIR__)))).DIRECTORY_SEPARATOR.'public'.DIRECTORY_SEPARATOR.'uploads'.DIRECTORY_SEPARATOR.'barimages'.DIRECTORY_SEPARATOR.date('Ymd').DIRECTORY_SEPARATOR);
class Generate
{
/**
... ...