作者 郭文星

123

@@ -192,7 +192,7 @@ return [ @@ -192,7 +192,7 @@ return [
192 '否', 192 '否',
193 '是', 193 '是',
194 ], 194 ],
195 - 'value' => '0', 195 + 'value' => '1',
196 'rule' => 'required', 196 'rule' => 'required',
197 'msg' => '', 197 'msg' => '',
198 'tip' => '', 198 'tip' => '',
@@ -235,8 +235,7 @@ return [ @@ -235,8 +235,7 @@ return [
235 'title' => '允许的域名列表', 235 'title' => '允许的域名列表',
236 'visible' => 'limitreferer=1', 236 'visible' => 'limitreferer=1',
237 'type' => 'text', 237 'type' => 'text',
238 - 'content' => [  
239 - ], 238 + 'content' => [],
240 'value' => '', 239 'value' => '',
241 'rule' => '', 240 'rule' => '',
242 'msg' => '', 241 'msg' => '',
@@ -106,13 +106,12 @@ class Car extends Backend @@ -106,13 +106,12 @@ class Car extends Backend
106 $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate; 106 $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate;
107 $this->model->validateFailException()->validate($validate); 107 $this->model->validateFailException()->validate($validate);
108 } 108 }
109 - $istrue=$this->model->where("driver_id",$params['driver_id'])->find();  
110 - if($istrue){  
111 - $this->error("该司机添加车辆");  
112 - } 109 +// $istrue=$this->model->where("driver_id",$params['driver_id'])->find();
  110 +// if($istrue){
  111 +// $this->error("该司机添加车辆");
  112 +// }
113 $route=Db::name("route")->where("id",$params['route_id'])->find(); 113 $route=Db::name("route")->where("id",$params['route_id'])->find();
114 $driver=Db::name("driver")->where("id",$params['driver_id'])->find(); 114 $driver=Db::name("driver")->where("id",$params['driver_id'])->find();
115 -  
116 $result = $this->model->allowField(true)->insertGetId($params); 115 $result = $this->model->allowField(true)->insertGetId($params);
117 116
118 $index=new Index(); 117 $index=new Index();
@@ -122,8 +121,8 @@ class Car extends Backend @@ -122,8 +121,8 @@ class Car extends Backend
122 "name"=>$driver["name"], 121 "name"=>$driver["name"],
123 "driver_id"=>$driver["id"], 122 "driver_id"=>$driver["id"],
124 ]; 123 ];
125 - $place_image=$index->build($data);  
126 - $result = Db::name('driver')->where('id','=',$driver["id"])->update(['place_image'=>$place_image]); 124 + $place_image=$index->build(json_encode($data));
  125 + $result = Db::name('driver')->where('id','=',$driver["id"])->update(['place_image'=>$avatar['fileurl']]);
127 Db::commit(); 126 Db::commit();
128 } catch (ValidateException|PDOException|Exception $e) { 127 } catch (ValidateException|PDOException|Exception $e) {
129 Db::rollback(); 128 Db::rollback();
@@ -3,9 +3,11 @@ @@ -3,9 +3,11 @@
3 namespace app\admin\controller; 3 namespace app\admin\controller;
4 4
5 use app\admin\model\AdminLog; 5 use app\admin\model\AdminLog;
  6 +use app\api\controller\inspection\Task;
6 use app\common\controller\Backend; 7 use app\common\controller\Backend;
7 use think\Config; 8 use think\Config;
8 use think\Hook; 9 use think\Hook;
  10 +use think\Response;
9 use think\Session; 11 use think\Session;
10 use think\Validate; 12 use think\Validate;
11 13
@@ -137,5 +139,33 @@ class Index extends Backend @@ -137,5 +139,33 @@ class Index extends Backend
137 139
138 return $html; 140 return $html;
139 } 141 }
  142 +// 生成二维码
  143 + public function build($text,$label='')
  144 + {
  145 +
  146 + $config = get_addon_config('qrcode');
  147 + $params = $this->request->get();
  148 + $params = array_intersect_key($params, array_flip(['text', 'size', 'padding', 'errorlevel', 'foreground', 'background', 'logo', 'logosize', 'logopath', 'label', 'labelfontsize', 'labelalignment']));
  149 + $params['text'] = $text;
  150 + $params['label'] = $label;
  151 + $qrCode = \addons\qrcode\library\Service::qrcode($params);
  152 + $mimetype = $config['format'] == 'png' ? 'image/png' : 'image/svg+xml';
  153 + $response = Response::create()->header("Content-Type", $mimetype);
  154 + // 写入到文件
  155 + if ($config['writefile']) {
  156 + $qrcodePath = ROOT_PATH . 'public/uploads/store_qrcode/';
  157 + if (!is_dir($qrcodePath)) {
  158 + @mkdir($qrcodePath);
  159 + }
  160 + if (is_really_writable($qrcodePath)) {
  161 + $filePath = $qrcodePath . md5(implode('', $params)) . '.' . $config['format'];
  162 + $qrCode->writeFile($filePath);
  163 + $code_name = md5(implode('', $params)) . '.' . $config['format'];
  164 + }
  165 + $task=new Task();
  166 + $res=$task->fileUpload($code_name);
  167 + }
  168 + return $res;
140 169
  170 + }
141 } 171 }