From 7e7e0c9d5b0cc79cd92890513606f333c2ed4e9a Mon Sep 17 00:00:00 2001 From: wangxiaowei Date: Wed, 14 Aug 2024 18:34:36 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E6=9C=AC=E5=9C=B0=E7=94=9F?= =?UTF-8?q?=E6=B4=BB=E5=95=86=E5=AE=B6=E4=BF=A1=E6=81=AF=E7=9A=84=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/shop/LocalStore.php | 61 +++- app/admin/logic/shop/LocalStoreLogic.php | 9 + .../validate/shop/LocalStoreValidate.php | 47 +++ app/admin/view/shop/local_store/add.html | 284 ++++++++++++------ app/admin/view/shop/local_store/lists.html | 2 +- app/admin/view/shop/local_store/user.html | 106 +++++++ app/common/utils/UploadAliOSS.php | 59 ++++ 7 files changed, 477 insertions(+), 91 deletions(-) create mode 100755 app/admin/validate/shop/LocalStoreValidate.php create mode 100755 app/admin/view/shop/local_store/user.html create mode 100644 app/common/utils/UploadAliOSS.php diff --git a/app/admin/controller/shop/LocalStore.php b/app/admin/controller/shop/LocalStore.php index 1b40b0c4..c2ee45d5 100755 --- a/app/admin/controller/shop/LocalStore.php +++ b/app/admin/controller/shop/LocalStore.php @@ -2,13 +2,15 @@ namespace app\admin\controller\shop; +use app\admin\logic\user\UserLogic; use app\common\basics\AdminBase; use app\common\server\ConfigServer; use app\common\enum\LocalLifeICBCEnum; use app\admin\logic\shop\LocalStoreLogic; use app\common\server\JsonServer; use think\facade\Request; - +use app\common\utils\UploadAliOSS; +use app\admin\validate\shop\LocalStoreValidate; class LocalStore extends AdminBase { @@ -24,6 +26,13 @@ class LocalStore extends AdminBase public function add() { + if ($this->request->isAjax()) { + $post = $this->request->post(); + (new LocalStoreValidate())->goCheck(); + $lists = LocalStoreLogic::create($post); +// return JsonServer::success('获取成功', $lists); + } + return view('', [ 'crftType1List' => LocalLifeICBCEnum::crftType1List(), // 商户证件类型列表 'crftType2List' => LocalLifeICBCEnum::crftType2List(), //法人/负责任人证件类型 @@ -118,4 +127,54 @@ class LocalStore extends AdminBase } } } + + public function uploadImage() + { + if ($this->request->isAjax()) { + $post = $this->request->post(); + $result = UploadAliOSS::uploadImage(LocalStoreLogic::$UPLOAD_PATH[$post['type']]); + if ($result['code'] == 1) { + return JsonServer::success('上传成功', $result['data']); + } + return JsonServer::error('上传失败'); + } + } + + public function delFile() + { + if ($this->request->isAjax()) { + $post = $this->request->post(); + $result = UploadAliOSS::delFile(LocalStoreLogic::$UPLOAD_PATH[$post['type']], $post['file']); + if ($result['code'] == 1) { + return JsonServer::success('上传成功', $result['data']); + } + + return JsonServer::error('上传失败'); + } + } + + public function user() + { + if ($this->request->isAjax()) { + $get = $this->request->get(); + return JsonServer::success('', UserLogic::lists($get)); + } + + return view(); + } + + public function map() + { + if ($this->request->isAjax()) { + $post = $this->request->post(); + $url = 'https://apis.map.qq.com/ws/geocoder/v1?key=' . ConfigServer::get('map', 'tx_map_key') . '&address=' . $post['address']; + $result = file_get_contents($url); + $data = json_decode($result, true); + if ($data['message'] == 'Success') { + return JsonServer::success('', $data['result']['location']); + } + + return JsonServer::error('获取失败'); + } + } } \ No newline at end of file diff --git a/app/admin/logic/shop/LocalStoreLogic.php b/app/admin/logic/shop/LocalStoreLogic.php index 38530daf..38f29d77 100755 --- a/app/admin/logic/shop/LocalStoreLogic.php +++ b/app/admin/logic/shop/LocalStoreLogic.php @@ -32,6 +32,15 @@ class LocalStoreLogic extends Logic ); } + // 添加 + public static function create($form) + { + unset($form['file']); + $form['create_time'] = date('Y-m-d H:i:s'); + $result = LocalStore::create($form); + dump($result);die; + } + public static function get_data($id) { return LocalStore::where(['lstore_id' => $id])->find(); diff --git a/app/admin/validate/shop/LocalStoreValidate.php b/app/admin/validate/shop/LocalStoreValidate.php new file mode 100755 index 00000000..87b0208b --- /dev/null +++ b/app/admin/validate/shop/LocalStoreValidate.php @@ -0,0 +1,47 @@ + 'require', + 'shopLogo' => 'require', + 'bankType' => 'require|checkBankType', + 'bankName' => 'require', + 'bankCard' => 'require', + 'businessLicense' => 'require', + 'crftNo1' => 'require', + 'idCard' => 'require', + 'name' => 'require', + 'empowerPhone' => 'require', + 'address' => 'require', + 'longitude' => 'require', + 'latitude' => 'require', + ]; + + protected $message = [ + 'shopName.require' => '商家名称不能为空', + 'shopLogo.require' => '商家Logo不能为空', + 'bankName.require' => '银行名称不能为空', + 'bankCard.require' => '银行卡号不能为空', + 'businessLicense.require' => '营业执照不能为空', + 'crftNo1.require' => '社会信用代码不能为空', + 'idCard.require' => '自拍照不能为空', + 'name.require' => '商户联系人不能为空', + 'empowerPhone.require' => '联系电话不能为空', + 'address.require' => '地址不能为空', + 'longitude.require' => '经纬度不能为空', + 'latitude.require' => '经纬度不能为空', + ]; + + protected function checkBankType($value, $rule, $data) + { + if ($value == 1 && empty($data['largeNumber'])) { + return '大额卡号不能为空'; + } + return true; + } +} \ No newline at end of file diff --git a/app/admin/view/shop/local_store/add.html b/app/admin/view/shop/local_store/add.html index 9e7a4f49..c8ef9370 100755 --- a/app/admin/view/shop/local_store/add.html +++ b/app/admin/view/shop/local_store/add.html @@ -8,12 +8,39 @@
+
+ +
+
+ + 绑定用户 +
+
+
- + +
+ +
+
+ +
+ +
+ +
建议尺寸:宽200像素*高200像素的jpg,jpeg,png图片
+
+
+ +
+
@@ -29,24 +56,23 @@
- +
- +
- @@ -55,16 +81,16 @@
- +
- @@ -73,16 +99,14 @@
- +
- +
@@ -123,12 +147,7 @@
-
- -
-
-
-
+
@@ -137,19 +156,19 @@ - + \ No newline at end of file diff --git a/app/admin/view/shop/local_store/lists.html b/app/admin/view/shop/local_store/lists.html index ad016466..55c94f78 100755 --- a/app/admin/view/shop/local_store/lists.html +++ b/app/admin/view/shop/local_store/lists.html @@ -114,7 +114,7 @@ var submit = layero.find("iframe").contents().find("#addSubmit"); iframeWindow.layui.form.on("submit(addSubmit)", function (data) { like.ajax({ - url: "{:url('shop.Category/add')}", + url: "{:url('shop.LocalStore/add')}", data: data.field, type: "POST", success: function (res) { diff --git a/app/admin/view/shop/local_store/user.html b/app/admin/view/shop/local_store/user.html new file mode 100755 index 00000000..2ad18b8c --- /dev/null +++ b/app/admin/view/shop/local_store/user.html @@ -0,0 +1,106 @@ +{layout name="layout1" /} +
+
+
+
+
+
+
+
+ +
+ +
+
+
+ +
+
+
+
+
+ +
+
+
+ +
+
+
+ +
+
+ + \ No newline at end of file diff --git a/app/common/utils/UploadAliOSS.php b/app/common/utils/UploadAliOSS.php new file mode 100644 index 00000000..ed83bb8c --- /dev/null +++ b/app/common/utils/UploadAliOSS.php @@ -0,0 +1,59 @@ + -1, 'msg' => '缺少上传路径']; + } else { + $StorageDriver = new StorageDriver(self::config()); + $StorageDriver->setUploadFile('file'); + if (!$StorageDriver->upload($path)) { + return ['code' => -1, 'msg' => '上传错误']; + } + + $fileName = $StorageDriver->getFileName(); + if ($fileName) { + return ['code' => 1, 'msg' => '', 'data' => array('file' => Config::get('aliyunoss.domain') . $path . '/'. $fileName)]; + } + + return ['code' => -1, 'msg' => '上传失败']; + } + } + + // 删除文件 + public static function delFile($path, $file) + { + if (!$path) { + return ['code' => -1, 'msg' => '缺少上传路径']; + } else { + $file = $path . '/' . basename($file); + $StorageDriver = new StorageDriver(self::config()); + $StorageDriver->delete($file); + } + + return ['code' => 1, 'msg' => '删除成功']; + } + + private static function config() + { + return [ + "default" => "aliyun", + "engine" => [ + "aliyun" => [ + "bucket" => Config::get('aliyunoss.bucket'), + "access_key_id" => Config::get('aliyunoss.access_key_id'), + "access_key_secret" => Config::get('aliyunoss.access_key_secret'), + "domain" => Config::get('aliyunoss.domain'), + ] + ] + ]; + } +} \ No newline at end of file