Commit f87f8b2b3c14a6480b840042217777ea14c5257e

Authored by u123231312
1 parent 0fb7fc34

no message

@@ -548,11 +548,17 @@ class Template extends Common{ @@ -548,11 +548,17 @@ class Template extends Common{
548 } 548 }
549 //模拟菜系 549 //模拟菜系
550 $arrayCai = array( 550 $arrayCai = array(
551 - 1 => '湘菜',  
552 - 2 => '粤菜',  
553 - 3 => '川菜',  
554 - 4 => '东北菜',  
555 - 5 => '湖南菜', 551 + 1 => '川菜',
  552 + 2 => '苏菜',
  553 + 3 => '鄂菜',
  554 + 4 => '湘菜',
  555 + 5 => '鲁菜',
  556 + 6 => '闽菜',
  557 + 7 => '浙菜',
  558 + 8 => '徽菜',
  559 + 9 => '京菜',
  560 + 10 => '豫菜',
  561 + 11 => '东北菜',
556 ); 562 );
557 $this->assign ('arrayCai',$arrayCai); 563 $this->assign ('arrayCai',$arrayCai);
558 $this->assign ( 'title','菜品库' ); 564 $this->assign ( 'title','菜品库' );
@@ -599,11 +605,17 @@ class Template extends Common{ @@ -599,11 +605,17 @@ class Template extends Common{
599 } 605 }
600 //模拟菜系 606 //模拟菜系
601 $arrayCai = array( 607 $arrayCai = array(
602 - 1 => '湘菜',  
603 - 2 => '粤菜',  
604 - 3 => '川菜',  
605 - 4 => '东北菜',  
606 - 5 => '湖南菜', 608 + 1 => '川菜',
  609 + 2 => '苏菜',
  610 + 3 => '鄂菜',
  611 + 4 => '湘菜',
  612 + 5 => '鲁菜',
  613 + 6 => '闽菜',
  614 + 7 => '浙菜',
  615 + 8 => '徽菜',
  616 + 9 => '京菜',
  617 + 10 => '豫菜',
  618 + 11 => '东北菜',
607 ); 619 );
608 $this->assign ('arrayCai',$arrayCai); 620 $this->assign ('arrayCai',$arrayCai);
609 $this->assign ('list',$arr); 621 $this->assign ('list',$arr);
@@ -106,6 +106,58 @@ class UpFiles extends Common @@ -106,6 +106,58 @@ class UpFiles extends Common
106 return $result; 106 return $result;
107 } 107 }
108 } 108 }
  109 + //菜品库
  110 + public function vegetabledata(){
  111 + // 获取上传文件表单字段名
  112 + $fileKey = array_keys(request()->file());
  113 + // 获取表单上传文件
  114 + $file = request()->file($fileKey['0']);
  115 + $obj = $file->getInfo();
  116 + $rs = array('code' => 0, 'url' => '');
  117 + $tmpName = $obj['tmp_name'];
  118 + $name = md5($obj['name'] . $_SERVER['REQUEST_TIME']);
  119 + $ext = strrchr($obj['name'], '.');
  120 + $uploadFolder = sprintf('%s/uploads/temp/',$_SERVER['DOCUMENT_ROOT']);
  121 + if (!is_dir($uploadFolder)) {
  122 + mkdir($uploadFolder);
  123 + chmod($uploadFolder,0777);
  124 + }
  125 + $imgPath = $uploadFolder . $name . $ext;
  126 + //移动到临时目录
  127 + if (move_uploaded_file($tmpName, $imgPath)) {
  128 + $accessKey = 'uva-aaonM8dukeR6phc9yuPBrOXk9brrNW_PxLD7';
  129 + $secretKey = 'oZMMVN6phk49lG0J1xwmi1Ju0ETT15EnAEWcU9Cs';
  130 + $auth = new Auth($accessKey, $secretKey);
  131 + $bucket = 'vegetable-data';
  132 + $key = $obj['name'];
  133 + // 生成上传Token
  134 + $token = $auth->uploadToken($bucket);
  135 + // 构建 UploadManager 对象
  136 + $uploadMgr = new UploadManager();
  137 + $backUrl = "pf1b1rwu0.bkt.clouddn.com"; //返回图片在七牛的路径
  138 + $image = new Compression($imgPath);
  139 + $imgPath = $image->getThumb();
  140 + list($ret, $err) = $uploadMgr->putFile($token,$key,$imgPath); //缩略图
  141 + $rs['url'] = $backUrl."/".$key;
  142 + }
  143 + if($rs['url']){
  144 + //上传成功之后删除服务器文件
  145 + $this->deldir($uploadFolder);
  146 + $result['code'] = 1;
  147 + $result['info'] = '图片上传成功!';
  148 + $path=str_replace('\\','/',$rs['url']);
  149 + $result['url'] = $path;
  150 + $key = substr($key,0,strrpos($key,"."));
  151 + $result['picname'] = $key;
  152 + return $result;
  153 + }else{
  154 + // 上传失败获取错误信息
  155 + $result['code'] =0;
  156 + $result['info'] = $file->getError();
  157 + $result['url'] = '';
  158 + return $result;
  159 + }
  160 + }
109 public function deldir($dirName) { 161 public function deldir($dirName) {
110 array_map('unlink', glob($dirName."*.*")); 162 array_map('unlink', glob($dirName."*.*"));
111 } 163 }
@@ -85,7 +85,7 @@ @@ -85,7 +85,7 @@
85 //GIF/视频上传 85 //GIF/视频上传
86 var uploadInst = upload.render({ 86 var uploadInst = upload.render({
87 elem: '.adbtncil' 87 elem: '.adbtncil'
88 - ,url: '{:url("UpFiles/qncloud")}' 88 + ,url: '{:url("UpFiles/vegetabledata")}'
89 ,before: function(obj){ 89 ,before: function(obj){
90 //预读本地文件示例,不支持ie8 90 //预读本地文件示例,不支持ie8
91 obj.preview(function(index, file, result){ 91 obj.preview(function(index, file, result){
@@ -85,7 +85,7 @@ @@ -85,7 +85,7 @@
85 //GIF/视频上传 85 //GIF/视频上传
86 var uploadInst = upload.render({ 86 var uploadInst = upload.render({
87 elem: '#adBtn' 87 elem: '#adBtn'
88 - ,url: '{:url("UpFiles/qncloud")}' 88 + ,url: '{:url("UpFiles/vegetabledata")}'
89 ,before: function(obj){ 89 ,before: function(obj){
90 //预读本地文件示例,不支持ie8 90 //预读本地文件示例,不支持ie8
91 obj.preview(function(index, file, result){ 91 obj.preview(function(index, file, result){