<?php if (!defined('THINK_PATH')) exit(); /*a:3:{s:86:"C:\phpStudy\PHPTutorial\WWW\aqm-web\public/../application/admin\view\product\form.html";i:1557480234;s:75:"C:\phpStudy\PHPTutorial\WWW\aqm-web\application\admin\view\layout\home.html";i:1557480234;s:82:"C:\phpStudy\PHPTutorial\WWW\aqm-web\application\admin\view\layout\admin_items.html";i:1557480234;}*/ ?>
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <title>安全猫官网</title>
        <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
        <!-- Bootstrap 3.3.7 -->
        <link rel="stylesheet" href="<?php echo PLUGINS_SITE_ROOT; ?>/layui/css/layui.css">
        <link rel="stylesheet" href="<?php echo ADMIN_SITE_ROOT; ?>/css/admin.css">
        <link rel="stylesheet" href="<?php echo ADMIN_SITE_ROOT; ?>/iconfont/iconfont.css">
        <script src="<?php echo PLUGINS_SITE_ROOT; ?>/jquery-2.1.4.min.js"></script>
        <script src="<?php echo ADMIN_SITE_ROOT; ?>/js/admin.js"></script>
        <script type="text/javascript" src="<?php echo PLUGINS_SITE_ROOT; ?>/layui/layui.js"></script>
        <script type="text/javascript">
            var BASESITEROOT = "<?php echo BASE_SITE_ROOT; ?>";
            var ADMINSITEROOT = "<?php echo ADMIN_SITE_ROOT; ?>";
            var BASESITEURL = "<?php echo BASE_SITE_URL; ?>";
            var HOMESITEURL = "<?php echo HOME_SITE_URL; ?>";
            var ADMINSITEURL = "<?php echo ADMIN_SITE_URL; ?>";
            layui.use('layer', function () {
                var layer = layui.layer;
            });
        </script>
    </head>
    <body>
        
<form class="layui-form" method="post" enctype="multipart/form-data" >
    <div class="layui-tab layui-tab-card">
        <?php if($admin_item): ?>
<ul class="layui-tab-title">
    <?php if(is_array($admin_item) || $admin_item instanceof \think\Collection || $admin_item instanceof \think\Paginator): if( count($admin_item)==0 ) : echo "" ;else: foreach($admin_item as $key=>$item): if(array_intersect(explode(" ",str_replace("/", ".",substr($item['url'],7,-5))),$allpower) || array_intersect(explode(" ",str_replace("/", ".",substr($item['url'],31,-16))),$allpower)): ?>
    <li <?php if($item['name'] == $curitem): ?>class="layui-this" <?php endif; ?>>
    <a href="<?php echo $item['url']; ?>"><?php echo $item['text']; ?></a>
    <?php endif; ?>
    </li>
    <?php endforeach; endif; else: echo "" ;endif; ?>
    <div class="tool-btns">
        <a href="javascript:location.reload();" title="刷新当前页面" class="iconfont icon-reload"></i></a>
    </div>
