Browse Source

新增企业信息管理

彭俊 6 years ago
parent
commit
50f3d18eeb

+ 1 - 1
application/admin/controller/AdminControl.php

@@ -250,7 +250,7 @@ class AdminControl extends Controller
                 'children' => array(
                 'children' => array(
                     'Information' => array(
                     'Information' => array(
                         'text' => '企业信息管理',
                         'text' => '企业信息管理',
-                        'url' => url('Server/index'),
+                        'url' => url('Information/index'),
                     ),
                     ),
                 ),
                 ),
             ),
             ),

+ 73 - 0
application/admin/controller/Information.php

@@ -0,0 +1,73 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: Jun.peng
+ * Date: 2019/6/19
+ * Time: 9:28
+ */
+
+namespace app\admin\controller;
+
+use map\Map;
+use think\Lang;
+use app\admin\model\IncInfo as IncInfoModel;
+
+/**
+ * Class Information
+ * @package app\admin\controller
+ * 企业信息管理
+ */
+class Information extends AdminControl
+{
+
+
+    public function _initialize()
+    {
+        parent::_initialize();
+        Lang::load(APP_PATH . 'admin/lang/' . config('default_lang') . '/inc_info.lang.php');
+    }
+
+    public function index() {
+        $allpower = $this->qxhans();
+        $this->assign('allpower',$allpower);
+        if (!request()->isPost()) {
+            $incData = IncInfoModel::get(1);
+            $this->assign('IncData',  $incData);
+            $this->setAdminCurItem('index');
+            return $this->fetch();
+        } else {
+            $update_array = array();
+            $update_array['inc_name'] = $_POST['inc_name'];
+            $update_array['inc_phone'] = $_POST['inc_phone'];
+            $update_array['inc_email'] = $_POST['inc_email'];
+            $update_array['inc_weixin'] = $_POST['inc_weixin'];
+            $update_array['inc_qq'] = $_POST['inc_qq'];
+            $update_array['inc_address'] = $_POST['inc_address'];
+
+            //获取地址经纬度
+            $map = Map::getLngLat($_POST['inc_address']);
+            $update_array['inc_location'] = json_encode($map['location']);
+            $imgurl = USER_SITE_ROOT . '/images/';
+            $file = request()->file('inc_logo');
+
+            if($file){
+                $imgname = "logo";//官网logo
+                $file = $file->setSaveName($imgname);//设置保存文件名
+                $imgo = $file->move($imgurl, $savename = false, $replace = true);
+                if($imgo){
+                    $update_array['inc_logo'] = $imgname.'.png';
+                }
+            }
+
+            $result = IncInfoModel::updateIncInfo($update_array);
+            if ($result === true) {
+                $this->log(lang('ds_edit') . lang('dis_dump'), 1);
+                $this->success('修改成功', 'Information/index');
+            } else {
+                $this->log(lang('ds_edit') . lang('dis_dump'), 0);
+                $this->error(lang('修改失败'));
+            }
+        }
+    }
+
+}

+ 13 - 0
application/admin/lang/zh-cn/inc_info.lang.php

@@ -0,0 +1,13 @@
+<?php
+
+$lang['inc_name'] = '公司名称';
+$lang['inc_phone'] = '联系电话';
+$lang['inc_email'] = '联系邮箱';
+$lang['inc_qq'] = '联系qq';
+$lang['inc_weixin'] = '联系微信';
+$lang['inc_address'] = '详细地址';
+$lang['inc_logo'] = '公司logo';
+
+
+
+?>

+ 36 - 0
application/admin/model/IncInfo.php

@@ -0,0 +1,36 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: Jun.peng
+ * Date: 2019/6/19
+ * Time: 10:37
+ */
+
+namespace app\admin\model;
+
+use think\Model;
+
+//企业信息
+class IncInfo extends Model
+{
+    protected $name = 'inc_info';
+
+    /**
+     * 更新信息
+     *
+     * @param array $param 更新数据
+     * @return bool 布尔类型的返回结果
+     */
+    public static function updateIncInfo($param)
+    {
+        if (empty($param)) {
+            return false;
+        }
+        if (is_array($param)) {
+            $result = self::where('id', 1)->update($param);
+            return true;
+        } else {
+            return false;
+        }
+    }
+}

