add.html 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736
  1. {extend name="app/shop/view/base.html"/}
  2. {block name="resources"}
  3. <style>
  4. .layui-layout-admin .layui-body .ns-body-content {
  5. min-height: initial;
  6. padding-top: 0;
  7. padding-bottom: 0;
  8. margin: 0;
  9. }
  10. .ns-form {
  11. margin-top: 0;
  12. }
  13. .layui-form-label.mid {
  14. width: 100px;
  15. }
  16. .layui-form-label.mid+.layui-input-block {
  17. margin-left: 100px;
  18. }
  19. .new-mid {
  20. margin-left: -20px !important;
  21. }
  22. .poster-form {
  23. display: flex;
  24. background: #eee;
  25. }
  26. .poster-left {
  27. width: 400px;
  28. height: 800px;
  29. background: #FFFFFF;
  30. padding: 10px 30px 10px 10px;
  31. }
  32. .poster-left-header {
  33. font-size: 18px;
  34. border-bottom: 1px solid #eee;
  35. padding: 0 0 10px 0;
  36. margin: 0 0 10px 0;
  37. }
  38. .poster-left-header1 {
  39. font-size: 18px;
  40. padding: 0 0 10px 0;
  41. }
  42. .poster-left-header2 {
  43. font-size: 18px;
  44. padding: 0 0 10px 0;
  45. }
  46. .layui-input-block {
  47. margin-left: 0;
  48. }
  49. .poster-headimg,
  50. .poster-name {
  51. display: flex;
  52. }
  53. .poster-right {
  54. width: 360px;
  55. height: 640px;
  56. opacity: 0.9;
  57. margin: 20px 0 0 271px;
  58. background-color: #fff;
  59. }
  60. .tips {
  61. width: 153px;
  62. height: 16px;
  63. font-size: 12px;
  64. font-family: Microsoft YaHei;
  65. font-weight: 400;
  66. color: #909399;
  67. padding-left: 100px;
  68. }
  69. .album-img-select {
  70. height: 30px;
  71. line-height: 30px;
  72. margin: 0 0 5px 20px;
  73. }
  74. .upload-img-block {
  75. width: 300px;
  76. height: 100px;
  77. }
  78. .upload {
  79. top: 50% !important;
  80. height: 100px;
  81. }
  82. .form-row {
  83. padding-top: 20px;
  84. }
  85. .bg-color {
  86. margin-left: 800px;
  87. background: #ff6a00;
  88. }
  89. .poster-tips {
  90. background: #fff;
  91. width: 280px;
  92. margin-left: 320px;
  93. padding: 20px 20px;
  94. border: 1px solid #e8e8e8;
  95. border-right: none;
  96. }
  97. .set-tips {
  98. font-size: 16px;
  99. font-family: Microsoft YaHei;
  100. font-weight: bolder;
  101. color: #303133;
  102. line-height: 22px;
  103. }
  104. .content {
  105. font-size: 12px;
  106. font-family: Microsoft YaHei;
  107. font-weight: 400;
  108. color: #909399;
  109. line-height: 22px;
  110. margin-top: 10px;
  111. }
  112. .goods-info {
  113. width: 340px;
  114. height: 354px;
  115. border-radius: 10px;
  116. margin: 50px 15px 20px;
  117. }
  118. .goods-desc {
  119. /*border-radius: 15px;*/
  120. font-family: Microsoft YaHei;
  121. font-weight: 400;
  122. line-height: 26px;
  123. text-align: left;
  124. margin: 30px 25px;
  125. }
  126. .goods-img {
  127. border-radius: 5px;
  128. }
  129. .price-info {
  130. width: 310px;
  131. height: 80px;
  132. border-radius: 10px;
  133. margin: 0 15px;
  134. padding: 15px;
  135. }
  136. .price {
  137. font-size: 18px;
  138. font-family: Microsoft YaHei;
  139. font-weight: 400;
  140. color: #FF4544;
  141. display: inline-block;
  142. width: 75px;
  143. height: 20px;
  144. }
  145. .line-price {
  146. font-size: 12px;
  147. font-family: Microsoft YaHei;
  148. font-weight: 400;
  149. text-decoration: line-through;
  150. color: #999999;
  151. display: inline-block;
  152. margin-top: 6px;
  153. }
  154. .baoyou {
  155. font-size: 14px;
  156. font-family: PingFang SC;
  157. font-weight: 500;
  158. color: #FF4544;
  159. line-height: 36px;
  160. margin-top: 15px;
  161. }
  162. .qianggou {
  163. width: 160px;
  164. height: 24px;
  165. line-height: 22px;
  166. background: #FF4544;
  167. border-radius: 5px;
  168. font-size: 12px;
  169. font-family: Microsoft YaHei;
  170. font-weight: 400;
  171. color: #FFFFFF;
  172. text-align: center;
  173. }
  174. .layui-nav-more1 {
  175. width: 7px;
  176. height: 7px;
  177. border-width: 1px;
  178. border-color: #333 #333 transparent transparent;
  179. border-style: solid;
  180. transform: rotate(135deg);
  181. top: 16px;
  182. right: 16px;
  183. margin-top: 7px;
  184. }
  185. .layui-nav-more2 {
  186. width: 7px;
  187. height: 7px;
  188. border-width: 1px;
  189. border-color: #333 #333 transparent transparent;
  190. border-style: solid;
  191. transform: rotate(135deg);
  192. top: 16px;
  193. right: 16px;
  194. margin-top: 7px;
  195. }
  196. .layui-new-more1 {
  197. transform: rotate(45deg);
  198. }
  199. .layui-new-more2 {
  200. transform: rotate(45deg);
  201. }
  202. .layui-colorpicker {
  203. margin-left: 15px;
  204. }
  205. .form-row {
  206. position: fixed;
  207. bottom: 0px;
  208. left: 180px;
  209. width: 89.7%;
  210. background: #fff;
  211. padding: 10px 0;
  212. }
  213. .layui-colorpicker-main-input .layui-btn {
  214. padding: 0 10px;
  215. }
  216. .circle {
  217. border-radius: 50%;
  218. }
  219. .aaa {
  220. margin-top: 20px;
  221. }
  222. .upload img {
  223. margin-top: 20px;
  224. }
  225. .img_prev {
  226. margin-top: 0 !important;
  227. }
  228. .no-background {
  229. background-image: none !important;
  230. }
  231. </style>
  232. {/block}
  233. {block name="main"}
  234. <div class="layui-form add-poster">
  235. <div class="poster-form">
  236. <div id="view" style="display: flex;"></div>
  237. <div class="poster-tips">
  238. <div class="set-tips">海报设置说明</div>
  239. <div class="content">
  240. 1. 用户头像,用户昵称这两个元素需要空出<br>
  241. 2. 裂变海报其他部分皆可自定义设计<br>
  242. 3. 可自行拖拉设置相应元素的大小
  243. </div>
  244. </div>
  245. </div>
  246. <div class="form-row">
  247. <button class="layui-btn bg-color" lay-submit lay-filter="save_poster">保存</button>
  248. <input type="hidden" name="template_id" value='{notempty name="$template_data"}{$template_data.template_id}{/notempty}'>
  249. <button class="layui-btn layui-btn-primary" onclick="back()">返回</button>
  250. </div>
  251. </div>
  252. {/block}
  253. {block name="script"}
  254. <script type="text/html" id="poster_left">
  255. <div class="poster-left">
  256. <div class="poster-left-header">
  257. 基础设置
  258. </div>
  259. <div class="layui-form-item">
  260. <label class="layui-form-label mid"><span class="required">*</span>海报名称</label>
  261. <div class="layui-input-block mid">
  262. <input type="text" class="layui-input" lay-verify="required" placeholder="请输入海报名称" name="poster_name"
  263. value='{notempty name="$template_data"}{$template_data.poster_name}{/notempty}'/>
  264. </div>
  265. </div>
  266. <div class="layui-form-item">
  267. <label class="layui-form-label mid"><span class="required">*</span>分享语</label>
  268. <div class="layui-input-block mid">
  269. <input type="text" class="layui-input poster-text" lay-verify="required" placeholder="请输入分享语" name="poster_text"
  270. value='{notempty name="$template_data"}{$template_data.poster_text}{/notempty}'/>
  271. </div>
  272. </div>
  273. <div class="layui-form-item">
  274. <label class="layui-form-label img-upload-lable ns-short-label mid"><span class="required">*</span>上传海报</label>
  275. <div class="layui-input-block mid">
  276. <div class="upload-img-block icon">
  277. <div class="upload-img-box {{# if (d.background) { }}hover{{# } }} {notempty name="$template_data.background"}hover{/notempty}" >
  278. <div class="ns-upload-default" id="posterImg">
  279. {notempty name="$template_data.background"}
  280. <div id="preview_posterImg" class="preview_img">
  281. <img layer-src src='{:img($template_data.background)}' class="img_prev" data-id="qr_img"/>
  282. <p style="width: 300px;"></p>
  283. </div>
  284. {else/}
  285. {{# if(d.background) { }}
  286. <div id="preview_posterImg" class="preview_img">
  287. <img layer-src src="{{ ns.img(d.background) }}" class="img_prev" data-id="qr_img"/>
  288. <p style="width: 300px;"></p>
  289. </div>
  290. {{# } }}
  291. {{# if (!d.background) { }}
  292. <div class="upload">
  293. <img class="aaa" src="SHOP_IMG/upload_img.png" />
  294. <p>点击上传</p>
  295. </div>
  296. {{# } }}
  297. {/notempty}
  298. </div>
  299. <div class="operation">
  300. <div style="position: absolute; top: -10px; left: 110px;">
  301. <i title="图片预览" class="iconfont iconreview js-preview"></i>
  302. <i title="删除图片" class="layui-icon layui-icon-delete js-delete"></i>
  303. </div>
  304. <div class="replace_img js-replace">点击替换</div>
  305. </div>
  306. <input type="hidden" lay-verify="posterImg" name="background" value='{notempty name="$template_data.background"}{$template_data.background}{/notempty}{{# if (d.background) { }}{{ d.background }} {{# } }}' />
  307. </div>
  308. </div>
  309. </div>
  310. </div>
  311. <div class="tips">建议图片尺寸:720*1280px</div>
  312. <div class="layui-form-item poster-headimg">
  313. <div class="layui-form album-img-select">
  314. <input type="checkbox" name="switch" lay-filter="poster_headimg" value="" lay-skin="primary" {{d.headimg_is_show == '1' ? 'checked' : ''}}>
  315. </div>
  316. <label class="layui-form-label mid" style="text-align: left;">用户头像</label>
  317. <div class="layui-input-block mid new-mid">
  318. <div class="layui-input-block">
  319. <input type="radio" lay-filter="circle" name="shop_status" value="1" title="圆形" data-value='circle' {{d.headimg_shape == 'circle' ? 'checked' : ''}}>
  320. <input type="radio" lay-filter="square" name="shop_status" value="0" title="方形" data-value='square' {{d.headimg_shape == 'square' ? 'checked' : ''}}>
  321. </div>
  322. </div>
  323. </div>
  324. <div class="layui-form-item poster-name">
  325. <div class="layui-form album-img-select">
  326. <input type="checkbox" name="check[]" lay-filter="poster_name" value="" lay-skin="primary" {{d.nickname_is_show == '1' ? 'checked' : ''}}>
  327. </div>
  328. <label class="layui-form-label mid" style="text-align: left;">用户昵称</label>
  329. <div class="layui-input-block mid new-mid">
  330. <div class="poster-name-box">
  331. <div class="layui-form poster-select len-short" lay-filter="poster-select">
  332. <select name="" class="mySelect" lay-filter="mySelect">
  333. {{# for (var font_index = 14; font_index <= 36; font_index++) { }}
  334. {{# if (font_index == d.nickname_font_size) { }}
  335. <option value="{{font_index}}" selected>{{font_index}}px</option>
  336. {{# } else { }}
  337. <option value="{{font_index}}">{{font_index}}px</option>
  338. {{# } }}
  339. {{# } }}
  340. </select>
  341. </div>
  342. </div>
  343. </div>
  344. <div class="layui-form poster-color">
  345. 颜色:
  346. <div>
  347. <input type="hidden" name="color" id="friendfission-all-input">
  348. <div class="friendfission-all"></div>
  349. </div>
  350. </div>
  351. </div>
  352. </div>
  353. <div class="poster-right design-sketch" style="position: relative;border: 1px solid #d6d6d6;
  354. {notempty name='$template_data.background'}background-image:url({:img($template_data.background)}); background-size: 100%; background-repeat: no-repeat;{/notempty}
  355. {{# if (d.background) { }}background-image:url({{ ns.img(d.background) }});background-size: 100%;background-repeat: no-repeat;{{# } }}
  356. ">
  357. <div class="" style="display: flex; justify-content: space-between; height: 90px;">
  358. <div style="margin: 20px; display: flex;">
  359. <div class="poster_head" style="position:absolute;top: {{d.headimg_top}}px; left: {{d.headimg_left}}px; width: {{d.headimg_width}}px; height: {{d.headimg_height}}px;">
  360. <img alt="" class="{{d.headimg_shape == 'circle' ? 'circle' : ''}} {{d.headimg_is_show == '1' ? '' : 'layui-hide'}}"
  361. src="__STATIC__/img/caner1.png" width="100%" />
  362. </div>
  363. <div class="poster_title {{d.nickname_is_show == '1' ? '' : 'layui-hide'}}" style="position:absolute;top: {{d.nickname_top}}px; left: {{d.nickname_left}}px; width: {{d.nickname_width}}px; color: {{d.nickname_color}}; font-size: {{d.nickname_font_size}}px;">
  364. <span class="design-text">用户昵称</span>
  365. </div>
  366. <div class="poster_img" style="position:absolute;top: {{d.qrcode_top}}px; left: {{d.qrcode_left}}px; height: {{d.qrcode_height}}px; width: {{d.qrcode_width}}px;">
  367. <img alt="" src="__STATIC__/img/caner_erweima.png" width="100%" />
  368. </div>
  369. <div class="poster_text" style="position:absolute;top: {{d.text_content_top}}px; left: {{d.text_content_left}}px">
  370. <span class="design-text">{{ d.poster_text }}</span>
  371. </div>
  372. </div>
  373. </div>
  374. </div>
  375. </script>
  376. <script src="STATIC_JS/tdrag.js"></script>
  377. <script>
  378. var form, laytpl, laypage, laydate, colorpicker, repeat_flag = false;
  379. var poster_detail = {
  380. 'poster_name': '',
  381. 'headimg_is_show': 1,
  382. 'headimg_shape': 'circle', // 头像形式 circle 圆 square 方形
  383. 'nickname_is_show': 1,
  384. 'nickname_font_size': 22,
  385. 'nickname_color': '#faa87a',
  386. 'background': '',
  387. 'qrcode_type': '',
  388. 'headimg_width': 56,
  389. 'headimg_height': 56,
  390. 'headimg_top': 426,
  391. 'headimg_left': 41,
  392. 'nickname_width': '',
  393. 'nickname_height': '',
  394. 'nickname_top': 515,
  395. 'nickname_left': 20,
  396. 'qrcode_width': 80,
  397. 'qrcode_height': 80,
  398. 'qrcode_top': 540,
  399. 'qrcode_left': 260,
  400. 'poster_text': '邀您一起分享赚佣金',
  401. 'text_content_size': 10,
  402. 'text_content_color': [141, 141, 141],
  403. 'text_content_top': 535,
  404. 'text_content_left':20,
  405. 'template_type': 'fenxiao',
  406. "template_id":''
  407. };
  408. {notempty name="$template_data.json_array"}
  409. poster_detail = {:json_encode($template_data.json_array)}
  410. {else/}
  411. poster_detail = {
  412. 'poster_name': '',
  413. 'headimg_is_show': 1,
  414. 'headimg_shape': 'circle', // 头像形式 circle 圆 square 方形
  415. 'nickname_is_show': 1,
  416. 'nickname_font_size': 22,
  417. 'nickname_color': '#faa87a',
  418. 'background': '',
  419. 'qrcode_type': '',
  420. 'headimg_width': 56,
  421. 'headimg_height': 56,
  422. 'headimg_top': 426,
  423. 'headimg_left': 41,
  424. 'nickname_width': '',
  425. 'nickname_height': '',
  426. 'nickname_top': 515,
  427. 'nickname_left': 20,
  428. 'qrcode_width': 80,
  429. 'qrcode_height': 80,
  430. 'qrcode_top': 540,
  431. 'qrcode_left': 260,
  432. 'poster_text': '邀您一起分享赚佣金',
  433. 'text_content_size': 10,
  434. 'text_content_color': [141, 141, 141],
  435. 'text_content_top': 535,
  436. 'text_content_left':20,
  437. 'template_type': 'fenxiao',
  438. "template_id":''
  439. }
  440. {/notempty}
  441. layui.use(['form', 'laytpl', 'laydate', 'colorpicker'], function() {
  442. var form = layui.form,
  443. laydate = layui.laydate,
  444. laytpl = layui.laytpl,
  445. colorpicker = layui.colorpicker,
  446. repeat_flag = false; //防重复标识
  447. form.render();
  448. laydate.render({
  449. elem: '#laydate'
  450. });
  451. if(localStorage.getItem('poster_data')) {
  452. var poster = JSON.parse(localStorage.getItem('poster_data'));
  453. if(poster.template_json) {
  454. poster.template_json = JSON.parse(poster.template_json)
  455. poster_detail = Object.assign(poster, poster.template_json)
  456. }
  457. }
  458. var data = poster_detail;
  459. var getTpl = $("#poster_left").html(),
  460. view = $('#view');
  461. laytpl(getTpl).render(data, function(html) {
  462. view.html(html);
  463. form.render();
  464. new Upload({
  465. elem: '#posterImg',
  466. data: {
  467. },
  468. callback: function(res) {
  469. if (res.code >= 0) {
  470. $('.poster-right').css({
  471. "background-image": `url('${ns.img(res.data.pic_path)}')`,
  472. "background-size": "100%",
  473. "background-repeat": "no-repeat"
  474. });
  475. poster_detail.background = res.data.pic_path
  476. }
  477. },
  478. deleteCallback: function() {
  479. poster_detail.background = '';
  480. }
  481. });
  482. });
  483. colorpicker.render({
  484. elem: '.poster-color', //绑定元素
  485. color: poster_detail.nickname_color,
  486. done: function(color) {
  487. $('.poster_title').css("color", color);
  488. poster_detail.nickname_color = color;
  489. }
  490. });
  491. form.on('checkbox(poster_headimg)', function(data) {
  492. poster_detail.headimg_is_show = data.elem.checked ? '1' : '0';
  493. if (data.elem.checked) {
  494. $(".poster_head img").removeClass("layui-hide");
  495. } else {
  496. $(".poster_head img").addClass("layui-hide");
  497. }
  498. })
  499. form.on('checkbox(poster_name)', function(data) {
  500. poster_detail.nickname_is_show = data.elem.checked ? '1' : '0';
  501. if (data.elem.checked) {
  502. $(".poster_title").removeClass("layui-hide");
  503. } else {
  504. $(".poster_title").addClass("layui-hide");
  505. }
  506. })
  507. $(".poster-text").change(function(){
  508. var text = $(".poster-text").val();
  509. $(".poster_text .design-text").html(text);
  510. })
  511. // 监听字体大小下拉框
  512. form.on('select(mySelect)', function(data) {
  513. $('.poster_title').css("font-size", data.value + "px");
  514. poster_detail.nickname_font_size = data.value;
  515. });
  516. form.on('radio(circle)', function(data) {
  517. poster_detail.headimg_shape = $(this).attr("data-value");
  518. $(".poster_head img").addClass("circle");
  519. })
  520. form.on('radio(square)', function(data) {
  521. poster_detail.headimg_shape = $(this).attr("data-value");
  522. $(".poster_head img").removeClass("circle");
  523. })
  524. var arr = ['head', 'title', 'img', 'text'];
  525. arr.forEach((_item, _index) => {
  526. $(`.poster_${_item}`).Tdrag({
  527. scope: '.design-sketch',
  528. cbChange: function(obj, self) {
  529. var top = parseFloat($(self.$element).css('top')),
  530. left =parseFloat($(self.$element).css('left')),
  531. width = parseFloat($(self.$element).css('width')),
  532. height = parseFloat($(self.$element).css('height')),
  533. font_size = parseFloat($(self.$element).css('font_size'));
  534. if (_item == 'head') {
  535. poster_detail.headimg_top = top ? top : poster_detail.headimg_top;
  536. poster_detail.headimg_left = left ? left : poster_detail.headimg_left;
  537. poster_detail.headimg_width = width ? width : poster_detail.headimg_width;
  538. poster_detail.headimg_height = height ? height : poster_detail.headimg_height;
  539. } else if (_item == 'title') {
  540. poster_detail.nickname_top = top ? top : poster_detail.nickname_top;
  541. poster_detail.nickname_left = left ? left : poster_detail.nickname_left;
  542. poster_detail.nickname_width = width ? width : poster_detail.nickname_width;
  543. poster_detail.nickname_height = height ? height : poster_detail.nickname_height;
  544. poster_detail.nickname_font_size = font_size ? font_size : poster_detail.nickname_font_size;
  545. } else if (_item == 'img') {
  546. poster_detail.qrcode_top = top ? top : poster_detail.qrcode_top;
  547. poster_detail.qrcode_left = left ? left : poster_detail.qrcode_left;
  548. poster_detail.qrcode_width = width ? width : poster_detail.qrcode_width;
  549. poster_detail.qrcode_height = height ? height : poster_detail.qrcode_height;
  550. } else if (_item == 'text'){
  551. poster_detail.text_content_top = top ? top : poster_detail.text_content_top;
  552. poster_detail.text_content_left = left ? left : poster_detail.text_content_left;
  553. poster_detail.text_content_width = width ? width : poster_detail.text_content_width;
  554. poster_detail.text_content_height = height ? height : poster_detail.text_content_height;
  555. }
  556. },
  557. cbEnd: function (obj, self) {
  558. var top = parseFloat($(self.$element).css('top')),
  559. left =parseFloat($(self.$element).css('left')),
  560. width = parseFloat($(self.$element).css('width')),
  561. height = parseFloat($(self.$element).css('height')),
  562. font_size = parseFloat($(self.$element).css('font_size'));
  563. if (_item == 'head') {
  564. poster_detail.headimg_top = top ? top : poster_detail.headimg_top;
  565. poster_detail.headimg_left = left ? left : poster_detail.headimg_left;
  566. poster_detail.headimg_width = width ? width : poster_detail.headimg_width;
  567. poster_detail.headimg_height = height ? height : poster_detail.headimg_height;
  568. } else if (_item == 'title') {
  569. poster_detail.nickname_top = top ? top : poster_detail.nickname_top;
  570. poster_detail.nickname_left = left ? left : poster_detail.nickname_left;
  571. poster_detail.nickname_width = width ? width : poster_detail.nickname_width;
  572. poster_detail.nickname_height = height ? height : poster_detail.nickname_height;
  573. poster_detail.nickname_font_size = font_size ? font_size : poster_detail.nickname_font_size;
  574. } else if (_item == 'img') {
  575. poster_detail.qrcode_top = top ? top : poster_detail.qrcode_top;
  576. poster_detail.qrcode_left = left ? left : poster_detail.qrcode_left;
  577. poster_detail.qrcode_width = width ? width : poster_detail.qrcode_width;
  578. poster_detail.qrcode_height = height ? height : poster_detail.qrcode_height;
  579. } else if (_item == 'text'){
  580. poster_detail.text_content_top = top ? top : poster_detail.text_content_top;
  581. poster_detail.text_content_left = left ? left : poster_detail.text_content_left;
  582. poster_detail.text_content_width = width ? width : poster_detail.text_content_width;
  583. poster_detail.text_content_height = height ? height : poster_detail.text_content_height;
  584. }
  585. }
  586. });
  587. })
  588. /**
  589. * 监听提交
  590. */
  591. form.on('submit(save_poster)', function(data) {
  592. poster_detail.poster_name = data.field.poster_name;
  593. poster_detail.poster_text = data.field.poster_text;
  594. var template_id = {notempty name="$template_data.template_id"}{$template_data.template_id}{else/} '' {/notempty};
  595. poster_detail.background = $('input[name="background"]').val();
  596. if( $('input[name="background"]').val() == ""){
  597. layui.msg("海报图片不能为空");
  598. return
  599. }
  600. localStorage.removeItem("poster_data");
  601. if (repeat_flag) return false;
  602. repeat_flag = true;
  603. $.ajax({
  604. url: ns.url("fenxiao://shop/poster/add"),
  605. data:{'poster_detail':poster_detail,'template_id':template_id} ,
  606. dataType: 'JSON', //服务器返回json格式数据
  607. type: 'POST', //HTTP请求类型
  608. success: function(res) {
  609. repeat_flag = false;
  610. if(res.code == 0){
  611. layer.confirm(template_id ? '编辑成功' : '添加成功',{
  612. title: '操作提示',
  613. btn: ['返回列表',template_id ? '继续编辑' : '继续添加'],
  614. closeBtn: 0,
  615. yes: function() {
  616. location.href = ns.url("fenxiao://shop/poster/list");
  617. },btn2: function() {
  618. location.reload();
  619. }
  620. })
  621. } else {
  622. layer.msg(res.message);
  623. }
  624. }
  625. });
  626. });
  627. });
  628. function back() {
  629. location.href = ns.url("fenxiao://shop/poster/list");
  630. localStorage.removeItem("poster_data");
  631. }
  632. $('body').on('click', '.layui-nav-more1', function() {
  633. $(this).addClass('layui-new-more1')
  634. $('.layer-form').css("display", 'none')
  635. })
  636. $('body').on('click', '.layui-new-more1', function() {
  637. $(this).removeClass('layui-new-more1')
  638. $('.layer-form').css("display", 'block')
  639. })
  640. $('body').on('click', '.layui-nav-more2', function() {
  641. $(this).addClass('layui-new-more2')
  642. $('.layer-form2').css("display", 'none')
  643. })
  644. $('body').on('click', '.layui-new-more2', function() {
  645. $(this).removeClass('layui-new-more2')
  646. $('.layer-form2').css("display", 'block')
  647. })
  648. $('body').on('click', '.js-delete', function() {
  649. $('.poster-right').css("background-image", 'none')
  650. })
  651. </script>
  652. {/block}
  653. {block name="copyright"}{/block}