getList(); return $this->renderSuccess('', compact('list')); } public function edit() { $template_id = input('template_id'); $model = (new BusinessTemplate())->where('template_id', $template_id)->find(); if (request()->isGet()) { $data = json_decode($model['style'], true); empty($data['position']) ? $data['position'] = [] : ''; empty($data['is_business']) ? $data['is_business'] = 0 : ''; empty($data['positionNum']) ? $data['positionNum'] = 0 : ''; empty($data['icon']) ? $data['icon'] = [] : ''; $data = json_encode($data, JSON_UNESCAPED_UNICODE); return $this->renderSuccess('', compact('data')); } $dealer = ['business_card_id' => $template_id, 'name' => 'XXX', 'unit' => [], 'duties' => [], 'address' => [], 'mobile' => 'xxxxxxxxxxx', 'wechat' => 'xxxxxxxxxxx', 'mailbox' => 'xxxxxxxxxxx@.xxx.com', 'phone' => 'xxx-xxx-xxx', 'website' => 'xxxxxxxxxxxxxx.com', 'fax' => 'xxx-xxx', 'zip_code' => 'xxxxxx', 'template_id' => $template_id, 'wxapp_id' => 10001]; $param = request()->param(); $imageInfo = getimagesize($param['template']['backdrop']['src']); $param['template']['backdrop']['height'] = $imageInfo[1]; $param['template']['backdrop']['width'] = $imageInfo[0]; foreach ($param['template']['unit'] as $key => $value) { // 写入公司 $dealer['unit'][] = 'xxxxx公司'; } // 写入职位 //$dealer['duties'][] = '职位'; // 写入职位 $dealer['duties'][] = '职位'; // 写入地址 $dealer['address'][] = '广西壮族自治区南宁市江南区壮锦大道八桂绿城·龙湖御景-A栋-2单元xxx号'; $Qrcode = new Poster($dealer); $paramL['image'] = $Qrcode->getImageE($param['template'], $template_id); $paramL['style'] = json_encode($param['template'], JSON_UNESCAPED_UNICODE); if ($model->add($paramL)) { return $this->renderSuccess('编辑成功'); } return $this->renderError('编辑失败'); } public function add() { $model = new BusinessTemplate(); if (request()->isGet()) { $data = ["backdrop" => [ "src" => $model::$base_url."/image/team/business.png", 'type' => 'backdrop' ], "is_business" => 0, "name" => [ "fontSize" => 14, "color" => "#000000", "left" => 170, "top" => 70, "fontWeight" => 400, 'type' => 'text' ], "avatar" => [ "width" => 70, "style" => "circle", "left" => 37, "top" => 37, "display" => 1, "src" => $model::$base_url."/image/agent/avatar.jpg", 'type' => 'avatar' ], "logo" => [ "width" => 70, "height" => 70, "style" => "square", "left" => 22, "src" => $model::$base_url."/image/diy/logo_top.png", "top" => 140, "display" => 1, 'type' => 'image' ], "mobile" => [ "fontSize" => 14, "color" => "#000000", "left" => 170, "top" => 180, "fontWeight" => 400 ], "address" => [ ["fontSize" => 14, "color" => "#000000", "left" => 170, "top" => 380, "fontWeight" => 400, 'type' => 'text'] ], "unit" => [ ["fontSize" => 14, "color" => "#000000", "left" => 367, "top" => 120, "fontWeight" => 100, 'type' => 'text'] ], "duties" => [ ["fontSize" => 14, "color" => "#000000", "left" => 170, "top" => 120, "fontWeight" => 400, 'type' => 'text'] ], "position" => [ ], "wechat" => [ "fontSize" => 14, "color" => "#000000", "left" => 170, "top" => 230, "fontWeight" => 400, 'type' => 'text' ], "mailbox" => [ "fontSize" => 14, "color" => "#000000", "left" => 170, "top" => 330, "fontWeight" => 400, 'type' => 'text' ], "phone" => [ "fontSize" => 14, "color" => "#000000", "left" => 170, "top" => 280, "fontWeight" => 400, 'type' => 'text' ], 'positionNum' => 0, "iconL" => [], ]; return $this->renderSuccess('', [ 'data' => json_encode($data, JSON_UNESCAPED_UNICODE) ]); } $param = request()->param(); $imageInfo = getimagesize($param['template']['backdrop']['src']); $param['template']['backdrop']['height'] = $imageInfo[1]; $param['template']['backdrop']['width'] = $imageInfo[0]; $paramL['style'] = json_encode($param['template'], JSON_UNESCAPED_UNICODE); if ($model->add($paramL)) { $template_id = $model->template_id; $dealer = ['business_card_id' => $template_id, 'name' => 'XXX', 'unit' => [], 'duties' => [], 'address' => [], 'mobile' => 'xxxxxxxxxxx', 'wechat' => 'xxxxxxxxxxx', 'mailbox' => 'Xxxxxxxxxxxxxxxxx', 'phone' => 'xxx-xxx-xxx', 'website' => 'xxxxxxxxxxxxxx.com', 'fax' => 'xxx-xxx', 'zip_code' => 'xxxxxx', 'template_id' => $template_id, 'wxapp_id' => 10001]; foreach ($param['template']['unit'] as $key => $value) { // 写入公司 $dealer['unit'][] = 'xxxxx公司' . ($key + 1); } // 写入职位 $dealer['duties'][] = '职位'; // 写入地址 $dealer['address'][] = '地址1号'; $Qrcode = new Poster($dealer); $paramI['image'] = $Qrcode->getImageE($param['template'], $template_id); $modelBusiness = (new BusinessTemplate())->where(['template_id' => $template_id])->find(); $modelBusiness->where(['template_id' => $template_id])->update($paramI); return $this->renderSuccess('添加成功'); } return $this->renderError('添加失败'); } public function delete($template_id) { if ((new BusinessTemplate())->where(['template_id' => $template_id])->delete()) { return $this->renderSuccess('删除成功'); } return $this->renderError('删除失败'); } }