add.blade.php 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. @extends('admin/layout')
  2. @section('header')
  3. <link href="{{asset('css/plugins/chosen/chosen.css')}}" rel="stylesheet">
  4. <link href="{{asset('css/plugins/switchery/switchery.css')}}" rel="stylesheet">
  5. {{--<link href="{{asset('js/plugins/bootstrap-select-1.13.5/css/bootstrap-select.min.css')}}" rel="stylesheet">--}}
  6. <link rel="stylesheet"
  7. href="https://cdn.jsdelivr.net/npm/bootstrap-select@1.13.9/dist/css/bootstrap-select.min.css">
  8. @endsection
  9. @section('content')
  10. <body class="gray-bg">
  11. <div class="wrapper wrapper-content animated fadeInRight">
  12. <div class="row">
  13. <div class="col-sm-12">
  14. <div class="ibox float-e-margins">
  15. <div class="ibox-content">
  16. <form method="get" class="form-horizontal" id="form">
  17. <input type="hidden" name="" id="">
  18. <div class="form-group">
  19. <label class="col-sm-2 control-label" for="nickname"><span
  20. class="red">* </span>标题:</label>
  21. <div class="col-sm-6">
  22. <input type="text" class="form-control" id="title" name="title" autocomplete="off"
  23. value="{{$messageInfo->title??''}}">
  24. </div>
  25. </div>
  26. <div class="form-group">
  27. <label class="col-sm-2 control-label" for="username_new"><span class="red">* </span>
  28. 内容:</label>
  29. <div class="col-sm-6">
  30. <input type="text" class="form-control" id="message" name="message"
  31. value="{{$messageInfo->message??''}}" autocomplete="off">
  32. </div>
  33. </div>
  34. <div class="form-group">
  35. <label class="col-sm-2 control-label" for="username_new"><span class="red">* </span>
  36. 链接:</label>
  37. <div class="col-sm-6">
  38. <input type="text" class="form-control" id="url" name="url"
  39. value="{{$messageInfo->url??''}}" autocomplete="off">
  40. </div>
  41. </div>
  42. <div class="form-group">
  43. <label class="col-sm-2 control-label" for="type"><span
  44. class="red">* </span>消息类型:</label>
  45. <div class="col-sm-8">
  46. @if (empty($messageInfo))
  47. <select class="form-control" style="width:350px;"
  48. id="type" name="type">
  49. <option value="0">请选择消息类型</option>
  50. <option value="1">网站到期</option>
  51. <option value="2">ssl证书到期</option>
  52. <option value="3">cdn加速到期</option>
  53. <option value="4">网站域名到期</option>
  54. <option value="5">网站服务期到期</option>
  55. <option value="6">软文</option>
  56. <option value="7">报表</option>
  57. <option value="8">询盘</option>
  58. </select>
  59. @else
  60. <select class="form-control" style="width:350px;"
  61. id="type" name="type">
  62. <option value="0" @if ($messageInfo->type==0) selected @endif>请选择消息类型
  63. </option>
  64. <option value="1" @if ($messageInfo->type==1) selected @endif>网站到期</option>
  65. <option value="2" @if ($messageInfo->type==2) selected @endif>ssl证书到期</option>
  66. <option value="3" @if ($messageInfo->type==3) selected @endif>cdn加速到期</option>
  67. <option value="4" @if ($messageInfo->type==4) selected @endif>网站域名到期</option>
  68. <option value="5" @if ($messageInfo->type==5) selected @endif>网站服务期到期</option>
  69. <option value="5" @if ($messageInfo->type==6) selected @endif>软文</option>
  70. <option value="5" @if ($messageInfo->type==7) selected @endif>报表</option>
  71. <option value="5" @if ($messageInfo->type==8) selected @endif>询盘</option>
  72. </select>
  73. @endif
  74. </div>
  75. </div>
  76. <div class="form-group">
  77. <label class="col-sm-2 control-label">banner:</label>
  78. <div class="col-sm-4">
  79. <button type="button" class="btn btn-primary" name="file_upload">文件上传
  80. </button>
  81. <input type="file" value="" style="display: none" name="uploadFile"
  82. data-for="logo_img">
  83. <img id="img" width="200px" src="{{$messageInfo->img??''}}">
  84. </div>
  85. </div>
  86. <div class="form-group">
  87. <div class="col-sm-4 col-sm-offset-2">
  88. <button class="btn btn-primary" type="button" data-id="{{$messageInfo->id??0}}"
  89. id="save">
  90. 保存
  91. </button>
  92. <button class="btn btn-white" type="button" id="cancel">取消</button>
  93. </div>
  94. </div>
  95. </form>
  96. </div>
  97. </div>
  98. </div>
  99. </div>
  100. </div>
  101. </body>
  102. @endsection
  103. @section('footer')
  104. <script src="{{asset('js/plugins/switchery/switchery.js')}}"></script>
  105. <script src="https://cdn.jsdelivr.net/npm/bootstrap-select@1.13.9/dist/js/bootstrap-select.min.js"></script>
  106. <script>
  107. $(document).on('click', '[name=file_upload]', function () {
  108. $(this).next().trigger('click');
  109. });
  110. var jsSwitch = document.querySelector(".js-switch");
  111. new Switchery(jsSwitch, {color: "#1AB394", size: 'small'});
  112. $(document).on('click', '#cancel', function () {
  113. tips.closeParentLayer();
  114. });
  115. $(document).on('change', '[name=uploadFile]', function () {
  116. if (!$(this)[0].files[0]) {
  117. return;
  118. }
  119. var formData = new FormData();
  120. formData.append('file', $(this)[0].files[0]);
  121. var ln;
  122. $.ajax({
  123. url: '/admin/oss/upload',
  124. type: 'POST',
  125. cache: false,
  126. data: formData,
  127. processData: false,
  128. contentType: false,
  129. beforeSend: function () {
  130. ln = layer.load();
  131. },
  132. complete: function () {
  133. layer.close(ln);
  134. },
  135. success: function (result) {
  136. var data = result.path;
  137. $('#img').attr('src', data);
  138. },
  139. error: function (XMLHttpRequest) {
  140. if (XMLHttpRequest.status === 500) {
  141. layer.alert("异步请求失败", {icon: 5});
  142. return;
  143. }
  144. layer.alert(JSON.parse(XMLHttpRequest.responseText).message, {icon: 0});
  145. }
  146. });
  147. });
  148. $(document).on('click', '#save', function () {
  149. var data = tips.getFormValues('#form');
  150. data.img = $("#img").attr('src');
  151. var id = $(this).data('id');
  152. var url = '/admin/message/addOrUpdate/' + id;
  153. var type = 'get';
  154. var ajaxConfig = {
  155. url: url,
  156. type: type,
  157. data: data,
  158. success: function (result) {
  159. layer.msg(result.message, {icon: 6, time: 1500}, function () {
  160. tips.closeParentLayer();
  161. window.parent.tips.tableRefresh('#table');
  162. });
  163. }
  164. };
  165. tips.ajax(ajaxConfig);
  166. });
  167. </script>
  168. @endsection