当前位置: 首页 > 后端技术 > PHP

商城网站建设电子商务在线网站开发源码

时间:2023-03-29 21:28:23 PHP

企业要想拓展电子商务业务,开发一个好的电子商务系统是必不可少的。电子商务商城网站是一个不错的选择。下面分享一下网站的代码。代码部分命名空间app\home\controller;使用think\Page;使用think\Verify;使用think\Db;使用think\Image;classIndexextendsBase{publicfunctionindex(){$web_list=S('web_index_data');if(!$web_list){$web_list=M('web')->where(array('web_show'=>1))->order('web_sort')->select();if($web_list){foreach($web_listas$kb=>$vb){$block_list=M('web_block')->where(array('web_id'=>$vb['web_id']))->order('web_id')->select();if(is_array($block_list)&&!empty($block_list)){foreach($block_listas$key=>$val){//将变量输出到页面$val['block_info']=unserialize($val['block_info']);$web_list[$kb][$val['var_name']]=$val['block_info'];}}}S('web_index_data',$web_list);}}$this->assign('web_list',$web_list);return$this->fetch();}公告详情页publicfunctionnotice(){return$this->fetch();}publicfunctionqr_code_raw(){ob_end_clean();//导入Vendor类库包库/Vendor/Zend/Server.class.phpvendor('phpqrcode.phpqrcode');//import('Vendor.phpqrcode.phpqrcode');error_reporting(E_ERROR);$url=urldecode($_GET["data"]);\QRcode::png($url);exit;}用户分发二维码publicfunctionqr_code(){ob_end_clean();vendor('topthink.think-image.src.Image');vendor('phpqrcode.phpqrcode');error_reporting(E_ERROR);$url=isset($_GET['数据'])?$_GET['数据']:'';$url=urldecode($url);$head_pic=input('get.head_pic','');$back_img=input('get.back_img','');$valid_date=input('get.valid_date',0);$qr_code_path='./public/upload/qr_code/';如果(!file_exists($qr_code_path)){mkdir($qr_code_path);}/*生成二维码*/$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();/*添加背景图片*/如果($back_img&&file_exists($back_img)){$back=Image::open($back_img);$back->thumb($QR_width,$QR_height,\think\Image::THUMB_CENTER)->water($qr_code_file,\think\Image::WATER_NORTHWEST,60);//->保存($qr_code_file);$QR=$返回;}/*添加头部图像*/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)->save($logo_file,null,100);$QR=$QR->thumb($QR_width,$QR_height)->water($logo_file,\think\Image::WATER_CENTER);取消链接($logo_file);}如果($head_pic_path){取消链接($head_pic_path);}}if($valid_date&&strpos($url,'weixin.qq.com')!==false){$QR=$QR->text('有效时间'.$valid_date,"./vendor/topthink/think-验证码/资产/zhttfs/1.ttf",7,'#00000000',Image::WATER_SOUTH);}$QR->save($qr_code_file,null,100);$qrHandle=imagecreatefromstring(file_get_contents($qr_code_file));取消链接($qr_code_file);//删除二维码文件header("Content-type:image/png");imagepng($qrHandle);imagedestroy($qrHandle);exit;}