tp3.2生成帶二維碼的海報
阿新 • • 發佈:2019-01-01
public function haibaoOld()
{
$id = I( 'get.id' );
$type = I( 'get.type' );
// dump($type);
$userid = $this->uid; //dump($this->uid);die;
$this->head_title = "招聘海報";
$job = D( 'Job' ); //根據uid查出公司正在招check_status的職位
$infodata = $job->field( 'id,name,contact_number,remuneration,charge_mode' )->where( array( 'id' => $id ) )->find();//查出最近發的一條資訊
//dump($infodata);
$level = 'L'; // 糾錯級別:L、M、Q、H
$size = 4; // 點的大小:1到10,用於手機端4就可以了
$path = $_SERVER['DOCUMENT_ROOT'] . '/Uploads/qrcodes/'; //二維碼儲存路徑 Uploads/qrcodes
$fileName = $path . $level . $userid . '_' . $id . '.png';
// dump($fileName);
// die;
if ( $type ) {
vendor( "phpqrcode.phpqrcode" );
$qrcode = new \QRcode();
$url = 'http://' . $_SERVER['HTTP_HOST'] . '/Job/detail/id/' . $infodata['id'];//需要跳轉的一個路徑';
// dump($url);die;
$info = $qrcode->png( $url, $fileName, $level, $size );//生成帶引數的二維碼
$final = $path . 'final/' . $level . $userid . '_' . $id . '.png';
$haibao = './Uploads/qrcodes/haibao/haibao' . rand( 1, 3 ) . '.jpg';
$msyh = './Uploads/qrcodes/msyh/msyh.ttf';
$erweima = './Uploads/qrcodes/tmp/' . $userid . '_' . $size . '.jpg';
$image = new \Think\Image();
$image->open( $fileName )
->thumb( 500, 500, \Think\Image::IMAGE_THUMB_FIXED )->save( $erweima );//二維碼小圖
$image->open( $haibao )
->water( $erweima, array( 925, 2800 ), 100 )
->text( '招聘職位:' . $infodata['name'], $msyh, 70, '#000000', array( 500, 2070 ) )
->text( '薪資:' . $infodata['remuneration'] . '元/月', $msyh, 70, '#000000', array( 500, 2200 ) )
->text( '聯絡電話:' . $infodata['contact_number'], $msyh, 70, '#000000', array( 500, 2330 ) )
->save( $final );
} else {
if ( !file_exists( $fileName ) ) {
vendor( "phpqrcode.phpqrcode" );
$qrcode = new \QRcode();
$url = 'http://' . $_SERVER['HTTP_HOST'] . '/Job/detail/id/' . $infodata['id'];//需要跳轉的一個路徑';
// dump($url);die;
$info = $qrcode->png( $url, $fileName, $level, $size );//生成帶引數的二維碼
}
$final = $path . 'final/' . $level . $userid . '_' . $id . '.png';
if ( !file_exists( $final ) ) {
$haibao = './Uploads/qrcodes/haibao/haibao' . rand( 1, 3 ) . '.jpg';
$msyh = './Uploads/qrcodes/msyh/msyh.ttf';
$erweima = './Uploads/qrcodes/tmp/' . $userid . '_' . $size . '.jpg';
$image = new \Think\Image();
$image->open( $fileName )
->thumb( 500, 500, \Think\Image::IMAGE_THUMB_FIXED )->save( $erweima );//二維碼小圖
$image->open( $haibao )
->water( $erweima, array( 925, 2800 ), 100 )
->text( '招聘職位:' . $infodata['name'], $msyh, 70, '#000000', array( 500, 2070 ) )
->text( '薪資:' . $infodata['remuneration'] . '元/月', $msyh, 70, '#000000', array( 500, 2200 ) )
->text( '聯絡電話:' . $infodata['contact_number'], $msyh, 70, '#000000', array( 500, 2330 ) )
->save( $final );
}
}
$pic_url = 'http://' . $_SERVER['HTTP_HOST'] . '/Uploads/qrcodes/final/' . $level . $userid . '_' . $id . '.png';//圖片最終的一個地址
if ( $pic_url ) {
$this->assign( 'image', $pic_url );//die;
}
$this->assign( 'id', $id );
$this->display();
}
{
$id = I( 'get.id' );
$type = I( 'get.type' );
// dump($type);
$userid = $this->uid; //dump($this->uid);die;
$this->head_title = "招聘海報";
$job = D( 'Job' ); //根據uid查出公司正在招check_status的職位
$infodata = $job->field( 'id,name,contact_number,remuneration,charge_mode' )->where( array( 'id' => $id ) )->find();//查出最近發的一條資訊
//dump($infodata);
$level = 'L'; // 糾錯級別:L、M、Q、H
$size = 4; // 點的大小:1到10,用於手機端4就可以了
$path = $_SERVER['DOCUMENT_ROOT'] . '/Uploads/qrcodes/'; //二維碼儲存路徑 Uploads/qrcodes
$fileName = $path . $level . $userid . '_' . $id . '.png';
// dump($fileName);
// die;
if ( $type ) {
vendor( "phpqrcode.phpqrcode" );
$qrcode = new \QRcode();
$url = 'http://' . $_SERVER['HTTP_HOST'] . '/Job/detail/id/' . $infodata['id'];//需要跳轉的一個路徑';
// dump($url);die;
$info = $qrcode->png( $url, $fileName, $level, $size );//生成帶引數的二維碼
$final = $path . 'final/' . $level . $userid . '_' . $id . '.png';
$haibao = './Uploads/qrcodes/haibao/haibao' . rand( 1, 3 ) . '.jpg';
$msyh = './Uploads/qrcodes/msyh/msyh.ttf';
$erweima = './Uploads/qrcodes/tmp/' . $userid . '_' . $size . '.jpg';
$image = new \Think\Image();
$image->open( $fileName )
->thumb( 500, 500, \Think\Image::IMAGE_THUMB_FIXED )->save( $erweima );//二維碼小圖
$image->open( $haibao )
->water( $erweima, array( 925, 2800 ), 100 )
->text( '招聘職位:' . $infodata['name'], $msyh, 70, '#000000', array( 500, 2070 ) )
->text( '薪資:' . $infodata['remuneration'] . '元/月', $msyh, 70, '#000000', array( 500, 2200 ) )
->text( '聯絡電話:' . $infodata['contact_number'], $msyh, 70, '#000000', array( 500, 2330 ) )
->save( $final );
} else {
if ( !file_exists( $fileName ) ) {
vendor( "phpqrcode.phpqrcode" );
$qrcode = new \QRcode();
$url = 'http://' . $_SERVER['HTTP_HOST'] . '/Job/detail/id/' . $infodata['id'];//需要跳轉的一個路徑';
// dump($url);die;
$info = $qrcode->png( $url, $fileName, $level, $size );//生成帶引數的二維碼
}
$final = $path . 'final/' . $level . $userid . '_' . $id . '.png';
if ( !file_exists( $final ) ) {
$haibao = './Uploads/qrcodes/haibao/haibao' . rand( 1, 3 ) . '.jpg';
$msyh = './Uploads/qrcodes/msyh/msyh.ttf';
$erweima = './Uploads/qrcodes/tmp/' . $userid . '_' . $size . '.jpg';
$image = new \Think\Image();
$image->open( $fileName )
->thumb( 500, 500, \Think\Image::IMAGE_THUMB_FIXED )->save( $erweima );//二維碼小圖
$image->open( $haibao )
->water( $erweima, array( 925, 2800 ), 100 )
->text( '招聘職位:' . $infodata['name'], $msyh, 70, '#000000', array( 500, 2070 ) )
->text( '薪資:' . $infodata['remuneration'] . '元/月', $msyh, 70, '#000000', array( 500, 2200 ) )
->text( '聯絡電話:' . $infodata['contact_number'], $msyh, 70, '#000000', array( 500, 2330 ) )
->save( $final );
}
}
$pic_url = 'http://' . $_SERVER['HTTP_HOST'] . '/Uploads/qrcodes/final/' . $level . $userid . '_' . $id . '.png';//圖片最終的一個地址
if ( $pic_url ) {
$this->assign( 'image', $pic_url );//die;
}
$this->assign( 'id', $id );
$this->display();
}