</ul>
<?php endif; ?>
        <div class="layui-tab-content page-tab-content">
            <div class="layui-tab-item layui-show ">
                
                <div class="layui-collapse">
                    <div class="layui-colla-item">
                        <h2 class="layui-colla-title">基本设置</h2>
                        <div class="layui-colla-content layui-show">
                            <div class="layui-form-item">
                                <label class="layui-form-label">所属类别</label>
                                <div class="layui-input-inline">
                                    <select name="product_type" id="product_type">
                                        <option value="<?php echo $product['product_type']; ?>"><?php if($product['product_type']==1): ?>客服常用语<?php elseif($product['product_type']==2): ?>客户常用问题<?php elseif($product['product_type']==3): ?>客服快捷回复<?php elseif($product['product_type']==4): ?>自动回复<?php elseif($product['product_type']==5): ?>新闻<?php else: ?>请选择类别<?php endif; ?></option>
                                        <option value="1">客服常用语</option>
                                        <option value="2">客户常用问题</option>
                                        <option value="3">客服快捷回复</option>
                                        <option value="4">自动回复</option>
                                        <option value="5">新闻</option>
                                    </select>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">时间段</label>
                                <div class="layui-input-inline">
                                    <select name="product_usetime" id="product_usetime">
                                        <option value="<?php echo $product['product_usetime']; ?>"><?php if($product['product_usetime']==1): ?>凌晨<?php elseif($product['product_usetime']==2): ?>上午<?php elseif($product['product_usetime']==3): ?>下午<?php elseif($product['product_usetime']==4): ?>晚上<?php else: ?>请选择时间段<?php endif; ?></option>
                                        <option value="1">凌晨</option>
                                        <option value="2">上午</option>
                                        <option value="3">下午</option>
                                        <option value="4">晚上</option>
                                    </select>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">所属公司</label>
                                <div class="layui-input-inline">
                                    <select name="product_companyid" id="product_companyid">
                                        <option value="<?php echo $onlygs['member_id']; ?>"><?php echo $onlygs['member_name']; ?></option>
                                        <?php if(is_array($allgs) || $allgs instanceof \think\Collection || $allgs instanceof \think\Paginator): if( count($allgs)==0 ) : echo "" ;else: foreach($allgs as $key=>$v): ?>
                                            <option value="<?php echo $v['member_id']; ?>"><?php echo $v['member_name']; ?></option>
                                        <?php endforeach; endif; else: echo "" ;endif; ?>
                                    </select>

                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">标题</label>
                                <div class="layui-input-inline">
                                    <input type="text" class="layui-input field-name" name="product_title" id="product_title" value="<?php echo (isset($product['product_title']) && ($product['product_title'] !== '')?$product['product_title']:''); ?>" lay-verify="product_title" autocomplete="off" placeholder="<?php echo \think\Lang::get('ds_please_enter'); ?>标题" required />
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">副标题</label>
                                <div class="layui-input-inline">
                                    <input type="text" class="layui-input field-name" name="product_ctitle" id="product_ctitle" value="<?php echo (isset($product['product_ctitle']) && ($product['product_ctitle'] !== '')?$product['product_ctitle']:''); ?>" lay-verify="product_ctitle" autocomplete="off" placeholder="<?php echo \think\Lang::get('ds_please_enter'); ?>副标题" required />
                                </div>
                            </div>

                            <div class="layui-form-item">
                                <label class="layui-form-label">关键字</label>
                                <div class="layui-input-inline">
                                    <input type="text" class="layui-input field-name" name="product_keywords" id="product_keywords" value="<?php echo (isset($product['product_keywords']) && ($product['product_keywords'] !== '')?$product['product_keywords']:''); ?>" lay-verify="product_keywords" autocomplete="off" placeholder="<?php echo \think\Lang::get('ds_please_enter'); ?>关键字" required />
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">状态</label>
                                <div class="layui-input-inline">
                                    <input type="checkbox" name="product_status" lay-skin="switch" lay-text="<?php echo \think\Lang::get('ds_yes'); ?>|<?php echo \think\Lang::get('ds_no'); ?>" value="1" <?php if($product['product_status'] == '1'): ?>checked<?php endif; ?>>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">是否跳转</label>
                                <div class="layui-input-inline">
                                    <input type="checkbox" name="product_isjump" lay-skin="switch" lay-text="<?php echo \think\Lang::get('ds_yes'); ?>|<?php echo \think\Lang::get('ds_no'); ?>" value="1" <?php if($product['product_isjump'] == '1'): ?>checked<?php endif; ?>>
                                </div>
                            </div>
                        </div>
                    </div>
                    
                    <div class="layui-colla-item">
                        <h2 class="layui-colla-title">详情内容</h2>
                        <div class="layui-colla-content">
                            <div class="layui-form-item">
                                <label class="layui-form-label"><?php echo \think\Lang::get('product_content'); ?></label>
                                <div class="layui-input-block">
                                    <?php echo build_editor(['name'=>'product_content','content'=>isset($product['product_content'])?$product['product_content']:'']); ?>
                                    <textarea name="product_content" id="product_content" style="min-height:400px;"></textarea>
                                </div>
                            </div>
                            <!-- <button type="button" class="layui-btn" id="upload_productpic"><i class="layui-icon"></i><?php echo \think\Lang::get('ds_uploading_files'); ?></button> -->
                            <div class="selected_pic clearfix">
                                <ul>
                                    <?php if(is_array($pic_list) || $pic_list instanceof \think\Collection || $pic_list instanceof \think\Paginator): if( count($pic_list)==0 ) : echo "" ;else: foreach($pic_list as $key=>$productpic): ?>
                                    <li id="<?php echo $productpic['pic_id']; ?>">
                                        <img src="<?php echo get_product_img($productpic['pic_cover']); ?>"/>
                                        <i class="delect layui-icon" title="<?php echo \think\Lang::get('ds_insert_editor'); ?>" onclick="insert_editor('<?php echo get_product_img($productpic['pic_cover']); ?>')">&#xe654;</i>
                                        <i class="insert layui-icon" title="<?php echo \think\Lang::get('ds_delete_picture'); ?>" onclick="del_productpic(<?php echo $productpic['pic_id']; ?>)">&#xe640;</i>
                                    </li>
                                    <?php endforeach; endif; else: echo "" ;endif; ?>
                                </ul>
                            </div>
                        </div>
                    </div>
                </div>
                
                <div class="layui-form-item mt20">
                    <div class="layui-input-inline">
                        <input type="submit" class="layui-btn layui-btn-normal" lay-submit value="<?php echo lang('ds_submit'); ?>" />
                    </div>
                </div>
            </div>
        </div>
    </div>
