123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407 |
- {extend name="public/layout" /} {block name="title"}每日发圈修改{/block} {block name="body"}
- <script src="/static/js/jquery.min.js"></script>
- <style type="text/css">
- html,
- body {
- display: block;
- width: 100%;
- background-color: #fff;
- }
- video {
- width: 144px;
- height: 253px;
- margin: 30px 0px;
- }
-
- .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;
- }
-
- .layui-input-inline.input-longer-inline {
- width: 290px;
- }
- html {
- background: #fff;
- }
-
- .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: 35%;
- }
-
- .imageDiv div:hover {
- background-color: #e6e6e680;
- }
-
- .imageDiv div:hover i {
- display: block;
- cursor: pointer;
- }
- .popwrapper{
- width: 100%;
- box-sizing: border-box;
- }
- .ml20b {
- margin-left: 11%;
- margin-top: 20px;
- }
- .layui-btn-primary {
- color: #249EFB;
- border: 1px solid #249EFB;
- }
- .layui-btn-primary:hover {
- background-color: #E3F7FF;
- color: #249EFB;
- }
- #layui-layer-photos {
- height: 300px !important;
- }
- </style>
- <body>
- <div class="popwrapper">
- <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;">
- <div class="layui-form-item" id="text">
- <label class="layui-form-label"><span style="color: red;">*</span>内容</label>
- <div class="layui-input-block">
- <textarea name="content" lay-verify="required" id="content" cols="6" rows="10" autocomplete="off" class="layui-textarea">{$data.content}</textarea>
- </div>
- </div>
- {if condition="$data.type eq 1"}
- <div class="layui-form-item video">
- <label class="layui-form-label">视频</label>
- <div class="layui-input-inline" style="width: 290px;display: block;" id="container">
- <a class="layui-btn btn" id="selectfiles" href="javascript:void(0);" >选择视频</a>
- <a class="layui-btn btn" id="postfiles" href="javascript:void(0);">开始上传</a>
- <div id="ossfile"></div>
- {if condition="$data.video"}
- <video src="{$data.video}" width="320" height="240" controls="controls">
- </video>
- {/if}
- <div id="symbshowed" class=""></div>
- <!--报错信息返回展示-->
- <pre id="console"></pre>
- <input type="hidden" value="{$data.video}" id="fileuri">
- <!--上传到OSS哪个文件下,在这里定义-->
- <input type="hidden" value="dailyWechatArticle" id="category_name">
- <div class="layui-form-mid layui-word-aux" style="color: red!important;">注:限制上传100M内</div>
- </div>
- </div>
- {else/}
- <div class="layui-form-item img" style="display: flex;">
- <label class="layui-form-label">配图片</label>
- <div class="picDiv" id="draggable" style="margin: 10px 0px;flex: 1;">
- {volist name="data.picture" id="vo" }
- <div class="imageDiv">
- <img src="{$vo}?x-oss-process=image/resize,l_125" class="layui-upload-img" width="100%" height="100%">
- <div><i class="layui-icon layui-icon-delete" prop="delete"></i> <i class="layui-icon layui-icon-search" prop="view" data-image="{$vo}?x-oss-process=image/resize,l_125" style="margin-left:30px;font-size: 25px;margin-top: 5px;"></i></div>
- <input type="hidden" name="article_image_exist[]" value="{$vo}" />
- </div>
- {/volist}
- <div class="addImages" id="img">
- <div class="text-detail">
- <span>+</span>
- <p>点击上传</p>
- </div>
- </div>
- </div>
- </div>
- {/if}
- <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">
- <label class="layui-form-label"><span style="color: red;">*</span>分类</label>
- <div class="layui-input-inline">
- <select name="label" lay-filter="label" id="label" lay-verify="required">
- <option value="">请选择</option>
- {volist name="label" id="v"}
- <option value="{$v.id}" {eq name="$data.festival_id" value="$v.id" }selected{/eq}>{$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">
- <label class="layui-form-label">展示时间</label>
- <div class="layui-input-inline">
- <input type="text" name="show_date" id="show_date" class="layui-input" value="{$data.show_date}">
- </div>
- </div>
- <input type="hidden" name="id" value="{$data.id}" />
- <div class="layui-form-item">
- <input class="layui-btn layui-btn-primary ml20b" type="button" lay-submit lay-filter="dailyWechatArticle-submit" id="dailyWechatArticle-submit" value="确认提交">
- </div>
- </div>
- </form>
- </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/Sortable.js"></script>
- <script type="text/javascript" src="__STATIC__/js/plupload/ossupload.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', 'form', 'upload', 'layedit', 'laydate'], function() {
- var form = layui.form,
- upload = layui.upload,
- layedit = layui.layedit,
- files = [],
- laydate = layui.laydate,
- $ = layui.jquery;
- form.render();
- var obj = {
- label: "{:$data['festival_id']}"
- };
- // 给表单初始赋值,但是无法实现对复选框赋值
- form.val("wxshow-form", obj);
- /* 监听提交 */
- form.on('submit(dailyWechatArticle-submit)', function(obj) {
- var index = parent.layer.getFrameIndex(window.name);
- var formData = new FormData(obj.form);
-
- //限制加载框
- var sd = parent.layer.load(1, {
- shade: [0.8, '#FFFFFF']
- });
-
- //监听分类,去除图片或视频
- // var radio = $('input:radio:checked').val();
- var radio = "{$data.type}";
- if(radio == 1) {
- formData.delete('article_image');
- formData.append('video_url',$('#fileuri').val());
- } else {
- formData.delete('video_url');
- formData.delete('article_image');
- // 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' && el[i].dataset.id) {
- formData.append('article_image[]', files[el[i].dataset.id]['imglink']);
- }
- }
- }
- $.ajax({
- url: '{:url("material/wxshowsave")}',
- type: 'post',
- data: formData,
- dataType: 'json',
- processData: false,
- contentType: false,
- success: function(res) {
- if(res.code === 0) {
- layer.msg(res.msg, {
- anim: 0,time: 400
- }, function() {
- parent.layui.table.reload('wxshow-table');//店面后台
- parent.layui.table.reload('wxshow-add-table');//集团后台
- parent.layer.close(index); //再执行关闭
- });
- } else {
- layer.msg(res.msg, {
- anim: 6,time: 400
- });
- }
- parent.layer.close(sd);
- }
- })
- });
- 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)
- //多图片上传
- upload.render({
- elem: '#img',
- accept: 'images',
- exts: 'jpg|png|bmp|jpeg|JPG|PNG|BMP|JPEG',
- field: 'article_image',
- size: 2 * 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="delete"></i><i class="layui-icon layui-icon-search" prop="view" data-image="'+result+'" style="margin-left:30px;font-size: 25px;margin-top: 5px;"></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)
- });
- })
- }
- form.on('radio(type)', function(data) {
- if(data.value == 1) {
- $('.video').removeClass('layui-hide');
- $('.img').addClass('layui-hide');
- $('.imgTips').addClass('layui-hide');
- }else if(data.value == 2){
- $('.img').removeClass('layui-hide');
- $('.imgTips').removeClass('layui-hide');
- $('.video').addClass('layui-hide');
- }else{
- $('.img').addClass('layui-hide');
- $('.imgTips').addClass('layui-hide');
- $('.video').addClass('layui-hide');
- }
- });
-
- //添加分类
- $('#wechat-label-add').click(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) {
- $('#label').append("<option value='"+res.data.id+"'>"+res.data.name+"</option>")
- form.render();
- layer.msg(res.msg, {
- anim: 0,time: 400
- }, function() {
- layer.close(index); //再执行关闭
- });
- } else {
- layer.msg(res.msg, {
- anim: 6,time: 400
- });
- }
- });
- });
- });
-
- $('.picDiv').on('click', 'i', function(e) {
- var that = this;
- if (e.target.attributes[1].nodeValue === 'delete') {
- 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});
- }
- });
- laydate.render({
- elem: '#show_date' //指定元素
- });
- });
- </script>
- {/block}
|