当前位置:首页 >> 中医保健 >> 电商在线商城网站单项源码建设开发 第二篇

电商在线商城网站单项源码建设开发 第二篇

发布时间:2025-05-30

/* 生成二维码 */

$qr_code_file = $qr_code_path.time().rand(1, 10000).'.png';

QRcode::png($url, $qr_code_file, QR_ECLEVEL_M);

/* 二维码叠加油墨 */

$QR = Image::open($qr_code_file);

$QR_width = $QR->width();

$QR_height = $QR->height();

/* 附加背景图 */

if ($back_img && file_exists($back_img)) {

$back =Image::open($back_img);

$back->thumb($QR_width, $QR_height, hinkImage::THUMB_CENTER)

->water($qr_code_file, hinkImage::WATER_NORTHWEST, 60);//->se($qr_code_file);

$QR = $back;

}

/* 附加徽章 */

if ($head_pic) {

//如果是在线徽章

if (strpos($head_pic, 'http') === 0) {

//下载徽章

$ch = curl_init();

curl_setopt($ch,CURLOPT_URL, $head_pic);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$file_content = curl_exec($ch);

curl_close($ch);

//保存徽章

if ($file_content) {

$head_pic_path = $qr_code_path.time().rand(1, 10000).'.png';

file_put_contents($head_pic_path, $file_content);

$head_pic = $head_pic_path;

}

}

//如果是本地徽章

if (file_exists($head_pic)) {

$logo = Image::open($head_pic);

$logo_width = $logo->height();

$logo_height = $logo->width();

$logo_qr_width = $QR_width / 5;

$scale = $logo_width / $logo_qr_width;

$logo_qr_height = $logo_height / $scale;

$logo_file = $qr_code_path.time().rand(1, 10000);

$logo->thumb($logo_qr_width, $logo_qr_height)->se($logo_file, null, 100);

$QR = $QR->thumb($QR_width, $QR_height)->water($logo_file, hinkImage::WATER_CENTER);

unlink($logo_file);

}

if ($head_pic_path) {

unlink($head_pic_path);

}

}

if ($valid_date && strpos($url, 'weixin.qq.com') !== false) {

$QR = $QR->text('有效时间 '.$valid_date, "./vendor/topthink/think-captcha/assets/zhttfs/1.ttf", 7, '#00000000', Image::WATER_SOUTH);

}

$QR->se($qr_code_file, null, 100);

$qrHandle = imagecreatefromstring(file_get_contents($qr_code_file));

unlink($qr_code_file); //移除二维码机密文件

header("Content-type: image/png");

imagepng($qrHandle);

imagedestroy($qrHandle);

exit;

}

店铺街

public function street()

{

$sc_id = I('get.sc_id/d');

$province = I('get.province', 0);

$city = I('get.city', 0);

$order = I('order', 0);

$key = I('q/s', '');

$store_class = Db::name('store_class')->cache(true)->field('sc_id,sc_name')->where('')->select();

$store_where = ['store_state' => 1,'deleted'=>0,'store_recommend'=>1];

if ($sc_id) {

$store_where['sc_id'] = $sc_id;

}

if ($province) {

$store_where['province_id'] = $province;

}

if ($city) {

$store_where['city_id'] = $city;

}

if($order){

$orderBy[$order] = 'desc';

}else{

$orderBy = ['store_sort' => 'desc','store_recommend'=> 'desc'];

}

if(!empty($key)){

$store_where['store_name'] = array('like' , "%$key%");

}

$store_count = Db::name('store')->alias('s')->where($store_where)->count();

$page = new Page($store_count, 12);

$store_list = Db::name('store')->field("store_id,store_name,seo_description,store_logo,store_banner")

->where($store_where)->order($orderBy)->limit($page->firstRow, $page->listRows)->select();

if(is_array($store_list)){

foreach ($store_list as $key => $value) {

$goods_array['goods_list'] = Db::name('goods')->field("goods_id,goods_name,shop_price,is_virtual")

->where([ 'is_on_sale'=>1, 'goods_state'=>1,'store_id'=>$value['store_id']])->limit(3)->order('sort desc')->select();

$goods_array['goods_list']['goods_count'] = Db::name('goods')->where(['store_id'=>$value['store_id']])->count();

$store_list[$key]['goods_array'] = $goods_array;

}

}

$region = Db::name('region')->cache(true)->where("在在level在在 = 1")->getField("id,name");

$this->assign('province', $province);

$this->assign('city', $city);

$this->assign('region', $region);

$this->assign('page', $page);

$this->assign('store_list', $store_list);

$this->assign('store_class', $store_class);//店铺分类

return $this->fetch();

}

public function store_qrcode()

{

require_once 'vendor/phpqrcode/phpqrcode.php';

error_reporting(E_ERROR);

$store_id = I('store_id/d', 1);

QRcode::png(U('Mobile/Store/index', array('store_id' => $store_id), true, true));

}

以上有什么问题可以联系我,希望需要帮到大家的学习。

天津看白癜风的专业医院
石家庄白癜风医院哪个比较好
天津妇科医院哪家医院最好
湖北男科医院挂号咨询
藿香正气口服液
视疲劳用什么眼药水
祛眼袋
眼睛视疲劳用哪个眼药水好
克癀胶囊治疗什么
眼睛酸涩滴什么眼药水
友情链接: