set.blade.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. @extends('layouts.base')
  2. @section('title', "基础设置")
  3. @section('content')
  4. <style type="text/css">
  5. .sub-color .btn-success{
  6. background-color: rgb(0, 188, 212);
  7. color: rgb(255, 255, 255);
  8. }
  9. .panel-body .form-group {
  10. padding-top: 20px !important;
  11. }
  12. </style>
  13. <script type="text/javascript" src="{{ plugin_assets('article', 'assets/js/jquery.json.js') }}"></script>
  14. <script type="text/javascript" src="{{ plugin_assets('article', 'assets/js/ueditor/ueditor.config.js') }}"></script>
  15. <script type="text/javascript" src="{{ plugin_assets('article', 'assets/js/ueditor/ueditor.all.min.js') }}"></script>
  16. <script type="text/javascript" src="{{ plugin_assets('article', 'assets/js/ueditor/ueditor.parse.js') }}"></script>
  17. <script type="text/javascript" src="{{ plugin_assets('article', 'assets/js/ueditor/lang/zh-cn/zh-cn.js') }}"></script>
  18. <script type="text/javascript">
  19. $(function(){
  20. var pagestate = 0;
  21. //初始化百度编辑器
  22. var opts = {type: 'image',direct: false,multi: true,tabs: {'upload': 'active','browser': '','crawler': ''},path: '',dest_dir: '',global: false,thumb: false,width: 0};
  23. var ue = UE.getEditor("editor", {
  24. topOffset: 0,
  25. autoFloatEnabled: false,
  26. autoHeightEnabled: false,
  27. autotypeset: {
  28. removeEmptyline: true
  29. },
  30. maximumWords : 9999999,
  31. initialFrameHeight: 607,
  32. focus : true,
  33. toolbars : [['fullscreen', 'source', '|', 'undo', 'redo', '|', 'bold', 'italic', 'underline', 'strikethrough', 'forecolor', 'backcolor', '|','justifyleft', 'justifycenter', 'justifyright', '|', 'insertorderedlist', 'insertunorderedlist', 'blockquote', 'emotion', 'insertvideo', 'removeformat', '|', 'rowspacingtop', 'rowspacingbottom', 'lineheight','indent', 'paragraph', 'fontsize', '|','inserttable', 'deletetable', 'insertparagraphbeforetable', 'insertrow', 'deleterow', 'insertcol', 'deletecol','mergecells', 'mergeright', 'mergedown', 'splittocells', 'splittorows', 'splittocols', '|', 'anchor', 'map', 'print', 'drafts', '|','autotypeset']],
  34. });
  35. ue.ready(function() {
  36. ue.addListener('contentChange',function(){
  37. $("#preview-content").html(ue.getContent());
  38. pagestate = 1;
  39. });
  40. $(".itembox").click(function(a) {
  41. ue.execCommand("insertHtml", "<div>" + $(this).html()+"<p></p>"+ "</div>");
  42. });
  43. $(".trash").click(function(){
  44. if(confirm("确定要清空编辑器?此操作不可恢复。")){
  45. ue.setContent("");
  46. }
  47. });
  48. $(document).on("click",".mylink-nav",function(){
  49. var href = $(this).data("href");
  50. var id = $("#modal-mylink").attr("data-id");
  51. if(id){
  52. $("input[data-id="+id+"]").val(href);
  53. $("#modal-mylink").attr("data-id","");
  54. }else{
  55. ue.execCommand('link', {href:href, 'class':'acolor'});
  56. }
  57. $("#modal-mylink .close").click();
  58. });
  59. $(".mylink-nav2").click(function(){
  60. var href = $("textarea[name=mylink_href]").val();
  61. if(href){
  62. var id = $("#modal-mylink").attr("data-id");
  63. if(id){
  64. $("input[data-id="+id+"]").val(href);
  65. $("#modal-mylink").attr("data-id","");
  66. }else{
  67. ue.execCommand('link', {href:href, 'class':'acolor'});
  68. }
  69. $("#modal-mylink .close").click();
  70. $("textarea[name=mylink_href]").val("");
  71. }else{
  72. $("textarea[name=mylink_href]").focus();
  73. alert("链接不能为空!");
  74. }
  75. });
  76. });
  77. let uploadUrl = @php echo json_encode(uploadUrl()); @endphp
  78. // 初始化调用微擎上传图片
  79. UE.registerUI('myinsertimage',function(editor, uiName) {
  80. editor.registerCommand(uiName, {
  81. execCommand: function() {
  82. require(['fileUploader'],
  83. function(uploader) {
  84. uploader.upload_url(uploadUrl.upload_url);
  85. uploader.image_url(uploadUrl.image_url);
  86. uploader.fetch_url(uploadUrl.fetch_url);
  87. uploader.delet_url(uploadUrl.delete_url);
  88. uploader.show(function(imgs) {
  89. if (imgs.length == 0) {
  90. return;
  91. } else if (imgs.length == 1) {
  92. editor.execCommand('insertimage', {
  93. 'src': imgs[0]['url'],
  94. '_src': imgs[0]['url'],
  95. 'width': '100%',
  96. 'alt': imgs[0].filename
  97. });
  98. } else {
  99. var imglist = [];
  100. for (i in imgs) {
  101. imglist.push({
  102. 'src': imgs[i]['url'],
  103. '_src': imgs[i]['url'],
  104. 'width': '100%',
  105. 'alt': imgs[i].filename
  106. });
  107. }
  108. editor.execCommand('insertimage', imglist);
  109. }
  110. },
  111. opts);
  112. });
  113. }
  114. });
  115. var btn = new UE.ui.Button({
  116. name: '插入图片',
  117. title: '插入图片',
  118. cssRules: 'background-position: -726px -77px',
  119. onclick: function() {
  120. editor.execCommand(uiName);
  121. }
  122. });
  123. editor.addListener('selectionchange',
  124. function() {
  125. var state = editor.queryCommandState(uiName);
  126. if (state == -1) {
  127. btn.setDisabled(true);
  128. btn.setChecked(false);
  129. } else {
  130. btn.setDisabled(false);
  131. btn.setChecked(state);
  132. }
  133. });
  134. return btn;
  135. },19);
  136. // 初始化 系统链接选择
  137. UE.registerUI('mylink', function(editor, uiName) {
  138. editor.registerCommand(uiName, {
  139. execCommand: function() {
  140. $("#modal-mylink").modal();
  141. }
  142. });
  143. var btn = new UE.ui.Button({
  144. name: '超链接',
  145. title: '超链接',
  146. cssRules: 'background-position: -500px 0;',
  147. onclick: function() {
  148. editor.execCommand(uiName);
  149. }
  150. });
  151. editor.addListener('selectionchange', function() {
  152. var state = editor.queryCommandState(uiName);
  153. if (state == -1) {
  154. btn.setDisabled(true);
  155. btn.setChecked(false);
  156. } else {
  157. btn.setDisabled(false);
  158. btn.setChecked(state);
  159. }
  160. });
  161. return btn;
  162. });
  163. //初始化百度编辑器结束
  164. });
  165. </script>
  166. <section class="content">
  167. <form id="setform" action="" method="post" class="form-horizontal form">
  168. <div class="top">
  169. <ul class="add-shopnav" id="myTab">
  170. <li class="active"><a href="" class="tab">基础设置</a></li>
  171. </ul>
  172. </div>
  173. <div class="info">
  174. <div class="panel-body">
  175. <div class="tab-content">
  176. <div class="tab-pane active">
  177. <div class="form-group">
  178. <label class="col-xs-12 col-sm-3 col-md-2 control-label">插件开启</label>
  179. <div class="col-sm-9 col-xs-12">
  180. <label class="radio-inline">
  181. <input type="radio" name="setdata[is_open]" value="1"
  182. @if($set['is_open'] == 1) checked="checked" @endif /> 开启</label>
  183. <label class="radio-inline">
  184. <input type="radio" name="setdata[is_open]" value="0"
  185. @if($set['is_open'] == 0) checked="checked" @endif /> 关闭</label>
  186. </div>
  187. </div>
  188. <div class="form-group">
  189. <label class="col-xs-12 col-sm-3 col-md-2 control-label">自定义名称</label>
  190. <div class="col-sm-9 col-xs-12 col-md-6">
  191. <input type="text" name="setdata[plugin_name]" class="form-control" value="{{$set['plugin_name']}}"/>
  192. </div>
  193. </div>
  194. <div class="form-group">
  195. <label class="col-xs-12 col-sm-3 col-md-2 control-label">banner图</label>
  196. <div class="col-sm-9 col-xs-12 col-md-6 detail-logo">
  197. {!! app\common\helpers\ImageHelper::tplFormFieldImage('setdata[banner]', $set['banner']) !!}
  198. <span class="help-block">建议尺寸: 350 * 136 </span>
  199. </div>
  200. </div>
  201. <div class="form-group">
  202. <label class="col-xs-12 col-sm-3 col-md-1 control-label">使用说明</label>
  203. <div class="col-sm-9 col-xs-12 col-md-11">
  204. <div class="content">
  205. <div class="con1" style="width:100% !important;">
  206. <textarea id="editor" name='setdata[synopsis]' style="width:100%;">
  207. {!! htmlspecialchars_decode($set['synopsis']) !!}
  208. </textarea>
  209. {{--<script id="editor" style="width:100%;">
  210. {!! htmlspecialchars_decode($set['synopsis']) !!}
  211. </script>--}}
  212. </div>
  213. </div>
  214. </div>
  215. </div>
  216. </div>
  217. </div>
  218. <div class="form-group sub-color">
  219. <input type="submit" name="submit" value="保存设置" class="btn btn-success"
  220. onclick="return formcheck()"/>
  221. </div>
  222. </div>
  223. </div>
  224. </form>
  225. </section>
  226. <script type="text/javascript">
  227. function formcheck()
  228. {
  229. $.ajax({
  230. //几个参数需要注意一下
  231. type: "POST",//方法类型
  232. dataType: "json",//预期服务器返回的数据类型
  233. url: "{!! yzWebFullUrl('plugin.promotion-assistant.admin.set.index') !!}" ,//url
  234. data: $('#setform').serialize(),
  235. success: function (result) {
  236. console.log(result);
  237. if (result.result == 1) {
  238. alert("保存成功");
  239. };
  240. },
  241. error : function() {
  242. alert("异常!");
  243. }
  244. });
  245. // var setdata = document.getElementsByName("setdata");
  246. // console.log(setdata);
  247. return false;
  248. }
  249. </script>
  250. @endsection