截流自动化的商城平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

add.html 8.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. {layout name="layout2" /}
  2. <style>
  3. .tips{
  4. color: red;
  5. }
  6. .link{
  7. display: none;
  8. }
  9. .size-tips-div{
  10. display: none;
  11. }
  12. .category{
  13. display: none;
  14. }
  15. .layui-form-label{
  16. width: 90px;
  17. }
  18. </style>
  19. <div class="layui-form" lay-filter="layuiadmin-form" id="layuiadmin-form" style="padding: 20px 30px 0 0;">
  20. <div class="layui-form-item">
  21. <label class="layui-form-label"><span class="tips">*</span>广告位标题:</label>
  22. <div class="layui-input-inline">
  23. <input type="text" name="title" lay-vertype="tips" autocomplete="off" class="layui-input">
  24. </div>
  25. </div>
  26. <div class="layui-form-item">
  27. <label class="layui-form-label" style="white-space:nowrap;"><span class="tips">*</span>广告位置:</label>
  28. <div class="layui-input-inline">
  29. <select name="pid" lay-filter="selectPid">
  30. <option value="" ></option>
  31. {foreach $position_list as $position }
  32. <option value="{$position.id}" data-width="{$position.width}" data-height="{$position.height}">{$position.name}</option>
  33. {/foreach}
  34. </select>
  35. </div>
  36. </div>
  37. <div class="layui-form-item category">
  38. <label class="layui-form-label" style="white-space:nowrap;"><span class="tips">*</span>商品分类:</label>
  39. <div class="layui-input-inline">
  40. <select name="category_id">
  41. <option value="">请选择分类</option>
  42. {foreach $category_list as $category }
  43. <option value="{$category.id}" >{$category.name}</option>
  44. {/foreach}
  45. </select>
  46. </div>
  47. </div>
  48. <div class="layui-form-item">
  49. <label class="layui-form-label" style="white-space:nowrap;"><span class="tips">*</span>广告图片:</label>
  50. <div class="layui-input-block">
  51. <div class="like-upload-image">
  52. <div class="upload-image-elem"><a class="add-upload-image"> + 添加图片</a></div>
  53. </div>
  54. </div>
  55. </div>
  56. <div class="layui-form-item size-tips-div">
  57. <label class="layui-form-label"></label>
  58. <span class="size-tips"></span>
  59. </div>
  60. <div class="layui-form-item">
  61. <label class="layui-form-label" style="white-space:nowrap;">广告链接:</label>
  62. <div class="layui-input-block">
  63. <input type="radio" name="link_type" title="商城页面" value="1" lay-filter="link">
  64. <input type="radio" name="link_type" title="商品页面" value="2" lay-filter="link">
  65. <input type="radio" name="link_type" title="自定义链接" value="3" lay-filter="link">
  66. </div>
  67. </div>
  68. <div class="layui-form-item link page">
  69. <label class="layui-form-label">商城页面:</label>
  70. <div class="layui-input-inline">
  71. <select name="page" style="width: 300px">
  72. {foreach $link_page as $item => $val}
  73. <option value="{$item}" >{$val.name}</option>
  74. {/foreach}
  75. </select>
  76. </div>
  77. </div>
  78. <div class="layui-form-item link goods">
  79. <label class="layui-form-label">商品页面:</label>
  80. <div class="layui-input-inline">
  81. <a class="layui-btn layui-btn-normal select-goods" >选择商品</a>
  82. </div>
  83. </div>
  84. <div class="layui-form-item link goods-tips">
  85. <label class="layui-form-label"></label>
  86. <div class="layui-input-block ">
  87. <input type="hidden" name="goods_id" value="">
  88. <table id="goods_list" class="layui-table" lay-size="sm">
  89. <colgroup>
  90. <col width="40px">
  91. </colgroup>
  92. <thead>
  93. <tr style="background-color: #f3f5f9">
  94. <th style="width: 120px;text-align: center">商品信息</th>
  95. <th style="width: 60px;text-align: center">商品价格</th>
  96. </tr>
  97. </thead>
  98. <tbody>
  99. </tbody>
  100. </table>
  101. </div>
  102. </div>
  103. <div class="layui-form-item link url">
  104. <label class="layui-form-label">跳转链接:</label>
  105. <div class="layui-input-block">
  106. <div class="layui-col-sm4">
  107. <input type="text" name="url" value="" placeholder="请输入跳转链接" autocomplete="off" class="layui-input">
  108. </div>
  109. </div>
  110. </div>
  111. <div class="layui-form-item link url-tips">
  112. <label class="layui-form-label"></label>
  113. <span>请填写完整的自定义链接,http或者https开头的完整链接。</span>
  114. </div>
  115. <div class="layui-form-item">
  116. <label class="layui-form-label">排序:</label>
  117. <div class="layui-input-inline">
  118. <input type="number" name="sort" class="layui-input">
  119. </div>
  120. </div>
  121. <div class="layui-form-item">
  122. <label class="layui-form-label"></label>
  123. <span style="color: #a3a3a3;font-size: 9px">排序值必须为整数;数值越小,越靠前</span>
  124. </div>
  125. <div class="layui-form-item">
  126. <label class="layui-form-label" style="white-space:nowrap;">广告位状态:</label>
  127. <div class="layui-input-inline">
  128. <input type="radio" name="status" value=0 title="停用" checked>
  129. <input type="radio" name="status" value=1 title="启用">
  130. </div>
  131. </div>
  132. <div class="layui-form-item layui-hide">
  133. <input type="button" lay-submit lay-filter="addSubmit" id="addSubmit" value="确认">
  134. </div>
  135. </div>
  136. <script>
  137. layui.use(["table", "laydate","form"], function(){
  138. var table = layui.table;
  139. var element = layui.element;
  140. var form = layui.form;
  141. // 监听 广告位置选择
  142. form.on('select(selectPid)', function(data){
  143. var id = data.value;
  144. var elem = $(data.elem).find("option:selected");
  145. if(id){
  146. renderSize(elem);
  147. }else{
  148. $('.size-tips-div').hide();
  149. }
  150. if(3 == id || 4 == id){
  151. $('.category').show();
  152. }else{
  153. $('.category').hide();
  154. }
  155. });
  156. form.on('radio(link)', function (data) {
  157. var value = data.value;
  158. $('.link').hide();
  159. switch (value) {
  160. case '1':
  161. $('.page').show();
  162. break;
  163. case '2':
  164. $('.goods').show();
  165. $('.goods-tips').show();
  166. break;
  167. case '3':
  168. $('.url').show();
  169. $('.url-tips').show();
  170. break;
  171. }
  172. })
  173. $(document).on('click','.select-goods',function () {
  174. layer.open({
  175. type: 2
  176. ,title: '选择商品'
  177. ,content: '{:url("common.goods/selectGoods")}'
  178. ,area: ['90%', '90%']
  179. ,btn: ['确认', '取消']
  180. ,yes: function(index, layero){
  181. var data = window["layui-layer-iframe" + index].callbackdata();
  182. if(data.length){
  183. $('#goods_list tbody').remove();
  184. var goods = data[0];
  185. var goods_html = '<tr>\n' +
  186. ' <td style="text-align: center"><img class="image-show" width="80px" height="80px" src="'+goods.image +'">'+goods.name+'</td>\n' +
  187. ' <td style="text-align: center">'+goods.price+'</td>\n' +
  188. ' </tr>';
  189. $('#goods_list').prev().val(goods.id);
  190. $('#goods_list').append(goods_html);
  191. $('.goods').show();
  192. }
  193. }
  194. })
  195. })
  196. function renderSize(elem) {
  197. var width = elem.attr('data-width') ? elem.attr('data-width'): 0;
  198. var height = elem.attr('data-height') ? elem.attr('data-height') : 0;
  199. if(width || height){
  200. $('.size-tips-div').show();
  201. var html = '建议上传广告图片宽*高, '+width+'px*'+height+'px';
  202. $('.size-tips').text(html);
  203. }
  204. }
  205. like.delUpload();
  206. $(document).on("click", ".add-upload-image", function () {
  207. like.imageUpload({
  208. limit: 1,
  209. field: "image",
  210. that: $(this)
  211. });
  212. })
  213. })
  214. </script>