Brak opisu
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.

add.htm 36KB

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