544782275@qq.com 3 years ago
parent
commit
9d80073337

+ 201 - 0
application/store/controller/Company.php

@@ -0,0 +1,201 @@
+<?php
+
+// +----------------------------------------------------------------------
+// | ThinkAdmin
+// +----------------------------------------------------------------------
+// | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
+// +----------------------------------------------------------------------
+// | 官方网站: http://demo.thinkadmin.top
+// +----------------------------------------------------------------------
+// | 开源协议 ( https://mit-license.org )
+// +----------------------------------------------------------------------
+// | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
+// | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
+// +----------------------------------------------------------------------
+
+namespace app\store\controller;
+
+use library\Controller;
+use library\tools\Data;
+use think\Db;
+
+/**
+ * 公司信息
+ * Class Goods
+ * @package app\store\controller
+ */
+class Company extends Controller
+{
+    /**
+     * 指定数据表
+     * @var string
+     */
+    protected $table = 'StoreCompany';
+
+    /**
+     * 公司信息
+     * @auth true
+     * @menu true
+     * @throws \think\Exception
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     * @throws \think\exception\PDOException
+     */
+    public function index()
+    {
+        $this->title = '公司信息';
+        $query = $this->_query($this->table)->equal('status,cate_id')->like('title');
+        $query->where(['is_deleted' => '0'])->where('cate_id','>',0)->order('sort desc,id desc')->page();
+    }
+
+    /**
+     * 数据列表处理
+     * @param array $data
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    protected function _index_page_filter(&$data)
+    {
+        $this->clist = Db::name('StoreGoodsCate')->where(['is_deleted' => '0', 'status' => '1'])->select();
+        $list = Db::name('StoreGoodsList')->where('status', '1')->whereIn('goods_id', array_unique(array_column($data, 'id')))->select();
+        $cate_id_arr = Db::name('store_goods_cate')->column('title','id');
+        foreach ($data as &$vo) {
+            list($vo['list'], $vo['cate']) = [[], []];
+            foreach ($list as $goods) if ($goods['goods_id'] === $vo['id']) array_push($vo['list'], $goods);
+            foreach ($this->clist as $cate) if ($cate['id'] === $vo['cate_id']) $vo['cate'] = $cate;
+            $vo['cate_name'] = $cate_id_arr[$vo['cate_id']];
+        }
+    }
+
+    /**
+     * 添加服务
+     * @auth true
+     * @throws \think\Exception
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     * @throws \think\exception\PDOException
+     */
+    public function add()
+    {
+        $this->title = '添加服务';
+        $this->isAddMode = '1';
+        $this->_form($this->table, 'form');
+    }
+
+    /**
+     * 编辑服务
+     * @auth true
+     * @throws \think\Exception
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     * @throws \think\exception\PDOException
+     */
+    public function edit()
+    {
+        $this->title = '编辑服务';
+        $this->isAddMode = '0';
+        $this->_form($this->table, 'form');
+    }
+
+    /**
+     * 表单数据处理
+     * @param array $data
+     * @throws \think\Exception
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     * @throws \think\exception\PDOException
+     */
+    protected function _form_filter(&$data)
+    {
+        // 生成服务ID
+        if(empty($data['id'])){
+            $goods_id = Db::name('store_goods')->order('id desc')->value('id');
+            $data['id'] = $goods_id + 1;
+        }
+        if ($this->request->isGet()) {
+            $fields = 'goods_spec,goods_id,status,price_market market,price_selling selling,number_virtual `virtual`,number_express express';
+            $defaultValues = Db::name('StoreGoodsList')->where(['goods_id' => $data['id']])->column($fields);
+            $this->defaultValues = json_encode($defaultValues, JSON_UNESCAPED_UNICODE);
+            $this->cates = Db::name('StoreGoodsCate')->where(['is_deleted' => '0', 'status' => '1'])->order('sort desc,id desc')->select();
+        } elseif ($this->request->isPost()) {
+            if (empty($data['logo'])) $this->error('服务LOGO不能为空,请上传图片');
+            Db::name('StoreGoodsList')->where(['goods_id' => $data['id']])->update(['status' => '0']);
+            //查询是否有规格信息
+            $goods_type = Db::name('store_goods_type')->where('goods_id',$data['id'])->find();
+            if(empty($goods_type)){
+                $serve_type = array();
+                foreach (json_decode($data['lists']) as $value){
+                    foreach ($value as $k=>$v){
+                        if($k == 0){
+                            if(!in_array($v->name,$serve_type)){
+                                $serve_type[] = $v->name;
+                            }
+                        }
+                    }
+                }
+                foreach ($serve_type as $v){
+                    Db::name('store_goods_type')->insert(array('goods_id'=>$data['id'],'spec_name'=>$v));
+                }
+            }
+            foreach (json_decode($data['lists'], true) as $vo) Data::save('StoreGoodsList', [
+                'goods_id'       => $data['id'],
+                'goods_spec'     => $vo[0]['key'],
+                'price_market'   => $vo[0]['market'],
+                'price_selling'  => $vo[0]['selling'],
+                'number_virtual' => $vo[0]['virtual'],
+                'number_express' => $vo[0]['express'],
+                'status'         => $vo[0]['status'] ? 1 : 0,
+            ], 'goods_spec', ['goods_id' => $data['id']]);
+        }
+    }
+
+    /**
+     * 表单结果处理
+     * @param boolean $result
+     */
+    protected function _form_result($result)
+    {
+        if ($result && $this->request->isPost()) {
+            $this->success('服务编辑成功!', 'javascript:history.back()');
+        }
+    }
+
+    /**
+     * 禁用服务
+     * @auth true
+     * @throws \think\Exception
+     * @throws \think\exception\PDOException
+     */
+    public function forbid()
+    {
+        $this->_save($this->table, ['status' => '0']);
+    }
+
+    /**
+     * 启用服务
+     * @auth true
+     * @throws \think\Exception
+     * @throws \think\exception\PDOException
+     */
+    public function resume()
+    {
+        $this->_save($this->table, ['status' => '1']);
+    }
+
+    /**
+     * 删除服务
+     * @auth true
+     * @throws \think\Exception
+     * @throws \think\exception\PDOException
+     */
+    public function remove()
+    {
+        $this->_delete($this->table);
+    }
+
+}

