addplatform.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <title></title>
  7. <meta name="description" content="">
  8. <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  9. <meta name="robots" content="all,follow">
  10. <!-- Bootstrap CSS-->
  11. <link rel="stylesheet" href="__VENDOR__/bootstrap/css/bootstrap.min.css">
  12. <!-- Font Awesome CSS-->
  13. <link rel="stylesheet" href="__VENDOR__/font-awesome/css/font-awesome.min.css">
  14. <!-- Fontastic Custom icon font-->
  15. <!--<link rel="stylesheet" href="__CSS__/fontastic.css">-->
  16. <link rel="stylesheet" href="__CSS__/iconfont.css">
  17. <!-- Google fonts - Poppins -->
  18. <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Poppins:300,400,700">
  19. <!-- theme stylesheet-->
  20. <link rel="stylesheet" href="__CSS__/style.default.css" id="theme-stylesheet">
  21. <!-- Custom stylesheet - for your changes-->
  22. <link rel="stylesheet" href="__CSS__/custom.css">
  23. <!-- Favicon-->
  24. <link rel="shortcut icon" href="__IMG__/favicon.ico">
  25. <!-- Tweaks for older IEs--><!--[if lt IE 9]>
  26. <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
  27. <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script><![endif]-->
  28. </head>
  29. <body>
  30. <div class="page">
  31. <!-- Main Navbar-->
  32. {include file="layout/header" /}
  33. <div class="page-content d-flex align-items-stretch">
  34. <!-- Side Navbar -->
  35. {include file="layout/navigation" /}
  36. <div class="content-inner">
  37. <!-- Page Header-->
  38. <header class="page-header">
  39. <div class="container-fluid">
  40. <h2 class="no-margin-bottom">新增平台</h2>
  41. </div>
  42. </header>
  43. <!-- Breadcrumb-->
  44. <div class="breadcrumb-holder container-fluid">
  45. <ul class="breadcrumb">
  46. <li class="breadcrumb-item">平台管理</li>
  47. <li class="breadcrumb-item">平台列表</li>
  48. <li class="breadcrumb-item active">新增平台</li>
  49. </ul>
  50. </div>
  51. <!-- Forms Section-->
  52. <section class="forms">
  53. <div class="container-fluid">
  54. <div class="row">
  55. <!-- Form Elements -->
  56. <div class="col-lg-12">
  57. <div class="card">
  58. <div class="card-header d-flex align-items-center">
  59. <h3 class="h4">新增平台</h3>
  60. </div>
  61. <div class="card-body">
  62. <form class="form-horizontal">
  63. <div class="form-group row">
  64. <label style="margin: 8px 0px 0px 30px; width: 80px;" class="form-control-label">平台名称:</label>
  65. <div class="col-sm-9">
  66. <input type="text" id="platform_name" class="form-control">
  67. </div>
  68. </div>
  69. <div class="line"></div>
  70. <div class="form-group row">
  71. <label style="margin: 8px 0px 0px 30px; width: 80px;" class="form-control-label">平台邮箱:</label>
  72. <div class="col-sm-9">
  73. <input type="text" id="platform_email" class="form-control">
  74. </div>
  75. </div>
  76. <div class="line"></div>
  77. <div class="form-group row">
  78. <label style="margin: 8px 0px 0px 30px; width: 80px;" class="form-control-label">平台电话:</label>
  79. <div class="col-sm-9">
  80. <input type="text" id="platform_phone" class="form-control">
  81. </div>
  82. </div>
  83. <div class="line"></div>
  84. <div class="form-group row">
  85. <label style="margin: 8px 0px 0px 30px; width: 80px;" class="form-control-label">平台图标:</label>
  86. <div class="layui-input-block" style="display: flex;">
  87. <input id="file" style="border-style: hidden;border-left: 1px solid #ededed;width: 150px;" type="file" class="layui-input field-name" name="file"/>
  88. <div style="display: flex;margin-left: 20px;">
  89. 所选图标:
  90. <img id="onFile" src="__IMG__/map-marker-violet.png" style="width: 30px;height: 30px">
  91. </div>
  92. </div>
  93. </div>
  94. <div class="line"></div>
  95. <div class="form-group row">
  96. <label style="margin: 8px 0px 0px 30px; width: 80px;" class="form-control-label">状&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;态:<br></label>
  97. <div class="col-sm-9" style="display: flex; line-height: 2.5;">
  98. <div>
  99. <input id="optionsRadios1" type="radio" checked value="1" name="platform_status">
  100. <label for="optionsRadios1">启用</label>
  101. </div>
  102. <div style="margin-left: 30px;">
  103. <input id="optionsRadios2" type="radio" value="2" name="platform_status">
  104. <label for="optionsRadios2">禁用</label>
  105. </div>
  106. </div>
  107. </div>
  108. <div class="line"></div>
  109. <div class="form-group row">
  110. <label style="margin: 8px 0px 0px 30px; width: 80px;" class="form-control-label">验证网址:</label>
  111. <div class="col-sm-9">
  112. <div class="input-group">
  113. <input id="newPlatformUrl" type="text" class="form-control">
  114. <div class="input-group-append">
  115. <button onclick="addPlatformUrl()" type="button" class="btn btn-primary">添加</button>
  116. </div>
  117. </div>
  118. </div>
  119. <div class="col-sm-9" style="margin-left: 110px">
  120. <div class="card-body no-padding" id="platformUrl">
  121. </div>
  122. </div>
  123. </div>
  124. <div class="line"></div>
  125. <div class="form-group row">
  126. <label style="margin: 8px 0px 0px 30px; width: 80px;" class="form-control-label">备&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;注:</label>
  127. <div class="col-sm-9">
  128. <textarea id="platform_remark" class="form-control"></textarea>
  129. </div>
  130. </div>
  131. <div class="line"></div>
  132. <div class="form-group row">
  133. <div class="col-sm-4" style="margin-left: 110px;">
  134. <a class="btn btn-primary" onclick="onSubmit()" style="color: #fff">提交</a>
  135. <a class="btn btn-secondary" onclick="goBack()" style="color: #fff">返回</a>
  136. </div>
  137. </div>
  138. </form>
  139. </div>
  140. </div>
  141. </div>
  142. </div>
  143. </div>
  144. </section>
  145. <!-- Page Footer-->
  146. {include file="layout/footer" /}
  147. </div>
  148. </div>
  149. </div>
  150. <!-- JavaScript files-->
  151. <script src="__VENDOR__/jquery/jquery.min.js"></script>
  152. <script src="__VENDOR__/popper.js/umd/popper.min.js"> </script>
  153. <script src="__VENDOR__/bootstrap/js/bootstrap.min.js"></script>
  154. <script src="__VENDOR__/jquery.cookie/jquery.cookie.js"> </script>
  155. <script src="__VENDOR__/chart.js/Chart.min.js"></script>
  156. <script src="__VENDOR__/jquery-validation/jquery.validate.min.js"></script>
  157. <script src="__JS__/jquery.form.js"></script>
  158. <script src="__JS__/plugins/layer/layer.min.js"></script>
  159. <!-- Main File-->
  160. <script src="__JS__/front.js"></script>
  161. <script>
  162. let platformUrl = [];
  163. function deleteUrl($k) {
  164. platformUrl.splice($k, 1);
  165. let newPlatformUrl = '';
  166. for(let key in platformUrl) {
  167. newPlatformUrl += '<div class="item d-flex">' +
  168. '<label style="width: 90%; word-break: break-all;">'+platformUrl[key]+'</label>' +
  169. '<div style="display: flex; align-items: center;">' +
  170. '<i onclick="deleteUrl('+key+')" class="icon iconfont icon-delete" style="margin-left: 20px; color: red; font-size: 20px; cursor:pointer"></i>' +
  171. '</div>' +
  172. '</div>';
  173. }
  174. $("#platformUrl").html(newPlatformUrl);
  175. }
  176. function addPlatformUrl() {
  177. let newPlatformUrl = $("#newPlatformUrl").val();
  178. platformUrl.push(newPlatformUrl);
  179. let nowPlatformUrl = '';
  180. for(let key in platformUrl) {
  181. nowPlatformUrl += '<div class="item d-flex">' +
  182. '<label style="width: 90%; word-break: break-all;">'+platformUrl[key]+'</label>' +
  183. '<div style="display: flex; align-items: center;">' +
  184. '<i onclick="deleteUrl('+key+')" class="icon iconfont icon-delete" style="margin-left: 20px; color: red; font-size: 20px; cursor:pointer"></i>' +
  185. '</div>' +
  186. '</div>';
  187. }
  188. $("#platformUrl").html(nowPlatformUrl);
  189. }
  190. function onSubmit() {
  191. let formData = new FormData();
  192. if ($("#file")[0].files[0]) {
  193. formData.append("file",$("#file")[0].files[0]);
  194. }
  195. formData.append("platform_name",$("#platform_name").val());
  196. formData.append("platform_email",$("#platform_email").val());
  197. formData.append("platform_phone",$("#platform_phone").val());
  198. formData.append("platform_status",$("input[name='platform_status']:checked").val());
  199. formData.append("platform_remark",$("#platform_remark").val());
  200. formData.append("platform_url",JSON.stringify(platformUrl));
  201. $.ajax({
  202. url: "{:url('admin/index/addPlatform')}", /*接口域名地址*/
  203. type:'post',
  204. data: formData,
  205. contentType: false,
  206. processData: false,
  207. success:function(res){
  208. if(res.code == 1){
  209. layer.alert(res.msg, {title: '友情提示', icon: 1, closeBtn: 0}, function(){
  210. let urlParam = "{:url('admin/index/platformList')}";
  211. window.location.href = urlParam;
  212. });
  213. } else {
  214. layer.alert(res.msg, {title: '友情提示', icon: 2});
  215. }
  216. }
  217. });
  218. /*$.getJSON("{:url('admin/index/addPlatform')}", param, function(res){
  219. if(1 == res.code){
  220. layer.alert(res.msg, {title: '友情提示', icon: 1, closeBtn: 0}, function(){
  221. let urlParam = "{:url('admin/index/platformList')}";
  222. window.location.href = urlParam;
  223. });
  224. }else{
  225. layer.alert(res.msg, {title: '友情提示', icon: 2});
  226. }
  227. });*/
  228. }
  229. function goBack() {
  230. let urlParam = "{:url('admin/index/platformList')}";
  231. window.location.href = urlParam;
  232. }
  233. // 图片预览.
  234. $(function() {
  235. $("#file").change(function(e) {
  236. var imgBox = e.target;
  237. uploadImg(imgBox)
  238. });
  239. function uploadImg(tag) {
  240. var file = tag.files[0];
  241. var imgSrc;
  242. if (!/image\/\w+/.test(file.type)) {
  243. layer.alert("您选择的图片格式错误", {title: '友情提示', icon: 2});
  244. let fileIput = $("#file").val("");
  245. //fileIput.after(fileIput.clone().val(""));
  246. $("#onFile").attr("src", '__IMG__//map-marker-violet.png');
  247. //fileIput.remove();
  248. return false;
  249. }
  250. var reader = new FileReader();
  251. reader.readAsDataURL(file);
  252. reader.onload = function() {
  253. imgSrc = this.result;
  254. $("#onFile").attr("src", imgSrc);
  255. };
  256. }
  257. })
  258. </script>
  259. </body>
  260. </html>