123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537 |
- {extend name="public/layout"/} {block name="title"}VR楼书{/block} {block name="body"}
- <link rel="stylesheet" href="__STATIC__/css/csspc.css">
- <link rel="stylesheet" href="__STATIC__/css/font.css">
- <style type="text/css">
- html,
- body {
- height: 100%;
- min-width: 800px
- }
- .body {
- background: #fff;
- height: 100%;
- overflow-y: auto;
- width: 100%;
- box-sizing: border-box;
- padding: 25px;
- }
- .layui-form-box .layui-form-label {
- width: 200px;
- text-align: right;
- float: left;
- line-height: 46px;
- padding: 0 10px;
- }
- .layui-form-box .layui-input-block {
- float: left;
- margin-left: 0;
- max-width: 25%;
- width: 100%;
- }
- .layui-input {
- height: 46px;
- }
- .radio_input {
- width: 22px;
- height: 22px;
- }
- .addImages {
- display: inline-block;
- width: 145px !important;
- height: 87px !important;
- -webkit-box-sizing: border-box;
- -moz-box-sizing: border-box;
- box-sizing: border-box;
- border: 1px dashed darkgray;
- background: #f8f8f8;
- position: relative;
- overflow: hidden;
- }
- .addImages .upload_ico {
- font-size: 50px;
- color: #28A1FF;
- margin-top: 2px;
- display: inline-block;
- }
- .imageDiv {
- display: inline-block;
- width: 145px;
- height: 87px;
- -webkit-box-sizing: border-box;
- -moz-box-sizing: border-box;
- box-sizing: border-box;
- border: 1px dashed darkgray;
- background: #f8f8f8;
- position: relative;
- overflow: hidden;
- margin-right: 10px;
- }
- .imageDiv div {
- width: 100%;
- height: 100%;
- position: absolute;
- top: 0px;
- background-color: #e6e6e600;
- }
- .imageDiv div:hover {
- background-color: #e6e6e680;
- }
- .imageDiv div:hover i {
- display: block;
- cursor: pointer;
- }
- .text-detail {
- text-align: center;
- }
- .imageDiv div i {
- display: none;
- font-size: 31px;
- line-height: 136px;
- text-align: center;
- }
- .isshow {
- display: none;
- }
- .vrdelbtn {
- height: 46px;
- width:46px;
- text-align: center;
- }
- .lanse {
- color: #28A1FF;
- }
- .isimgupload{width:190px;height: 114px;margin-bottom: 10px;overflow: hidden;}
- .imageDivs{position: absolute;top:0;left:0;width:100%;height: 100%;background: rgba(230,230,230,.5);display: none;}
- .imageDivs i{display: block;width:18px;height: 18px;position: absolute;top:0;left:0;bottom:0;right: 0;margin:auto;}
- .layui-upload-drag{padding:18px 46px;}
- #vrWorks {
- position: relative;
- top: 5px;
- }
- </style>
- <body>
- <div class="body">
- <form class="layui-form layui-form-box">
- <div class="layui-form-item width100_ mdt30">
- <label class="layui-form-label"> 阶段命名:</label>
- <div class="layui-input-block">
- <input type="text" name="name" required placeholder="请输入标题" autocomplete="off"
- class="layui-input" value="{$data.name}">
- </div>
- </div>
- <div class="layui-form-item">
- <label class="layui-form-label"> 标签:</label>
- <div class="layui-input-block">
- <select name="label_id" id="label_id">
- <option value="">请选择标签</option>
- {volist name="label" id="v"}
- {if $v.id==$data.label_id}
- <option value="{$v.id}" selected>{$v.name}</option>
- {else/}
- <option value="{$v.id}">{$v.name}</option>
- {/if}
- {/volist}
- </select>
- </div>
- </div>
- <div class="layui-form-item woverflow mdt20">
- <label class="layui-form-label"><i style="color:red;">*</i> 更新类型:</label>
- <div class="layui-input-block lh45 mdl20" style="max-width: 400px !important;">
- <input type="radio" id="1" class="radio_input" lay-filter="heads_reward_type"
- name="type" value="img" title="图片" {if condition='$data.type eq "img"'}checked{/if}>
- <input type="radio" id="2" class="radio_input" lay-filter="heads_reward_type"
- name="type" value="vr" title="VR链接" {if condition='$data.type eq "vr"'}checked{/if}>
- <input type="radio" id="3" class="radio_input" lay-filter="heads_reward_type"
- name="type" value="video" title="视频" {if condition='$data.type eq "video"'}checked{/if}>
- <input type="radio" id="4" class="radio_input" lay-filter="heads_reward_type"
- name="type" value="group" title="VR作品" {if condition='$data.type eq "group"'}checked{/if}>
- </div>
- </div>
- <div class="layui-form-item woverflow mdt20">
- <div class="isshow" {if condition='$data.type eq "img"'}style="display: block;"{/if}>
- <label class="layui-form-label"><i style="color:red;">*</i> 图片:</label>
- <div class="layui-input-block" style="max-width: 70%;">
- <div class="picDiv" id="draggable" style="margin: 20px 0px;">
- {volist name='data.img' id='vo'}
- <div class="imageDiv">
- <img style="width:100%;height:100%" class="layui-upload-img" src="{$vo}" alt="">
- <div class="imgDivico"><i class="layui-icon layui-icon-delete" prop="del"></i> <i class="layui-icon layui-icon-search" prop="view" data-image="{$vo}" style="margin-left:25px;"></i></div>
- <input type="hidden" name="img_exist[]" value="{$vo}" />
- </div>
- {/volist}
- <div class="addImages" id="img">
- <div class="text-detail">
- <i class="layui-icon upload_ico"></i>
- <p style="width:100px;margin: 0 auto;">选择单、多图</p>
- </div>
- </div>
- </div>
- </div>
- <div class="layui-form-item">
- <label class="layui-form-label"></label>
- <div style="margin-left: 197px;"><i style="color:red;margin-right: 5px;">*</i><span>注:不支持拖拽文件 宽:高=5:3</span></div>
- </div>
- </div>
- <div class="isshow" {if condition='$data.type eq "vr"'}style="display: block;"{/if}>
- <label class="layui-form-label"><i style="color:red;">*</i> VR链接:</label>
- <div class="wleft width50_ vrurllist">
- </div>
- </div>
- <input id="category_name" type="hidden" value="evidence" />
- <div class="isshow" {if condition='$data.type eq "video"'}style="display: block;"{/if}>
- <div class="layui-form-item">
- <label class="layui-form-label">视频封面图</label>
- <div class="isimgupload layui-input-inline" style="position:relative;">
- <div class="" id="upload-drag">
- {if condition="$data.img neq ''"}
- <img class="fmimages" src="{$data.img[0]}" style="height: 100%;width:100%;">
- {else/}
- <div class="layui-upload-drag">
- <i class="layui-icon"></i>
- <p style="width:100px;">上传视频封面</p>
- </div>
- {/if}
- </div>
- <div class="imageDivs"><i class="layui-icon layui-icon-delete" prop="del"></i></div>
- {if condition="$data.img neq ''"}
- <input type="hidden" name="covers" id="covers" value="{$data.img[0]}" />
- {else/}
- <input type="hidden" name="covers" id="covers" value="" />
- {/if}
- </div>
- <div class="layui-form-item">
- <label class="layui-form-label"></label>
- <div style="margin-left: 197px;"><i style="color:red;margin-right: 5px;">*</i><span>注:不支持拖拽文件 宽:高=5:3</span></div>
- </div>
- </div>
- <label class="layui-form-label"><span style="color: red;">*</span>视频</label>
- <div class="layui-input-inline" style="width: 290px;display: block;" id="container">
- <a class="layui-btn btn layui-border-btn" id="selectfiles" href="javascript:void(0);">选择视频</a>
- <a class="layui-btn btn layui-border-btn" id="postfiles" href="javascript:void(0);">开始上传</a>
- <div id="ossfile"></div>
- <div id="symbshowed">
- <video style="margin-top:15px;" poster="{$data.img[0]|default=''}" src="{$data.video}" width="320" height="240" controls="controls"></video>
- </div>
- <div id="symbshowed"></div>
- <div class="layui-form-mid layui-word-aux" style="color: red!important;margin-left:10px;">注:选择视频并上传,限制100M内</div>
- <!--报错信息返回展示-->
- <pre id="console"></pre>
- <input type="hidden" value="" id="fileuri">
- <input type="hidden" value="{$data.video}" id="videos">
- <!--上传到OSS哪个文件下,在这里定义 -->
- <input type="hidden" value="dailyWechatArticle" id="wechat_label_name">
- </div>
- </div>
- <div class="isshow" {if condition='$data.type eq "group"'}style="display: block;"{/if}>
- <label class="layui-form-label"><span style="color: red;">*</span>VR作品</label>
- <div class="layui-input-inline" style="width: 400px;display: block;">
- <a class="layui-btn btn layui-border-btn" style="margin-top: 5px;" id="selectVRCreate" href="javascript:void(0);">选择VR作品</a>
- <span id="vrWorks">{$data.vr_name}</span>
- </div>
- </div>
- <input id="vrGroupEle" type="text" hidden name="vr_group_ids" value="{$data.vr_group_ids}">
- </div>
- <!-- <p class="wleft wpsr width50_" style="color:red;height: 136px;">
- <span class="wpsa font14 bottom0 left0">注:不支持拖拽文件 宽:高=1:1</span>
- </p> -->
- <div class="layui-form-item woverflow mdt30">
- <label class="layui-form-label">内容:</label>
- <div class="layui-input-block mdl20 wleft" style="max-width: 70%;">
- <textarea name="content" id="content" rows="10" autocomplete="off"
- class="layui-textarea width100_ pdtb15">{$data.content}</textarea>
- </div>
- </div>
- <div class="mdt50 mdl200">
- <button type="button" class="layui-btn layui-btn-normal layuiSubmit pdlr30" lay-submit
- lay-filter="spellgroup-submit" id="spellgroup-submit">保存</button>
- </div>
- </form>
- </div>
- </body>
- <script type="text/javascript" src="__STATIC__/js/plupload/js/plupload.full.min.js"></script>
- <script type="text/javascript" src="__STATIC__/js/plupload/ossupload.js"></script>
- {/block} {block name="js"}
- <script>
- layui.config({
- base: '__LAYUI__/',
- urlbase: '/sys'
- }).extend({
- index: 'lib/index' //主入口模块
- }).use(['index', 'element', 'upload', 'form'], function () {
- var $ = layui.$,
- layer = layui.layer,
- upload = layui.upload,
- element = layui.element,
- form = layui.form,
- set_List=[],
- files = [],
- ossConfig = {},
- loadindex = 0;
-
- form.render();
- intlist = "{$data.vr}";
- intlistarr=intlist.split(',');
- for(var i=0;i<intlistarr.length;i++){
- set_List.push({
- name:intlistarr[i]
- });
- }
- let id = "{$id}";
- form.on('radio(heads_reward_type)', function (data) {
- var this_=$(this).attr('id')-1;
- $('.isshow').eq(this_).show().siblings().hide();
- });
- //视频封面图
- upload.render({
- elem: '#upload-drag',
- accept: 'image',
- exts: 'png|jpg|jpeg',
- auto: false,
- field: 'cover',
- size: 3 * 1024,
- choose: function(obj) {
- obj.preview(function(index, file, result) {
- $('#upload-drag').html('<img class="fmimages" src="' + result + '" style="width:100%;">');
- });
- }
- });
- $('.isimgupload').hover(function(){
- if($("#upload-drag:has(img.fmimages)").length>0){
- $('.imageDivs').show();
- }
- },function(){
- $('.imageDivs').hide();
- })
-
- $('.imageDivs').on('click', function(e) {
- var that = this;
- layer.confirm('确定删除该图片么?',{title: ['信息', 'color:#333333;background-color:#D8E6F1;'],}, function(index) {
- var imgDiv = $('#upload-drag').find('img');
- imgDiv.remove();
- $('#covers').val('');
- $('#upload-drag').html('<div class="layui-upload-drag"><i class="layui-icon"></i><p style="width:100px">上传视频封面</p></div>');
- layer.close(index);
- });
- });
-
- //多图片上传
- upload.render({
- elem: '#img',
- accept: 'images',
- url: '/upload/',
- exts: 'jpg|png|bmp|jpeg|JPG|PNG|BMP|JPEG',
- field: 'img',
- size: 5 * 1024,
- auto: false,
- multiple: true,
- choose: function(obj) {
- files = obj.pushFile();
- length = $('.imageDiv').length;
- obj.preview(function(index, file, result) {
- length++;
- if(length > 9) {
- if(length == 10) layer.msg('限制九张图片以下');
- delete files[index];
- } else {
- $('.picDiv').prepend('<div class="imageDiv" data-id="' + index + '"><img src="' + result + '" alt="' + file.name + '" class="layui-upload-img" width="100%" height="100%"><div><i class="layui-icon layui-icon-delete" prop="del"></i> <i class="layui-icon layui-icon-search" prop="view" data-image="'+result+'" style="margin-left:25px;"></i></div></div>');
- }
- });
- }
- });
- $('.picDiv').on('click', 'i', function(e) {
- var that = this;
- console.log(e.target)
- if (e.target.attributes[1].nodeValue === 'del') {
- layer.confirm('确定删除该图片么?',{title: ['信息', 'color:#333333;background-color:#D8E6F1;'],}, function(index) {
- var imgDiv = $(that).closest('.imageDiv');
- if(id = imgDiv.data('id')) {
- delete files[id];
- }
- imgDiv.remove();
- layer.close(index);
- });
- } else {
- layer.photos({ photos: {"data": [{"src": e.target.attributes[2].nodeValue}]} ,closeBtn:true});
- }
- });
- set_step_Html(set_List);
- function set_step_Html(set_List) {
- $('.vrurllist')[0].innerHTML = $.map(set_List, (v, i) => {
- return `<div class="woverflow width100_ mdb20">
- <div class="layui-input-block" style="max-width:50% !important; ">
- <input type="text" data-type="name" data-index="${i}" placeholder="请输入标题" autocomplete="off" class="layui-input" value="${v.name}">
- </div>
- <p class="wleft lh46 wpsr mdl10 href vrdelbtn add_step font32" data-index="${set_List.length + 1}">
- <span class="wpsa wpsauto lanse ds">+</span>
- </p>
- <p class="wleft lh40 wpsr href vrdelbtn delete font50" data-index="${i}">
- <span class="wpsa wpsauto lanse ds">-</span>
- </p>
- </div>`
- }).join('');
- setTimeout(() => {
- $('.add_step').click((e) => {
- let index = parseInt(e.delegateTarget.dataset.index);
- if (set_List.length < 9) {
- console.log(set_List.length)
- set_List.push({
- name:''
- })
- set_step_Html(set_List);
- } else {
- layer.msg('最多设置9个VR链接');
- }
- })
- $('.delete').click((e) => {
- if (set_List.length <= 1) {
- layer.msg('只剩最后一个了');
- } else {
- let index = parseInt(e.delegateTarget.dataset.index);
- set_List.splice(index, 1);
- set_step_Html(set_List)
- }
- })
- $('input').change((e) => {
- let type = e.target.dataset.type;
- let val = e.target.value;
- if (type && type != undefined) {
- let index = parseInt(e.delegateTarget.dataset.index);
- set_List[index][type] = val;
- }
- })
- }, 500)
- }
- form.on('submit(spellgroup-submit)', function(data) {
- var formData = new FormData(data.form);
- formData.append('id',{$id});
- Object.keys(files).forEach((v,i) => {
- formData.append(`img[${i}]`, files[v])
- })
- if (data.field.type == 'img') {
- if (!Object.keys(files).length && !data.field["img_exist[0]"]) {
- layer.msg('请添加图片')
- return;
- }
- formData.delete('img')
- formData.append('vr','')
- } else if(data.field.type == 'vr'){
-
- let list = set_List.filter(v => v);
- if (!list.length) {
- layer.msg('请添加VR链接')
- return;
- }
-
- var arrstep = [];
- set_List.forEach(v => {
- arrstep.push(v.name)
- })
- formData.append('img','');
- formData.append('vr',arrstep)
- } else if (data.field.type == 'group') {
- if (!data.field.vr_group_ids) {
- layer.msg('请选择VR作品')
- return;
- }
- formData.append('img', '')
- formData.append('vr', '')
- } else{
- var xin = $('#fileuri').val();
- var videos = $('#videos').val();
- var video_url = xin?xin:videos;
- if (video_url=='') {
- layer.msg('请选择视频', {anim: 6,time: 1000,icon: 5});
- return false;
- }
- formData.delete('img')
- formData.append('img','');
- formData.append('video',video_url);
- formData.append('vr','')
- if($("#upload-drag:has(img.fmimages)").length<1){
- formData.delete('cover');
- }
- }
- loadindex = layer.msg('加载中..', {
- icon: 16
- , shade: 0.3
- , time: false
- });
- $.ajax({
- url: '{:url("building/edit_progress")}',
- type: 'post',
- data: formData,
- dataType: 'json',
- processData: false,
- contentType: false,
- success: function (res) {
- if (res.code === 0) {
- layer.close(loadindex);
- layer.msg(res.msg, {
- anim: 0, time: 1000, icon: 6,
- }, function () {
- var index = parent.layer.getFrameIndex(window.name);
- // parent.layui.table.reload('company-activity'); //重载表格
- parent.layer.close(index); //再执行关闭
- });
- } else {
- layer.msg(res.msg, { anim: 0, time: 1000, icon: 5 });
- }
- }
-
- });
- return false;
- })
- //vr作品
- $('#selectVRCreate').click(function(){
- layer.open({
- type: 2,
- title: ['选择VR作品', 'color:#333333;background-color:#D8E6F1;'],
- content: '{:url("building/group")}?id=' + "{$data.vr_group_ids}",
- area: ['80%', '80%'],
- btn: ['确定', '取消'],
- yes: function (index, layero) {
- let data = layero.find('iframe').contents().find("#hiddentext").val();
- if (data) {
- let vrObject = JSON.parse(data);
- $("#vrGroupEle").val(vrObject.id);
- $("#vrWorks").text(vrObject.name);
- }
- layer.close(index);
- //点击确认触发 iframe 内容中的按钮提交
- }
- });
- })
- })
- </script>
- {/block}
|