123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575 |
- {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: 87px;
- text-align: center;
- }
- .isshow {
- display: none;
- }
- .vrdelbtn {
- height: 46px;
- }
- .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 62px;
- }
- #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">
- </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"}
- <option value="{$v.id}">{$v.name}</option>
- {/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="types" name="type" value="img" title="图片"
- checked>
- <input type="radio" id="2" class="radio_input" lay-filter="types" name="type" value="vr"
- title="VR链接">
- <input type="radio" id="3" class="radio_input" lay-filter="types" name="type" value="video"
- title="视频">
- <input type="radio" id="4" class="radio_input" lay-filter="types" name="type" value="group"
- title="VR作品">
- </div>
- </div>
- <div class="layui-form-item woverflow mdt20">
- <div class="isshow" style="display: block;">
- <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;">
- <div class="addImages" id="img">
- <div class="text-detail">
- <i class="layui-icon upload_ico"></i>
- <p>选择单、多图</p>
- </div>
- </div>
- </div>
- </div>
- <div class="layui-form-item">
- <label class="layui-form-label"></label>
- <div style="margin-left: 193px;"><i style="color:red;margin-right: 5px;">*</i><span>注:不支持拖拽文件
- 宽:高=5:3</span></div>
- </div>
- </div>
- <div class="isshow">
- <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">
- <div class="layui-form-item">
- <label class="layui-form-label">视频封面图</label>
- <div class="layui-input-inline isimgupload" style="position: relative;">
- <div class="" id="upload-drag">
- <div class="layui-upload-drag">
- <i class="layui-icon"></i>
- <p>上传图片</p>
- </div>
- </div>
- <div class="imageDivs"><i class="layui-icon layui-icon-delete" prop="del"></i></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>
- <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"></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">
- <!--上传到OSS哪个文件下,在这里定义 -->
- <input type="hidden" value="dailyWechatArticle" id="wechat_label_name">
- </div>
- </div>
- <div class="isshow">
- <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"></span>
- </div>
- </div>
- </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"></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 = [{
- name: ''
- }],
- vrlinkVal = 0,
- files = [],
- ossConfig = {};
- var imglist = [];
- var imglistlen = [];
- form.render()
- let building_id = "{$building_id}";
- form.on('radio(types)', 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();
- $('#upload-drag').html('<div class="layui-upload-drag"><i class="layui-icon"></i><p>上传图片</p></div>');
- layer.close(index);
- });
- });
- var loadindex;
- var load_status = 0;
- var load_end = 0;
- //多图片上传
- upload.render({
- elem: '#img',
- accept: 'images',
- url: '{:url("building/fileupload")}',
- exts: 'jpg|png|bmp|jpeg|JPG|PNG|BMP|JPEG',
- field: 'file',
- size: 5 * 1024,
- auto: true,
- multiple: true,
- choose: function (obj) {
- files = obj.pushFile();
- length = $('.imageDiv').length;
- imglist = [];
- obj.preview(function (index, file, result) {
- length++;
- if (length > 9) {
- loadindex = layer.msg('限制九张图片以下..', {
- icon: 16
- , shade: 0.3
- , time: false
- });
- delete files[index];
- } else {
- load_status = length;
- if (length == 1) {
- loadindex = layer.msg('加载中..', {
- icon: 16
- , shade: 0.3
- , time: false
- });
- }
- $('.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>');
- }
- });
- },
- done: function (res) {
- load_end++;
- console.log(load_end)
- if (res.code == 0) {
- if (imglist.length < 9) {
- imglist.push(res.data.src);
- if (load_status == load_end) {
- layer.close(loadindex);
- }
- }
- }
- }
- });
- $('.picDiv').on('click', 'i', function (e) {
- var that = this;
- if (e.target.attributes[1].nodeValue === 'del') {
- layer.confirm('确定删除该图片么?', { title: ['信息', 'color:#333333;background-color:#D8E6F1;'], }, function (index) {
- var imgDiv = $(that).closest('.imageDiv');
- imglist.splice(imgDiv.index(), 1);
- 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 mdl40 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.target.dataset.index);
- if (set_List.length < 9) {
- set_List.push({
- id: 0,
- 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.target.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.target.dataset.index);
- set_List[index][type] = val;
- }
- })
- }, 500)
- }
- form.on('submit(spellgroup-submit)', function (data) {
- // 单击之后提交按钮不可选,防止重复提交
- var formData = new FormData(data.form);
- formData.delete('file');
- if ($("#upload-drag:has(img.fmimages)").length < 1) {
- formData.delete('cover');
- }
- formData.append('building_id', building_id);
- // Object.keys(files).forEach((v,i) => {
- // formData.append(`img[${i}]`, files[v])
- // })
- if (data.field.type == 'img') {
- // if (!Object.keys(files).length) {
- // layer.msg('请添加图片')
- // return;
- // }
- if (imglist.length == 0) {
- layer.msg('请添加图片')
- return;
- }
- formData.append('img', imglist)
- formData.append('vr', '')
- } else if (data.field.type == 'vr') {
- let list = set_List.filter(v => v.name);
- if (!list.length) {
- layer.msg('请添加VR链接')
- return;
- }
- let vrStr = set_List.map(v => v.name).join(',')
- formData.append('img', '');
- formData.append('vr', vrStr)
- } else if (data.field.type == 'group') {
- if (vrlinkVal==0) {
- layer.msg('请选择VR作品')
- return;
- }
- formData.append('img', '')
- formData.append('vr', '')
- formData.append('vr_group_ids', vrlinkVal);
- } else {
- var video_url = $('#fileuri').val();
- //video_url = 'Building/62a060cb2a61c.jpg';
- formData.append('video', video_url);
- formData.append('vr', '')
- if (video_url == '') {
- layer.msg('请选择视频', { anim: 6, time: 1000, icon: 5 });
- return false;
- }
- }
- var DISABLED = 'layui-btn-disabled';
- var target = '#spellgroup-submit';
- $(target).addClass(DISABLED);
- $(target).attr('disabled', 'disabled');
- loadindex = layer.msg('正在提交..', {
- icon: 16
- , shade: 0.3
- , time: false
- });
- $.ajax({
- url: '{:url("building/add_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.layer.close(index);
- });
- } else {
- $(target).removeClass(DISABLED);
- $(target).removeAttr('disabled');
- layer.msg(res.msg, { anim: 0, time: 1000, icon: 5 });
- }
- },
- error: function (e) {
- $(target).removeClass(DISABLED);
- $(target).removeAttr('disabled');
- }
- });
- return false;
- })
- //vr作品
- $('#selectVRCreate').click(function(){
- layer.open({
- type: 2,
- title: ['选择VR作品', 'color:#333333;background-color:#D8E6F1;'],
- content: '{:url("building/group")}?id=' + "{$building_id}",
- area: ['80%', '80%'],
- btn: ['确定', '取消'],
- yes: function (index, layero) {
- let data = layero.find('iframe').contents().find("#hiddentext").val();
- if (data) {
- let vrObject = JSON.parse(data);
- vrlinkVal = vrObject.id;
- $("#vrWorks").text(vrObject.name);
- }
- layer.close(index);
- //点击确认触发 iframe 内容中的按钮提交
- }
- });
- })
- })
- </script>
- {/block}
|