+ 82 - 0
application/store/view/company/form.html

@@ -0,0 +1,82 @@
+{extend name='admin@main'}
+
+{block name="content"}
+
+{include file='store@goods/form_style'}
+
+<form onsubmit="return false;" id="GoodsForm" data-auto="true" method="post" class='layui-form layui-card' autocomplete="off">
+
+    <div class="layui-card-body think-box-shadow padding-left-40">
+
+        <div class="layui-form-item layui-row layui-col-space15">
+            <label class="layui-col-xs6 relative">
+                <span class="color-green">公司网址</span>
+                <input name="website" required class="layui-input" placeholder="请输入公司网址" value="{$vo.website|default=''}">
+            </label>
+            <label class="layui-col-xs6 relative">
+                <span class="color-green">公司电话</span>
+                <input name="phone" required class="layui-input" placeholder="请输入公司电话" value="{$vo.phone|default=''}">
+            </label>
+        </div>
+
+        <div class="layui-form-item layui-row layui-col-space15">
+            <label class="layui-col-xs3 relative">
+                <span class="color-green">公司QQ</span>
+                <input name="qq" required class="layui-input" placeholder="请输入公司QQ" value="{$vo.qq|default=''}">
+            </label>
+            <label class="layui-col-xs9 relative">
+                <span class="color-green">赔付承诺简介</span>
+                <input name="compensate_synopsis" required class="layui-input" placeholder="请输入赔付承诺简介" value="{$vo.compensate_synopsis|default=''}">
+            </label>
+        </div>
+
+        <div class="layui-form-item">
+            <span class="color-green label-required-prev">品牌保障</span>
+            <table class="layui-table">
+                <thead>
+                <tr>
+                    <th class="text-center">品牌保障图片</th>
+                </tr>
+                <tr>
+                    <td width="90px" style="float: left;" class="text-center"><input name="brand_protection" type="hidden" value="{$vo.brand_protection|default=''}"></td>
+                </tr>
+                </thead>
+            </table>
+            <script>$('[name="brand_protection"]').uploadMultipleImage()</script>
+        </div>
+
+        <div class="layui-form-item">
+            <span class="color-green label-required-prev">营业执照</span>
+            <table class="layui-table">
+                <thead>
+                <tr>
+                    <th class="text-center">营业执照图片</th>
+                </tr>
+                <tr>
+                    <td width="90px" style="float: left;" class="text-center"><input name="license" type="hidden" value="{$vo.license|default=''}"></td>
+                </tr>
+                </thead>
+            </table>
+            <script>$('[name="license"]').uploadMultipleImage()</script>
+        </div>
+
+
+
+        <div class="layui-form-item text-center">
+            {notempty name='vo.id'}<input type="hidden" name="id" value="{$vo.id}">{/notempty}
+            <button class="layui-btn layui-btn-danger" ng-click="hsitoryBack()" type="button">取消编辑</button>
+            <button class="layui-btn" type="submit">保存服务</button>
+        </div>
+
+    </div>
+</form>
+{/block}
+
+{block name='script'}
+<script>
+    window.form.render();
+    require(['ckeditor', 'angular'], function () {
+        window.createEditor('[name="content"]', {height: 500});
+    })
+</script>
+{/block}

+ 87 - 0
application/store/view/company/form_style.html

