Aucune description
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

add.htm 37KB

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