1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312 |
-
- <!-- 已作废 -->
-
- <!-- 用户自定义扩展模板文件 -->
- {include file="diy_extend/archives_extend" /}
- <!-- end -->
-
- {volist name="$addonFieldExtList" id="vo"}
- {if isset($vo.ifeditable) && $vo.ifeditable == 1}
- {switch name="vo.dtype"}
- {case value="hidden"}
- <!-- 隐藏域 start -->
- <dl class="row" style="display: none;">
- <dt class="tit">
- <label>{if condition="isset($vo['ifrequire']) AND !empty($vo['ifrequire'])"}<em>*</em>{/if}{$vo.title|default=''}</label>
- </dt>
- <dd class="opt">
- <input type="hidden" class="input-txt" id="{$vo.fieldArr}_{$vo.name|default=''}" name="{$vo.fieldArr}[{$vo.name|default=''}]" value="{$vo.dfvalue|default=''}">
- <span class="err"></span>
- <p class="notic">{$vo.remark|default=''}</p>
- </dd>
- </dl>
- <!-- 隐藏域 start -->
- {/case}
-
- {case value="region"}
- <!-- 区域选项 start -->
- <dl class="row">
- <dt class="tit">
- <label>{if condition="isset($vo['ifrequire']) AND !empty($vo['ifrequire'])"}<em>*</em>{/if}{$vo.title|default=''}</label>
- </dt>
- <dd class="opt">
- {volist name="$vo.dfvalue" id="v2"}
- <label>
- <input type="radio" id="{$vo.fieldArr}_{$vo.name|default=''}" name="{$vo.fieldArr}[{$vo.name|default=''}]" value="{$v2['id']}" {if condition="isset($vo['trueValue']) AND in_array($v2['id'], $vo['trueValue'])"}checked="checked"{/if}>{$v2['name']}
- </label>
- {/volist}
- <span class="err"></span>
- <p class="notic">{$vo.remark|default=''}</p>
- </dd>
- </dl>
- <!-- 区域选项 end -->
- {/case}
-
- {case value="text"}
- <!-- 单行文本框 start -->
- <dl class="row">
- <dt class="tit">
- <label>{if condition="isset($vo['ifrequire']) AND !empty($vo['ifrequire'])"}<em>*</em>{/if}{$vo.title|default=''}</label>
- </dt>
- <dd class="opt">
- <input type="text" class="input-txt" id="{$vo.fieldArr}_{$vo.name|default=''}" name="{$vo.fieldArr}[{$vo.name|default=''}]" value="{$vo.dfvalue|default=''}"> {$vo.dfvalue_unit|default=''}
- <span class="err"></span>
- <p class="notic">{$vo.remark|default=''}</p>
- </dd>
- </dl>
- <!-- 单行文本框 end -->
- {/case}
-
- {case value="multitext"}
- <!-- 多行文本框 start -->
- <dl class="row">
- <dt class="tit">
- <label>{if condition="isset($vo['ifrequire']) AND !empty($vo['ifrequire'])"}<em>*</em>{/if}{$vo.title|default=''}</label>
- </dt>
- <dd class="opt">
- <textarea rows="5" cols="60" id="{$vo.fieldArr}_{$vo.name|default=''}" name="{$vo.fieldArr}[{$vo.name|default=''}]" style="height:60px;">{$vo.dfvalue|default=''}</textarea>
- <span class="err"></span>
- <p class="notic">{$vo.remark|default=''}</p>
- </dd>
- </dl>
- <!-- 多行文本框 end -->
- {/case}
-
- {case value="checkbox"}
- <!-- 复选框 start -->
- <dl class="row">
- <dt class="tit">
- <label>{if condition="isset($vo['ifrequire']) AND !empty($vo['ifrequire'])"}<em>*</em>{/if}{$vo.title|default=''}</label>
- </dt>
- <dd class="opt">
- {volist name="$vo.dfvalue" id="v2"}
- <label><input type="checkbox" name="{$vo.fieldArr}[{$vo.name|default=''}][]" value="{$v2}" {if condition="isset($vo['trueValue']) AND in_array($v2, $vo['trueValue'])"}checked="checked"{/if} onclick="func_{$vo.name}_eyempty();">{$v2}</label>
- {/volist}
- <input type="hidden" name="{$vo.fieldArr}[{$vo.name}_eyempty]" value="{if condition="!empty($vo['trueValue'])"}1{else /}0{/if}">
- <span class="err"></span>
- <p class="notic">{$vo.remark|default=''}</p>
- </dd>
- </dl>
- <script type="text/javascript">
- function func_{$vo.name}_eyempty()
- {
- var len = $("input[name='{$vo.fieldArr}[{$vo.name}][]']:checked").length;
- $("input[name='{$vo.fieldArr}[{$vo.name}_eyempty]']").val(len);
- }
- </script>
- <!-- 复选框 end -->
- {/case}
-
- {case value="radio"}
- <!-- 单选项 start -->
- <dl class="row">
- <dt class="tit">
- <label>{if condition="isset($vo['ifrequire']) AND !empty($vo['ifrequire'])"}<em>*</em>{/if}{$vo.title|default=''}</label>
- </dt>
- <dd class="opt">
- {volist name="$vo.dfvalue" id="v2"}
- <label><input type="radio" id="{$vo.fieldArr}_{$vo.name|default=''}" name="{$vo.fieldArr}[{$vo.name|default=''}]" value="{$v2}" {if condition="isset($vo['trueValue']) AND in_array($v2, $vo['trueValue'])"}checked="checked"{/if}>{$v2}</label>
- {/volist}
- <span class="err"></span>
- <p class="notic">{$vo.remark|default=''}</p>
- </dd>
- </dl>
- <!-- 单选项 end -->
- {/case}
-
- {case value="switch"}
- <!-- 开关 start -->
- <dl class="row">
- <dt class="tit">
- <label>{if condition="isset($vo['ifrequire']) AND !empty($vo['ifrequire'])"}<em>*</em>{/if}{$vo.title|default=''}</label>
- </dt>
- <dd class="opt">
- <div class="onoff">
- <label for="{$vo.fieldArr}_{$vo.name|default=''}1" class="cb-enable {if condition="0 != $vo['dfvalue']"}selected{/if}">是</label>
- <label for="{$vo.fieldArr}_{$vo.name|default=''}0" class="cb-disable {if condition="0 == $vo['dfvalue']"}selected{/if}">否</label>
- <input id="{$vo.fieldArr}_{$vo.name|default=''}1" name="{$vo.fieldArr}[{$vo.name|default=''}]" value="1" type="radio" {if condition="0 != $vo['dfvalue']"}checked="checked"{/if}>
- <input id="{$vo.fieldArr}_{$vo.name|default=''}0" name="{$vo.fieldArr}[{$vo.name|default=''}]" value="0" type="radio" {if condition="0 == $vo['dfvalue']"}checked="checked"{/if}>
- </div>
- <span class="err"></span>
- <p class="notic">{$vo.remark|default=''}</p>
- </dd>
- </dl>
- <script type="text/javascript">
- $(function(){
- //自定义radio样式
- $(".cb-enable").on('click', function(){
- var parent = $(this).parents('.onoff');
- $('.cb-disable',parent).removeClass('selected');
- $(this).addClass('selected');
- $('.checkbox',parent).attr('checked', true);
- });
- $(".cb-disable").on('click', function(){
- var parent = $(this).parents('.onoff');
- $('.cb-enable',parent).removeClass('selected');
- $(this).addClass('selected');
- $('.checkbox',parent).attr('checked', false);
- });
- });
- </script>
- <!-- 开关 end -->
- {/case}
-
- {case value="select"}
- <!-- 下拉框 start -->
- <dl class="row">
- <dt class="tit">
- <label>{if condition="isset($vo['ifrequire']) AND !empty($vo['ifrequire'])"}<em>*</em>{/if}{$vo.title|default=''}</label>
- </dt>
- <dd class="opt">
- <select name="{$vo.fieldArr}[{$vo.name|default=''}]" id="{$vo.fieldArr}_{$vo.name|default=''}">
- {volist name="$vo.dfvalue" id="v2"}
- <option value="{$v2}" {if condition="isset($vo['trueValue']) AND in_array($v2, $vo['trueValue'])"}selected{/if}>{$v2}</option>
- {/volist}
- </select>
- <span class="err"></span>
- <p class="notic">{$vo.remark|default=''}</p>
- </dd>
- </dl>
- <!-- 下拉框 end -->
- {/case}
-
- {case value="img"}
- <!-- 单张图 start -->
- <dl class="row">
- <dt class="tit">
- <label>{if condition="isset($vo['ifrequire']) AND !empty($vo['ifrequire'])"}<em>*</em>{/if}{$vo.title|default=''}</label>
- </dt>
- <dd class="opt">
- <div class="input-file-show div_{$vo.fieldArr}_{$vo.name|default=''}_eyou_local" {neq name="$vo[$vo['name'].'_eyou_is_remote']" value="0"}style="display: none;"{/neq}>
- <span class="show">
- <a id="img_a_{$vo.fieldArr}_{$vo.name|default=''}" target="_blank" class="nyroModal" rel="gal" href="{$vo[$vo['name'].'_eyou_local']|default='javascript:void(0);'}">
- <i id="img_i_{$vo.fieldArr}_{$vo.name|default=''}" class="fa fa-picture-o" {notempty name="$vo[$vo['name'].'_eyou_local']"}onmouseover="layer_tips=layer.tips('<img src={$vo[$vo['name'].'_eyou_local']} class=\'layer_tips_img\'>',this,{tips: [1, '#fff']});"{/notempty} onmouseout="layer.close(layer_tips);"></i>
- </a>
- </span>
- <span class="type-file-box">
- <input type="text" id="{$vo.fieldArr}_{$vo.name|default=''}_eyou_local" name="{$vo.fieldArr}[{$vo.name|default=''}_eyou_local]" value="{$vo[$vo['name'].'_eyou_local']|default=''}" class="type-file-text" autocomplete="off">
- <input type="button" name="button" id="button1" value="选择上传..." class="type-file-button">
- <input class="type-file-file" onClick="GetUploadify(1,'','allimg','{$vo.fieldArr}_{$vo.name|default=''}_call_back')" size="30" hidefocus="true" nc_type="change_site_{$vo.fieldArr}_{$vo.name|default=''}"
- title="点击前方预览图可查看大图,点击按钮选择文件并提交表单后上传生效">
- </span>
- </div>
- <input type="text" id="{$vo.fieldArr}_{$vo.name|default=''}_eyou_remote" name="{$vo.fieldArr}[{$vo.name|default=''}_eyou_remote]" value="{$vo[$vo['name'].'_eyou_remote']|default=''}" placeholder="http://" class="input-txt" {neq name="$vo[$vo['name'].'_eyou_is_remote']" value="1"}style="display: none;"{/neq}>
-
- <label><input type="checkbox" name="{$vo.fieldArr}[{$vo.name|default=''}_eyou_is_remote]" id="{$vo.fieldArr}_{$vo.name|default=''}_eyou_is_remote" value="1" {eq name="$vo[$vo['name'].'_eyou_is_remote']" value="1"}checked="checked"{/eq} onClick="clickRemote(this, '{$vo.fieldArr}_{$vo.name|default=''}_eyou');">远程图片</label>
- <span class="err"></span>
- <p class="notic">{$vo.remark|default=''}</p>
- </dd>
- </dl>
- <script type="text/javascript">
- function {$vo.fieldArr}_{$vo.name|default=''}_call_back(fileurl_tmp)
- {
- $("#{$vo.fieldArr}_{$vo.name|default=''}_eyou_local").val(fileurl_tmp);
- $("#img_a_{$vo.fieldArr}_{$vo.name|default=''}").attr('href', fileurl_tmp);
- $("#img_i_{$vo.fieldArr}_{$vo.name|default=''}").attr('onmouseover', "layer_tips=layer.tips('<img src="+fileurl_tmp+" class=\\'layer_tips_img\\'>',this,{tips: [1, '#fff']});");
- }
- </script>
- <!-- 单张图 end -->
- {/case}
-
- {case value="file"}
- <!-- 单个文件 start -->
- <dl class="row">
- <dt class="tit">
- <label>{if condition="isset($vo['ifrequire']) AND !empty($vo['ifrequire'])"}<em>*</em>{/if}{$vo.title|default=''}</label>
- </dt>
- <dd class="opt">
- <div class="input-file-show div_{$vo.fieldArr}_{$vo.name|default=''}_eyou_local" {neq name="$vo[$vo['name'].'_eyou_is_remote']" value="0"}style="display: none;"{/neq}>
- <span class="show">
- <a id="file_a_{$vo.fieldArr}_{$vo.name|default=''}" class="nyroModal" rel="gal" href="{$vo[$vo['name'].'_eyou_local']|default='javascript:void(0);'}" download="{$vo[$vo['name'].'_eyou_local']|get_filename=###}">
- <i id="file_i_{$vo.fieldArr}_{$vo.name|default=''}" class="layui-icon layui-icon-file-b" ></i>
- </a>
- </span>
- <span class="type-file-box">
- <input type="text" id="{$vo.fieldArr}_{$vo.name|default=''}_eyou_local" name="{$vo.fieldArr}[{$vo.name|default=''}_eyou_local]" value="{$vo[$vo['name'].'_eyou_local']|default=''}" class="type-file-text" autocomplete="off">
- <input type="button" name="button" id="{$vo.fieldArr}_{$vo.name|default=''}_button" value="选择上传..." class="type-file-button">
- <input title="点击前方文件图标可下载文件,点击按钮选择文件并提交表单后上传生效" class="type-file-file" type="file" data-type="{$vo.upload_flag}" onchange="upload_file_{$vo.fieldArr}_{$vo.name|default=''}_1585641737(this)" size="30" hidefocus="true" nc_type="change_site_{$vo.fieldArr}_{$vo.name|default=''}">
- </span>
- </div>
- <input type="text" id="{$vo.fieldArr}_{$vo.name|default=''}_eyou_remote" name="{$vo.fieldArr}[{$vo.name|default=''}_eyou_remote]" value="{$vo[$vo['name'].'_eyou_remote']|default=''}" placeholder="http://" class="input-txt" {neq name="$vo[$vo['name'].'_eyou_is_remote']" value="1"}style="display: none;"{/neq}>
-
- <label><input type="checkbox" name="{$vo.fieldArr}[{$vo.name|default=''}_eyou_is_remote]" id="{$vo.fieldArr}_{$vo.name|default=''}_eyou_is_remote" value="1" {eq name="$vo[$vo['name'].'_eyou_is_remote']" value="1"}checked="checked"{/eq} onClick="clickRemote(this, '{$vo.fieldArr}_{$vo.name|default=''}_eyou');">远程文件</label>
- <span class="err"></span>
- <p class="notic">{$vo.remark|default=''}</p>
- </dd>
- </dl>
- <script type="text/javascript">
- function upload_file_{$vo.fieldArr}_{$vo.name|default=''}_1585641737(e){
- var data_type = $(e).attr('data-type');
- if ('qny' == data_type) {
- // 七牛云上传
- {$vo.fieldArr}_{$vo.name|default=''}_qny_file(e);
- } else if ('oss' == data_type) {
- // OSS上传
- {$vo.fieldArr}_{$vo.name|default=''}_oss_file(e);
- } else if ('cos' == data_type) {
- // COS上传
- {$vo.fieldArr}_{$vo.name|default=''}_cos_file(e);
- } else {
- // 本地上传
- {$vo.fieldArr}_{$vo.name|default=''}_local_file(e);
- }
- }
- function judgeExtFile(ext) {
- var type = '{$vo.ext}';
- var extArr = [];
- extArr = type.split("|");
- var exts = ext.replace(".","");
- return extArr.indexOf(exts);
- }
-
- // 七牛云
- function {$vo.fieldArr}_{$vo.name|default=''}_qny_file(e) {
- // 获取文件路径名
- var file = $(e)[0].files[0];
-
- // 验证上传格式
- var fileName = file.name;
- var fileExt = fileName.substr(fileName.lastIndexOf('.')).toLowerCase();
- var ext = judgeExtFile(fileExt);
- if (ext == -1) {
- showErrorMsg('仅支持{$vo.ext}格式,可在附件设置中修改');
- return false;
- }
-
- // 验证上传大小
- size = parseInt("{$vo.filesize}");
- if (file.size > size) {
- showErrorMsg('附件大小超过限制,可在附件设置中修改');
- return false;
- }
-
- // 执行上传
- layer_loading('上传七牛云');
- $.ajax({
- type: 'POST',
- url: '__ROOT_DIR__/index.php?m=plugins&c=Qiniuyun&a=qiniu_upload',
- data: {_ajax: 1},
- dataType: "JSON",
- success: function(res1) {
- if (1 == res1.code) {
- var token = res1.data.token;
- var formData = new FormData();
- formData.append('file', file);
- formData.append('token', token);
-
- fileName = res1.data.filePath + fileExt;
- formData.append('key', fileName);
- $.ajax({
- url: res1.data.uphost,
- type: 'POST',
- dataType: 'JSON',
- data: formData,
- timeout: 1200000,
- cache: false,
- processData: false,
- contentType: false,
- xhr: function () {
- myXhr = $.ajaxSettings.xhr();
- if (myXhr.upload) {
- myXhr.upload.addEventListener('progress', function(e){
- var curr = e.loaded;
- var total = e.total;
- process = parseInt(curr / total * 100);
- $("#{$vo.fieldArr}_{$vo.name|default=''}_button").text('上传中...'+process+"%");
- });
- }
- return myXhr;
- },
- success: function(res2) {
- layer.closeAll();
- $("#{$vo.fieldArr}_{$vo.name|default=''}_button").text('上传成功');
- setTimeout(function() {
- $('#{$vo.fieldArr}_{$vo.name|default=\'\'}_button').text('选择上传...');
- }, 2000);
- var video_url = res1.data.domain + "/" + res2.key;
- $("#{$vo.fieldArr}_{$vo.name|default=''}_eyou_local").val(video_url);
- $("#file_a_{$vo.fieldArr}_{$vo.name|default=''}").attr('href',video_url);
- var arr = video_url.split("/");
- var download = arr[arr.length-1];
- $("#file_a_{$vo.fieldArr}_{$vo.name|default=''}").attr('download',download);
- },
- error: function(e) {
- layer.closeAll();
- showErrorMsg(e.responseText);
- return false;
- }
- });
- } else {
- layer.closeAll();
- showErrorMsg(res1.msg);
- }
- },
- error: function(e) {
- layer.closeAll();
- showErrorMsg(e.responseText);
- }
- });
- }
-
- //OSS
- function {$vo.fieldArr}_{$vo.name|default=''}_oss_file(e) {
- // 获取文件路径名
- var file = $(e)[0].files[0];
-
- // 验证上传格式
- var fileName = file.name;
- var fileExt = fileName.substr(fileName.lastIndexOf('.')).toLowerCase();
- var ext = judgeExtFile(fileExt);
- if (ext == -1) {
- showErrorMsg('仅支持{$vo.ext}格式,可在附件设置中修改');
- return false;
- }
-
- // 验证上传大小
- size = parseInt("{$vo.filesize}");
- if (file.size > size) {
- showErrorMsg('附件大小超过限制,可在附件设置中修改');
- return false;
- }
-
- // 执行上传
- layer_loading('上传阿里云OSS');
- $.ajax({
- type: 'POST',
- url: '__ROOT_DIR__/index.php?m=plugins&c=AliyunOss&a=oss_upload',
- data: {_ajax: 1},
- dataType: "JSON",
- success: function(res1){
- if (1 == res1.code){
- fileName = res1.data.filePath + fileExt;
- //组装发送数据
- var request = new FormData();
- request.append("OSSAccessKeyId",res1.data.accessid);
- request.append("policy",res1.data.policy);
- request.append("Signature",res1.data.signature);
- request.append("key",fileName);
- request.append("success_action_status",201);
- request.append('file', file);
-
- $.ajax({
- url : res1.data.host,
- data : request,
- processData: false,
- cache: false,
- contentType: false,
- dataType: 'xml',
- type : 'post',
- xhr: function () {
- myXhr = $.ajaxSettings.xhr();
- if (myXhr.upload) {
- myXhr.upload.addEventListener('progress', function(e){
- var curr = e.loaded;
- var total = e.total;
- var process = parseInt(curr / total * 100);
- $("#{$vo.fieldArr}_{$vo.name|default=''}_button").text('上传中...'+process+"%");
- });
- }
- return myXhr;
- },
- success : function(data) {
- layer.closeAll();
- var res = $(data).find('PostResponse');
- if (res) {
- var key = res.find('Key').text();
- $("#{$vo.fieldArr}_{$vo.name|default=''}_button").text('上传成功');
- setTimeout(function() {
- $("#{$vo.fieldArr}_{$vo.name|default=''}_button").text('选择上传...');
- }, 2000);
- var video_url = res1.data.domain + "/" + key;
- $("#{$vo.fieldArr}_{$vo.name|default=''}_eyou_local").val(video_url);
- $("#file_a_{$vo.fieldArr}_{$vo.name|default=''}").attr('href',video_url);
- var arr = video_url.split("/");
- var download = arr[arr.length-1];
- $("#file_a_{$vo.fieldArr}_{$vo.name|default=''}").attr('download',download);
-
- } else {
- $("#{$vo.fieldArr}_{$vo.name|default=''}_button").text('上传失败');
- setTimeout(function() {
- $("#{$vo.fieldArr}_{$vo.name|default=''}_button").text('选择上传...');
- }, 2000);
- }
- },
- error : function(e) {
- layer.closeAll();
- console.log(e.responseText);
- }
- });
- } else {
- layer.closeAll();
- showErrorMsg(res1.msg);
- }
- },
- error: function(e) {
- layer.closeAll();
- showErrorMsg(e.responseText);
- }
- });
- }
-
- //COS
- function {$vo.fieldArr}_{$vo.name|default=''}_cos_file(e) {
- // 获取文件路径名
- var file = $(e)[0].files[0];
-
- // 验证上传格式
- var fileName = file.name;
- var fileExt = fileName.substr(fileName.lastIndexOf('.')).toLowerCase();
- var ext = judgeExtFile(fileExt);
- if (ext == -1) {
- showErrorMsg('仅支持{$vo.ext}格式,可在附件设置中修改');
- return false;
- }
-
- // 验证上传大小
- size = parseInt("{$vo.filesize}");
- if (file.size > size) {
- showErrorMsg('附件大小超过限制,可在附件设置中修改');
- return false;
- }
-
- // 上传参数
- var formData = new FormData();
- formData.append('file', file);
- formData.append('file_ext', fileExt);
-
- // 执行上传
- $.ajax({
- type: 'post',
- url: '__ROOT_DIR__/index.php?m=plugins&c=Cos&a=cos_upload&_ajax=1',
- data: formData,
- contentType: false,
- processData: false,
- dataType: 'json',
- xhr: function () {
- myXhr = $.ajaxSettings.xhr();
- if (myXhr.upload) {
- myXhr.upload.addEventListener('progress', function(e){
- var curr = e.loaded;
- var total = e.total;
- process = parseInt(curr / total * 100);
- if (100 == process) {
- process = 99;
- layer_loading('上传腾讯云');
- }
- $("#{$vo.fieldArr}_{$vo.name|default=''}_cos_upload_media").text('上传中...'+process+"%");
- });
- }
- return myXhr;
- },
- success: function(res) {
- layer.closeAll();
- if (1 == res.code) {
- video_url = res.data.url;
- $("#{$vo.fieldArr}_{$vo.name|default=''}_eyou_local").val(video_url);
- $("#file_a_{$vo.fieldArr}_{$vo.name|default=''}").attr('href',video_url);
- var arr = video_url.split("/");
- var download = arr[arr.length-1];
- $("#file_a_{$vo.fieldArr}_{$vo.name|default=''}").attr('download',download);
-
- $("#{$vo.fieldArr}_{$vo.name|default=''}_button").text('上传成功');
- } else {
- $("#{$vo.fieldArr}_{$vo.name|default=''}_button").text('上传失败');
- }
- setTimeout(function() {
- $('#{$vo.fieldArr}_{$vo.name|default=\'\'}_button').text('选择上传...');
- }, 2000);
- },
- error: function(e) {
- layer.closeAll();
- showErrorMsg(e.responseText);
- }
- });
- }
-
- // 本地上传
- function {$vo.fieldArr}_{$vo.name|default=''}_local_file(e){
- // 获取文件路径名
- var file = $(e)[0].files[0];
- // 验证上传格式
- var fileName = file.name;
- var fileExt = fileName.substr(fileName.lastIndexOf('.')).toLowerCase();
- var ext = judgeExtFile(fileExt);
- if (ext == -1) {
- showErrorMsg('仅支持{$vo.ext}格式,可在附件设置中修改');
- return false;
- }
-
- // 验证上传大小
- size = parseInt("{$vo.filesize}");
- if (file.size > size) {
- showErrorMsg('附件大小超过限制,可在附件设置中修改');
- return false;
- }
-
- // 定义上传数据
- var formData = new FormData();
- formData.append('file', file);
-
- // 执行上传
- layer_loading('上传本地');
- $.ajax({
- type: 'post',
- url : "{:url('Ueditor/DownloadUploadFileAjax')}",
- data: formData,
- contentType: false,
- processData: false,
- dataType: 'json',
- xhr: function () {
- myXhr = $.ajaxSettings.xhr();
- if (myXhr.upload) {
- myXhr.upload.addEventListener('progress', function(e){
- var curr = e.loaded;
- var total = e.total;
- process = parseInt(curr / total * 100);
- $("#{$vo.fieldArr}_{$vo.name|default=''}_button").html('上传中...'+process+"%");
- });
- }
- return myXhr;
- },
- success: function (res) {
- layer.closeAll();
- if (res.code==0){
- layer.msg(res.msg)
- setTimeout(function() {
- $('#{$vo.fieldArr}_{$vo.name|default=\'\'}_button').html('选择上传...');
- }, 2000);
- }else {
- $("#{$vo.fieldArr}_{$vo.name|default=''}_button").html('上传成功');
- setTimeout(function() {
- $('#{$vo.fieldArr}_{$vo.name|default=\'\'}_button').html('选择上传...');
- }, 2000);
-
- $("#{$vo.fieldArr}_{$vo.name|default=''}_eyou_local").val(res.file_url);
- $("#file_a_{$vo.fieldArr}_{$vo.name|default=''}").attr('href',res.file_url);
- var arr = res.file_url.split("/");
- var download = arr[arr.length-1];
- $("#file_a_{$vo.fieldArr}_{$vo.name|default=''}").attr('download',download);
- }
- }
- });
- }
- </script>
- <!-- 单个文件 end -->
- {/case}
-
- {case value="imgs"}
- <!-- 多张图 start -->
- <dl class="row" id="dl_{$vo.fieldArr}_{$vo.name|default=''}">
- <dt class="tit">
- <label>{if condition="isset($vo['ifrequire']) AND !empty($vo['ifrequire'])"}<em>*</em>{/if}{$vo.title|default=''}</label>
- </dt>
- <dd class="opt">
- <div class="tab-pane pics" id="tab_{$vo.fieldArr}_{$vo.name|default=''}">
- <!-- <a href="javascript:void(0);" onClick="GetUploadify(100,'','allimg','{$vo.fieldArr}_{$vo.name|default=''}_call_back');" class="imgupload">
- <i class="fa fa-photo"></i>上传图片
- </a> -->
- <table class="table table-bordered">
- <tbody>
- <tr>
- <td >
- <div class="sort-list-{$vo.fieldArr}_{$vo.name|default=''}">
- {volist name="$vo[$vo['name'].'_eyou_imgupload_list']" id="v2" key="k2"}
- <div class="images_upload images_upload_html" style="display:inline-block;">
- <div style="position: relative; height: 130px;">
- <input type="hidden" name="{$vo.fieldArr}[{$vo.name|default=''}][]" value="{$v2['image_url']}">
- <a href="{$v2['image_url']}" onclick="" class="upimg" target="_blank" title="拖动修改排序">
- <img src="{$v2['image_url']}" width="136" height="136">
- </a>
- <a href="javascript:void(0)" onclick="{$vo.fieldArr}_{$vo.name|default=''}_ClearPicArr2(this,'{$v2['image_url']}')" class="delect" title="删除"></a>
- </div>
- <textarea rows="5" cols="60" name="{$vo.fieldArr}[{$vo.name|default=''}_eyou_intro][]" style="height:28px; width: 136px;" placeholder="图片注释">{$v2.intro}</textarea>
- </div>
- {/volist}
- <div class="images_upload"></div>
- </div>
- <a href="javascript:void(0);" onClick="GetUploadify(100,'','allimg','{$vo.fieldArr}_{$vo.name|default=''}_call_back');" class="img-upload mb15" title="点击上传">
- <div class="y-line"></div>
- <div class="x-line"></div>
- </a>
- </td>
- </tr>
- </tbody>
- </table>
- </div>
- <!-- 上传图片显示的样板 start -->
- <div class="{$vo.fieldArr}_{$vo.name|default=''}_upload_tpl none">
- <div class="images_upload images_upload_html" style="display:inline-block;">
- <div style="position: relative; height: 130px;">
- <input type="hidden" name="{$vo.fieldArr}[{$vo.name|default=''}][]" value="" />
- <a href="javascript:void(0);" onClick="" class="upimg" title="拖动修改排序">
- <img src="__STATIC__/admin/images/add-button.jpg" width="136" height="136" />
- </a>
- <a href="javascript:void(0)" class="delect" title="删除"> </a>
- </div>
- <textarea rows="5" cols="60" name="{$vo.fieldArr}[{$vo.name|default=''}_eyou_intro][]" style="height:28px; width: 136px;" placeholder="图片注释"></textarea>
- </div>
- </div>
- <!-- 上传图片显示的样板 end -->
- </dd>
- </dl>
- <script type="text/javascript">
- // 上传多图回调函数
- function {$vo.fieldArr}_{$vo.name|default=''}_call_back(paths){
-
- var last_div = $(".{$vo.fieldArr}_{$vo.name|default=''}_upload_tpl").html();
- for (var i=0;i<paths.length ;i++ )
- {
- if ($(".sort-list-{$vo.fieldArr}_{$vo.name|default=''} .images_upload_html").length > 0) {
- $(".sort-list-{$vo.fieldArr}_{$vo.name|default=''} .images_upload_html:last").after(last_div); // 插入一个 新图片
- } else {
- $(".sort-list-{$vo.fieldArr}_{$vo.name|default=''} .images_upload:last").before(last_div); // 插入一个 新图片
- }
- $(".sort-list-{$vo.fieldArr}_{$vo.name|default=''} .images_upload_html:last").find('a:eq(0)').attr('href',paths[i]).attr('onclick','').attr('target', "_blank");// 修改他的链接地址
- $(".sort-list-{$vo.fieldArr}_{$vo.name|default=''} .images_upload_html:last").find('img').attr('src',paths[i]);// 修改他的图片路径
- $(".sort-list-{$vo.fieldArr}_{$vo.name|default=''} .images_upload_html:last").find('a:eq(1)').attr('onclick',"{$vo.fieldArr}_{$vo.name|default=''}_ClearPicArr2(this,'"+paths[i]+"')").text('');
- $(".sort-list-{$vo.fieldArr}_{$vo.name|default=''} .images_upload_html:last").find('input').val(paths[i]); // 设置隐藏域 要提交的值
- }
- }
- /*
- * 上传之后删除组图input
- * @access public
- * @val string 删除的图片input
- */
- function {$vo.fieldArr}_{$vo.name|default=''}_ClearPicArr2(obj,path)
- {
- // 删除数据库记录
- $.ajax({
- type:'GET',
- url:"{:url('Field/del_channelimgs', ['_ajax'=>1])}",
- data:{filename:path,channel:"{$channeltype|default='0'}",fieldid:"{$vo.id}",aid:"{$aid|default='0'}"},
- success:function(){
- $(obj).parent().parent().remove(); // 删除完服务器的, 再删除 html上的图片
- $.ajax({
- type:'GET',
- url:"{:url('Uploadimgnew/delupload', ['_ajax'=>1])}",
- data:{action:"del", filename:path},
- success:function(){}
- });
- }
- });
- }
-
- /** 以下 产品相册的拖动排序相关 js*/
-
- $( ".sort-list-{$vo.fieldArr}_{$vo.name|default=''}" ).sortable({
- start: function( event, ui) {
-
- }
- ,stop: function( event, ui ) {
-
- }
- });
- //因为他们要拖动,所以尽量设置他们的文字不能选择。
- $( ".sort-list-{$vo.fieldArr}_{$vo.name|default=''}" ).disableSelection();
- </script>
- <!-- 多张图 end -->
- {/case}
-
- {case value="int"}
- <!-- 整数类型 start -->
- <dl class="row">
- <dt class="tit">
- <label>{if condition="isset($vo['ifrequire']) AND !empty($vo['ifrequire'])"}<em>*</em>{/if}{$vo.title|default=''}</label>
- </dt>
- <dd class="opt">
- <input type="text" value="{$vo.dfvalue|default=''}" name="{$vo.fieldArr}[{$vo.name|default=''}]" id="{$vo.fieldArr}_{$vo.name|default=''}" placeholder="只允许纯数字" class="input-txt" onkeyup="this.value=this.value.replace(/[^0-9]/g,'');" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^0-9]/g,''));"> {$vo.dfvalue_unit|default=''}
- <span class="err"></span>
- <p class="notic">{$vo.remark|default=''}</p>
- </dd>
- </dl>
- <!-- 整数类型 end -->
- {/case}
-
- {case value="float"}
- <!-- 小数类型 start -->
- <dl class="row">
- <dt class="tit">
- <label>{if condition="isset($vo['ifrequire']) AND !empty($vo['ifrequire'])"}<em>*</em>{/if}{$vo.title|default=''}</label>
- </dt>
- <dd class="opt">
- <input type="text" value="{$vo.dfvalue|default=''}" name="{$vo.fieldArr}[{$vo.name|default=''}]" id="{$vo.fieldArr}_{$vo.name|default=''}" placeholder="允许带有小数点的数值" class="input-txt" onkeyup="this.value=this.value.replace(/[^0-9\.]/g,'');" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^0-9\.]/g,''));"> {$vo.dfvalue_unit|default=''}
- <span class="err"></span>
- <p class="notic">{$vo.remark|default=''}</p>
- </dd>
- </dl>
- <!-- 小数类型 end -->
- {/case}
-
- {case value="decimal"}
- <!-- 金额类型 start -->
- <dl class="row">
- <dt class="tit">
- <label>{if condition="isset($vo['ifrequire']) AND !empty($vo['ifrequire'])"}<em>*</em>{/if}{$vo.title|default=''}</label>
- </dt>
- <dd class="opt">
- <input type="text" value="{$vo.dfvalue|default=''}" name="{$vo.fieldArr}[{$vo.name|default=''}]" id="{$vo.fieldArr}_{$vo.name|default=''}" placeholder="允许带有小数点的金额" class="input-txt" onkeyup="this.value=this.value.replace(/[^0-9\.]/g,'');" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^0-9\.]/g,''));"> {$vo.dfvalue_unit|default=''}
- <span class="err"></span>
- <p class="notic">{$vo.remark|default=''}</p>
- </dd>
- </dl>
- <!-- 金额类型 end -->
- {/case}
-
- {case value="datetime"}
- <!-- 日期和时间 start -->
- <dl class="row">
- <dt class="tit">
- <label>{if condition="isset($vo['ifrequire']) AND !empty($vo['ifrequire'])"}<em>*</em>{/if}{$vo.title|default=''}</label>
- </dt>
- <dd class="opt">
- <input type="text" class="input-txt" name="{$vo.fieldArr}[{$vo.name|default=''}]" id="{$vo.fieldArr}_{$vo.name|default=''}" value="{$vo['dfvalue']}" autocomplete="off">
- <span class="add-on input-group-addon">
- <i class="glyphicon glyphicon-calendar fa fa-calendar"></i>
- </span>
- <span class="err"></span>
- <p class="notic">{$vo.remark|default=''}</p>
- </dd>
- </dl>
- <script type="text/javascript">
- layui.use('laydate', function() {
- var laydate = layui.laydate;
-
- //常规用法
- laydate.render({
- elem: "#{$vo.fieldArr}_{$vo.name|default=''}"
- ,type: 'datetime'
- });
- })
- </script>
- <!-- 日期和时间 end -->
- {/case}
-
- {case value="htmltext"}
- <!-- HTML文本 start -->
- {eq name="$editor.editor_select" value="1"}
- <dl class="row">
- <dt class="tit">
- <label>{if condition="isset($vo['ifrequire']) AND !empty($vo['ifrequire'])"}<em>*</em>{/if}{$vo.title|default=''}</label>
- </dt>
- <dd class="opt">
- {if condition="isset($vo['first']) AND 1 == $vo['first']"}
- <label class="curpoin"><input type="checkbox" id="editor_remote_img_local" data-val="{$vo.editor.editor_remote_img_local}" {eq name="$vo.editor.editor_remote_img_local" value="1"} checked {/eq}>远程图片本地化</label> <a href="javascript:void(0);" onclick="editor_handle_210607(1);">[手动]</a>
-
- <label class="curpoin"><input type="checkbox" id="editor_img_clear_link" data-val="{$vo.editor.editor_img_clear_link}" {eq name="$vo.editor.editor_img_clear_link" value="1"} checked {/eq}>清除非本站链接</label> <a href="javascript:void(0);" onclick="editor_handle_210607(2);">[手动]</a>
- {/if}
- <textarea class="span12 ckeditor" id="{$vo.fieldArr}_{$vo.name|default=''}" data-func="{$vo.fieldArr}_{$vo.name|default=''}" name="{$vo.fieldArr}[{$vo.name|default=''}]" title="">{$vo.dfvalue|default=''}</textarea>
- <span class="err"></span>
- <p class="notic">{$vo.remark|default=''}</p>
- </dd>
- </dl>
-
- {if condition="isset($vo['first']) AND 1 == $vo['first']"}
- <script type="text/javascript">
- // 打开多图选择及上传界面
- function OpenImagesList(e, obj) {
- var func = '';
- if (e.path && e.path[10] && e.path[10].id && undefined != e.path[10].id) {
- func = e.path[10].id;
- } else {
- func = $(obj).parent().parent().parent().parent().parent().parent().parent().parent().parent().attr('id');
- }
- if (func.indexOf('addonFieldExt_') == -1) {
- func = 'addonFieldExt_content';
- }
- var OpenUrl = "{:url('Uploadimgnew/upload', ['num'=>30, 'path'=>'allimg', 'is_water'=>1])}";
- OpenUrl += "&func=images_call_" + func;
- top.layer.open({
- type: 2,
- title: '图片上传',
- maxmin: false,
- shadeClose: false,
- area: ['1000px', '625px'],
- content: OpenUrl
- });
- }
- </script>
- {/if}
-
- <script type="text/javascript">
- var ue_{$vo.fieldArr}_{$vo.name|default=''} = UE.getEditor('{$vo.fieldArr}_{$vo.name|default=''}',{
- serverUrl :"{:url('Ueditor/index',array('savepath'=>'allimg'))}",
- zIndex: 999,
- initialFrameWidth: "100%", //初化宽度
- initialFrameHeight: 450, //初化高度
- focus: false, //初始化时,是否让编辑器获得焦点true或false
- maximumWords: 99999,
- removeFormatAttributes: 'class,style,lang,width,height,align,hspace,valign',//允许的最大字符数 'fullscreen',
- pasteplain:false, //是否默认为纯文本粘贴。false为不使用纯文本粘贴,true为使用纯文本粘贴
- autoHeightEnabled: false,
- toolbars: ueditor_toolbars
- });
-
- //必须在提交前渲染编辑器;
- function {$vo.fieldArr}_{$vo.name|default=''}() {
- //判断编辑模式状态:0表示【源代码】HTML视图;1是【设计】视图,即可见即所得;-1表示不可用
- if(UE.getEditor("{$vo.fieldArr}_{$vo.name|default=''}").queryCommandState('source') != 0) {
- UE.getEditor("{$vo.fieldArr}_{$vo.name|default=''}").execCommand('source'); //切换到【设计】视图
- }
- }
-
- // 加载图片到编辑器指定位置
- function images_call_{$vo.fieldArr}_{$vo.name|default=''}(fileurl_tmp) {
- var addBody = '';
- $.each(fileurl_tmp, function(index, items) {
- addBody += '<p><img src="'+items+'"></p>';
- });
- UE.getEditor("{$vo.fieldArr}_{$vo.name|default=''}").execCommand('inserthtml', addBody);
- }
-
- // 自动远程图片本地化/自动清除非本站链接
- function ajax_auto_editor_{$vo.fieldArr}_{$vo.name|default=''}(local,link) {
- var body = UE.getEditor("{$vo.fieldArr}_{$vo.name|default=''}").getContent();
- $.ajax({
- type: 'POST',
- url: "{:url('Archives/ajax_auto_editor')}",
- data: {local:local,link:link,body:body,_ajax:1},
- dataType: "JSON",
- async:false,
- success: function(res){
- if (res.code == 1) {
- UE.getEditor("{$vo.fieldArr}_{$vo.name|default=''}").setContent(res.data.body);
- }
- }
- });
- }
- </script>
- {else/}
- <dl class="row">
- <dt class="tit">
- <label>{if condition="isset($vo['ifrequire']) AND !empty($vo['ifrequire'])"}<em>*</em>{/if}{$vo.title|default=''}</label>
- </dt>
- <dd class="opt">
- {if condition="isset($vo['first']) AND 1 == $vo['first']"}
- <label class="curpoin"><input type="checkbox" id="editor_remote_img_local" data-val="{$vo.editor.editor_remote_img_local}" {eq name="$vo.editor.editor_remote_img_local" value="1"} checked {/eq} >远程图片本地化</label> <a href="javascript:void(0);" onclick="editor_handle_210607(1);">[手动]</a>
-
- <label class="curpoin"><input type="checkbox" id="editor_img_clear_link" data-val="{$vo.editor.editor_img_clear_link}" {eq name="$vo.editor.editor_img_clear_link" value="1"} checked {/eq} >清除非本站链接</label> <a href="javascript:void(0);" onclick="editor_handle_210607(2);">[手动]</a>
- {/if}
- <textarea id="{$vo.fieldArr}_{$vo.name|default=''}" name="{$vo.fieldArr}[{$vo.name|default=''}]">{$vo.dfvalue|default=''}</textarea>
- <span class="err"></span>
- <p class="notic">{$vo.remark|default=''}</p>
- </dd>
- </dl>
- <script type="text/javascript">
- // 加载编辑器,若存在编辑器则先进行销毁
- try {
- var elemtid = "{$vo.fieldArr}_{$vo.name|default=''}";
- var editor = CKEDITOR.instances[elemtid];
- if (editor) editor.destroy(true);
- } catch(e) {}
-
- CKEDITOR.replace(elemtid, {
- filebrowserBrowseUrl: "{:url('Ueditor/index', ['savepath'=>'allimg', 'action'=>'uploadimage'])}",
- filebrowserImageBrowseUrl: "{:url('Ueditor/index', ['savepath'=>'allimg', 'action'=>'uploadimage'])}",
- filebrowserUploadUrl: "{:url('Ueditor/index', ['savepath'=>'allimg', 'action'=>'uploadimage'])}",
- filebrowserImageUploadUrl: "{:url('Ueditor/index', ['savepath'=>'allimg', 'action'=>'uploadimage'])}",
- });
-
- // 自动远程图片本地化/自动清除非本站链接
- function ajax_auto_editor_{$vo.fieldArr}_{$vo.name|default=''}(local,link) {
- var body = CKEDITOR.instances.{$vo.fieldArr}_{$vo.name|default=''}.getData();
- $.ajax({
- type: 'POST',
- url: "{:url('Archives/ajax_auto_editor')}",
- data: {local:local,link:link,body:body,_ajax:1},
- dataType: "JSON",
- async:false,
- success: function(res){
- if (res.code == 1) {
- CKEDITOR.instances.{$vo.fieldArr}_{$vo.name|default=''}.setData(res.data.body);
- }
- }
- });
- }
-
- </script>
- {/eq}
- <!-- HTML文本 end -->
- {/case}
-
- <!-- 多媒体类型 start -->
- {case value="media"}
- <dl class="row">
- <dt class="tit">
- <label>{if condition="isset($vo['ifrequire']) AND !empty($vo['ifrequire'])"}<em>*</em>{/if}{$vo.title|default=''}</label>
- </dt>
- <dd class="opt">
- <input type="text" class="input-txt" id="{$vo.fieldArr}_{$vo.name|default=''}_media_url" name="{$vo.fieldArr}[{$vo.name|default=''}]" value="{$vo.dfvalue|default=''}" style="width: 400px !important;" >
- <input type="file" id="{$vo.fieldArr}_{$vo.name|default=''}_upload_media" onchange="{$vo.fieldArr}_{$vo.name|default=''}_upload_media_20210408(this)" style="display: none;">
- {if condition='qny == $vo.upload_flag'}
- <button type="button" class="layui-btn" id="{$vo.fieldArr}_{$vo.name|default=''}_qny_upload_media" onclick="$('#{$vo.fieldArr}_{$vo.name|default=\'\'}_upload_media').attr('data-type', 'qny').trigger('click');">七牛云上传</button>
- {elseif condition='oss == $vo.upload_flag'}
- <button type="button" class="layui-btn" id="{$vo.fieldArr}_{$vo.name|default=''}_oss_upload_media" onclick="$('#{$vo.fieldArr}_{$vo.name|default=\'\'}_upload_media').attr('data-type', 'oss').trigger('click');">oss上传</button>
- {elseif condition='cos == $vo.upload_flag'}
- <button type="button" class="layui-btn" id="{$vo.fieldArr}_{$vo.name|default=''}_cos_upload_media" onclick="$('#{$vo.fieldArr}_{$vo.name|default=\'\'}_upload_media').attr('data-type', 'cos').trigger('click');">cos上传</button>
- {else}
- <button type="button" class="layui-btn" id="{$vo.fieldArr}_{$vo.name|default=''}_local_upload_media" onclick="$('#{$vo.fieldArr}_{$vo.name|default=\'\'}_upload_media').attr('data-type', 'local').trigger('click');">本地上传</button>
- {/if}
- <span class="err"></span>
- <p class="notic">{$vo.remark|default=''}</p>
- </dd>
- </dl>
- <script>
- // 上传媒体文件
- function {$vo.fieldArr}_{$vo.name|default=''}_upload_media_20210408(e){
- var data_type = $(e).attr('data-type');
- if ('qny' == data_type) {
- // 七牛云上传
- {$vo.fieldArr}_{$vo.name|default=''}_qny_upload_media(e);
- } else if ('oss' == data_type) {
- // OSS上传
- {$vo.fieldArr}_{$vo.name|default=''}_oss_upload_media(e);
- } else if ('cos' == data_type) {
- // COS上传
- {$vo.fieldArr}_{$vo.name|default=''}_cos_upload_media(e);
- } else {
- // 本地上传
- {$vo.fieldArr}_{$vo.name|default=''}_local_upload_media(e);
- }
- }
- function judgeExtMedia(ext) {
- var type = '{$vo.ext}';
- var extArr = [];
- extArr = type.split("|");
- var exts = ext.replace(".","");
- return extArr.indexOf(exts);
- }
-
- // 七牛云
- function {$vo.fieldArr}_{$vo.name|default=''}_qny_upload_media(e) {
- // 获取文件路径名
- var file = $(e)[0].files[0];
-
- // 验证上传格式
- var fileName = file.name;
- var fileExt = fileName.substr(fileName.lastIndexOf('.')).toLowerCase();
- var ext = judgeExtMedia(fileExt);
- if (ext == -1) {
- showErrorMsg('仅支持{$vo.ext}格式,可在附件设置中修改');
- return false;
- }
-
- // 验证上传大小
- size = parseInt("{$vo.filesize}");
- if (file.size > size) {
- showErrorMsg('文件大小超过限制,可在附件设置中修改');
- return false;
- }
-
- // 执行上传
- layer_loading('上传七牛云');
- $.ajax({
- type: 'POST',
- url: '__ROOT_DIR__/index.php?m=plugins&c=Qiniuyun&a=qiniu_upload',
- data: {_ajax: 1},
- dataType: "JSON",
- success: function(res1) {
- if (1 == res1.code) {
- var token = res1.data.token;
- var formData = new FormData();
- formData.append('file', file);
- formData.append('token', token);
-
- fileName = res1.data.filePath + fileExt;
- formData.append('key', fileName);
- $.ajax({
- url: res1.data.uphost,
- type: 'POST',
- dataType: 'JSON',
- data: formData,
- timeout: 1200000,
- cache: false,
- processData: false,
- contentType: false,
- xhr: function () {
- myXhr = $.ajaxSettings.xhr();
- if (myXhr.upload) {
- myXhr.upload.addEventListener('progress', function(e){
- var curr = e.loaded;
- var total = e.total;
- process = parseInt(curr / total * 100);
- $("#{$vo.fieldArr}_{$vo.name|default=''}_qny_upload_media").text('上传中...'+process+"%");
- });
- }
- return myXhr;
- },
- success: function(res2) {
- layer.closeAll();
- $("#{$vo.fieldArr}_{$vo.name|default=''}_qny_upload_media").text('上传成功');
- setTimeout(function() {
- $('#{$vo.fieldArr}_{$vo.name|default=\'\'}_qny_upload_media').text('七牛云上传');
- }, 2000);
- var video_url = res1.data.domain + "/" + res2.key;
- $("#{$vo.fieldArr}_{$vo.name|default=''}_media_url").val(video_url);
- },
- error: function(e) {
- layer.closeAll();
- showErrorMsg(e.responseText);
- return false;
- }
- });
- } else {
- layer.closeAll();
- showErrorMsg(res1.msg);
- }
- },
- error: function(e) {
- layer.closeAll();
- showErrorMsg(e.responseText);
- }
- });
- }
-
- //OSS
- function {$vo.fieldArr}_{$vo.name|default=''}_oss_upload_media(e) {
- // 获取文件路径名
- var file = $(e)[0].files[0];
-
- // 验证上传格式
- var fileName = file.name;
- var fileExt = fileName.substr(fileName.lastIndexOf('.')).toLowerCase();
- var ext = judgeExtMedia(fileExt);
- if (ext == -1) {
- showErrorMsg('仅支持{$vo.ext}格式,可在附件设置中修改');
- return false;
- }
-
- // 验证上传大小
- size = parseInt("{$vo.filesize}");
- if (file.size > size) {
- showErrorMsg('文件大小超过限制,可在附件设置中修改');
- return false;
- }
-
- // 执行上传
- layer_loading('上传阿里云OSS');
- $.ajax({
- type: 'POST',
- url: '__ROOT_DIR__/index.php?m=plugins&c=AliyunOss&a=oss_upload',
- data: {_ajax: 1},
- dataType: "JSON",
- success: function(res1){
- if (1 == res1.code){
- fileName = res1.data.filePath + fileExt;
- //组装发送数据
- var request = new FormData();
- request.append("OSSAccessKeyId",res1.data.accessid);
- request.append("policy",res1.data.policy);
- request.append("Signature",res1.data.signature);
- request.append("key",fileName);
- request.append("success_action_status",201);
- request.append('file', file);
-
- $.ajax({
- url : res1.data.host,
- data : request,
- processData: false,
- cache: false,
- contentType: false,
- dataType: 'xml',
- type : 'post',
- xhr: function () {
- myXhr = $.ajaxSettings.xhr();
- if (myXhr.upload) {
- myXhr.upload.addEventListener('progress', function(e){
- var curr = e.loaded;
- var total = e.total;
- var process = parseInt(curr / total * 100);
- $("#{$vo.fieldArr}_{$vo.name|default=''}_oss_upload_media").text('上传中...'+process+"%");
- });
- }
- return myXhr;
- },
- success : function(data) {
- layer.closeAll();
- var res = $(data).find('PostResponse');
- if (res) {
- var key = res.find('Key').text();
- $("#{$vo.fieldArr}_{$vo.name|default=''}_oss_upload_media").text('上传成功');
- setTimeout(function() {
- $('#{$vo.fieldArr}_{$vo.name|default=\'\'}_oss_upload_media').text('oss上传');
- }, 2000);
- var video_url = res1.data.domain + "/" + key;
- $("#{$vo.fieldArr}_{$vo.name|default=''}_media_url").val(video_url);
- } else {
- $("#{$vo.fieldArr}_{$vo.name|default=''}_oss_upload_media").text('上传失败');
- setTimeout(function() {
- $('#{$vo.fieldArr}_{$vo.name|default=\'\'}_oss_upload_media').text('oss上传');
- }, 2000);
- }
- },
- error : function(e) {
- layer.closeAll();
- console.log(e.responseText);
- }
- });
- } else {
- layer.closeAll();
- showErrorMsg(res1.msg);
- }
- },
- error: function(e) {
- layer.closeAll();
- showErrorMsg(e.responseText);
- }
- });
- }
-
- //COS
- function {$vo.fieldArr}_{$vo.name|default=''}_cos_upload_media(e) {
- // 获取文件路径名
- var file = $(e)[0].files[0];
-
- // 验证上传格式
- var fileName = file.name;
- var fileExt = fileName.substr(fileName.lastIndexOf('.')).toLowerCase();
- var ext = judgeExtMedia(fileExt);
- if (ext == -1) {
- showErrorMsg('仅支持{$vo.ext}格式,可在附件设置中修改');
- return false;
- }
-
- // 验证上传大小
- size = parseInt("{$vo.filesize}");
- if (file.size > size) {
- showErrorMsg('文件大小超过限制,可在附件设置中修改');
- return false;
- }
-
- // 上传参数
- var formData = new FormData();
- formData.append('file', file);
- formData.append('file_ext', fileExt);
-
- // 执行上传
- $.ajax({
- type: 'post',
- url: '__ROOT_DIR__/index.php?m=plugins&c=Cos&a=cos_upload&_ajax=1',
- data: formData,
- contentType: false,
- processData: false,
- dataType: 'json',
- xhr: function () {
- myXhr = $.ajaxSettings.xhr();
- if (myXhr.upload) {
- myXhr.upload.addEventListener('progress', function(e){
- var curr = e.loaded;
- var total = e.total;
- process = parseInt(curr / total * 100);
- if (100 == process) {
- process = 99;
- layer_loading('上传腾讯云');
- }
- $("#{$vo.fieldArr}_{$vo.name|default=''}_cos_upload_media").text('上传中...'+process+"%");
- });
- }
- return myXhr;
- },
- success: function(res) {
- layer.closeAll();
- if (1 == res.code) {
- $("#{$vo.fieldArr}_{$vo.name|default=''}_cos_upload_media").text('上传成功');
- $("#{$vo.fieldArr}_{$vo.name|default=''}_media_url").val(res.data.url);
- } else {
- $("#{$vo.fieldArr}_{$vo.name|default=''}_cos_upload_media").text('上传失败');
- }
- setTimeout(function() {
- $('#{$vo.fieldArr}_{$vo.name|default=\'\'}_cos_upload_media').text('cos上传');
- }, 2000);
- },
- error: function(e) {
- layer.closeAll();
- showErrorMsg(e.responseText);
- }
- });
- }
-
- // 本地上传
- function {$vo.fieldArr}_{$vo.name|default=''}_local_upload_media(e){
- // 获取文件路径名
- var file = $(e)[0].files[0];
-
- // 验证上传格式
- var fileName = file.name;
- var fileExt = fileName.substr(fileName.lastIndexOf('.')).toLowerCase();
- var ext = judgeExtMedia(fileExt);
- if (ext == -1) {
- showErrorMsg('仅支持{$vo.ext}格式,可在附件设置中修改');
- return false;
- }
-
- // 验证上传大小
- size = parseInt("{$vo.filesize}");
- if (file.size > size) {
- showErrorMsg('文件大小超过限制,可在附件设置中修改');
- return false;
- }
-
- // 定义上传数据
- var formData = new FormData();
- formData.append('file', file);
-
- // 执行上传
- layer_loading('上传本地');
- $.ajax({
- type: 'post',
- url : "{:url('Ueditor/upVideo', ['savepath'=>'media'])}",
- data: formData,
- contentType: false,
- processData: false,
- dataType: 'json',
- xhr: function () {
- myXhr = $.ajaxSettings.xhr();
- if (myXhr.upload) {
- myXhr.upload.addEventListener('progress', function(e){
- var curr = e.loaded;
- var total = e.total;
- process = parseInt(curr / total * 100);
- $("#upload_video_litpic_local").html('上传中...'+process+"%");
- });
- }
- return myXhr;
- },
- success: function (res) {
- layer.closeAll();
- if ("SUCCESS" == res.state) {
- $("#{$vo.fieldArr}_{$vo.name|default=''}_local_upload_media").html('上传成功');
- setTimeout(function() {
- $('#{$vo.fieldArr}_{$vo.name|default=\'\'}_local_upload_media').html('本地上传');
- }, 2000);
- $("#{$vo.fieldArr}_{$vo.name|default=''}_media_url").val(res.url);
- } else {
- showErrorMsg(res.msg);
- }
- }
- });
- }
- </script>
- {/case}
- <!-- 多媒体类型 end -->
- {/switch}
- {/if}
- {/volist}
-
- <script>
- $(function(){
- auto_notic_tips();
- /**
- * 自动小提示
- */
- function auto_notic_tips()
- {
- var html = '<a class="ui_tips" href="javascript:void(0);" onmouseover="layer_tips = layer.tips($(this).parent().find(\'p.notic\').html(), this, {time:100000});" onmouseout="layer.close(layer_tips);">提示</a>';
- $.each($('dd.opt > p.notic'), function(index, item){
- var a_length = $(item).prev("a.ui_tips").length;
- if ($(item).html() != '' && 0 == a_length) {
- $(item).before(html);
- }
- });
- }
- });
- </script>
|