@@ -0,0 +1,87 @@
+<style>
+    .inner-input {
+        width: 80px;
+        height: 14px;
+        padding: 1px 5px;
+        line-height: 12px;
+    }
+
+    .goods-spec-box {
+        position: relative;
+        margin: 0 10px 10px 0;
+        vertical-align: middle;
+    }
+
+    .goods-spec-title {
+        z-index: 2;
+        width: 40px;
+        color: #fff;
+        height: 28px;
+        position: absolute;
+        background: #999;
+        line-height: 28px;
+    }
+
+    .goods-spec-close {
+        right: 8px;
+        z-index: 2;
+        line-height: 28px;
+        position: absolute;
+        display: inline-block
+    }
+
+    .goods-spec-btn {
+        height: 28px;
+        margin-left: 5px !important;
+        line-height: 26px !important;
+    }
+
+    .goods-spec-box input {
+        z-index: 1;
+        width: 180px;
+        position: relative;
+        border: 1px solid #999;
+        padding: 5px 0 5px 45px;
+        display: inline-block !important;
+    }
+
+    .goods-spec-box input[type=checkbox] {
+        z-index: 2;
+        width: 40px;
+        height: 28px;
+        border: none;
+        cursor: pointer;
+        appearance: none;
+        position: absolute;
+        -webkit-appearance: none;
+    }
+
+    .goods-spec-box input[type=checkbox]:before {
+        top: 1px;
+        left: 1px;
+        width: 40px;
+        height: 26px;
+        content: ' ';
+        position: absolute;
+        background: #c9c9c9;
+    }
+
+    .goods-spec-box input[type=checkbox]:after {
+        top: 1px;
+        left: 1px;
+        color: #999;
+        width: 40px;
+        height: 26px;
+        content: '\e63f';
+        font-size: 16px;
+        line-height: 26px;
+        position: absolute;
+        text-align: center;
+        font-family: 'layui-icon';
+    }
+
+    .goods-spec-box input[type=checkbox]:checked:after {
+        color: #333;
+        content: '\e605';
+    }
+</style>

+ 70 - 0
application/store/view/company/index.html

@@ -0,0 +1,70 @@
+{extend name='admin@main'}
+
+{block name="button"}
+<!--{if auth("store/serve/add")}-->
+<button data-open='{:url("add")}' data-title="添加" class='layui-btn layui-btn-sm layui-btn-primary'>添加服务</button>
+<!--{/if}-->
+{/block}
+
+{block name="content"}
+<div class="think-box-shadow">
+    <table class="layui-table margin-top-10" lay-skin="line">
+        {notempty name='list'}
+        <thead>
+        <tr>
+            <th class='list-table-check-td think-checkbox'>
+                <input data-auto-none data-check-target='.list-check-box' type='checkbox'>
+            </th>
+            <th class='list-table-sort-td'>
+                <button type="button" data-reload class="layui-btn layui-btn-xs">刷 新</button>
+            </th>
+            <th class='text-left nowrap' width="13%">公司网址</th>
+            <th class='text-left nowrap' width="13%">公司电话</th>
+            <th class='text-left nowrap' width="13%">客服QQ</th>
+            <th class='text-left nowrap' width="13%">品牌保障</th>
+            <th class='text-left nowrap' width="13%">营业执照</th>
+            <th>操作</th>
+        </tr>
+        </thead>
+        {/notempty}
+        <tbody>
+        {foreach $list as $key=>$vo}
+        <tr data-dbclick>
+            <td class='list-table-check-td think-checkbox'><input class="list-check-box" value='{$vo.id}' type='checkbox'></td>
+            <td class='list-table-sort-td'><input data-action-blur="{:request()->url()}" data-value="id#{$vo.id};action#sort;sort#{value}" data-loading="false" value="{$vo.sort}" class="list-sort-input"></td>
+            <td class='text-left nowrap'>{$vo.website|default='--'}</td>
+            <td class='text-left nowrap'>{$vo.phone|default='--'}</td>
+            <td class='text-left nowrap'>{$vo.qq|default='--'}</td>
+            <td class='text-left nowrap'>
+                {if $vo['brand_protection']}
+                {foreach $vo['brand_protection'] as $v}
+                <img data-tips-image style="width:40px;height:40px" src="{$v|default=''}" class="margin-right-5 text-top">
+                {/foreach}
+                {else}
+                暂无
+                {/if}
+            </td>
+            <td class='text-left nowrap'>
+                {if $vo['license']}
+                {foreach $vo['license'] as $v}
+                <img data-tips-image style="width:40px;height:40px" src="{$v|default=''}" class="margin-right-5 text-top">
+                {/foreach}
+                {else}
+                暂无
+                {/if}
+            </td>
+
+            <td class='text-left nowrap'>
+                <div class="nowrap margin-bottom-5">
+                    <a data-dbclick class="layui-btn layui-btn-sm" data-open='{:url("edit")}?id={$vo.id}'>编 辑</a>
+                </div>
+            </td>
+        </tr>
+        {/foreach}
+        </tbody>
+    </table>
+
+    {empty name='list'}<span class="notdata">没有记录哦</span>{else}{$pagehtml|raw|default=''}{/empty}
+
+</div>
+{/block}