截流自动化的商城平台
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

add.html 4.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. {layout name="layout2" /}
  2. <style>
  3. .layui-form-label {
  4. color: #6a6f6c;
  5. width: 140px;
  6. }
  7. .layui-input-block{
  8. margin-left:170px;
  9. }
  10. .reqRed::before {
  11. content: '*';
  12. color: red;
  13. }
  14. </style>
  15. <div class="layui-form" style="padding: 20px 30px 0 0;">
  16. <div class="layui-form-item">
  17. <label class="layui-form-label reqRed">分类名称:</label>
  18. <div class="layui-input-inline">
  19. <input type="text" name="name" lay-verify="required" lay-verType="tips" autocomplete="off" class="layui-input">
  20. </div>
  21. </div>
  22. <div class="layui-form-item">
  23. <label class="layui-form-label reqRed">上级分类:</label>
  24. <div class="layui-input-inline">
  25. <select name="pid" lay-verify="required" placeholder="请选择" lay-filter="search_pid">
  26. <option value="0" data-level="1">顶级分类</option>
  27. {foreach $category_list as $item => $val}
  28. <option value="{$item}" data-level={$val.level}>{$val.name}</option>
  29. {/foreach}
  30. </select>
  31. </div>
  32. </div>
  33. <div class="layui-form-item" id="bg_image">
  34. <label class="layui-form-label">首页分类背景图:</label>
  35. <div class="layui-input-inline">
  36. <div class="like-upload-image">
  37. <div class="upload-image-elem"><a class="add-upload-image" id="bgimage"> + 添加图片</a></div>
  38. </div>
  39. </div>
  40. </div>
  41. <div class="layui-form-item">
  42. <label class="layui-form-label"></label>
  43. <span style="color: #a3a3a3;font-size: 9px">建议尺寸:宽200像素*高200像素的jpg,jpeg,png图片。顶级类可以设置首页分类背景图</span>
  44. </div>
  45. <div class="layui-form-item">
  46. <label class="layui-form-label">分类图标:</label>
  47. <div class="layui-input-inline">
  48. <div class="like-upload-image">
  49. <div class="upload-image-elem"><a class="add-upload-image" id="image"> + 添加图片</a></div>
  50. </div>
  51. </div>
  52. </div>
  53. <div class="layui-form-item">
  54. <label class="layui-form-label"></label>
  55. <span style="color: #a3a3a3;font-size: 9px">建议尺寸:宽200像素*高200像素的jpg,jpeg,png图片</span>
  56. </div>
  57. <div class="layui-form-item">
  58. <label class="layui-form-label">排序:</label>
  59. <div class="layui-input-inline">
  60. <input type="number" name="sort" value="255" class="layui-input">
  61. </div>
  62. </div>
  63. <div class="layui-form-item">
  64. <label class="layui-form-label"></label>
  65. <span style="color: #a3a3a3;font-size: 9px">排序值必须为整数;数值越小,越靠前</span>
  66. </div>
  67. <div class="layui-form-item">
  68. <label class="layui-form-label">显示状态:</label>
  69. <div class="layui-input-inline">
  70. <input type="radio" name="is_show" value="1" title="显示" checked>
  71. <input type="radio" name="is_show" value="0" title="不显示">
  72. </div>
  73. </div>
  74. <div class="layui-form-item">
  75. <label class="layui-form-label">分类描述:</label>
  76. <div class="layui-input-inline">
  77. <textarea name="remark" autocomplete="off" class="layui-textarea"></textarea>
  78. </div>
  79. </div>
  80. <div class="layui-form-item layui-hide">
  81. <input type="button" lay-submit lay-filter="add-goods_category-submit" id="add-goods_category-submit" value="确认">
  82. </div>
  83. </div>
  84. <script>
  85. layui.config({
  86. version:"{$front_version}",
  87. base: '/static/lib' //静态资源所在路径
  88. }).use(['form'], function(){
  89. var $ = layui.$
  90. ,form = layui.form;
  91. //监听上级分类选择
  92. form.on('select(search_pid)', function(data){
  93. if(data.value != 0) {
  94. // 只有顶级类才可以设置首页分类背景图,,其它级别分类隐藏上传设置
  95. $('#bg_image').addClass('layui-hide');
  96. // 先存值至data-img属性中
  97. $("input[name='bg_image']").attr('data-img', $("input[name='bg_image']").val());
  98. $("input[name='bg_image']").val('');
  99. }else{
  100. // 显示图片上传
  101. $('#bg_image').removeClass('layui-hide');
  102. // 还原值隐藏字段值
  103. $("input[name='bg_image']").val($("input[name='bg_image']").attr('data-img'));
  104. }
  105. });
  106. // 图片上传
  107. like.delUpload();
  108. // 分类图标
  109. $(document).on("click", "#image", function () {
  110. like.imageUpload({
  111. limit: 1,
  112. field: "image",
  113. that: $(this)
  114. });
  115. })
  116. // 首页分类背景图
  117. $(document).on("click", "#bgimage", function () {
  118. like.imageUpload({
  119. limit: 1,
  120. field: "bg_image",
  121. that: $(this)
  122. });
  123. })
  124. })
  125. </script>