Açıklama Yok
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

modelfield.htm 77KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312
  1. <!-- 已作废 -->
  2. <!-- 用户自定义扩展模板文件 -->
  3. {include file="diy_extend/archives_extend" /}
  4. <!-- end -->
  5. {volist name="$addonFieldExtList" id="vo"}
  6. {if isset($vo.ifeditable) && $vo.ifeditable == 1}
  7. {switch name="vo.dtype"}
  8. {case value="hidden"}
  9. <!-- 隐藏域 start -->
  10. <dl class="row" style="display: none;">
  11. <dt class="tit">
  12. <label>{if condition="isset($vo['ifrequire']) AND !empty($vo['ifrequire'])"}<em>*</em>{/if}{$vo.title|default=''}</label>
  13. </dt>
  14. <dd class="opt">
  15. <input type="hidden" class="input-txt" id="{$vo.fieldArr}_{$vo.name|default=''}" name="{$vo.fieldArr}[{$vo.name|default=''}]" value="{$vo.dfvalue|default=''}">
  16. <span class="err"></span>
  17. <p class="notic">{$vo.remark|default=''}</p>
  18. </dd>
  19. </dl>
  20. <!-- 隐藏域 start -->
  21. {/case}
  22. {case value="region"}
  23. <!-- 区域选项 start -->
  24. <dl class="row">
  25. <dt class="tit">
  26. <label>{if condition="isset($vo['ifrequire']) AND !empty($vo['ifrequire'])"}<em>*</em>{/if}{$vo.title|default=''}</label>
  27. </dt>
  28. <dd class="opt">
  29. {volist name="$vo.dfvalue" id="v2"}
  30. <label>
  31. <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']}
  32. </label>&nbsp;
  33. {/volist}
  34. <span class="err"></span>
  35. <p class="notic">{$vo.remark|default=''}</p>
  36. </dd>
  37. </dl>
  38. <!-- 区域选项 end -->
  39. {/case}
  40. {case value="text"}
  41. <!-- 单行文本框 start -->
  42. <dl class="row">
  43. <dt class="tit">
  44. <label>{if condition="isset($vo['ifrequire']) AND !empty($vo['ifrequire'])"}<em>*</em>{/if}{$vo.title|default=''}</label>
  45. </dt>
  46. <dd class="opt">
  47. <input type="text" class="input-txt" id="{$vo.fieldArr}_{$vo.name|default=''}" name="{$vo.fieldArr}[{$vo.name|default=''}]" value="{$vo.dfvalue|default=''}">&nbsp;{$vo.dfvalue_unit|default=''}
  48. <span class="err"></span>
  49. <p class="notic">{$vo.remark|default=''}</p>
  50. </dd>
  51. </dl>
  52. <!-- 单行文本框 end -->
  53. {/case}
  54. {case value="multitext"}
  55. <!-- 多行文本框 start -->
  56. <dl class="row">
  57. <dt class="tit">
  58. <label>{if condition="isset($vo['ifrequire']) AND !empty($vo['ifrequire'])"}<em>*</em>{/if}{$vo.title|default=''}</label>
  59. </dt>
  60. <dd class="opt">
  61. <textarea rows="5" cols="60" id="{$vo.fieldArr}_{$vo.name|default=''}" name="{$vo.fieldArr}[{$vo.name|default=''}]" style="height:60px;">{$vo.dfvalue|default=''}</textarea>
  62. <span class="err"></span>
  63. <p class="notic">{$vo.remark|default=''}</p>
  64. </dd>
  65. </dl>
  66. <!-- 多行文本框 end -->
  67. {/case}
  68. {case value="checkbox"}
  69. <!-- 复选框 start -->
  70. <dl class="row">
  71. <dt class="tit">
  72. <label>{if condition="isset($vo['ifrequire']) AND !empty($vo['ifrequire'])"}<em>*</em>{/if}{$vo.title|default=''}</label>
  73. </dt>
  74. <dd class="opt">
  75. {volist name="$vo.dfvalue" id="v2"}
  76. <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>&nbsp;
  77. {/volist}
  78. <input type="hidden" name="{$vo.fieldArr}[{$vo.name}_eyempty]" value="{if condition="!empty($vo['trueValue'])"}1{else /}0{/if}">
  79. <span class="err"></span>
  80. <p class="notic">{$vo.remark|default=''}</p>
  81. </dd>
  82. </dl>
  83. <script type="text/javascript">
  84. function func_{$vo.name}_eyempty()
  85. {
  86. var len = $("input[name='{$vo.fieldArr}[{$vo.name}][]']:checked").length;
  87. $("input[name='{$vo.fieldArr}[{$vo.name}_eyempty]']").val(len);
  88. }
  89. </script>
  90. <!-- 复选框 end -->
  91. {/case}
  92. {case value="radio"}
  93. <!-- 单选项 start -->
  94. <dl class="row">
  95. <dt class="tit">
  96. <label>{if condition="isset($vo['ifrequire']) AND !empty($vo['ifrequire'])"}<em>*</em>{/if}{$vo.title|default=''}</label>
  97. </dt>
  98. <dd class="opt">
  99. {volist name="$vo.dfvalue" id="v2"}
  100. <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>&nbsp;
  101. {/volist}
  102. <span class="err"></span>
  103. <p class="notic">{$vo.remark|default=''}</p>
  104. </dd>
  105. </dl>
  106. <!-- 单选项 end -->
  107. {/case}
  108. {case value="switch"}
  109. <!-- 开关 start -->
  110. <dl class="row">
  111. <dt class="tit">
  112. <label>{if condition="isset($vo['ifrequire']) AND !empty($vo['ifrequire'])"}<em>*</em>{/if}{$vo.title|default=''}</label>
  113. </dt>
  114. <dd class="opt">
  115. <div class="onoff">
  116. <label for="{$vo.fieldArr}_{$vo.name|default=''}1" class="cb-enable {if condition="0 != $vo['dfvalue']"}selected{/if}">是</label>
  117. <label for="{$vo.fieldArr}_{$vo.name|default=''}0" class="cb-disable {if condition="0 == $vo['dfvalue']"}selected{/if}">否</label>
  118. <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}>
  119. <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}>
  120. </div>
  121. <span class="err"></span>
  122. <p class="notic">{$vo.remark|default=''}</p>
  123. </dd>
  124. </dl>
  125. <script type="text/javascript">
  126. $(function(){
  127. //自定义radio样式
  128. $(".cb-enable").on('click', function(){
  129. var parent = $(this).parents('.onoff');
  130. $('.cb-disable',parent).removeClass('selected');
  131. $(this).addClass('selected');
  132. $('.checkbox',parent).attr('checked', true);
  133. });
  134. $(".cb-disable").on('click', function(){
  135. var parent = $(this).parents('.onoff');
  136. $('.cb-enable',parent).removeClass('selected');
  137. $(this).addClass('selected');
  138. $('.checkbox',parent).attr('checked', false);
  139. });
  140. });
  141. </script>
  142. <!-- 开关 end -->
  143. {/case}
  144. {case value="select"}
  145. <!-- 下拉框 start -->
  146. <dl class="row">
  147. <dt class="tit">
  148. <label>{if condition="isset($vo['ifrequire']) AND !empty($vo['ifrequire'])"}<em>*</em>{/if}{$vo.title|default=''}</label>
  149. </dt>
  150. <dd class="opt">
  151. <select name="{$vo.fieldArr}[{$vo.name|default=''}]" id="{$vo.fieldArr}_{$vo.name|default=''}">
  152. {volist name="$vo.dfvalue" id="v2"}
  153. <option value="{$v2}" {if condition="isset($vo['trueValue']) AND in_array($v2, $vo['trueValue'])"}selected{/if}>{$v2}</option>
  154. {/volist}
  155. </select>
  156. <span class="err"></span>
  157. <p class="notic">{$vo.remark|default=''}</p>
  158. </dd>
  159. </dl>
  160. <!-- 下拉框 end -->
  161. {/case}
  162. {case value="img"}
  163. <!-- 单张图 start -->
  164. <dl class="row">
  165. <dt class="tit">
  166. <label>{if condition="isset($vo['ifrequire']) AND !empty($vo['ifrequire'])"}<em>*</em>{/if}{$vo.title|default=''}</label>
  167. </dt>
  168. <dd class="opt">
  169. <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}>
  170. <span class="show">
  171. <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);'}">
  172. <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>
  173. </a>
  174. </span>
  175. <span class="type-file-box">
  176. <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">
  177. <input type="button" name="button" id="button1" value="选择上传..." class="type-file-button">
  178. <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=''}"
  179. title="点击前方预览图可查看大图,点击按钮选择文件并提交表单后上传生效">
  180. </span>
  181. </div>
  182. <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}>
  183. &nbsp;
  184. <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>
  185. <span class="err"></span>
  186. <p class="notic">{$vo.remark|default=''}</p>
  187. </dd>
  188. </dl>
  189. <script type="text/javascript">
  190. function {$vo.fieldArr}_{$vo.name|default=''}_call_back(fileurl_tmp)
  191. {
  192. $("#{$vo.fieldArr}_{$vo.name|default=''}_eyou_local").val(fileurl_tmp);
  193. $("#img_a_{$vo.fieldArr}_{$vo.name|default=''}").attr('href', fileurl_tmp);
  194. $("#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']});");
  195. }
  196. </script>
  197. <!-- 单张图 end -->
  198. {/case}
  199. {case value="file"}
  200. <!-- 单个文件 start -->
  201. <dl class="row">
  202. <dt class="tit">
  203. <label>{if condition="isset($vo['ifrequire']) AND !empty($vo['ifrequire'])"}<em>*</em>{/if}{$vo.title|default=''}</label>
  204. </dt>
  205. <dd class="opt">
  206. <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}>
  207. <span class="show">
  208. <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=###}">
  209. <i id="file_i_{$vo.fieldArr}_{$vo.name|default=''}" class="layui-icon layui-icon-file-b" ></i>
  210. </a>
  211. </span>
  212. <span class="type-file-box">
  213. <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">
  214. <input type="button" name="button" id="{$vo.fieldArr}_{$vo.name|default=''}_button" value="选择上传..." class="type-file-button">
  215. <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=''}">
  216. </span>
  217. </div>
  218. <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}>
  219. &nbsp;
  220. <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>
  221. <span class="err"></span>
  222. <p class="notic">{$vo.remark|default=''}</p>
  223. </dd>
  224. </dl>
  225. <script type="text/javascript">
  226. function upload_file_{$vo.fieldArr}_{$vo.name|default=''}_1585641737(e){
  227. var data_type = $(e).attr('data-type');
  228. if ('qny' == data_type) {
  229. // 七牛云上传
  230. {$vo.fieldArr}_{$vo.name|default=''}_qny_file(e);
  231. } else if ('oss' == data_type) {
  232. // OSS上传
  233. {$vo.fieldArr}_{$vo.name|default=''}_oss_file(e);
  234. } else if ('cos' == data_type) {
  235. // COS上传
  236. {$vo.fieldArr}_{$vo.name|default=''}_cos_file(e);
  237. } else {
  238. // 本地上传
  239. {$vo.fieldArr}_{$vo.name|default=''}_local_file(e);
  240. }
  241. }
  242. function judgeExtFile(ext) {
  243. var type = '{$vo.ext}';
  244. var extArr = [];
  245. extArr = type.split("|");
  246. var exts = ext.replace(".","");
  247. return extArr.indexOf(exts);
  248. }
  249. // 七牛云
  250. function {$vo.fieldArr}_{$vo.name|default=''}_qny_file(e) {
  251. // 获取文件路径名
  252. var file = $(e)[0].files[0];
  253. // 验证上传格式
  254. var fileName = file.name;
  255. var fileExt = fileName.substr(fileName.lastIndexOf('.')).toLowerCase();
  256. var ext = judgeExtFile(fileExt);
  257. if (ext == -1) {
  258. showErrorMsg('仅支持{$vo.ext}格式,可在附件设置中修改');
  259. return false;
  260. }
  261. // 验证上传大小
  262. size = parseInt("{$vo.filesize}");
  263. if (file.size > size) {
  264. showErrorMsg('附件大小超过限制,可在附件设置中修改');
  265. return false;
  266. }
  267. // 执行上传
  268. layer_loading('上传七牛云');
  269. $.ajax({
  270. type: 'POST',
  271. url: '__ROOT_DIR__/index.php?m=plugins&c=Qiniuyun&a=qiniu_upload',
  272. data: {_ajax: 1},
  273. dataType: "JSON",
  274. success: function(res1) {
  275. if (1 == res1.code) {
  276. var token = res1.data.token;
  277. var formData = new FormData();
  278. formData.append('file', file);
  279. formData.append('token', token);
  280. fileName = res1.data.filePath + fileExt;
  281. formData.append('key', fileName);
  282. $.ajax({
  283. url: res1.data.uphost,
  284. type: 'POST',
  285. dataType: 'JSON',
  286. data: formData,
  287. timeout: 1200000,
  288. cache: false,
  289. processData: false,
  290. contentType: false,
  291. xhr: function () {
  292. myXhr = $.ajaxSettings.xhr();
  293. if (myXhr.upload) {
  294. myXhr.upload.addEventListener('progress', function(e){
  295. var curr = e.loaded;
  296. var total = e.total;
  297. process = parseInt(curr / total * 100);
  298. $("#{$vo.fieldArr}_{$vo.name|default=''}_button").text('上传中...'+process+"%");
  299. });
  300. }
  301. return myXhr;
  302. },
  303. success: function(res2) {
  304. layer.closeAll();
  305. $("#{$vo.fieldArr}_{$vo.name|default=''}_button").text('上传成功');
  306. setTimeout(function() {
  307. $('#{$vo.fieldArr}_{$vo.name|default=\'\'}_button').text('选择上传...');
  308. }, 2000);
  309. var video_url = res1.data.domain + "/" + res2.key;
  310. $("#{$vo.fieldArr}_{$vo.name|default=''}_eyou_local").val(video_url);
  311. $("#file_a_{$vo.fieldArr}_{$vo.name|default=''}").attr('href',video_url);
  312. var arr = video_url.split("/");
  313. var download = arr[arr.length-1];
  314. $("#file_a_{$vo.fieldArr}_{$vo.name|default=''}").attr('download',download);
  315. },
  316. error: function(e) {
  317. layer.closeAll();
  318. showErrorMsg(e.responseText);
  319. return false;
  320. }
  321. });
  322. } else {
  323. layer.closeAll();
  324. showErrorMsg(res1.msg);
  325. }
  326. },
  327. error: function(e) {
  328. layer.closeAll();
  329. showErrorMsg(e.responseText);
  330. }
  331. });
  332. }
  333. //OSS
  334. function {$vo.fieldArr}_{$vo.name|default=''}_oss_file(e) {
  335. // 获取文件路径名
  336. var file = $(e)[0].files[0];
  337. // 验证上传格式
  338. var fileName = file.name;
  339. var fileExt = fileName.substr(fileName.lastIndexOf('.')).toLowerCase();
  340. var ext = judgeExtFile(fileExt);
  341. if (ext == -1) {
  342. showErrorMsg('仅支持{$vo.ext}格式,可在附件设置中修改');
  343. return false;
  344. }
  345. // 验证上传大小
  346. size = parseInt("{$vo.filesize}");
  347. if (file.size > size) {
  348. showErrorMsg('附件大小超过限制,可在附件设置中修改');
  349. return false;
  350. }
  351. // 执行上传
  352. layer_loading('上传阿里云OSS');
  353. $.ajax({
  354. type: 'POST',
  355. url: '__ROOT_DIR__/index.php?m=plugins&c=AliyunOss&a=oss_upload',
  356. data: {_ajax: 1},
  357. dataType: "JSON",
  358. success: function(res1){
  359. if (1 == res1.code){
  360. fileName = res1.data.filePath + fileExt;
  361. //组装发送数据
  362. var request = new FormData();
  363. request.append("OSSAccessKeyId",res1.data.accessid);
  364. request.append("policy",res1.data.policy);
  365. request.append("Signature",res1.data.signature);
  366. request.append("key",fileName);
  367. request.append("success_action_status",201);
  368. request.append('file', file);
  369. $.ajax({
  370. url : res1.data.host,
  371. data : request,
  372. processData: false,
  373. cache: false,
  374. contentType: false,
  375. dataType: 'xml',
  376. type : 'post',
  377. xhr: function () {
  378. myXhr = $.ajaxSettings.xhr();
  379. if (myXhr.upload) {
  380. myXhr.upload.addEventListener('progress', function(e){
  381. var curr = e.loaded;
  382. var total = e.total;
  383. var process = parseInt(curr / total * 100);
  384. $("#{$vo.fieldArr}_{$vo.name|default=''}_button").text('上传中...'+process+"%");
  385. });
  386. }
  387. return myXhr;
  388. },
  389. success : function(data) {
  390. layer.closeAll();
  391. var res = $(data).find('PostResponse');
  392. if (res) {
  393. var key = res.find('Key').text();
  394. $("#{$vo.fieldArr}_{$vo.name|default=''}_button").text('上传成功');
  395. setTimeout(function() {
  396. $("#{$vo.fieldArr}_{$vo.name|default=''}_button").text('选择上传...');
  397. }, 2000);
  398. var video_url = res1.data.domain + "/" + key;
  399. $("#{$vo.fieldArr}_{$vo.name|default=''}_eyou_local").val(video_url);
  400. $("#file_a_{$vo.fieldArr}_{$vo.name|default=''}").attr('href',video_url);
  401. var arr = video_url.split("/");
  402. var download = arr[arr.length-1];
  403. $("#file_a_{$vo.fieldArr}_{$vo.name|default=''}").attr('download',download);
  404. } else {
  405. $("#{$vo.fieldArr}_{$vo.name|default=''}_button").text('上传失败');
  406. setTimeout(function() {
  407. $("#{$vo.fieldArr}_{$vo.name|default=''}_button").text('选择上传...');
  408. }, 2000);
  409. }
  410. },
  411. error : function(e) {
  412. layer.closeAll();
  413. console.log(e.responseText);
  414. }
  415. });
  416. } else {
  417. layer.closeAll();
  418. showErrorMsg(res1.msg);
  419. }
  420. },
  421. error: function(e) {
  422. layer.closeAll();
  423. showErrorMsg(e.responseText);
  424. }
  425. });
  426. }
  427. //COS
  428. function {$vo.fieldArr}_{$vo.name|default=''}_cos_file(e) {
  429. // 获取文件路径名
  430. var file = $(e)[0].files[0];
  431. // 验证上传格式
  432. var fileName = file.name;
  433. var fileExt = fileName.substr(fileName.lastIndexOf('.')).toLowerCase();
  434. var ext = judgeExtFile(fileExt);
  435. if (ext == -1) {
  436. showErrorMsg('仅支持{$vo.ext}格式,可在附件设置中修改');
  437. return false;
  438. }
  439. // 验证上传大小
  440. size = parseInt("{$vo.filesize}");
  441. if (file.size > size) {
  442. showErrorMsg('附件大小超过限制,可在附件设置中修改');
  443. return false;
  444. }
  445. // 上传参数
  446. var formData = new FormData();
  447. formData.append('file', file);
  448. formData.append('file_ext', fileExt);
  449. // 执行上传
  450. $.ajax({
  451. type: 'post',
  452. url: '__ROOT_DIR__/index.php?m=plugins&c=Cos&a=cos_upload&_ajax=1',
  453. data: formData,
  454. contentType: false,
  455. processData: false,
  456. dataType: 'json',
  457. xhr: function () {
  458. myXhr = $.ajaxSettings.xhr();
  459. if (myXhr.upload) {
  460. myXhr.upload.addEventListener('progress', function(e){
  461. var curr = e.loaded;
  462. var total = e.total;
  463. process = parseInt(curr / total * 100);
  464. if (100 == process) {
  465. process = 99;
  466. layer_loading('上传腾讯云');
  467. }
  468. $("#{$vo.fieldArr}_{$vo.name|default=''}_cos_upload_media").text('上传中...'+process+"%");
  469. });
  470. }
  471. return myXhr;
  472. },
  473. success: function(res) {
  474. layer.closeAll();
  475. if (1 == res.code) {
  476. video_url = res.data.url;
  477. $("#{$vo.fieldArr}_{$vo.name|default=''}_eyou_local").val(video_url);
  478. $("#file_a_{$vo.fieldArr}_{$vo.name|default=''}").attr('href',video_url);
  479. var arr = video_url.split("/");
  480. var download = arr[arr.length-1];
  481. $("#file_a_{$vo.fieldArr}_{$vo.name|default=''}").attr('download',download);
  482. $("#{$vo.fieldArr}_{$vo.name|default=''}_button").text('上传成功');
  483. } else {
  484. $("#{$vo.fieldArr}_{$vo.name|default=''}_button").text('上传失败');
  485. }
  486. setTimeout(function() {
  487. $('#{$vo.fieldArr}_{$vo.name|default=\'\'}_button').text('选择上传...');
  488. }, 2000);
  489. },
  490. error: function(e) {
  491. layer.closeAll();
  492. showErrorMsg(e.responseText);
  493. }
  494. });
  495. }
  496. // 本地上传
  497. function {$vo.fieldArr}_{$vo.name|default=''}_local_file(e){
  498. // 获取文件路径名
  499. var file = $(e)[0].files[0];
  500. // 验证上传格式
  501. var fileName = file.name;
  502. var fileExt = fileName.substr(fileName.lastIndexOf('.')).toLowerCase();
  503. var ext = judgeExtFile(fileExt);
  504. if (ext == -1) {
  505. showErrorMsg('仅支持{$vo.ext}格式,可在附件设置中修改');
  506. return false;
  507. }
  508. // 验证上传大小
  509. size = parseInt("{$vo.filesize}");
  510. if (file.size > size) {
  511. showErrorMsg('附件大小超过限制,可在附件设置中修改');
  512. return false;
  513. }
  514. // 定义上传数据
  515. var formData = new FormData();
  516. formData.append('file', file);
  517. // 执行上传
  518. layer_loading('上传本地');
  519. $.ajax({
  520. type: 'post',
  521. url : "{:url('Ueditor/DownloadUploadFileAjax')}",
  522. data: formData,
  523. contentType: false,
  524. processData: false,
  525. dataType: 'json',
  526. xhr: function () {
  527. myXhr = $.ajaxSettings.xhr();
  528. if (myXhr.upload) {
  529. myXhr.upload.addEventListener('progress', function(e){
  530. var curr = e.loaded;
  531. var total = e.total;
  532. process = parseInt(curr / total * 100);
  533. $("#{$vo.fieldArr}_{$vo.name|default=''}_button").html('上传中...'+process+"%");
  534. });
  535. }
  536. return myXhr;
  537. },
  538. success: function (res) {
  539. layer.closeAll();
  540. if (res.code==0){
  541. layer.msg(res.msg)
  542. setTimeout(function() {
  543. $('#{$vo.fieldArr}_{$vo.name|default=\'\'}_button').html('选择上传...');
  544. }, 2000);
  545. }else {
  546. $("#{$vo.fieldArr}_{$vo.name|default=''}_button").html('上传成功');
  547. setTimeout(function() {
  548. $('#{$vo.fieldArr}_{$vo.name|default=\'\'}_button').html('选择上传...');
  549. }, 2000);
  550. $("#{$vo.fieldArr}_{$vo.name|default=''}_eyou_local").val(res.file_url);
  551. $("#file_a_{$vo.fieldArr}_{$vo.name|default=''}").attr('href',res.file_url);
  552. var arr = res.file_url.split("/");
  553. var download = arr[arr.length-1];
  554. $("#file_a_{$vo.fieldArr}_{$vo.name|default=''}").attr('download',download);
  555. }
  556. }
  557. });
  558. }
  559. </script>
  560. <!-- 单个文件 end -->
  561. {/case}
  562. {case value="imgs"}
  563. <!-- 多张图 start -->
  564. <dl class="row" id="dl_{$vo.fieldArr}_{$vo.name|default=''}">
  565. <dt class="tit">
  566. <label>{if condition="isset($vo['ifrequire']) AND !empty($vo['ifrequire'])"}<em>*</em>{/if}{$vo.title|default=''}</label>
  567. </dt>
  568. <dd class="opt">
  569. <div class="tab-pane pics" id="tab_{$vo.fieldArr}_{$vo.name|default=''}">
  570. <!-- <a href="javascript:void(0);" onClick="GetUploadify(100,'','allimg','{$vo.fieldArr}_{$vo.name|default=''}_call_back');" class="imgupload">
  571. <i class="fa fa-photo"></i>上传图片
  572. </a> -->
  573. <table class="table table-bordered">
  574. <tbody>
  575. <tr>
  576. <td >
  577. <div class="sort-list-{$vo.fieldArr}_{$vo.name|default=''}">
  578. {volist name="$vo[$vo['name'].'_eyou_imgupload_list']" id="v2" key="k2"}
  579. <div class="images_upload images_upload_html" style="display:inline-block;">
  580. <div style="position: relative; height: 130px;">
  581. <input type="hidden" name="{$vo.fieldArr}[{$vo.name|default=''}][]" value="{$v2['image_url']}">
  582. <a href="{$v2['image_url']}" onclick="" class="upimg" target="_blank" title="拖动修改排序">
  583. <img src="{$v2['image_url']}" width="136" height="136">
  584. </a>
  585. <a href="javascript:void(0)" onclick="{$vo.fieldArr}_{$vo.name|default=''}_ClearPicArr2(this,'{$v2['image_url']}')" class="delect" title="删除"></a>
  586. </div>
  587. <textarea rows="5" cols="60" name="{$vo.fieldArr}[{$vo.name|default=''}_eyou_intro][]" style="height:28px; width: 136px;" placeholder="图片注释">{$v2.intro}</textarea>
  588. </div>
  589. {/volist}
  590. <div class="images_upload"></div>
  591. </div>
  592. <a href="javascript:void(0);" onClick="GetUploadify(100,'','allimg','{$vo.fieldArr}_{$vo.name|default=''}_call_back');" class="img-upload mb15" title="点击上传">
  593. <div class="y-line"></div>
  594. <div class="x-line"></div>
  595. </a>
  596. </td>
  597. </tr>
  598. </tbody>
  599. </table>
  600. </div>
  601. <!-- 上传图片显示的样板 start -->
  602. <div class="{$vo.fieldArr}_{$vo.name|default=''}_upload_tpl none">
  603. <div class="images_upload images_upload_html" style="display:inline-block;">
  604. <div style="position: relative; height: 130px;">
  605. <input type="hidden" name="{$vo.fieldArr}[{$vo.name|default=''}][]" value="" />
  606. <a href="javascript:void(0);" onClick="" class="upimg" title="拖动修改排序">
  607. <img src="__STATIC__/admin/images/add-button.jpg" width="136" height="136" />
  608. </a>
  609. <a href="javascript:void(0)" class="delect" title="删除">&nbsp;&nbsp;</a>
  610. </div>
  611. <textarea rows="5" cols="60" name="{$vo.fieldArr}[{$vo.name|default=''}_eyou_intro][]" style="height:28px; width: 136px;" placeholder="图片注释"></textarea>
  612. </div>
  613. </div>
  614. <!-- 上传图片显示的样板 end -->
  615. </dd>
  616. </dl>
  617. <script type="text/javascript">
  618. // 上传多图回调函数
  619. function {$vo.fieldArr}_{$vo.name|default=''}_call_back(paths){
  620. var last_div = $(".{$vo.fieldArr}_{$vo.name|default=''}_upload_tpl").html();
  621. for (var i=0;i<paths.length ;i++ )
  622. {
  623. if ($(".sort-list-{$vo.fieldArr}_{$vo.name|default=''} .images_upload_html").length > 0) {
  624. $(".sort-list-{$vo.fieldArr}_{$vo.name|default=''} .images_upload_html:last").after(last_div); // 插入一个 新图片
  625. } else {
  626. $(".sort-list-{$vo.fieldArr}_{$vo.name|default=''} .images_upload:last").before(last_div); // 插入一个 新图片
  627. }
  628. $(".sort-list-{$vo.fieldArr}_{$vo.name|default=''} .images_upload_html:last").find('a:eq(0)').attr('href',paths[i]).attr('onclick','').attr('target', "_blank");// 修改他的链接地址
  629. $(".sort-list-{$vo.fieldArr}_{$vo.name|default=''} .images_upload_html:last").find('img').attr('src',paths[i]);// 修改他的图片路径
  630. $(".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('');
  631. $(".sort-list-{$vo.fieldArr}_{$vo.name|default=''} .images_upload_html:last").find('input').val(paths[i]); // 设置隐藏域 要提交的值
  632. }
  633. }
  634. /*
  635. * 上传之后删除组图input
  636. * @access public
  637. * @val string 删除的图片input
  638. */
  639. function {$vo.fieldArr}_{$vo.name|default=''}_ClearPicArr2(obj,path)
  640. {
  641. // 删除数据库记录
  642. $.ajax({
  643. type:'GET',
  644. url:"{:url('Field/del_channelimgs', ['_ajax'=>1])}",
  645. data:{filename:path,channel:"{$channeltype|default='0'}",fieldid:"{$vo.id}",aid:"{$aid|default='0'}"},
  646. success:function(){
  647. $(obj).parent().parent().remove(); // 删除完服务器的, 再删除 html上的图片
  648. $.ajax({
  649. type:'GET',
  650. url:"{:url('Uploadimgnew/delupload', ['_ajax'=>1])}",
  651. data:{action:"del", filename:path},
  652. success:function(){}
  653. });
  654. }
  655. });
  656. }
  657. /** 以下 产品相册的拖动排序相关 js*/
  658. $( ".sort-list-{$vo.fieldArr}_{$vo.name|default=''}" ).sortable({
  659. start: function( event, ui) {
  660. }
  661. ,stop: function( event, ui ) {
  662. }
  663. });
  664. //因为他们要拖动,所以尽量设置他们的文字不能选择。
  665. $( ".sort-list-{$vo.fieldArr}_{$vo.name|default=''}" ).disableSelection();
  666. </script>
  667. <!-- 多张图 end -->
  668. {/case}
  669. {case value="int"}
  670. <!-- 整数类型 start -->
  671. <dl class="row">
  672. <dt class="tit">
  673. <label>{if condition="isset($vo['ifrequire']) AND !empty($vo['ifrequire'])"}<em>*</em>{/if}{$vo.title|default=''}</label>
  674. </dt>
  675. <dd class="opt">
  676. <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,''));">&nbsp;{$vo.dfvalue_unit|default=''}
  677. <span class="err"></span>
  678. <p class="notic">{$vo.remark|default=''}</p>
  679. </dd>
  680. </dl>
  681. <!-- 整数类型 end -->
  682. {/case}
  683. {case value="float"}
  684. <!-- 小数类型 start -->
  685. <dl class="row">
  686. <dt class="tit">
  687. <label>{if condition="isset($vo['ifrequire']) AND !empty($vo['ifrequire'])"}<em>*</em>{/if}{$vo.title|default=''}</label>
  688. </dt>
  689. <dd class="opt">
  690. <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,''));">&nbsp;{$vo.dfvalue_unit|default=''}
  691. <span class="err"></span>
  692. <p class="notic">{$vo.remark|default=''}</p>
  693. </dd>
  694. </dl>
  695. <!-- 小数类型 end -->
  696. {/case}
  697. {case value="decimal"}
  698. <!-- 金额类型 start -->
  699. <dl class="row">
  700. <dt class="tit">
  701. <label>{if condition="isset($vo['ifrequire']) AND !empty($vo['ifrequire'])"}<em>*</em>{/if}{$vo.title|default=''}</label>
  702. </dt>
  703. <dd class="opt">
  704. <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,''));">&nbsp;{$vo.dfvalue_unit|default=''}
  705. <span class="err"></span>
  706. <p class="notic">{$vo.remark|default=''}</p>
  707. </dd>
  708. </dl>
  709. <!-- 金额类型 end -->
  710. {/case}
  711. {case value="datetime"}
  712. <!-- 日期和时间 start -->
  713. <dl class="row">
  714. <dt class="tit">
  715. <label>{if condition="isset($vo['ifrequire']) AND !empty($vo['ifrequire'])"}<em>*</em>{/if}{$vo.title|default=''}</label>
  716. </dt>
  717. <dd class="opt">
  718. <input type="text" class="input-txt" name="{$vo.fieldArr}[{$vo.name|default=''}]" id="{$vo.fieldArr}_{$vo.name|default=''}" value="{$vo['dfvalue']}" autocomplete="off">
  719. <span class="add-on input-group-addon">
  720. <i class="glyphicon glyphicon-calendar fa fa-calendar"></i>
  721. </span>
  722. <span class="err"></span>
  723. <p class="notic">{$vo.remark|default=''}</p>
  724. </dd>
  725. </dl>
  726. <script type="text/javascript">
  727. layui.use('laydate', function() {
  728. var laydate = layui.laydate;
  729. //常规用法
  730. laydate.render({
  731. elem: "#{$vo.fieldArr}_{$vo.name|default=''}"
  732. ,type: 'datetime'
  733. });
  734. })
  735. </script>
  736. <!-- 日期和时间 end -->
  737. {/case}
  738. {case value="htmltext"}
  739. <!-- HTML文本 start -->
  740. {eq name="$editor.editor_select" value="1"}
  741. <dl class="row">
  742. <dt class="tit">
  743. <label>{if condition="isset($vo['ifrequire']) AND !empty($vo['ifrequire'])"}<em>*</em>{/if}{$vo.title|default=''}</label>
  744. </dt>
  745. <dd class="opt">
  746. {if condition="isset($vo['first']) AND 1 == $vo['first']"}
  747. <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>&nbsp;<a href="javascript:void(0);" onclick="editor_handle_210607(1);">[手动]</a>
  748. &nbsp;
  749. <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>&nbsp;<a href="javascript:void(0);" onclick="editor_handle_210607(2);">[手动]</a>
  750. {/if}
  751. <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>
  752. <span class="err"></span>
  753. <p class="notic">{$vo.remark|default=''}</p>
  754. </dd>
  755. </dl>
  756. {if condition="isset($vo['first']) AND 1 == $vo['first']"}
  757. <script type="text/javascript">
  758. // 打开多图选择及上传界面
  759. function OpenImagesList(e, obj) {
  760. var func = '';
  761. if (e.path && e.path[10] && e.path[10].id && undefined != e.path[10].id) {
  762. func = e.path[10].id;
  763. } else {
  764. func = $(obj).parent().parent().parent().parent().parent().parent().parent().parent().parent().attr('id');
  765. }
  766. if (func.indexOf('addonFieldExt_') == -1) {
  767. func = 'addonFieldExt_content';
  768. }
  769. var OpenUrl = "{:url('Uploadimgnew/upload', ['num'=>30, 'path'=>'allimg', 'is_water'=>1])}";
  770. OpenUrl += "&func=images_call_" + func;
  771. top.layer.open({
  772. type: 2,
  773. title: '图片上传',
  774. maxmin: false,
  775. shadeClose: false,
  776. area: ['1000px', '625px'],
  777. content: OpenUrl
  778. });
  779. }
  780. </script>
  781. {/if}
  782. <script type="text/javascript">
  783. var ue_{$vo.fieldArr}_{$vo.name|default=''} = UE.getEditor('{$vo.fieldArr}_{$vo.name|default=''}',{
  784. serverUrl :"{:url('Ueditor/index',array('savepath'=>'allimg'))}",
  785. zIndex: 999,
  786. initialFrameWidth: "100%", //初化宽度
  787. initialFrameHeight: 450, //初化高度
  788. focus: false, //初始化时,是否让编辑器获得焦点true或false
  789. maximumWords: 99999,
  790. removeFormatAttributes: 'class,style,lang,width,height,align,hspace,valign',//允许的最大字符数 'fullscreen',
  791. pasteplain:false, //是否默认为纯文本粘贴。false为不使用纯文本粘贴,true为使用纯文本粘贴
  792. autoHeightEnabled: false,
  793. toolbars: ueditor_toolbars
  794. });
  795. //必须在提交前渲染编辑器;
  796. function {$vo.fieldArr}_{$vo.name|default=''}() {
  797. //判断编辑模式状态:0表示【源代码】HTML视图;1是【设计】视图,即可见即所得;-1表示不可用
  798. if(UE.getEditor("{$vo.fieldArr}_{$vo.name|default=''}").queryCommandState('source') != 0) {
  799. UE.getEditor("{$vo.fieldArr}_{$vo.name|default=''}").execCommand('source'); //切换到【设计】视图
  800. }
  801. }
  802. // 加载图片到编辑器指定位置
  803. function images_call_{$vo.fieldArr}_{$vo.name|default=''}(fileurl_tmp) {
  804. var addBody = '';
  805. $.each(fileurl_tmp, function(index, items) {
  806. addBody += '<p><img src="'+items+'"></p>';
  807. });
  808. UE.getEditor("{$vo.fieldArr}_{$vo.name|default=''}").execCommand('inserthtml', addBody);
  809. }
  810. // 自动远程图片本地化/自动清除非本站链接
  811. function ajax_auto_editor_{$vo.fieldArr}_{$vo.name|default=''}(local,link) {
  812. var body = UE.getEditor("{$vo.fieldArr}_{$vo.name|default=''}").getContent();
  813. $.ajax({
  814. type: 'POST',
  815. url: "{:url('Archives/ajax_auto_editor')}",
  816. data: {local:local,link:link,body:body,_ajax:1},
  817. dataType: "JSON",
  818. async:false,
  819. success: function(res){
  820. if (res.code == 1) {
  821. UE.getEditor("{$vo.fieldArr}_{$vo.name|default=''}").setContent(res.data.body);
  822. }
  823. }
  824. });
  825. }
  826. </script>
  827. {else/}
  828. <dl class="row">
  829. <dt class="tit">
  830. <label>{if condition="isset($vo['ifrequire']) AND !empty($vo['ifrequire'])"}<em>*</em>{/if}{$vo.title|default=''}</label>
  831. </dt>
  832. <dd class="opt">
  833. {if condition="isset($vo['first']) AND 1 == $vo['first']"}
  834. <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>&nbsp;<a href="javascript:void(0);" onclick="editor_handle_210607(1);">[手动]</a>
  835. &nbsp;
  836. <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>&nbsp;<a href="javascript:void(0);" onclick="editor_handle_210607(2);">[手动]</a>
  837. {/if}
  838. <textarea id="{$vo.fieldArr}_{$vo.name|default=''}" name="{$vo.fieldArr}[{$vo.name|default=''}]">{$vo.dfvalue|default=''}</textarea>
  839. <span class="err"></span>
  840. <p class="notic">{$vo.remark|default=''}</p>
  841. </dd>
  842. </dl>
  843. <script type="text/javascript">
  844. // 加载编辑器,若存在编辑器则先进行销毁
  845. try {
  846. var elemtid = "{$vo.fieldArr}_{$vo.name|default=''}";
  847. var editor = CKEDITOR.instances[elemtid];
  848. if (editor) editor.destroy(true);
  849. } catch(e) {}
  850. CKEDITOR.replace(elemtid, {
  851. filebrowserBrowseUrl: "{:url('Ueditor/index', ['savepath'=>'allimg', 'action'=>'uploadimage'])}",
  852. filebrowserImageBrowseUrl: "{:url('Ueditor/index', ['savepath'=>'allimg', 'action'=>'uploadimage'])}",
  853. filebrowserUploadUrl: "{:url('Ueditor/index', ['savepath'=>'allimg', 'action'=>'uploadimage'])}",
  854. filebrowserImageUploadUrl: "{:url('Ueditor/index', ['savepath'=>'allimg', 'action'=>'uploadimage'])}",
  855. });
  856. // 自动远程图片本地化/自动清除非本站链接
  857. function ajax_auto_editor_{$vo.fieldArr}_{$vo.name|default=''}(local,link) {
  858. var body = CKEDITOR.instances.{$vo.fieldArr}_{$vo.name|default=''}.getData();
  859. $.ajax({
  860. type: 'POST',
  861. url: "{:url('Archives/ajax_auto_editor')}",
  862. data: {local:local,link:link,body:body,_ajax:1},
  863. dataType: "JSON",
  864. async:false,
  865. success: function(res){
  866. if (res.code == 1) {
  867. CKEDITOR.instances.{$vo.fieldArr}_{$vo.name|default=''}.setData(res.data.body);
  868. }
  869. }
  870. });
  871. }
  872. </script>
  873. {/eq}
  874. <!-- HTML文本 end -->
  875. {/case}
  876. <!-- 多媒体类型 start -->
  877. {case value="media"}
  878. <dl class="row">
  879. <dt class="tit">
  880. <label>{if condition="isset($vo['ifrequire']) AND !empty($vo['ifrequire'])"}<em>*</em>{/if}{$vo.title|default=''}</label>
  881. </dt>
  882. <dd class="opt">
  883. <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;" >
  884. <input type="file" id="{$vo.fieldArr}_{$vo.name|default=''}_upload_media" onchange="{$vo.fieldArr}_{$vo.name|default=''}_upload_media_20210408(this)" style="display: none;">
  885. {if condition='qny == $vo.upload_flag'}
  886. <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>
  887. {elseif condition='oss == $vo.upload_flag'}
  888. <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>
  889. {elseif condition='cos == $vo.upload_flag'}
  890. <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>
  891. {else}
  892. <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>
  893. {/if}
  894. <span class="err"></span>
  895. <p class="notic">{$vo.remark|default=''}</p>
  896. </dd>
  897. </dl>
  898. <script>
  899. // 上传媒体文件
  900. function {$vo.fieldArr}_{$vo.name|default=''}_upload_media_20210408(e){
  901. var data_type = $(e).attr('data-type');
  902. if ('qny' == data_type) {
  903. // 七牛云上传
  904. {$vo.fieldArr}_{$vo.name|default=''}_qny_upload_media(e);
  905. } else if ('oss' == data_type) {
  906. // OSS上传
  907. {$vo.fieldArr}_{$vo.name|default=''}_oss_upload_media(e);
  908. } else if ('cos' == data_type) {
  909. // COS上传
  910. {$vo.fieldArr}_{$vo.name|default=''}_cos_upload_media(e);
  911. } else {
  912. // 本地上传
  913. {$vo.fieldArr}_{$vo.name|default=''}_local_upload_media(e);
  914. }
  915. }
  916. function judgeExtMedia(ext) {
  917. var type = '{$vo.ext}';
  918. var extArr = [];
  919. extArr = type.split("|");
  920. var exts = ext.replace(".","");
  921. return extArr.indexOf(exts);
  922. }
  923. // 七牛云
  924. function {$vo.fieldArr}_{$vo.name|default=''}_qny_upload_media(e) {
  925. // 获取文件路径名
  926. var file = $(e)[0].files[0];
  927. // 验证上传格式
  928. var fileName = file.name;
  929. var fileExt = fileName.substr(fileName.lastIndexOf('.')).toLowerCase();
  930. var ext = judgeExtMedia(fileExt);
  931. if (ext == -1) {
  932. showErrorMsg('仅支持{$vo.ext}格式,可在附件设置中修改');
  933. return false;
  934. }
  935. // 验证上传大小
  936. size = parseInt("{$vo.filesize}");
  937. if (file.size > size) {
  938. showErrorMsg('文件大小超过限制,可在附件设置中修改');
  939. return false;
  940. }
  941. // 执行上传
  942. layer_loading('上传七牛云');
  943. $.ajax({
  944. type: 'POST',
  945. url: '__ROOT_DIR__/index.php?m=plugins&c=Qiniuyun&a=qiniu_upload',
  946. data: {_ajax: 1},
  947. dataType: "JSON",
  948. success: function(res1) {
  949. if (1 == res1.code) {
  950. var token = res1.data.token;
  951. var formData = new FormData();
  952. formData.append('file', file);
  953. formData.append('token', token);
  954. fileName = res1.data.filePath + fileExt;
  955. formData.append('key', fileName);
  956. $.ajax({
  957. url: res1.data.uphost,
  958. type: 'POST',
  959. dataType: 'JSON',
  960. data: formData,
  961. timeout: 1200000,
  962. cache: false,
  963. processData: false,
  964. contentType: false,
  965. xhr: function () {
  966. myXhr = $.ajaxSettings.xhr();
  967. if (myXhr.upload) {
  968. myXhr.upload.addEventListener('progress', function(e){
  969. var curr = e.loaded;
  970. var total = e.total;
  971. process = parseInt(curr / total * 100);
  972. $("#{$vo.fieldArr}_{$vo.name|default=''}_qny_upload_media").text('上传中...'+process+"%");
  973. });
  974. }
  975. return myXhr;
  976. },
  977. success: function(res2) {
  978. layer.closeAll();
  979. $("#{$vo.fieldArr}_{$vo.name|default=''}_qny_upload_media").text('上传成功');
  980. setTimeout(function() {
  981. $('#{$vo.fieldArr}_{$vo.name|default=\'\'}_qny_upload_media').text('七牛云上传');
  982. }, 2000);
  983. var video_url = res1.data.domain + "/" + res2.key;
  984. $("#{$vo.fieldArr}_{$vo.name|default=''}_media_url").val(video_url);
  985. },
  986. error: function(e) {
  987. layer.closeAll();
  988. showErrorMsg(e.responseText);
  989. return false;
  990. }
  991. });
  992. } else {
  993. layer.closeAll();
  994. showErrorMsg(res1.msg);
  995. }
  996. },
  997. error: function(e) {
  998. layer.closeAll();
  999. showErrorMsg(e.responseText);
  1000. }
  1001. });
  1002. }
  1003. //OSS
  1004. function {$vo.fieldArr}_{$vo.name|default=''}_oss_upload_media(e) {
  1005. // 获取文件路径名
  1006. var file = $(e)[0].files[0];
  1007. // 验证上传格式
  1008. var fileName = file.name;
  1009. var fileExt = fileName.substr(fileName.lastIndexOf('.')).toLowerCase();
  1010. var ext = judgeExtMedia(fileExt);
  1011. if (ext == -1) {
  1012. showErrorMsg('仅支持{$vo.ext}格式,可在附件设置中修改');
  1013. return false;
  1014. }
  1015. // 验证上传大小
  1016. size = parseInt("{$vo.filesize}");
  1017. if (file.size > size) {
  1018. showErrorMsg('文件大小超过限制,可在附件设置中修改');
  1019. return false;
  1020. }
  1021. // 执行上传
  1022. layer_loading('上传阿里云OSS');
  1023. $.ajax({
  1024. type: 'POST',
  1025. url: '__ROOT_DIR__/index.php?m=plugins&c=AliyunOss&a=oss_upload',
  1026. data: {_ajax: 1},
  1027. dataType: "JSON",
  1028. success: function(res1){
  1029. if (1 == res1.code){
  1030. fileName = res1.data.filePath + fileExt;
  1031. //组装发送数据
  1032. var request = new FormData();
  1033. request.append("OSSAccessKeyId",res1.data.accessid);
  1034. request.append("policy",res1.data.policy);
  1035. request.append("Signature",res1.data.signature);
  1036. request.append("key",fileName);
  1037. request.append("success_action_status",201);
  1038. request.append('file', file);
  1039. $.ajax({
  1040. url : res1.data.host,
  1041. data : request,
  1042. processData: false,
  1043. cache: false,
  1044. contentType: false,
  1045. dataType: 'xml',
  1046. type : 'post',
  1047. xhr: function () {
  1048. myXhr = $.ajaxSettings.xhr();
  1049. if (myXhr.upload) {
  1050. myXhr.upload.addEventListener('progress', function(e){
  1051. var curr = e.loaded;
  1052. var total = e.total;
  1053. var process = parseInt(curr / total * 100);
  1054. $("#{$vo.fieldArr}_{$vo.name|default=''}_oss_upload_media").text('上传中...'+process+"%");
  1055. });
  1056. }
  1057. return myXhr;
  1058. },
  1059. success : function(data) {
  1060. layer.closeAll();
  1061. var res = $(data).find('PostResponse');
  1062. if (res) {
  1063. var key = res.find('Key').text();
  1064. $("#{$vo.fieldArr}_{$vo.name|default=''}_oss_upload_media").text('上传成功');
  1065. setTimeout(function() {
  1066. $('#{$vo.fieldArr}_{$vo.name|default=\'\'}_oss_upload_media').text('oss上传');
  1067. }, 2000);
  1068. var video_url = res1.data.domain + "/" + key;
  1069. $("#{$vo.fieldArr}_{$vo.name|default=''}_media_url").val(video_url);
  1070. } else {
  1071. $("#{$vo.fieldArr}_{$vo.name|default=''}_oss_upload_media").text('上传失败');
  1072. setTimeout(function() {
  1073. $('#{$vo.fieldArr}_{$vo.name|default=\'\'}_oss_upload_media').text('oss上传');
  1074. }, 2000);
  1075. }
  1076. },
  1077. error : function(e) {
  1078. layer.closeAll();
  1079. console.log(e.responseText);
  1080. }
  1081. });
  1082. } else {
  1083. layer.closeAll();
  1084. showErrorMsg(res1.msg);
  1085. }
  1086. },
  1087. error: function(e) {
  1088. layer.closeAll();
  1089. showErrorMsg(e.responseText);
  1090. }
  1091. });
  1092. }
  1093. //COS
  1094. function {$vo.fieldArr}_{$vo.name|default=''}_cos_upload_media(e) {
  1095. // 获取文件路径名
  1096. var file = $(e)[0].files[0];
  1097. // 验证上传格式
  1098. var fileName = file.name;
  1099. var fileExt = fileName.substr(fileName.lastIndexOf('.')).toLowerCase();
  1100. var ext = judgeExtMedia(fileExt);
  1101. if (ext == -1) {
  1102. showErrorMsg('仅支持{$vo.ext}格式,可在附件设置中修改');
  1103. return false;
  1104. }
  1105. // 验证上传大小
  1106. size = parseInt("{$vo.filesize}");
  1107. if (file.size > size) {
  1108. showErrorMsg('文件大小超过限制,可在附件设置中修改');
  1109. return false;
  1110. }
  1111. // 上传参数
  1112. var formData = new FormData();
  1113. formData.append('file', file);
  1114. formData.append('file_ext', fileExt);
  1115. // 执行上传
  1116. $.ajax({
  1117. type: 'post',
  1118. url: '__ROOT_DIR__/index.php?m=plugins&c=Cos&a=cos_upload&_ajax=1',
  1119. data: formData,
  1120. contentType: false,
  1121. processData: false,
  1122. dataType: 'json',
  1123. xhr: function () {
  1124. myXhr = $.ajaxSettings.xhr();
  1125. if (myXhr.upload) {
  1126. myXhr.upload.addEventListener('progress', function(e){
  1127. var curr = e.loaded;
  1128. var total = e.total;
  1129. process = parseInt(curr / total * 100);
  1130. if (100 == process) {
  1131. process = 99;
  1132. layer_loading('上传腾讯云');
  1133. }
  1134. $("#{$vo.fieldArr}_{$vo.name|default=''}_cos_upload_media").text('上传中...'+process+"%");
  1135. });
  1136. }
  1137. return myXhr;
  1138. },
  1139. success: function(res) {
  1140. layer.closeAll();
  1141. if (1 == res.code) {
  1142. $("#{$vo.fieldArr}_{$vo.name|default=''}_cos_upload_media").text('上传成功');
  1143. $("#{$vo.fieldArr}_{$vo.name|default=''}_media_url").val(res.data.url);
  1144. } else {
  1145. $("#{$vo.fieldArr}_{$vo.name|default=''}_cos_upload_media").text('上传失败');
  1146. }
  1147. setTimeout(function() {
  1148. $('#{$vo.fieldArr}_{$vo.name|default=\'\'}_cos_upload_media').text('cos上传');
  1149. }, 2000);
  1150. },
  1151. error: function(e) {
  1152. layer.closeAll();
  1153. showErrorMsg(e.responseText);
  1154. }
  1155. });
  1156. }
  1157. // 本地上传
  1158. function {$vo.fieldArr}_{$vo.name|default=''}_local_upload_media(e){
  1159. // 获取文件路径名
  1160. var file = $(e)[0].files[0];
  1161. // 验证上传格式
  1162. var fileName = file.name;
  1163. var fileExt = fileName.substr(fileName.lastIndexOf('.')).toLowerCase();
  1164. var ext = judgeExtMedia(fileExt);
  1165. if (ext == -1) {
  1166. showErrorMsg('仅支持{$vo.ext}格式,可在附件设置中修改');
  1167. return false;
  1168. }
  1169. // 验证上传大小
  1170. size = parseInt("{$vo.filesize}");
  1171. if (file.size > size) {
  1172. showErrorMsg('文件大小超过限制,可在附件设置中修改');
  1173. return false;
  1174. }
  1175. // 定义上传数据
  1176. var formData = new FormData();
  1177. formData.append('file', file);
  1178. // 执行上传
  1179. layer_loading('上传本地');
  1180. $.ajax({
  1181. type: 'post',
  1182. url : "{:url('Ueditor/upVideo', ['savepath'=>'media'])}",
  1183. data: formData,
  1184. contentType: false,
  1185. processData: false,
  1186. dataType: 'json',
  1187. xhr: function () {
  1188. myXhr = $.ajaxSettings.xhr();
  1189. if (myXhr.upload) {
  1190. myXhr.upload.addEventListener('progress', function(e){
  1191. var curr = e.loaded;
  1192. var total = e.total;
  1193. process = parseInt(curr / total * 100);
  1194. $("#upload_video_litpic_local").html('上传中...'+process+"%");
  1195. });
  1196. }
  1197. return myXhr;
  1198. },
  1199. success: function (res) {
  1200. layer.closeAll();
  1201. if ("SUCCESS" == res.state) {
  1202. $("#{$vo.fieldArr}_{$vo.name|default=''}_local_upload_media").html('上传成功');
  1203. setTimeout(function() {
  1204. $('#{$vo.fieldArr}_{$vo.name|default=\'\'}_local_upload_media').html('本地上传');
  1205. }, 2000);
  1206. $("#{$vo.fieldArr}_{$vo.name|default=''}_media_url").val(res.url);
  1207. } else {
  1208. showErrorMsg(res.msg);
  1209. }
  1210. }
  1211. });
  1212. }
  1213. </script>
  1214. {/case}
  1215. <!-- 多媒体类型 end -->
  1216. {/switch}
  1217. {/if}
  1218. {/volist}
  1219. <script>
  1220. $(function(){
  1221. auto_notic_tips();
  1222. /**
  1223. * 自动小提示
  1224. */
  1225. function auto_notic_tips()
  1226. {
  1227. 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>';
  1228. $.each($('dd.opt > p.notic'), function(index, item){
  1229. var a_length = $(item).prev("a.ui_tips").length;
  1230. if ($(item).html() != '' && 0 == a_length) {
  1231. $(item).before(html);
  1232. }
  1233. });
  1234. }
  1235. });
  1236. </script>