</form>
<script>
    layui.use('form', function () {
        var form = layui.form;
    });
    layui.use('element', function () {
        var element = layui.element;
    });
    layui.use('laydate', function(){
        var laydate = layui.laydate;
        laydate.render({
            elem: '#product_addtime'
        });
    });
    /**
     * 图片异步上传
     */
    layui.use('upload', function () {
        var $ = layui.jquery, upload = layui.upload;
        //指定允许上传的文件类型
        upload.render({
            elem: '#upload_productpic'
            , url: "<?php echo url('pic/upload',['pic_type_id'=>\think\Request::instance()->param('product_id'),'pic_type'=>$product_pic_type['pic_type']]); ?>"
            , accept: 'file' //普通文件
            , done: function (res) {
                add_uploadedfile(res);
//                console.log(res)
            }
        });
    });
    function add_uploadedfile(file_data)
    {
        var newImg = '<li id="' + file_data.file_id + '"><img src="' + file_data.file_url + '"/><i class="delect layui-icon" title="插入编辑器" onclick="insert_editor(\''+file_data.file_url+'\')">&#xe654;</i><i class="insert layui-icon" title="删除图片" onclick="del_productpic(' + file_data.file_id + ')">&#xe640;</i></li>'
        $('.selected_pic ul').prepend(newImg);
    }


    /**
     * 插入编辑器
     */
    function insert_editor(file_path){
        ue.execCommand('insertimage', {src:file_path});
    }

    function del_productpic(file_id)
    {
        layer.open({
            content: '<?php echo \think\Lang::get('ds_confirm_cancel'); ?>',
            yes: function(index, layero){
                $.getJSON("<?php echo url('pic/del'); ?>",{file_id: + file_id,pic_type:'product'}, function(result){
                    if(result){
                        $('#' + file_id).remove();
                        layer.msg('<?php echo \think\Lang::get('del_succ'); ?>');
                        layer.close(index);
                        return;
                    }else{
                        layer.msg('<?php echo \think\Lang::get('del_fail'); ?>');
                        layer.close(index);
                        return;
                    }
                });
            }
        });
    }
</script>

    </body>
</html>



