roomedit.php 9.81 KB
<?php
use yii\web\View;
use yii\helpers\Html;
use backend\widgets\YHGImage\Common\Images as CommonImages;

$this->title = $this->params['main_title'].'-'.$this->params['sub_title'];
?>
<?php
$this->registerCssFile('/css/select2.css',array('postion'=>View::POS_END));

$this->registerJsFile('/js/My97DatePicker/WdatePicker.js',array('postion'=>View::POS_END));
$this->registerJsFile('/js/select2.min.js',array('postion'=>View::POS_END));
?>
<script type="text/javascript">
<?php $this->beginBlock('javascript');?>
jQuery(document).ready(function() {
    // Select2
    jQuery(".select-basic").select2();

    if (!$('input[name=pic]').val()){
        $('#pic').remove();
    }
    
    if (!$('input[name=background_pic]').val()){
        $('#background_pic').remove();
    }
});
/**
 * 表单验证
 * @returns {Boolean}
 */
function verify(){
    if (!$('input[name=pic]').val()){
        alert('头图不能为空。');
        return false;
    }
    if (!$('input[name=background_pic]').val()){
        alert('背景图不能为空。');
        return false;
    }
    return true;
}
<?php 
$this->endBlock();
$this->registerJs($this->blocks['javascript'],View::POS_END)
?>
</script>

<div class="col-md-9">
<form id="form" method="POST" action="">
    <div class="panel panel-default">
        <div class="panel-body">
            <!-- 左侧表单 begin-->
            <div class="col-md-6">
                <div class="row">
                    <div class="form-group">
                        <label class="col-sm-3 control-label">房间号: </label>
                        <div class="col-sm-9">
                            <?=$model->room_id ? : '保存后生成'?>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-3 control-label">直播标题: <span class="asterisk">*</span></label>
                        <div class="col-sm-9">
                            <input type="text" name="title" class="form-control" required="required" value="<?=$model->title?>">(建议不超过18个汉字)
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-3 control-label">水印文案: </label>
                        <div class="col-sm-5">
                            <input type="text" name="watermark" class="form-control" value="<?=$model->watermark?>">
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-3 control-label">主播: <span class="asterisk">*</span></label>
                        <div class="col-sm-5">
                            <?php echo Html::dropDownList('master_id', $model->master_id,$masters, ['class' => 'width300 select-basic', 'required'=>"required"]);?>
                        </div>

                    </div>

                    <div class="form-group">
                        <label class="col-sm-3 control-label">预告开始时间: </label>
                        <div class="col-sm-5">
                            <input type="text" name="starting_time" class="form-control" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" value="<?=$model->starting_time ? date('Y-m-d H:i:s',$model->starting_time) : ''?>">
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-3 control-label">房间密钥: <span class="asterisk">*</span></label>
                        <div class="col-sm-5">
                            <input type="text" name="secret" class="form-control" required="required" value="<?=$model->secret?>">
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-3 control-label">是否精选: </label>
                        <div class="col-sm-2">
                            <?php echo Html::dropDownList('best', $model->best,Yii::$app->params['config']['best'], ['class' => 'form-control']);?>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-3 control-label">马甲状态: </label>
                        <div class="col-sm-2">
                            <?php echo Html::dropDownList('vest', $model->vest,Yii::$app->params['config']['vest'], ['class' => 'form-control']);?>
                        </div>
                        <div class="col-sm-2">
                            累加人数:<?php echo Html::checkbox('is_addup', $model->is_addup==Yii::$app->params['config']['is_addup'],['value'=>Yii::$app->params['config']['is_addup']])?>
                        </div>
                    </div>

                    <div class="form-group" style="display: none">
                        <label class="col-sm-3 control-label">直播状态: </label>
                        <div class="col-sm-2">
                            <?php echo Html::dropDownList('living', $model->living,Yii::$app->params['config']['room_living'], ['class' => 'form-control']);?>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-3 control-label">头图: <span class="asterisk">*</span></label>
                        <div class="col-sm-9">
                            <?=$picUploader?>
                            <?php if ($model->pic):?>
                            <div class="file-item thumbnail upload-state-done" id="pic"><img src="<?=CommonImages::getImageUrl($model->pic, 110, 110)?>"><div class="info">当前图片</div></div>
                            <?php endif;?>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-3 control-label">背景图: <span class="asterisk">*</span></label>
                        <div class="col-sm-9">
                            <?=$backgroundUploader?>
                            <?php if ($model->background_pic):?>
                            <div class="file-item thumbnail upload-state-done" id="background_pic"><img src="<?=CommonImages::getImageUrl($model->background_pic, 110, 110)?>"><div class="info">当前图片</div></div>
                            <?php endif;?>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-3 control-label">业务线: <span class="asterisk">*</span></label>
                        <div class="col-sm-5">
                            <?php foreach (Yii::$app->params['config']['app'] as $k=>$v):?>
                            <div class="checkbox block"><label><?php echo Html::checkbox('app[]', in_array($k,(array)$model->app),['value'=>$k])?> <?=$v?></label></div>
                            <?php endforeach;?>
                        </div>
                    </div>

                </div><!-- row -->
            </div>
            <!-- 左侧表单 end-->
            <!-- 右侧表单 begin-->
            <div class="col-md-6">
                <div class="row">

                    <div class="form-group">
                        <label class="col-sm-3 control-label">未开始排序: </label>
                        <div class="col-sm-3">
                            <input type="text" name="unstart_sort" class="form-control" value="<?=$model->unstart_sort?>">
                        </div>
                        <label class="col-sm-3 control-label">直播中排序: </label>
                        <div class="col-sm-3">
                            <input type="text" name="living_sort" class="form-control" value="<?=$model->living_sort?>">
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-3 control-label">分享主图: </label>
                        <div class="col-sm-9">
                            <?=$sharePicUploader?>
                            <?php if ($model->id && $roomShare['pic']):?>
                                <div class="file-item thumbnail upload-state-done" id="share_pic"><img src="<?=CommonImages::getImageUrl($roomShare['pic'], 110, 110)?>"><div class="info">当前图片</div></div>
                            <?php endif;?>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">分享标题: </label>
                        <div class="col-sm-9">
                            <input type="text" name="share_title" class="form-control" value="<?php echo ($model->id && $roomShare['title']) ? $roomShare['title']:''?>">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">分享内容: </label>
                        <div class="col-sm-9">
<!--                            <input type="text" name="share_content" class="form-control" value="">-->
                            <textarea rows="5" name="share_content" class="form-control"><?php echo ($model->id && $roomShare['content']) ? $roomShare['content']:''?></textarea>
                        </div>
                    </div>
                </div>
            </div>
            <!-- 右侧表单 end-->
        </div><!-- panel-body -->
        <div class="panel-footer">
            <div class="row">
                <div class="col-sm-9 col-sm-offset-3">
                    <button class="btn btn-primary mr5" id="upload_button" onclick="return verify()">保存</button>
                    <a href="<?=$_refer?>" class="btn btn-dark">取消</a>
                </div>
            </div>
        </div><!-- panel-footer -->
    </div><!-- panel -->
</form>
</div>