+ 17 - 0
application/admin/model/SaleGroup.php

@@ -0,0 +1,17 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: Jun.peng
+ * Date: 2019/6/19
+ * Time: 10:37
+ */
+
+namespace app\admin\model;
+
+use think\Model;
+
+//销售 人员 分组
+class SaleInfo extends Model
+{
+    protected $name = 'sale_group';
+}

+ 17 - 0
application/admin/model/SaleInfo.php

@@ -0,0 +1,17 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: Jun.peng
+ * Date: 2019/6/19
+ * Time: 10:37
+ */
+
+namespace app\admin\model;
+
+use think\Model;
+
+//销售 人员 信息
+class SaleInfo extends Model
+{
+    protected $name = 'sale_info';
+}

+ 84 - 0
application/admin/view/information/index.html

@@ -0,0 +1,84 @@
+
+{extend name="layout:home" /}
+
+{block name="container"}
+<form class="layui-form layui-form-pane" method="post" action="" enctype="multipart/form-data">
+    <div class="layui-tab layui-tab-card">
+        {include file="layout/admin_items" /}
+        <div class="layui-tab-content page-tab-content">
+            <div class="layui-tab-item layui-show ">
+
+                <div class="layui-form-item">
+                    <label class="layui-form-label">{$Think.lang.inc_name}</label>
+                    <div class="layui-input-inline">
+                        <input type="text" class="layui-input field-name" name="inc_name" id="inc_name" value="{$IncData.inc_name|default=''}" lay-verify="" autocomplete="off" placeholder="{$Think.lang.ds_please_enter}{$Think.lang.site_name}" required />
+                    </div>
+                </div>
+                <div class="layui-form-item">
+                    <label class="layui-form-label">{$Think.lang.inc_phone}</label>
+                    <div class="layui-input-inline">
+                        <input type="text" class="layui-input field-name" name="inc_phone" id="inc_phone" value="{$IncData.inc_phone|default=''}" lay-verify="" autocomplete="off" placeholder="{$Think.lang.ds_please_enter}{$Think.lang.icp_number}" required />
+                    </div>
+                </div>
+                <div class="layui-form-item">
+                    <label class="layui-form-label">{$Think.lang.inc_email}</label>
+                    <div class="layui-input-inline">
+                        <input type="text" class="layui-input field-name" name="inc_email" id="inc_email" value="{$IncData.inc_email|default=''}" lay-verify="" autocomplete="off" placeholder="{$Think.lang.ds_please_enter}{$Think.lang.site_phone}" required />
+                    </div>
+                </div>
+                <div class="layui-form-item">
+                    <label class="layui-form-label">{$Think.lang.inc_qq}</label>
+                    <div class="layui-input-inline">
+                        <input type="text" class="layui-input field-name" name="inc_qq" id="inc_qq" value="{$IncData.inc_qq|default=''}" lay-verify="" autocomplete="off" placeholder="{$Think.lang.ds_please_enter}{$Think.lang.flow_static_code}" required />
+                    </div>
+                </div>
+                <div class="layui-form-item">
+                    <label class="layui-form-label">{$Think.lang.inc_weixin}</label>
+                    <div class="layui-input-inline">
+                        <input type="text" class="layui-input field-name" name="inc_weixin" id="inc_weixin" value="{$IncData.inc_weixin|default=''}" lay-verify="" autocomplete="off" placeholder="{$Think.lang.ds_please_enter}{$Think.lang.fax}" required />
+                    </div>
+                </div>
+                <div class="layui-form-item">
+                    <label class="layui-form-label">{$Think.lang.inc_address}</label>
+                    <div class="layui-input-inline">
+                        <input type="text" class="layui-input field-name" name="inc_address" id="inc_address" value="{$IncData.inc_address|default=''}" lay-verify="" autocomplete="off" placeholder="{$Think.lang.ds_please_enter}{$Think.lang.fax}" required />
+                    </div>
+                </div>
+                <div class="layui-form-item">
+                    <label class="layui-form-label">{$Think.lang.inc_logo}</label>
+                    <div class="layui-input-inline">
+                        <input type="file" name="inc_logo" />
+                    </div>
+                </div>
+
+                <div class="layui-form-item">
+                    <div class="layui-input-block">
+                        <input type="submit" class="layui-btn layui-btn-normal" lay-submit value="{:lang('ds_submit')}"/>
+                    </div>
+                </div>
+            </div>
+        </div>
+    </div>
+</form>
+<script>
+    layui.use('form', function () {
+        var form = layui.form;
+    });
+</script>
+<script>
+    //Demo
+    layui.use('form', function () {
+        var form = layui.form;
+
+        //监听提交
+        form.on('submit(formDemo)', function (data) {
+            layer.msg(JSON.stringify(data.field));
+            return false;
+        });
+    });
+</script>
+
+{/block}
+
+
+

