addwelcome.html 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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/addWelcome')}">
  83. <div class="form-group" style="display: flex">
  84. <label style="margin-left: 40px; line-height: 2.5;">排序:</label>
  85. <div class="input-group col-sm-4">
  86. <input class="form-control" name="sort" required="" aria-required="true"/>
  87. </div>
  88. </div>
  89. <div class="form-group">
  90. <label style="margin-left: 40px">欢迎语:</label>
  91. <div class="input-group col-sm-4" style="margin-top: 10px; margin-left: 40px">
  92. <textarea id="contentqq" name="word" style="width:700px;height:200px;visibility:hidden;"></textarea>
  93. </div>
  94. </div>
  95. <div class="form-group">
  96. <div style="margin-left: 40px; margin-top: 20px;">
  97. <button class="btn btn-primary" type="submit">提交</button>
  98. </div>
  99. </div>
  100. </form>
  101. </div>
  102. </div>
  103. </div>
  104. </div>
  105. </div>
  106. <script src="__JS__/jquery.min.js?v=2.1.4"></script>
  107. <script src="__JS__/bootstrap.min.js?v=3.3.6"></script>
  108. <script src="__JS__/content.min.js?v=1.0.0"></script>
  109. <script src="__JS__/plugins/validate/jquery.validate.min.js"></script>
  110. <script src="__JS__/plugins/validate/messages_zh.min.js"></script>
  111. <script src="__JS__/plugins/layer/layer.min.js"></script>
  112. <script src="__JS__/layui/layui.js"></script>
  113. <script src="__JS__/jquery.form.js"></script>
  114. <script src="/static/customer/js/md5.js"></script>
  115. <script type="text/javascript">
  116. let config = {
  117. socket: '{$socket}',
  118. };
  119. let date = new Date(new Date().setHours(0, 0, 0, 0)) / 1000;
  120. let getLocation = window.location.href;
  121. let host = getLocation.split('/admin')[0];
  122. //let apiToken = hex_md5('customer-service'+date+host);
  123. let apiToken = hex_md5('customer-service'+host);
  124. const myHost = "http://" + window.location.host;
  125. layui.use(['form', 'upload'], function(){
  126. var form = layui.form;
  127. });
  128. var index = '';
  129. function showStart(){
  130. index = layer.load(0, {shade: false});
  131. return true;
  132. }
  133. function showSuccess(res){
  134. let socket = new WebSocket(config.socket+'?apiToken=' + apiToken);
  135. socket.onopen = function(res) {
  136. console.log('握手成功');
  137. socket.send(JSON.stringify({
  138. type: 'updatecache',
  139. data: {dtype: ''},
  140. }));
  141. };
  142. layer.ready(function(){
  143. layer.close(index);
  144. if(1 == res.code){
  145. layer.alert(res.msg, {title: '友情提示', icon: 1, closeBtn: 0}, function(){
  146. window.location.href = myHost + '/admin/system/welcoming';
  147. });
  148. }else if(111 == res.code){
  149. window.location.reload();
  150. }else{
  151. layer.msg(res.msg, {anim: 6});
  152. }
  153. });
  154. }
  155. $(document).ready(function(){
  156. // 添加管理员
  157. var options = {
  158. beforeSubmit:showStart,
  159. success:showSuccess
  160. };
  161. $('#commentForm').submit(function(){
  162. $(this).ajaxSubmit(options);
  163. return false;
  164. });
  165. });
  166. // 表单验证
  167. $.validator.setDefaults({
  168. highlight: function(e) {
  169. $(e).closest(".form-group").removeClass("has-success").addClass("has-error")
  170. },
  171. success: function(e) {
  172. e.closest(".form-group").removeClass("has-error").addClass("has-success")
  173. },
  174. errorElement: "span",
  175. errorPlacement: function(e, r) {
  176. e.appendTo(r.is(":radio") || r.is(":checkbox") ? r.parent().parent().parent() : r.parent())
  177. },
  178. errorClass: "help-block m-b-none",
  179. validClass: "help-block m-b-none"
  180. });
  181. layui.use(['form', 'upload'], function(){
  182. var form = layui.form;
  183. form.on('select(group)', function(value){
  184. $("#groups_id").val(value.value);
  185. });
  186. form.on('select(robotgroups)', function(value){
  187. $("#robotgroups_id").val(value.value);
  188. });
  189. });
  190. </script>
  191. </body>
  192. </html>