123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694 |
- {extend name="public/layout" /} {block name="title"}素材库{/block} {block name="body"}
- <!--<link rel="stylesheet" href="__LAYUI__/common.css" media="all">-->
- <style type="text/css">
- html,
- body {
- display: block;
- width: 100%;
- background-color: #fff;
- }
-
- .layui-fluid {
- display: block;
- border-radius: 5px;
- background-color: #ffffff;
- padding: 15px 30px;
- }
- .layui-icon{font-size:18px !important;line-height: 38px;}
- .layui-tab {
- padding: 15px;
- height: 100%;
- }
-
- .layui-table-view .layui-table th,
- .layui-table-view .layui-table td {
- text-align: center;
- border-color: #B6CADE;
- }
-
- .layui-table thead tr,
- .layui-table-header {
- background-color: #D8E6F1;
- }
-
- .input-indent-box {
- display: inline;
- width: 80%;
- }
-
- .input-indent-box-small {
- display: inline;
- width: 20%;
- }
-
- .adding {
- cursor: pointer;
- }
-
- .upload-img .area i {
- font-size: 50px;
- color: #009688;
- }
-
- .evi-block {
- float: left;
- margin-right: 10px;
- }
- /*///*/
-
- .imageDiv {
- display: inline-block;
- width: 140px;
- height: 125px;
- -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;
- }
-
- .addImages {
- display: inline-block;
- width: 140px;
- height: 125px;
- -webkit-box-sizing: border-box;
- -moz-box-sizing: border-box;
- box-sizing: border-box;
- border: 1px dashed darkgray;
- background: #f8f8f8;
- position: relative;
- overflow: hidden;
- }
-
- .text-detail {
- margin-top: 40px;
- text-align: center;
- }
-
- .text-detail>span {
- font-size: 40px;
- }
-
- .imageDiv div {
- width: 100%;
- height: 100%;
- position: absolute;
- top: 0px;
- background-color: #e6e6e600;
- }
-
- .imageDiv div i {
- display: none;
- font-size: 31px;
- position: absolute;
- top: 37%;
- left: 40%;
- }
-
- .imageDiv div:hover {
- background-color: #e6e6e680;
- }
-
- .imageDiv div:hover i {
- display: block;
- cursor: pointer;
- }
-
- .rotate180 {
- -webkit-transform: rotate(180deg);
- transform: rotate(180deg);
- }
-
- .layui-edge.rotate180 {
- margin-top: -9px;
- }
-
- .layui-input-inline.input-longer-inline {
- width: 290px;
- }
- .goback {
- float: right;
- }
- .goback a {
- color: #269efb;
- }
- .goback i {
- position: relative !important;
- }
- @media screen and (max-width: 450px){
- .layui-form-item{
- position: relative;
- }
- .layui-form-item .layui-input-inline {
- padding-right: 40px !important;
- }
- .adding {
- position: absolute;
- right: 10px;
- top: 0;
- }
- }
- input:disabled, input[disabled]{
- color: black;
- opacity: 1;
- -webkit-text-fill-color:black;
- -webkit-opacity:1;
- }
- .imgs{
- width: 89%;
- float:left;
- margin-top: -1%;
- margin-left: -1%;
- }
- .labels{
- display:block;
- float:left;
- /* margin-left: 1.5%;*/
- height: 4%;
- }
- .layui-btn-primary {
- color: #249EFB;
- border: 1px solid #249EFB;
- }
- .layui-btn-primary:hover {
- background-color: #E3F7FF;
- color: #249EFB;
- }
- .layui-border-btn,.layui-border-btn:hover {
- background-color: #fff;
- color: #249EFB;
- border: 1px solid #249EFB;
- }
- .layui-card-body {
- padding: 10px 0px 0px;
- }
- </style>
- <body>
- <div class="layui-fluid">
- <div class="layui-card">
- <div class="layui-card-header ">
- <div class="layui-form-item">
- <div class="layui-inline wzh_ays-inline">
- <strong>朋友圈</strong>
- </div>
- <!--<div class="goback">
- <a href="{:url('material/wxshowlisting')}"><i class="layui-icon layui-icon-return"></i>
- <span>返回列表</span>
- </a>
- </div>-->
- </div>
- </div>
- <div class="layui-card-body">
- <form class="layui-form" id="admin" enctype="multipart/form-data" lay-filter="wxshow-form">
- <div class="layui-form" lay-filter="layuiadmin-app-form-list" id="layuiadmin-app-form-list" style="padding: 20px 30px 0 0;">
- <input id="category_name" type="hidden" value="dailyWechatArticle" />
- <div class="layui-form-item">
- <label class="layui-form-label"><span style="color: red;">*</span>内容</label>
- <div class="layui-input-inline input-longer-inline" style="width: 70%;">
- <textarea name="content" lay-verify="required" id="content" cols="6" autocomplete="off" class="layui-textarea"></textarea>
- </div>
- </div>
- <div class="layui-form-item">
- <label class="layui-form-label"><span style="color: red;"></span></label>
- <div class="layui-input-inline input-longer-inline">
- <input type="radio" name="type" value="1" title="视频" lay-filter="type"/>
- <input type="radio" name="type" value="2" title="图片" lay-filter="type" checked/>
- <!-- <input type="radio" name="type" value="3" title="文字" lay-filter="type" /> -->
- </div>
- </div>
- <div class="layui-form-item video layui-hide">
- <label class="layui-form-label">视频</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="layui-form-item img">
- <label class="layui-form-label labels">配图片</label>
- <div class="imgs" style="width:80%;margin-left: 5px;">
- <div class="picDiv" id="draggable" style="margin: 20px 0px;">
- <div class="addImages" id="img">
- <div class="text-detail">
- <span>+</span>
- <p>选择单、多图</p>
- </div>
- </div>
- </div>
- </div>
- </div>
- <div class="layui-form-item imgTips">
- <label class="layui-form-label labels"></label>
- <div><i style="color: red;margin-right: 5px;"></i>建议上传图片宽高比例1:1,图片大小不超过1M</div>
- </div>
- <!-- <div class="layui-form-item wxtext layui-hide">-->
- <!-- <label class="layui-form-label">标题<span style="color: red;">*</span></label>-->
- <!-- <div class="layui-input-inline">-->
- <!-- <input type="text" id="texttitle" class="layui-input inputBox" value="" autocomplete="off"/>-->
- <!-- </div>-->
- <!-- </div>-->
- <div class="layui-form-item">
- <label class="layui-form-label"><i style="color:red;">*</i>分类</label>
- <div class="layui-input-inline">
- <div class="layui-unselect layui-form-select">
- <div class="layui-select-title wechatlabel-ele-group select_wechatlabel_input">
- <input type="text" lay-verify="required" id="select_wechatlabel" class="layui-input layui-unselect wechatlabel-ele-group" readonly="readonly" value="" data-selectedid="" placeholder="请选择分类" autocomplete="off" />
- <i class="layui-edge wechatlabel-ele-group" id="wechatlabel_arrow"></i>
- </div>
- <dl class="layui-anim layui-anim-upbit wechatlabel-ele-group" id="dropdown_wechatlabel">
- <dd class="topselectbtn wechatlabel-ele-group" data-ref="addwechatlabel"> + 添加分类 + </dd>
- {volist name="Wechatlabel" id="vo"}
- <dd class="wechatlabel_option wechatlabel-ele-group" data-id="{$vo.id}"> {$vo.label_name}</dd>
- {/volist}
- </dl>
- </div>
- <!-- <select name="label" lay-filter="label">-->
- <!-- <option value="">请选择</option>-->
- <!-- {volist name="Wechatlabel" id="v"}-->
- <!-- <option value="{$v.id}">{$v.label_name}</option>-->
- <!-- {/volist}-->
- <!-- </select>-->
- </div>
- <i class="layui-icon layui-icon-add-circle adding" style="font-size: 32px" id="wechat-label-add"></i>
- </div>
- <!-- <div class="layui-form-item" id="text">
- <label class="layui-form-label"><i style="color:red;">*</i>内容</label>
- <div class="layui-input-block">
- <textarea name="content" lay-verify="required" id="content" cols="6" rows="10" autocomplete="off" class="layui-textarea"></textarea>
- </div>
- </div> -->
- <div class="layui-form-item">
- <label class="layui-form-label">展示时间</label>
- <div class="layui-input-inline">
- <input type="text" name="show_date" id="show_date" class="layui-input">
- </div>
- </div>
- <div class="layui-form-item">
- <label class="layui-form-label">继续添加</label>
- <div class="layui-input-block">
- <input type="checkbox" name="adding" title="" lay-skin="primary" {if condition="$adding eq 1"}checked{/if}>
- </div>
- </div>
- <div class="layui-form-item ">
- <input type="button" class="layui-btn btn layui-btn-primary" style="margin-left:12%;" lay-submit lay-filter="dailyWechatArticle-submit" id="dailyWechatArticle-submit" value="确认添加">
- </div>
- </div>
- </form>
- </div>
- </div>
- </div>
- </body>
- {/block} {block name="js"}
- <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>
- <script type="text/javascript" src="__STATIC__/js/Sortable.js"></script>
- <script src="https://gosspublic.alicdn.com/aliyun-oss-sdk-6.3.1.min.js" async></script>
- <script>
- layui.config({
- base: '__LAYUI__/' //静态资源所在路径
- ,
- urlbase: '/sys'
- }).extend({
- index: 'lib/index' //主入口模块
- }).use(['index', 'table', 'layedit', 'element', 'upload', 'laydate'], function() {
- var $ = layui.$,
- element = layui.element,
- upload = layui.upload,
- form = layui.form,
- laydate = layui.laydate,
- files;
- //每日发圈添加
- form.on('submit(dailyWechatArticle-submit)', function(obj) {
- var index = parent.layer.getFrameIndex(window.name);
- var formData = new FormData(obj.form);
- formData.append('label', $('#select_wechatlabel').data('selectedid'));
- //限制加载框
- var sd = layer.load(1, {
- shade: [0.8, '#FFFFFF']
- });
- //监听分类,去除图片或视频
- var radio = $('input:radio:checked').val();
- if(radio == 1) {
- formData.delete('article_image');
- formData.append('video_url', $('#fileuri').val());
- } else if(radio == 2) {
- formData.delete('video_url');
- formData.delete('article_image');
- if (typeof(files) == "undefined" || JSON.stringify(files)=="{}") {
- // layer.close(sd);
- // layer.msg('请至少选择一张图片', {
- // anim: 6
- // });
- // return false;
- }
- // for(i in files) {
- // formData.append('article_image[]', files[i]);
- // }
-
- let el = document.querySelector('#draggable').children;
- for (let i = 0; i < el.length; i++) {
- if (el[i].className === 'imageDiv') {
- formData.append('article_image[]', files[el[i].dataset.id]['imglink']);
- }
- }
- } else {
- formData.delete('video_url');
- formData.delete('article_image');
- formData.append('article_image', '');
- }
- // 单击之后提交按钮不可选,防止重复提交
- var DISABLED = 'layui-btn-disabled';
- var target = '#dailyWechatArticle-submit';
- $(target).addClass(DISABLED);
- $(target).attr('disabled', 'disabled');
- $.ajax({
- url: '{:url("material/apiwxadding")}',
- type: 'post',
- data: formData,
- dataType: 'json',
- processData: false,
- contentType: false,
- success: function(res) {
- $(target).removeClass(DISABLED);
- $(target).removeAttr('disabled');
- layer.close(sd);
- if(res.code === 0) {
- layer.msg(res.msg, {
- anim: 0,time: 400
- }, function() {
- var adding = $("input[name='adding']").is(":checked");
- if (adding) {
- // window.location.reload();
- location.href = "{:url('material/wxshow_add')}?adding=1";
- } else {
- var index = parent.layer.getFrameIndex(window.name);
- parent.layer.close(index);
- parent.layui.table.reload('wxshow-table');//店面后台
- parent.layui.table.reload('wxshow-add-table');//集团后台
-
-
-
- }
- });
- } else {
- layer.msg(res.msg, {
- anim: 6,time: 400
- });
- }
- },
- error : function(e){
- $(target).removeClass(DISABLED);
- $(target).removeAttr('disabled');
- }
- });
- return false;
- });
- setTimeout(() => {
- let el = document.querySelector('#draggable');
- new Sortable(el, {
- animation: 150,
- ghostClass: 'blue-background-class',
- filter: ".addImages", // 过滤器,不需要进行拖动的元素
- // 结束拖拽
- onEnd: function (/**Event*/evt) {
- var itemEl = evt.item; // dragged HTMLElement
- evt.to; // target list
- evt.from; // previous list
- evt.oldIndex; // element's old index within old parent
- evt.newIndex; // element's new index within new parent
- evt.clone // the clone element
- evt.pullMode; // when item is in another sortable: `"clone"` if cloning, `true` if moving
- },
- });
- },800)
- $('.layui-tab-content').on('click', function(e) {
- // console.log(e.target);
- if(!$(e.target).hasClass('wechatlabel-ele-group')) {
- $('#dropdown_wechatlabel').hide();
- $('#wechatlabel_arrow').removeClass('rotate180');
- }
- });
- ///////
- $('.select_wechatlabel_input').on('click', function() {
- $('#dropdown_wechatlabel').toggle();
- $('#wechatlabel_arrow').toggleClass('rotate180');
- });
- ////////
- $(".wechatlabel_option").on('click', function() {
- var wechatlabel_name = $(this).text();
- var wechatlabel_id = $(this).data('id');
- var select_wechatlabel = $("#select_wechatlabel");
- select_wechatlabel.val(wechatlabel_name);
- select_wechatlabel.data('selectedid', wechatlabel_id);
- select_wechatlabel.click();
- });
- ///
- $('.topselectbtn').on('click', function() {
- console.log($(this).data('ref'));
- var gonnado = $(this).data('ref');
- if(gonnado == 'addwechatlabel') {
- addwechatlabel();
- $('#select_wechatlabel').click();
- }
- });
- ////
- //发圈分类添加
- $('#wechat-label-add').on('click', function() {
- addwechatlabel();
- });
- var addwechatlabel = function() {
- layer.prompt({
- title: ['发圈分类添加', 'color:#333333;background-color:#D8E6F1;'],
- }, function(value, index, elem) {
- var value = $.trim(value);
- if(value == '') {
- layer.msg('请输入分类名称', {
- anim: 6,time: 400
- });
- return false;
- }
- if(value.length > 6) {
- layer.msg('分类名称超长', {
- anim: 6,time: 400
- });
- return false;
- }
- $.post('{:url("material/add_wechat_label")}', {
- value: value
- }, function(res) {
- if(res.code == 0) {
- var dd_ele = document.createElement("dd");
- dd_ele.classList.add('wechatlabel_option');
- dd_ele.classList.add('wechatlabel-ele-group');
- dd_ele.setAttribute('data-id', res.data.id);
- dd_ele.innerHTML = ' ' + res.data.name;
- dd_ele.addEventListener('click', function() {
- var wechatlabel_name = $(this).text();
- var wechatlabel_id = $(this).data('id');
- var select_wechatlabel = $("#select_wechatlabel");
- select_wechatlabel.val(wechatlabel_name);
- select_wechatlabel.data('selectedid', wechatlabel_id);
- select_wechatlabel.click();
- });
- var targetEle = document.getElementById('dropdown_wechatlabel');
- targetEle.appendChild(dd_ele);
- var select_wechatlabel = $("#select_wechatlabel");
- select_wechatlabel.val(res.data.name);
- select_wechatlabel.attr('data-selectedid', res.data.id);
- layer.close(index);
- } else {
- layer.msg(res.msg, {
- anim: 6,time: 400
- });
- }
- });
- });
- }
-
- $('.upload-img-btn').on('click', function() {
- layer.open({
- title: ['图文添加', 'color:#333333;background-color:#D8E6F1;'],
- type: 2,
- content: '{:url("material/evidenceadd")}',
- resize: false,
- area: ['80%', '80%']
- });
- });
-
- //案例封面图
- upload.render({
- elem: '#anlicoverimg',
- accept: 'images',
- url: '/upload/',
- exts: 'jpg|png|bmp|jpeg|JPG|PNG|BMP|JPEG',
- field: 'cover_img',
- size: 1 * 1024,
- auto: false,
- 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 {
- $('#anlicoverimg').html('<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"></i></div></div>');
- }
- });
- }
- });
- //多图片上传
- upload.render({
- elem: '#img',
- accept: 'images',
- url: '/upload/',
- exts: 'jpg|png|bmp|jpeg|JPG|PNG|BMP|JPEG',
- field: 'article_image',
- 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 {
- ossuploadimg(file).then(f => {
- files[index]['imglink'] = f;
- $('.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>');
- })
- }
- });
- }
- });
- function ossuploadimg(file) {
- return new Promise((resolve,reject) => {
- var client = new OSS({
- region: "oss-cn-hangzhou",
- accessKeyId: "LTAI5tHjWupJSCAycy2yVbQZ",
- accessKeySecret: "eNFicm77Cfq3u7ZnQyw1urFmFNpf3w",
- bucket: "zyzswzh",
- secure: true
- });
- var date = new Date().getTime();
- var objectName = 'crm/' + date + "/" + Date.now() + ".jpeg";
- client.put(objectName, file).then(function (result) {
- resolve(result.name);
- }).catch(function (error) {
- reject(error)
- });
- })
- }
- upload.render({
- elem: '#evidence_imgs',
- accept: 'images',
- url: '/upload/',
- exts: 'jpg|png|bmp|jpeg|JPG|PNG|BMP|JPEG',
- field: 'evidence_image',
- 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"></i></div></div>');
- }
- });
- }
- });
- form.on('radio(type)', function(data) {
- if(data.value == 1) {
- $('.video').removeClass('layui-hide');
- $('.img').addClass('layui-hide');
- $('.imgTips').addClass('layui-hide');
- // $('.wxtext').addClass('layui-hide');
- } else if(data.value == 2) {
- $('.img').removeClass('layui-hide');
- $('.imgTips').removeClass('layui-hide');
- $('.video').addClass('layui-hide');
- // $('.wxtext').addClass('layui-hide');
- } else {
- // $('.wxtext').removeClass('layui-hide');
- $('.video').addClass('layui-hide');
- $('.img').addClass('layui-hide');
- $('.imgTips').addClass('layui-hide');
- }
- });
- $('.picDiv').on('click', 'i', function(e) {
- var that = this;
- if (e.target.attributes[1].nodeValue === 'view') {
- layer.photos({ photos: {"data": [{"src": e.target.attributes[2].nodeValue}]} ,closeBtn:true});
- } else {
- 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);
- });
- }
- });
- laydate.render({
- elem: '#show_date' //指定元素
- });
- });
- </script>
- {/block}
|