+ 81 - 0
extend/map/Map.php

@@ -0,0 +1,81 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: Jun.peng
+ * Date: 2019/6/19
+ * Time: 15:53
+ */
+namespace map;
+
+class Map
+{
+    //根据地址获取经纬度
+    public static function getLngLat($address)
+    {
+        // http://api.map.baidu.com/geocoder/v2/?address=北京市海淀区上地十街10号&output=json&ak=您的ak&callback=showLocation //GET请求
+        $data = [
+            'address' => $address,
+            'ak' => 'EglSDP3UNYtT2GsjGsoBFrHYBfixPrDv',
+            'output' => 'json',
+        ];
+        //转化为网址形式
+        $url = 'http://api.map.baidu.com/geocoder/v2/?' . http_build_query($data);
+        $res = self::doCurl($url);
+        $res = json_decode($res,true);
+        return $res['result'];
+    }
+
+    //根据经纬度或者地址获取百度地图
+    public static function staticimage($center)
+    {
+        if (!$center) {
+            return '';
+        }
+        $data = [
+            'ak' => 'EglSDP3UNYtT2GsjGsoBFrHYBfixPrDv',
+            'width' => '100',
+            'height' => '200',
+            'center' => $center,
+            'markers' => $center,
+        ];
+        $url = 'http://api.map.baidu.com/geocoder/v2/?' . http_build_query($data);
+        $res = self::doCurl($url);
+        return $res;
+    }
+
+    public static function doCurl($url, $type = 0, $data = [])
+    {
+        $ch = curl_init(); //初始化
+//设置选项
+        curl_setopt($ch, CURLOPT_URL, $url);
+        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+        curl_setopt($ch, CURLOPT_HEADER, 0);
+        if ($type == 1) {
+            //post
+            curl_setopt($ch, CURLOPT_PORT, 1);
+            curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
+        }
+//执行获取内容
+        $output = curl_exec($ch);
+//释放curl句柄
+        curl_close($ch);
+        return $output;
+    }
+
+
+    /**
+     * 【腾讯地图】
+     * 【根据详细地址获取经纬度】
+     *  20170920
+     *
+     * @param $address
+     * @return array
+     */
+    public static function getPoint($address)
+    {
+        $url = "https://apis.map.qq.com/ws/geocoder/v1/?address=" . $address . "&key=5ULBZ-2M4LJ-QS3FO-F6SSW-X3CRK-WABPO";
+        $res = self::doCurl($url);
+
+        return $res;
+    }
+}

+ 1 - 0
public/index.php

@@ -13,5 +13,6 @@
 
 
 // 定义应用目录
 // 定义应用目录
 define('APP_PATH', __DIR__ . '/../application/');
 define('APP_PATH', __DIR__ . '/../application/');
+define('EXTEND_PATH', __DIR__ .'/../extend/');
 // 加载框架引导文件
 // 加载框架引导文件
 require __DIR__ . '/../thinkphp/start.php';
 require __DIR__ . '/../thinkphp/start.php';