説明なし
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

edit.htm 41KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938
  1. {include file="public/layout" /}
  2. <body class="ad_postion bodystyle" style="overflow-y: scroll;">
  3. <div id="toolTipLayer" style="position: absolute; z-index: 9999; display: none; visibility: visible; left: 95px; top: 573px;"></div>
  4. <div id="append_parent"></div>
  5. <div id="ajaxwaitid"></div>
  6. <div class="page min-hg-c-10">
  7. <form class="form-horizontal" id="post_form" action="{:url('ZczsPosition/edit')}" method="post">
  8. <div class="ncap-form-default">
  9. <dl class="row">
  10. <dt class="tit"> <label for="title"><em>*</em>证书名称</label> </dt>
  11. <dd class="opt">
  12. <input type="text" name="title" value="{$field.title}" id="title" onkeyup="DetectionTitleRepeat(this);" class="input-txt" autocomplete="off">
  13. <span class="err"></span>
  14. <p class="notic2 red" id="title_tips"></p>
  15. </dd>
  16. </dl>
  17. <dl class="row" style="display: block;">
  18. <dt class="tit"> <label for="type">选择级别</label> </dt>
  19. <dd class="opt">
  20. <?php
  21. /*
  22. *
  23. * <select name="type" class="select" style="margin:0px 5px;height:30px;">
  24. <option value="">--选择地区--</option>
  25. {eyou:foreach name='$pro_list' item='field1'}
  26. <option value="{$field1.id}" {eq name="$curr_id" value="$field1.id"}selected{/eq}>{$field1.name}</option>
  27. {/eyou:foreach}
  28. </select>
  29. */
  30. ?>
  31. <select name="type2" class="select" id="selectTest" style="margin:0px 5px;height:30px;">
  32. {eyou:foreach name='$pos_list' item='field1'}
  33. <option value="{$field1.id}" {eq name="$pid" value="$field1.id"}selected{/eq}>{$field1.name}</option>
  34. {/eyou:foreach}
  35. </select>
  36. {eyou:notempty name='$pos_list2' /}
  37. <select name="type" class="select" id="selectTest2" style="margin:0px 5px;height:30px;">
  38. {eyou:foreach name='$pos_list2' item='field1'}
  39. <option value="{$field1.id}" {eq name="$field.type" value="$field1.id"}selected{/eq}>{$field1.name}</option>
  40. {/eyou:foreach}
  41. </select>
  42. {eyou:else /}
  43. <span>请先添加二级分类</span>
  44. <input type="hidden" name="type" value="">
  45. {/eyou:notempty}
  46. <script>
  47. $(function(){
  48. $("#selectTest").change(function(e){
  49. console.log($(this).val());
  50. var v = $(this).val();
  51. if(v == 1){
  52. //$('#citychoose').show();
  53. }else{
  54. //$('#citychoose').hide();
  55. }
  56. //ajax
  57. $.ajax({
  58. type:'POST',
  59. url:"{:url('ZczsPosition/getType', ['_ajax'=>1])}",
  60. data:{
  61. id: $(this).val()
  62. ,_ajax:1
  63. },
  64. success:function(res){
  65. $('#selectTest2').html(res.data);
  66. }
  67. });
  68. });
  69. });
  70. </script>
  71. </dd>
  72. </dl>
  73. <dl class="row" id="citychoose" style="display: none;" >
  74. <dt class="tit"> <label for="title"><em>*</em>地区选择</label> </dt>
  75. <dd class="opt">
  76. <!---checked $map_list-->
  77. {eyou:foreach name='$pro_list' item='field1'}
  78. <input type="checkbox" name="map[]" value="{$field1.id}" id="category{$field1.id}"
  79. {$field1.is_check}
  80. />{$field1.name}
  81. {/eyou:foreach}
  82. <span class="err"></span>
  83. <p class="notic2 red" id="title_tips"></p>
  84. </dd>
  85. </dl>
  86. <!--暂时找不到控制显示隐藏的地方-->
  87. <dl class="row 1615775137_dl" style="display: none;" id="1615775137_1" style="z-index: 2">
  88. <dt class="tit"> <label>主题背景</label> </dt>
  89. <dd class="opt">
  90. <div class="tab-pane" id="tab_imgupload">
  91. <table class="table table-bordered">
  92. <tbody>
  93. <tr>
  94. <td>
  95. <div class="sort-list">
  96. {volist name="ad_data" id="vo" key="k"}
  97. {eq name="$vo.media_type" value="1"}
  98. <div class="images_upload">
  99. <div class="ic">
  100. <div class='upimg' title="拖动修改排序" onmouseover="upimgMouseover(this);" onmouseout="upimgMouseout(this);">
  101. <div class='icaction' style="display: none" >
  102. <span class="load_images" onclick="Images('{$vo['litpic']}', 900, 600);">
  103. <a href="javascript:void(0);" style="color:white">
  104. <i class='fa fa-search-plus'></i>大图
  105. </a>
  106. </span>
  107. <span class="load_images" onclick="LoadImagesId('{$vo['id']}');">
  108. <i class='fa fa-photo'></i>更换
  109. </span>
  110. <span class="load_images" onclick="ShowInput('{$vo['id']}');">
  111. <i class='fa fa-file-text-o'></i>信息
  112. </span>
  113. </div>
  114. <div class='cover-bg' style="display: none" ></div>
  115. <img id="{$vo['id']}_Id" src="{$vo['litpic']}"/>
  116. {if condition="$main_lang == $admin_lang || !empty($global['language_split'])"}
  117. <a class="delect" href="javascript:void(0);" onclick="ClearPicArr(this,'{$vo['litpic']}','{$vo['id']}');" title="删除">
  118. </a>
  119. {/if}
  120. </div>
  121. <div class="load_input" id="{$vo['id']}_ShowInput" data-showOrHide="hide">
  122. <input type="hidden" name="img_id[]" value="{$vo['id']}"/>
  123. <span class="span_input">
  124. <input type="hidden" id="{$vo['id']}_Litpic" name="img_litpic[]" value="{$vo['litpic']}"/>
  125. </span>
  126. <textarea name="img_title[]" placeholder="请输入标题..." style="height: 28px;">{$vo.title}</textarea>
  127. <textarea name="img_links[]" placeholder="请输入链接网址..." style="height: 28px;">{$vo.links}</textarea>
  128. <textarea name="img_intro[]" placeholder="广告注释:支持HTML代码" style="height: 64px;">{$vo.intro}</textarea>
  129. <div class="operation">
  130. <a href="javascript:void(0);">
  131. <label>
  132. <input type="checkbox" {eq name="$vo['target']" value="1"} checked="checked" {/eq} title="在新窗口打开" onclick="CheckedTarget(this)"/>新窗口
  133. <input type="hidden" name="img_target[]" value="{$vo['target']}">
  134. </label>
  135. </a>
  136. <a href="javascript:void(0);" onclick="copyToClipBoard({$vo['id']});">
  137. <i class="fa fa-file-code-o"></i>标签调用
  138. </a>
  139. <a onclick="HideInput('{$vo['id']}');" style="width: 32%;" href="javascript:void(0);" title="收回"><i style="font-size:16px;" class="fa fa-angle-double-up"></i></a>
  140. </div>
  141. </div>
  142. </div>
  143. </div>
  144. {/eq}
  145. {/volist}
  146. <div class="images_upload"></div>
  147. </div>
  148. {if condition="$main_lang == $admin_lang || !empty($global['language_split'])"}
  149. <a href="javascript:void(0);" onClick="GetUploadify(30,'','allimg','imgupload_call_back');" class="img-upload b-img-upload mb15" title="点击上传">
  150. <div class="y-line"></div>
  151. <div class="x-line"></div>
  152. </a>
  153. {/if}
  154. <input type="hidden" id="ImagesId">
  155. </td>
  156. </tr>
  157. </tbody>
  158. </table>
  159. </div>
  160. <!-- 上传图片显示的样板 start -->
  161. <div class="images_upload_tpl none">
  162. <div class="images_upload ic">
  163. <div class="ic">
  164. <div class='upimg' title="拖动修改排序" onmouseover="upimgMouseover(this);" onmouseout="upimgMouseout(this);">
  165. <div class='icaction' style="display: none">
  166. <span class="load_images" onclick="">
  167. <a href="javascript:void(0);" style="color: white">
  168. <i class='fa fa-search-plus'></i>大图
  169. </a>
  170. </span>
  171. <span class="load_images" onclick="">
  172. <i class='fa fa-file-text-o'></i>信息
  173. </span>
  174. </div>
  175. <div class='cover-bg' style="display: none"></div>
  176. <img src="__STATIC__/admin/images/add-button.jpg"/>
  177. <a class="delect" href="javascript:void(0);" title="删除"></a>
  178. </div>
  179. <div class="load_input" data-showOrHide="hide">
  180. <input type="hidden"/>
  181. <span class="span_input"> <input type="hidden"/> </span>
  182. <textarea placeholder="请输入标题..." style="height: 28px;"></textarea>
  183. <textarea placeholder="请输入链接网址..." style="height: 28px;"></textarea>
  184. <textarea placeholder="广告注释:支持HTML代码" style="height: 64px;"></textarea>
  185. <div class="operation">
  186. <a href="javascript:void(0);">&nbsp;&nbsp;</a>
  187. <a href="javascript:void(0);">&nbsp;&nbsp;</a>
  188. <a style="width: 32%;" href="javascript:void(0);">&nbsp;&nbsp;</a>
  189. </div>
  190. </div>
  191. </div>
  192. </div>
  193. </div>
  194. <!-- 上传图片显示的样板 end -->
  195. </dd>
  196. </dl>
  197. <dl class="row 1615775137_dl" style="display: none;" id="1615775137_2" style="z-index: 2">
  198. <dt class="tit"> <label for="type">广告内容</label> </dt>
  199. <dd class="opt">
  200. <input type="hidden" name="video_id" {eq name="$ad_data.0.media_type" value="2"} value="{$ad_data.0.id}" {/eq} class="input-txt">
  201. <input type="text" name="video_litpic" id="video_litpic" {eq name="$ad_data.0.media_type" value="2"} value="{$ad_data.0.litpic}" {/eq} class="input-txt">
  202. <input type="file" id="courseware_file" data-type='local' onchange="upload_video_litpic_1615775137(this)" style="display: none;">
  203. {eq name="$WeappOpen.qny_open" value="1"}
  204. &nbsp;<a href="javascript:void(0);" class="ncap-btn ncap-btn-green" id="upload_video_litpic_qiniu" onclick="$('#courseware_file').attr('data-type', 'qiniu').trigger('click');">七牛云上传</a>
  205. {/eq}
  206. {eq name="$WeappOpen.oss_open" value="1"}
  207. &nbsp;<a href="javascript:void(0);" class="ncap-btn ncap-btn-green" id="upload_video_litpic_oss" onclick="$('#courseware_file').attr('data-type', 'oss').trigger('click');">oss上传</a>
  208. {/eq}
  209. {eq name="$WeappOpen.cos_open" value="1"}
  210. &nbsp;<a href="javascript:void(0);" class="ncap-btn ncap-btn-green" id="upload_video_litpic_cos" onclick="$('#courseware_file').attr('data-type', 'cos').trigger('click');">cos上传</a>
  211. {/eq}
  212. &nbsp;<a href="javascript:void(0);" class="ncap-btn ncap-btn-green " id="upload_video_litpic_local" onclick="$('#courseware_file').attr('data-type', 'local').trigger('click');">本地上传</a>
  213. <input type="hidden" id="OpenPreviewVideoUrl" value="{:url('ZczsPosition/open_preview_video')}">
  214. &nbsp;<a href="javascript:void(0);" class="ncap-btn ncap-btn-green" id="PreviewVideo" onclick="OpenPreviewVideo();">预览</a>
  215. </dd>
  216. </dl>
  217. <dl class="row 1615775137_dl" style="display: none;" id="1615775137_3" style="z-index: 2">
  218. <dt class="tit"> <label for="type">广告内容</label> </dt>
  219. <dd class="opt">
  220. <input type="hidden" name="html_id" {eq name="$ad_data.0.media_type" value="3"} value="{$ad_data.0.id}" {/eq} class="input-txt">
  221. <textarea rows="5" cols="60" id="html_intro" name="html_intro" style="height: 200px;">{eq name="$ad_data.0.media_type" value="3"}{$ad_data.0.intro}{/eq}</textarea>
  222. <span class="err"></span>
  223. <p class="notic"></p>
  224. </dd>
  225. </dl>
  226. <dl class="row">
  227. <dt class="tit">
  228. <label>备注信息</label>
  229. </dt>
  230. <dd class="opt">
  231. <textarea rows="5" cols="60" id="intro" name="intro" style="height:60px;">{$field.intro}</textarea>
  232. <span class="err"></span>
  233. <p class="notic"></p>
  234. </dd>
  235. </dl>
  236. <div class="bot">
  237. <input type="hidden" name="id" id="1615775137_id" value="{$field.id}">
  238. <a href="JavaScript:void(0);" onclick="checkForm();" class="ncap-btn-big ncap-btn-green" id="submitBtn">确认提交</a>
  239. </div>
  240. </div>
  241. </form>
  242. </div>
  243. <script type="text/javascript">
  244. var SelectedType = '{$field.type}';
  245. $(function() {
  246. // 新增时,广告类型默认选中图片类型
  247. // $('#type'+SelectedType).prop('checked', 'checked');
  248. // 新增时,默认显示图片上传
  249. //$('#1615775137_'+SelectedType).show();
  250. // 多媒体类型 && 广告内容不为空 则执行显示 否则 执行隐藏
  251. VideoLitpicValue('#video_litpic');
  252. });
  253. // 切换广告类型
  254. function TypeSwitch(typeValue) {
  255. // 隐藏全部类型内容
  256. $('.1615775137_dl').hide();
  257. // 显示指定类型内容
  258. $('#1615775137_'+typeValue).show();
  259. // 切换类型后设置为当前切换的类型
  260. SelectedType = typeValue;
  261. // var ad_type = '{$field.type}';
  262. // if (typeValue != ad_type) {
  263. // // 切换至不同类型则显示
  264. // $('.notic2').show();
  265. // } else {
  266. // // 切换至相同类型则隐藏
  267. // $('.notic2').hide();
  268. // }
  269. }
  270. // 多媒体类型 && 广告内容不为空 则执行显示 否则 执行隐藏
  271. function VideoLitpicValue(obj) {
  272. // 获取广告内容(多媒体为播放链接)
  273. // var video_litpic = $(obj).val();
  274. // 判断隐藏显示预览按钮if (2 == SelectedType && video_litpic)
  275. if (2 == SelectedType) {
  276. $('#PreviewVideo').show();
  277. } else {
  278. $('#PreviewVideo').hide();
  279. }
  280. }
  281. // 打开预览视频
  282. function OpenPreviewVideo() {
  283. // 获取视频链接
  284. var video_litpic = $('#video_litpic').val();
  285. if (video_litpic == '') {
  286. $('#video_litpic').focus();
  287. showErrorMsg('请先上传视频');
  288. return false;
  289. }
  290. /* 视频链接后缀验证处理 */
  291. var fileExt = video_litpic.substr(video_litpic.lastIndexOf('.')).toLowerCase();
  292. var fileExt = judgeExt(fileExt);
  293. if (fileExt == -1) {
  294. $('#video_litpic').focus();
  295. showErrorMsg('不支持的视频格式,可在附件设置中修改');
  296. return false;
  297. }
  298. /* END */
  299. /* 视频链接是否存在斜杠处理 */
  300. var fileInfo = video_litpic.lastIndexOf('/');
  301. if (fileInfo == -1) {
  302. $('#video_litpic').focus();
  303. showErrorMsg('视频链接不完整,无法正常预览');
  304. return false;
  305. }
  306. /* END */
  307. // 打开视频播放
  308. $.ajax({
  309. type : 'post',
  310. url : $('#OpenPreviewVideoUrl').val(),
  311. data : {video_litpic: video_litpic},
  312. dataType : 'json',
  313. success : function(res) {
  314. if (1 == res.code) {
  315. var PreviewVideo = "<video style='width:100%; height:100%;' src='"+res.url+"' controls preload='auto' oncontextmenu='return fase' autoplay></video>";
  316. layer.open({
  317. type: 1,
  318. title: false,
  319. fixed: true, //不固定
  320. shadeClose: false,
  321. shade: layer_shade,
  322. area: ['80%', '80%'],
  323. content: PreviewVideo
  324. });
  325. } else {
  326. showErrorMsg(res.msg);
  327. }
  328. },
  329. error: function(e) {
  330. showErrorAlert(e.responseText);
  331. }
  332. });
  333. }
  334. // 上传媒体文件
  335. function upload_video_litpic_1615775137(e) {
  336. var data_type = $(e).attr('data-type');
  337. if ('qiniu' == data_type) {
  338. // 七牛云上传
  339. upload_video_litpic_qiniu(e);
  340. } else if ('oss' == data_type) {
  341. // OSS上传
  342. upload_video_litpic_oss(e);
  343. } else if ('cos' == data_type) {
  344. // COS上传
  345. upload_video_litpic_cos(e);
  346. } else {
  347. // 本地上传
  348. upload_video_litpic_local(e);
  349. }
  350. }
  351. // 七牛云上传
  352. function upload_video_litpic_qiniu(e) {
  353. // 获取文件路径名
  354. var file = $(e)[0].files[0];
  355. // 验证上传格式
  356. var fileName = file.name;
  357. var fileExt = fileName.substr(fileName.lastIndexOf('.')).toLowerCase();
  358. var ext = judgeExt(fileExt);
  359. if (ext == -1) {
  360. showErrorMsg('不支持选中的视频格式,可在附件设置中修改');
  361. return false;
  362. }
  363. // 验证上传大小
  364. var size = "{$upload_max_filesize}";
  365. if (file.size > size) {
  366. showErrorMsg('视频大小超过限制,可在附件设置中修改');
  367. return false;
  368. }
  369. // 执行上传
  370. layer_loading('上传七牛云');
  371. $.ajax({
  372. type: 'POST',
  373. url: '__ROOT_DIR__/index.php?m=plugins&c=Qiniuyun&a=qiniu_upload',
  374. data: {_ajax: 1},
  375. dataType: "JSON",
  376. success: function(res1) {
  377. if (1 == res1.code) {
  378. var token = res1.data.token;
  379. var formData = new FormData();
  380. formData.append('file', file);
  381. formData.append('token', token);
  382. fileName = res1.data.filePath + fileExt;
  383. formData.append('key', fileName);
  384. $.ajax({
  385. url: res1.data.uphost,
  386. type: 'POST',
  387. dataType: 'JSON',
  388. data: formData,
  389. timeout: 1200000,
  390. cache: false,
  391. processData: false,
  392. contentType: false,
  393. xhr: function () {
  394. myXhr = $.ajaxSettings.xhr();
  395. if (myXhr.upload) {
  396. myXhr.upload.addEventListener('progress', function(e){
  397. var curr = e.loaded;
  398. var total = e.total;
  399. process = parseInt(curr / total * 100);
  400. $("#upload_video_litpic_qiniu").text('上传中...'+process+"%");
  401. });
  402. }
  403. return myXhr;
  404. },
  405. success: function(res2) {
  406. layer.closeAll();
  407. $("#upload_video_litpic_qiniu").text('上传成功');
  408. setTimeout(function() {
  409. $('#upload_video_litpic_qiniu').text('七牛云上传');
  410. }, 2000);
  411. var video_url = res1.data.domain + "/" + res2.key;
  412. $("#video_litpic").empty().val(video_url);
  413. },
  414. error: function(e) {
  415. layer.closeAll();
  416. showErrorMsg(e.responseText);
  417. return false;
  418. }
  419. });
  420. } else {
  421. layer.closeAll();
  422. showErrorMsg(res1.msg);
  423. }
  424. },
  425. error: function(e) {
  426. layer.closeAll();
  427. showErrorMsg(e.responseText);
  428. }
  429. });
  430. }
  431. // 阿里云OSS上传
  432. function upload_video_litpic_oss(e) {
  433. // 获取文件路径名
  434. var file = $(e)[0].files[0];
  435. // 验证上传格式
  436. var fileName = file.name;
  437. var fileExt = fileName.substr(fileName.lastIndexOf('.')).toLowerCase();
  438. var ext = judgeExt(fileExt);
  439. if (ext == -1) {
  440. showErrorMsg('不支持选中的视频格式,可在附件设置中修改');
  441. return false;
  442. }
  443. // 验证上传大小
  444. var size = "{$upload_max_filesize}";
  445. if (file.size > size) {
  446. showErrorMsg('视频大小超过限制,可在附件设置中修改');
  447. return false;
  448. }
  449. // 执行上传
  450. layer_loading('上传阿里云OSS');
  451. $.ajax({
  452. type: 'POST',
  453. url: '__ROOT_DIR__/index.php?m=plugins&c=AliyunOss&a=oss_upload',
  454. data: {_ajax: 1},
  455. dataType: "JSON",
  456. success: function(res1){
  457. if (1 == res1.code){
  458. fileName = res1.data.filePath + fileExt;
  459. //组装发送数据
  460. var request = new FormData();
  461. request.append("OSSAccessKeyId",res1.data.accessid);
  462. request.append("policy",res1.data.policy);
  463. request.append("Signature",res1.data.signature);
  464. request.append("key",fileName);
  465. request.append("success_action_status",201);
  466. request.append('file', file);
  467. $.ajax({
  468. url : res1.data.host,
  469. data : request,
  470. processData: false,
  471. cache: false,
  472. contentType: false,
  473. dataType: 'xml',
  474. type : 'post',
  475. xhr: function () {
  476. myXhr = $.ajaxSettings.xhr();
  477. if (myXhr.upload) {
  478. myXhr.upload.addEventListener('progress', function(e){
  479. var curr = e.loaded;
  480. var total = e.total;
  481. var process = parseInt(curr / total * 100);
  482. $("#upload_video_litpic_oss").text('上传中...'+process+"%");
  483. });
  484. }
  485. return myXhr;
  486. },
  487. success : function(data) {
  488. layer.closeAll();
  489. var res = $(data).find('PostResponse');
  490. if (res) {
  491. var key = res.find('Key').text();
  492. $("#upload_video_litpic_oss").text('上传成功');
  493. setTimeout(function() {
  494. $('#upload_video_litpic_oss').text('oss上传');
  495. }, 2000);
  496. var video_url = res1.data.domain + "/" + key;
  497. $("#video_litpic").val(video_url);
  498. } else {
  499. $("#upload_video_litpic_oss").text('上传失败');
  500. setTimeout(function() {
  501. $('#upload_video_litpic_oss').text('oss上传');
  502. }, 2000);
  503. }
  504. },
  505. error : function(e) {
  506. layer.closeAll();
  507. console.log(e.responseText);
  508. }
  509. });
  510. } else {
  511. layer.closeAll();
  512. showErrorMsg(res1.msg);
  513. }
  514. },
  515. error: function(e) {
  516. layer.closeAll();
  517. showErrorMsg(e.responseText);
  518. }
  519. });
  520. }
  521. // 腾讯云COS上传
  522. function upload_video_litpic_cos(e) {
  523. // 获取文件路径名
  524. var file = $(e)[0].files[0];
  525. // 验证上传格式
  526. var fileName = file.name;
  527. var fileExt = fileName.substr(fileName.lastIndexOf('.')).toLowerCase();
  528. var ext = judgeExt(fileExt);
  529. if (ext == -1) {
  530. showErrorMsg('不支持选中的视频格式,可在附件设置中修改');
  531. return false;
  532. }
  533. // 验证上传大小
  534. var size = "{$upload_max_filesize}";
  535. if (file.size > size) {
  536. showErrorMsg('视频大小超过限制,可在附件设置中修改');
  537. return false;
  538. }
  539. // 上传参数
  540. var formData = new FormData();
  541. formData.append('file', file);
  542. formData.append('file_ext', fileExt);
  543. // 执行上传
  544. $.ajax({
  545. type: 'post',
  546. url: '__ROOT_DIR__/index.php?m=plugins&c=Cos&a=cos_upload&_ajax=1',
  547. data: formData,
  548. contentType: false,
  549. processData: false,
  550. dataType: 'json',
  551. xhr: function () {
  552. myXhr = $.ajaxSettings.xhr();
  553. if (myXhr.upload) {
  554. myXhr.upload.addEventListener('progress', function(e){
  555. var curr = e.loaded;
  556. var total = e.total;
  557. process = parseInt(curr / total * 100);
  558. if (100 == process) {
  559. process = 99;
  560. layer_loading('上传腾讯云COS');
  561. }
  562. $("#upload_video_litpic_cos").text('上传中...'+process+"%");
  563. });
  564. }
  565. return myXhr;
  566. },
  567. success: function(res) {
  568. layer.closeAll();
  569. if (1 == res.code) {
  570. $("#video_litpic").val(res.data.url);
  571. $("#upload_video_litpic_cos").text('上传成功');
  572. } else {
  573. $("#upload_video_litpic_cos").text('上传失败');
  574. }
  575. setTimeout(function() {
  576. $('#upload_video_litpic_cos').text('cos上传');
  577. }, 2000);
  578. },
  579. error: function(e) {
  580. layer.closeAll();
  581. showErrorMsg(e.responseText);
  582. }
  583. });
  584. }
  585. // 本地上传
  586. function upload_video_litpic_local(e) {
  587. // 获取文件路径名
  588. var file = $(e)[0].files[0];
  589. // 验证上传格式
  590. var fileName = file.name;
  591. var fileExt = fileName.substr(fileName.lastIndexOf('.')).toLowerCase();
  592. var ext = judgeExt(fileExt);
  593. if (ext == -1) {
  594. showErrorMsg('不支持选中的视频格式,可在附件设置中修改');
  595. return false;
  596. }
  597. // 验证上传大小
  598. var size = "{$upload_max_filesize}";
  599. if (file.size > size) {
  600. showErrorMsg('视频大小超过限制,可在附件设置中修改');
  601. return false;
  602. }
  603. // 定义上传数据
  604. var formData = new FormData();
  605. formData.append('file', file);
  606. // 执行上传
  607. layer_loading('上传本地');
  608. $.ajax({
  609. type: 'post',
  610. url : "{:url('Ueditor/upVideo', ['savepath'=>'media'])}",
  611. data: formData,
  612. contentType: false,
  613. processData: false,
  614. dataType: 'json',
  615. xhr: function () {
  616. myXhr = $.ajaxSettings.xhr();
  617. if (myXhr.upload) {
  618. myXhr.upload.addEventListener('progress', function(e){
  619. var curr = e.loaded;
  620. var total = e.total;
  621. process = parseInt(curr / total * 100);
  622. $("#upload_video_litpic_local").html('上传中...'+process+"%");
  623. });
  624. }
  625. return myXhr;
  626. },
  627. success: function (res) {
  628. layer.closeAll();
  629. $("#upload_video_litpic_local").html('上传成功');
  630. setTimeout(function() {
  631. $('#upload_video_litpic_local').html('本地上传');
  632. }, 2000);
  633. if ("SUCCESS" == res.state) {
  634. $("#video_litpic").val(res.url);
  635. } else {
  636. showErrorMsg(res.msg);
  637. }
  638. }
  639. });
  640. }
  641. // 验证格式
  642. function judgeExt(ext) {
  643. var type = "{$media_type}";
  644. var extArr = [];
  645. extArr = type.split("|");
  646. var ext = ext.replace(".","");
  647. return extArr.indexOf(ext);
  648. }
  649. </script>
  650. <script type="text/javascript">
  651. // 勾选新窗口打开链接
  652. function CheckedTarget(t){
  653. if ($(t).is(':checked')) {
  654. $(t).parent().find('input[name="img_target[]"]').val(1);
  655. }else{
  656. $(t).parent().find('input[name="img_target[]"]').val(0);
  657. }
  658. }
  659. // 鼠标事件,加载查看大图和更新图片
  660. function upimgMouseover(obj)
  661. {
  662. $(obj).find('div.icaction').show();
  663. $(obj).find('div.cover-bg').show();
  664. }
  665. function upimgMouseout(obj)
  666. {
  667. $(obj).find('div.icaction').hide();
  668. $(obj).find('div.cover-bg').hide();
  669. }
  670. // 检测广告名称是否存在重复
  671. function DetectionTitleRepeat(obj) {
  672. // 当前广告ID
  673. var id = $('#1615775137_id').val();
  674. // 传入的广告名称
  675. var title = $(obj).val();
  676. // 执行检测
  677. $.ajax({
  678. type: 'post',
  679. url : "{:url('ZczsPosition/detection_title_repeat', ['_ajax'=>1])}",
  680. data: {id: id, title: title},
  681. dataType: 'json',
  682. success: function(res) {
  683. if (0 == res.code) {
  684. $('#title_tips').show().html(res.msg);
  685. } else {
  686. $('#title_tips').hide().html('');
  687. }
  688. },
  689. error: function(e){
  690. layer.closeAll();
  691. showErrorAlert(e.responseText);
  692. }
  693. });
  694. }
  695. // 判断输入框是否为空
  696. function checkForm(){
  697. if($('input[name=title]').val() == ''){
  698. layer.msg('广告位名称不能为空!', {icon: 2,time: 1000});
  699. return false;
  700. }
  701. if($('input[name=type]').val() == ''){
  702. layer.msg('分类不能为空,请添加二级分类!', {icon: 2,time: 1000});
  703. return false;
  704. }
  705. /*if($('#selectTest').val() == '1'){
  706. var checkedValues = [];
  707. $('#post_form input[type=checkbox]:checked').each(function() {
  708. checkedValues.push($(this).val());
  709. });
  710. console.log(checkedValues); // 打印选中的checkbox值
  711. if(checkedValues.length > 0){
  712. }else{
  713. layer.msg('请选择地区!', {icon: 2,time: 1000});
  714. return false;
  715. }
  716. }*/
  717. //打印
  718. /*console.log($('#post_form').serialize());
  719. return false;*/
  720. layer_loading('正在处理');
  721. $.ajax({
  722. type : 'post',
  723. url : "{:url('ZczsPosition/edit', ['_ajax'=>1])}",
  724. data : $('#post_form').serialize(),
  725. dataType : 'json',
  726. success : function(res){
  727. layer.closeAll();
  728. if (res.code == 1) {
  729. layer.msg(res.msg, {icon: 1, shade: layer_shade, time: 1000}, function(){
  730. window.location.reload();
  731. });
  732. } else {
  733. showErrorMsg(res.msg);
  734. }
  735. },
  736. error: function(e){
  737. layer.closeAll();
  738. showErrorAlert(e.responseText);
  739. }
  740. });
  741. }
  742. // 获取点击更新图片的ID并加载隐藏域
  743. function LoadImagesId(id){
  744. // 加载ID到隐藏域
  745. $('#ImagesId').val(id);
  746. // 调用图片上传JS
  747. GetUploadify(1,'','allimg','UpdataImages');
  748. }
  749. // 更新图片
  750. function UpdataImages(path){
  751. // 获取点击的ID
  752. var id = $('#ImagesId').val();
  753. // 加载图片到显示层
  754. $("#"+id+"_Id").attr('src', path);
  755. // 加载图片到提交的隐藏域
  756. $("#"+id+"_Litpic").val(path);
  757. }
  758. // 显示信息输入框
  759. function ShowInput(id) {
  760. var obj = $("#"+id+"_ShowInput");
  761. var showOrHide = obj.attr('data-showOrHide');
  762. if ('hide' == showOrHide) {
  763. obj.show().attr('data-showOrHide', 'show');
  764. } else {
  765. obj.hide().attr('data-showOrHide', 'hide');
  766. }
  767. }
  768. // 隐藏信息输入
  769. function HideInput(id) {
  770. $("#"+id+"_ShowInput").hide().attr('data-showOrHide', 'hide');
  771. }
  772. // 上传图集相册回调函数
  773. function imgupload_call_back(paths){
  774. var last_div = $(".images_upload_tpl").html();
  775. var inputs = $('.span_input input');
  776. var timestamp = 0;
  777. // 图片数据处理
  778. for (var i=0; i<paths.length; i++) {
  779. // 生成新的时间戳
  780. timestamp = (new Date()).getTime();
  781. // 插入一个 新图片
  782. $(".images_upload:eq(0)").before(last_div);
  783. // 处理他的链接地址
  784. $(".images_upload:eq(0)").find('span:eq(0)').attr('onclick', "Images('"+paths[i]+"', 900, 600);");
  785. // 处理信息显示隐藏按钮
  786. $(".images_upload:eq(0)").find('span:eq(1)').attr('onclick', "ShowInput('"+timestamp+"');");
  787. // 处理他的图片路径
  788. $(".images_upload:eq(0)").find('img').attr('src', paths[i]);
  789. // 处理删除按钮
  790. $(".images_upload:eq(0)").find('a:eq(1)').attr('onclick', "ClearPicArr(this, '"+paths[i]+"', 0);");
  791. // 处理图片信息框ID
  792. $(".images_upload:eq(0)").find('.load_input:eq(0)').attr('id', timestamp+'_ShowInput');
  793. // 处理图片路径及隐藏域
  794. if (inputs.length > 0) {
  795. // 修改隐藏域
  796. $(".images_upload:eq(0)").find('input:eq(0)').attr('name', 'img_id[]').attr('value', '');
  797. $(".span_input:eq(0)").find('input:eq(0)').attr('name', 'img_litpic[]').attr('value', paths[i]);
  798. // 处理标题
  799. $(".images_upload:eq(0)").find('textarea:eq(0)').attr('name', 'img_title[]');
  800. // 处理跳转链接
  801. $(".images_upload:eq(0)").find('textarea:eq(1)').attr('name', 'img_links[]');
  802. // 处理内容描述
  803. $(".images_upload:eq(0)").find('textarea:eq(2)').attr('name', 'img_intro[]');
  804. // 处理新窗口选项
  805. $(".images_upload:eq(0)").find('div.operation a:eq(0)').html("<label><input type='checkbox' title='在新窗口打开' onclick='CheckedTarget(this);'/>新窗口<input type='hidden' name='img_target[]' value='0'></label>");
  806. // 处理收回按钮
  807. $(".images_upload:eq(0)").find('div.operation a:eq(2)').attr('onclick', "HideInput('"+timestamp+"');").attr('title', "收回").html('<i style="font-size:16px;" class="fa fa-angle-double-up"></i>');
  808. }
  809. }
  810. }
  811. // 上传之后删除组图input
  812. function ClearPicArr(obj, path, id) {
  813. // 删除数据库记录
  814. $.ajax({
  815. type:'POST',
  816. url:"{:url('ZczsPosition/del_imgupload')}",
  817. data:{del_id:id,_ajax:1},
  818. success:function(){
  819. $(obj).parent().parent().parent().remove(); // 删除完服务器的, 再删除 html上的图片
  820. $.ajax({
  821. type:'POST',
  822. url:"{:url('Uploadimgnew/delupload')}",
  823. data:{action:"del", filename:path,_ajax:1},
  824. success:function(){}
  825. });
  826. }
  827. });
  828. }
  829. // 代码调用js
  830. function copyToClipBoard(id) {
  831. var adstr = "{eyou:ad aid='" + id + "'}\r\n <a href='{$"+"field.links}' {$"+"field.target}><img src='{$"+"field.litpic}' alt='{$"+"field.title}' /></a>\r\n 广告注释:{$"+"field.intro}\r\n{/eyou:ad";
  832. var contentdiv = '<div class="dialog_content" style="margin: 0px; padding: 0px;"><dl style="padding:10px 30px;line-height:30px"><dd>标签 ad 调用:</dd>';
  833. contentdiv += '<textarea rows="4" cols="60" style="width:400px;height:100px;">' + adstr + '}</textarea>';
  834. contentdiv += '<dd style="border-top: dotted 1px #E7E7E7; color: #F60;">请将对应标签代码复制并粘贴到对应模板文件中!</dd></dl></div>';
  835. layer.open({
  836. title: '代码调用',
  837. type: 1,
  838. shade: layer_shade,
  839. skin: 'layui-layer-demo',
  840. area: ['480px', '260px'], //宽高
  841. content: contentdiv
  842. });
  843. }
  844. // 图集相册的拖动排序相关 js
  845. $( ".sort-list" ).sortable({
  846. start: function( event, ui) {
  847. }
  848. ,stop: function( event, ui ) {
  849. }
  850. });
  851. //因为他们要拖动,所以尽量设置他们的文字不能选择。
  852. // $( ".sort-list" ).disableSelection();
  853. </script>
  854. {include file="public/footer" /}