{layout name="public/layout_main"}

<link rel="stylesheet" href="/static/datetimepicker/css/bootstrap-datetimepicker.min.css">
<link rel="stylesheet" href="/static/validation/css/validationEngine.jquery.css">

<section class="wrapper">
    <h3 class="top-back">
        <a href="<?php echo url('@admin/Miniapp/index')?>">
            <i class="fa fa-angle-left"></i> 
            <?php echo isset($model)?'修改小程序':'添加小程序';?>
        </a>
    </h3>
    <hr>

    <!-- 错误信息：php需使用 $this->assign('errmsg', '错误信息'); 来设置显示内容！ -->
    <?php if(isset($errmsg)):?>
    <div class="row margin-bottom">
        <div class="col-md-12">
            <div class="alert alert-danger alert-dismissible fade in" role="alert">
                <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
                <?php echo $errmsg;?>
            </div>
        </div>
    </div>
    <?php endif;?>

    <div class="row margin-bottom">
        <div class="col-md-12">
            <form class="form-horizontal" method="POST" action="<?php if(ACTION_NAME == 'update'){ }else{ echo url('@admin/Miniapp/create'); }?>" id="create-form" enctype="multipart/form-data">
                <div class="form-group">
                    <label for="name" class="col-sm-2 control-label text-right">小程序名</label>
                    <div class="col-sm-10 col-md-8 col-lg-6">
                        <input type="text" class="form-control validate[required]" name="name" id="name" placeholder="小程序名" value="<?php echo isset($model)?$model->name:'';?>">
                    </div>
                </div>
                <div class="form-group">
                    <label for="subject" class="col-sm-2 control-label text-right">简介</label>
                    <div class="col-sm-10 col-md-8 col-lg-6">
                        <input type="text" class="form-control validate[required]" name="subject" id="subject" placeholder="简介" value="<?php echo isset($model)?$model->subject:'';?>">
                    </div>
                </div>
                <div class="form-group">
                    <label for="desc" class="col-sm-2 control-label text-right">封面图</label>
                    <div class="col-sm-10 col-md-8 col-lg-6">
                        <!-- 1.上传ID和Input ID需在jq中添加事件 2.预览的类属性imgpreview不能缺失 -->
                        <div class="input-group">
                            <span class="input-group-addon pointer" id="upbtn_poster">上传</span>
                            <input type="text" class="form-control validate[required,custom[url]] imginpunt" name="poster" id="poster" placeholder="上传图片或输入图片链接" value="<?php echo isset($model)?$model->poster:'';?>">
                            <div class="input-group-addon imgpreview">
                                <a href="<?php echo isset($model)?$model->poster:'';?>" target="_blank" data-fancybox="images">预览</a>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <a href="http://www.114la.com/other/rgb.htm" target="view_window">
                        <label class="col-sm-2 control-label text-right">按钮颜色</label>
                    </a>
                    <div class="col-sm-10 col-md-8 col-lg-6">
                        <input type="text" class="form-control validate[required]" name="btn_color"  id="btn_color" placeholder="按钮颜色，点击label选择颜色" value="<?php echo isset($model)?$model->btn_color:'';?>"></input>
                    </div>
                </div>
                <div class="form-group">
                    <a href="http://www.114la.com/other/rgb.htm" target="view_window">
                        <label class="col-sm-2 control-label text-right">标题颜色</label>
                    </a>
                    <div class="col-sm-10 col-md-8 col-lg-6">
                        <input type="text" class="form-control validate[required]" name="title_color"  id="title_color" placeholder="标题颜色，点击label选择颜色" value="<?php echo isset($model)?$model->title_color:'';?>"></input>
                    </div>
                </div>
                <div class="form-group">
                    <label for="desc" class="col-sm-2 control-label text-right">图标</label>
                    <div class="col-sm-10 col-md-8 col-lg-6">
                        <!-- 1.上传ID和Input ID需在jq中添加事件 2.预览的类属性imgpreview不能缺失 -->
                        <div class="input-group">
                            <span class="input-group-addon pointer" id="upbtn_icon">上传</span>
                            <input type="text" class="form-control validate[required,custom[url]] imginpunt" name="icon" id="icon" placeholder="上传图片或输入图片链接" value="<?php echo isset($model)?$model->icon:'';?>">
                            <div class="input-group-addon imgpreview">
                                <a href="<?php echo isset($model)?$model->icon:'';?>" target="_blank" data-fancybox="images">预览</a>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label for="desc" class="col-sm-2 control-label text-right">小程序码</label>
                    <div class="col-sm-10 col-md-8 col-lg-6">
                        <!-- 1.上传ID和Input ID需在jq中添加事件 2.预览的类属性imgpreview不能缺失 -->
                        <div class="input-group">
                            <span class="input-group-addon pointer" id="upbtn_qrcode">上传</span>
                            <input type="text" class="form-control validate[required,custom[url]] imginpunt" name="qrcode" id="qrcode" placeholder="上传图片或输入图片链接" value="<?php echo isset($model)?$model->qrcode:'';?>">
                            <div class="input-group-addon imgpreview">
                                <a href="<?php echo isset($model)?$model->qrcode:'';?>" target="_blank" data-fancybox="images">预览</a>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-offset-2 col-sm-10">
                        <button type="submit" class="btn btn-success">提交</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</section>

<script src="/static/datetimepicker/js/bootstrap-datetimepicker.min.js"></script>
<script src="/static/datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js"></script>

<script src="/static/validation/js/jquery.validationEngine-zh_CN.js"></script>
<script src="/static/validation/js/jquery.validationEngine.js"></script>
<script src="/static/plupload/moxie.min.js" type="text/javascript"></script>
<script src="/static/plupload/plupload.min.js" type="text/javascript"></script>
<script src="/static/qiniu/qiniu.min.js" type="text/javascript"></script>

<script type="text/javascript">
$(function(){
    $('#create-form').validationEngine('attach', {
        promptPosition: 'centerRight',
        binded: true,
        scroll: true
    });

    // 设置要上传图片的input输入框
    setImageUp('upbtn_poster', 'poster');
    setImageUp('upbtn_icon', 'icon');
    setImageUp('upbtn_qrcode', 'qrcode');

    // 图片输入框改变，则改变预览的图片地址
    $('.imginpunt').on('input', function(){
        $(this).siblings('.imgpreview').children('a').attr('href', $(this).val());
    });
})
</script>





