123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183 |
- <?php
- /**
- * Created by PhpStorm.
- * User: Administrator
- * Date: 2017/3/17 0017
- * Time: 下午 3:41
- */
- use yii\helpers\Url;
- use yii\widgets\ActiveForm;
- use common\models\UploadForm;
- use kucha\ueditor\UEditor;
- $position_arr = [
- '0'=>'轮播框',
- '1'=>'平台公告',
- '2'=>'轮播框下方',
- ];
- //$type_arr = [
- // '0'=>'图片',
- // '1'=>'文字公告',
- // '2'=>'轮播框下方',
- //]
- ?>
- <script src="/js/layer/laydate/laydate.js"></script>
- <style type="text/css">
- .modal-backdrop.in {display: none!important;}
- .modal-open .modal {background: rgba(0, 0, 0, 0.52);}
- .modal.in .modal-dialog{position: fixed;margin-left: -300px;top: 10%;left: 50%;}
- .red{color: red;}
- </style>
- <?php if(empty($model->id)):?>
- <form id="tijiao" action="<?=Url::toRoute(['webconfig/add_information']);?>" method="post">
- <?php else:?>
- <form id="tijiao" action="<?=Url::toRoute(['webconfig/edit_information']);?>" method="post">
- <?php endif;?>
- <div class="col-sm-12">
- <div class="ibox float-e-margins">
- <div class="ibox-content form-horizontal">
- <div class="form-group">
- <label class="col-sm-2 control-label">类型:</label>
- <div class="col-sm-10" style="padding-left:0;padding-top: 7px;">
- <label><input name="Information[type]" type="radio" value="10"<?php if(!empty($model->type)):?><?=($model->type=='10')?"checked='checked'":''?><?php else:?>checked='checked'<?php endif ?>/>公告 </label>
- <label><input name="Information[type]" type="radio" value="20"<?php if(!empty($model->type)):?><?=($model->type=='20')?"checked='checked'":''?><?php endif;?> />关于我们 </label>
- </div>
- </div>
- <div class="form-group">
- <label class="col-sm-2 control-label">标题:</label>
- <div class="col-sm-10" style="padding-left:0">
- <input type="text" name="Information[title]" id="title" class="form-control " rows="2" maxlength="120" value="<?=empty($model->title)?"":"$model->title";?>">
- <label class="red notice"></label>
- </div>
- </div>
- <!--上传封面-->
- <div class="form-group">
- <label class="col-sm-2 control-label">封面:</label><br>
- <a>
- <img src="<?=empty($model->covers)?"../images/default.jpg":Yii::getAlias('@imgdomain').'/'."$model->covers"?>" class="img-thumbnail articlelibrary_imgurl" id="imgurl" style="width: 200px;height: 100px;" imgtype="img">
- <input id="imgurl_input" type="hidden" name="Information[covers]" value="<?=empty($model->covers)?"":"$model->covers"?>" >
- </a>
- <!-- <span>轮播图片大小为1000*480</span>-->
- </div>
- <div class="form-group">
- <label class="col-sm-2 control-label">内容:</label>
- <div class="col-sm-10" style="padding-left:0">
- <div class="summernote"><?=isset($model->content)?$model->content:''?></div>
- <textarea name="Information[content]" id="content" class="form-control desc" style="display:none;" maxlength="255"></textarea>
- </div>
- </div>
- <input type="hidden" name="_csrf-backend" value="<?=Yii::$app->request->csrfToken;?>" />
- <input type="hidden" name="id" value="<?=empty($model->id)?'': $model->id;?>" />
- <div class="form-group">
- <div class="col-sm-2"></div>
- <div class="col-sm-10">
- <button type="button" class="btn btn-primary" id="submit1">提交</button>
- <button type="button" class="btn btn-default" onclick="location.href='<?=Url::toRoute(['webconfig/information']);?>';return false;">取消</button>
- </label>
- </div>
- </div>
- </div>
- </div>
-
- </form>
- <!--上传封面图片的div-->
- <iframe name="upload_target" style="display: none;"></iframe>
- <div id="upload_picture" style="display: none;">
- <?php $form = ActiveForm::begin(
- [
- 'options' => ['enctype' => 'multipart/form-data','target'=>'upload_target'],
- 'action'=>Url::toRoute(['webconfig/advertimgurl']),
- 'method'=>'post',
- ]
- )?>
- <?= $form->field($picture_form, 'imageFile')->fileInput() ?>
- <input type="hidden" id="upfield" name="type" value="covers">
- <?php ActiveForm::end() ?>
- </div>
- <script>
- $('#title').blur(function(){
- var title = $('#title').val();
- $.ajax({
- url: '<?=Url::toRoute(['webconfig/checktitle'])?>',
- type: 'POST',
- dataType:"json",
- data: {title:title, '_csrf-backend': '<?=Yii::$app->request->getCsrfToken();?>'},
- success: function (data) {
- console.log(data)
- if(data=='该内容标题已存在'){
- lock = false;
- $('.notice').text('该内容标题已存在');
- }else{
- lock = true;
- $('.notice').text('');
- }
- }
- })
- });
- // 富文本編輯器
- $('.summernote').summernote({
- lang:"zh-CN",
- height: "300px",
- onImageUpload: function (files,editor, welEditable) { //the onImageUpload API
- img = sendFile(files[0], editor, welEditable);
- $('.gray-bg .modal-backdrop').hide();
- }
- });
- //编辑框里图片上传
- function sendFile(file, editor, welEditable) {
- data = new FormData();
- data.append("file", file);
- data.append("type", 'information');
- data.append("_csrf-backend", '<?=Yii::$app->request->csrfToken;?>');
- $.ajax({
- data: data,
- type: "POST",
- url: "<?=Url::toRoute(['webconfig/uploadsummernote'])?>",
- cache: false,
- contentType: false,
- processData: false,
- success: function(url) {
- editor.insertImage(welEditable,'<?=Yii::getAlias('@imgdomain'); ?>'+url);
- }
- });
- }
- $(document).on('click','#submit1',function(){
- var content = $('.note-editable').html();
- $('#content').text(content);
- $('#tijiao').submit()
- })
- // 上传封面
- $(".articlelibrary_imgurl").click(function(){
- $("#upload_picture input").click();
- $('#upload_picture input').change(function(){
- if($("#uploadpictureform-picture").val() != ""){
- $('#upload_picture form').submit();
- }
- });
- // var id = $(this).attr('id');
- // $('#upfield').attr('data',id);
- // var type=$(this).attr('imgtype');
- // $('#type').attr('value',type);
- });
- // 添加图片的返回函数
- function callback(message,status,url){
- if(status==1){
- var id = $('#upfield').attr('data');
- $('#imgurl').attr("src","<?=Yii::getAlias('@imgdomain'); ?>"+url);
- $('#imgurl_input').val(url);
- // $('#'+id+"_input").val(url);
- $("#uploadpictureform-picture").val("");
- $('#upload_picture form')[0].reset();
- }else{
- alert(message);
- }
- }
- </script>
|