editwelcome.html 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>编辑欢迎语</title>
  7. <link rel="shortcut icon" href="favicon.ico">
  8. <link href="__CSS__/bootstrap.min.css?v=3.3.6" rel="stylesheet">
  9. <link href="__CSS__/font-awesome.min.css?v=4.4.0" rel="stylesheet">
  10. <link href="__CSS__/animate.min.css" rel="stylesheet">
  11. <link href="__JS__/layui/css/layui.css" rel="stylesheet">
  12. <link href="__CSS__/style.min.css?v=4.1.0" rel="stylesheet">
  13. <script charset="utf-8" src="__EDIT__/kindeditor-min.js"></script>
  14. <script charset="utf-8" src="__EDIT__/lang/zh_CN.js"></script>
  15. <script>
  16. KindEditor.ready(function(K) {
  17. K.each({
  18. 'plug-align' : {
  19. name : '对齐方式',
  20. method : {
  21. 'justifyleft' : '左对齐',
  22. 'justifycenter' : '居中对齐',
  23. 'justifyright' : '右对齐'
  24. }
  25. },
  26. 'plug-order' : {
  27. name : '编号',
  28. method : {
  29. 'insertorderedlist' : '数字编号',
  30. 'insertunorderedlist' : '项目编号'
  31. }
  32. },
  33. 'plug-indent' : {
  34. name : '缩进',
  35. method : {
  36. 'indent' : '向右缩进',
  37. 'outdent' : '向左缩进'
  38. }
  39. }
  40. },function( pluginName, pluginData ){
  41. var lang = {};
  42. lang[pluginName] = pluginData.name;
  43. KindEditor.lang( lang );
  44. KindEditor.plugin( pluginName, function(K) {
  45. var self = this;
  46. self.clickToolbar( pluginName, function() {
  47. var menu = self.createMenu({
  48. name : pluginName,
  49. width : pluginData.width || 100
  50. });
  51. K.each( pluginData.method, function( i, v ){
  52. menu.addItem({
  53. title : v,
  54. checked : false,
  55. iconClass : pluginName+'-'+i,
  56. click : function() {
  57. self.exec(i).hideMenu();
  58. }
  59. });
  60. })
  61. });
  62. });
  63. });
  64. K.create('#contentqq', {
  65. themeType : 'qq',
  66. items : [
  67. 'bold','italic','underline','fontname','fontsize','forecolor','hilitecolor','plug-align','plug-order','plug-indent','link'
  68. ]
  69. });
  70. });
  71. </script>
  72. </head>
  73. <body class="gray-bg">
  74. <div class="wrapper wrapper-content animated fadeInRight">
  75. <div class="row">
  76. <div class="col-sm-8">
  77. <div class="ibox float-e-margins">
  78. <div class="ibox-title">
  79. <h5>编辑欢迎语</h5>
  80. </div>
  81. <div class="ibox-content">
  82. <form class="form-horizontal m-t layui-form" id="commentForm" method="post" action="{:url('system/editWelcome')}">
  83. <input type="hidden" name="id" value="{$replySystem['id']}"/>
  84. <div class="form-group" style="display: flex">
  85. <label style="margin-left: 40px; line-height: 2.5;">排序:</label>
  86. <div class="input-group col-sm-4">
  87. <input class="form-control" name="sort" required="" aria-required="true" value="{$replySystem['sort']}"/>
  88. </div>
  89. </div>
  90. <div class="form-group">
  91. <label style="margin-left: 40px">欢迎语:</label>
  92. <div class="input-group col-sm-4" style="margin-top: 10px; margin-left: 40px">
  93. <textarea id="contentqq" name="word" style="width:700px;height:200px;visibility:hidden;">{$replySystem['word']}</textarea>
  94. </div>
  95. </div>
  96. <div class="form-group">
  97. <div style="margin-left: 40px; margin-top: 20px;">
  98. <button class="btn btn-primary" type="submit">提交</button>
  99. </div>
  100. </div>
  101. </form>
  102. </div>
  103. </div>
  104. </div>
  105. </div>
  106. </div>
  107. <script src="__JS__/jquery.min.js?v=2.1.4"></script>
  108. <script src="__JS__/bootstrap.min.js?v=3.3.6"></script>
  109. <script src="__JS__/content.min.js?v=1.0.0"></script>
  110. <script src="__JS__/plugins/validate/jquery.validate.min.js"></script>
  111. <script src="__JS__/plugins/validate/messages_zh.min.js"></script>
  112. <script src="__JS__/plugins/layer/layer.min.js"></script>
  113. <script src="__JS__/layui/layui.js"></script>
  114. <script src="__JS__/jquery.form.js"></script>
  115. <script src="/static/customer/js/md5.js"></script>
  116. <script type="text/javascript">
  117. let config = {
  118. socket: '{$socket}',
  119. };
  120. let date = new Date(new Date().setHours(0, 0, 0, 0)) / 1000;
  121. let getLocation = window.location.href;
  122. let host = getLocation.split('/admin')[0];
  123. //let apiToken = hex_md5('customer-service'+date+host);
  124. let apiToken = hex_md5('customer-service'+host);
  125. const myHost = "http://" + window.location.host;
  126. layui.use(['form', 'upload'], function(){
  127. var form = layui.form;
  128. });
  129. var index = '';
  130. function showStart(){
  131. index = layer.load(0, {shade: false});
  132. return true;
  133. }
  134. function showSuccess(res){
  135. let socket = new WebSocket('ws://' + config.socket+'?apiToken=' + apiToken);
  136. socket.onopen = function(res) {
  137. console.log('握手成功');
  138. socket.send(JSON.stringify({
  139. type: 'updatecache',
  140. data: {dtype: ''},
  141. }));
  142. };
  143. layer.ready(function(){
  144. layer.close(index);
  145. if(1 == res.code){
  146. layer.alert(res.msg, {title: '友情提示', icon: 1, closeBtn: 0}, function(){
  147. window.location.href = myHost + '/admin/system/welcoming';
  148. });
  149. }else if(111 == res.code){
  150. window.location.reload();
  151. }else{
  152. layer.msg(res.msg, {anim: 6});
  153. }
  154. });
  155. }
  156. $(document).ready(function(){
  157. // 添加管理员
  158. var options = {
  159. beforeSubmit:showStart,
  160. success:showSuccess
  161. };
  162. $('#commentForm').submit(function(){
  163. $(this).ajaxSubmit(options);
  164. return false;
  165. });
  166. });
  167. // 表单验证
  168. $.validator.setDefaults({
  169. highlight: function(e) {
  170. $(e).closest(".form-group").removeClass("has-success").addClass("has-error")
  171. },
  172. success: function(e) {
  173. e.closest(".form-group").removeClass("has-error").addClass("has-success")
  174. },
  175. errorElement: "span",
  176. errorPlacement: function(e, r) {
  177. e.appendTo(r.is(":radio") || r.is(":checkbox") ? r.parent().parent().parent() : r.parent())
  178. },
  179. errorClass: "help-block m-b-none",
  180. validClass: "help-block m-b-none"
  181. });
  182. layui.use(['form', 'upload'], function(){
  183. var form = layui.form;
  184. form.on('select(group)', function(value){
  185. $("#groups_id").val(value.value);
  186. });
  187. form.on('select(robotgroups)', function(value){
  188. $("#robotgroups_id").val(value.value);
  189. });
  190. });
  191. </script>
  192. </body>
  193. </html>