sitemap_info_add.html 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. {extend name="common/base"/}
  2. <!-- 主体 -->
  3. {block name="body"}
  4. <form class="layui-form p-4">
  5. <h3 class="pb-3">网站地图内容</h3>
  6. <table class="layui-table layui-table-form">
  7. <tr>
  8. <td class="layui-td-gray">标题<font>*</font></td>
  9. <td>
  10. <input type="hidden" name="id" value="{$id}" />
  11. <input type="text" name="name" lay-verify="required" autocomplete="off" placeholder="请输入标题" lay-reqText="请输入标题" class="layui-input" {notempty name="$sitemap.name" }value="{$sitemap.name}" {/notempty}>
  12. </td>
  13. <td class="layui-td-gray">排序</td>
  14. <td><input type="text" name="sort" placeholder="请输入排序,数字" autocomplete="off" class="layui-input" {notempty name="$sitemap.sort" }value="{$sitemap.sort}" {/notempty}></td>
  15. </tr>
  16. <tr>
  17. <td class="layui-td-gray">PC端链接<font>*</font></td>
  18. <td>
  19. <input type="text" name="pc_src" lay-verify="required" autocomplete="off" placeholder="请输入PC端链接" lay-reqText="请输入PC端链接" class="layui-input" {notempty name="$sitemap.pc_src"}value="{$sitemap.pc_src}" {/notempty}>
  20. </td>
  21. <td class="layui-td-gray">移动端链接<font>*</font></td>
  22. <td>
  23. <input type="text" name="mobile_src" lay-verify="required" autocomplete="off" placeholder="请输入移动端链接" lay-reqText="请输入移动端链接" class="layui-input" {notempty name="$sitemap.mobile_src"}value="{$sitemap.mobile_src}" {/notempty}>
  24. </td>
  25. </tr>
  26. <tr>
  27. <td class="layui-td-gray-2">PC端图片</td>
  28. <td>
  29. <div class="layui-upload">
  30. <button type="button" class="layui-btn layui-btn-sm" id="uploadBtn">上传PC端图片</button>
  31. <div class="layui-upload-list" id="demo1" style="width:200px; height:120px; overflow:hidden">
  32. <img {notempty name="$sitemap.pc_img" }src="{:get_file($sitemap.pc_img)}" {/notempty} heght="120px;" style="max-width: 100%;" />
  33. <input type="hidden" name="pc_img" {notempty name="$sitemap.pc_img" }value="{$sitemap.pc_img}" {/notempty}>
  34. </div>
  35. </div>
  36. </td>
  37. <td class="layui-td-gray-2">移动端图片</td>
  38. <td>
  39. <div class="layui-upload">
  40. <button type="button" class="layui-btn layui-btn-sm" id="uploadBtn2">上传移动端图片</button>
  41. <div class="layui-upload-list" id="demo2" style="width:200px; height:120px; overflow:hidden">
  42. <img {notempty name="$sitemap.mobile_img" }src="{:get_file($sitemap.mobile_img)}" {/notempty} heght="120px;" style="max-width: 100%;" />
  43. <input type="hidden" name="mobile_img" {notempty name="$sitemap.mobile_img" }value="{$sitemap.mobile_img}" {/notempty}>
  44. </div>
  45. </div>
  46. </td>
  47. </tr>
  48. </table>
  49. <div class="py-3">
  50. {notempty name="$sitemap.sitemap_cate_id" }
  51. <input type="hidden" name="sitemap_cate_id" value="{$sitemap.sitemap_cate_id}" />
  52. {else/}
  53. <input type="hidden" name="sitemap_cate_id" value="{$sitemap_cate_id}" />
  54. {/notempty}
  55. <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform">立即提交</button>
  56. <button type="reset" class="layui-btn layui-btn-primary">重置</button>
  57. </div>
  58. </form>
  59. {/block}
  60. <!-- /主体 -->
  61. <!-- 脚本 -->
  62. {block name="script"}
  63. <script>
  64. const moduleInit = ['tool'];
  65. function gouguInit() {
  66. var form = layui.form,tool=layui.tool,upload = layui.upload;
  67. //pc端图片
  68. var uploadInst = upload.render({
  69. elem: '#uploadBtn',
  70. url: '/admin/api/upload',
  71. done: function (res) {
  72. //如果上传失败
  73. if (res.code == 1) {
  74. return layer.msg('上传失败');
  75. }
  76. //上传成功
  77. $('#demo1 input').attr('value', res.data.id);
  78. $('#demo1 img').attr('src', res.data.filepath);
  79. }
  80. });
  81. //移动端图片
  82. var uploadInst2 = upload.render({
  83. elem: '#uploadBtn2',
  84. url: '/admin/api/upload',
  85. done: function (res) {
  86. //如果上传失败
  87. if (res.code == 1) {
  88. return layer.msg('上传失败');
  89. }
  90. //上传成功
  91. $('#demo2 input').attr('value', res.data.id);
  92. $('#demo2 img').attr('src', res.data.filepath);
  93. }
  94. });
  95. //监听提交
  96. form.on('submit(webform)', function (data) {
  97. let callback = function (e) {
  98. layer.msg(e.msg);
  99. if (e.code == 0) {
  100. parent.layui.tool.close(1000);
  101. }
  102. }
  103. tool.post("/admin/sitemap/sitemap_info_add", data.field, callback);
  104. return false;
  105. });
  106. }
  107. </script>
  108. {/block}
  109. <!-- /脚本 -->