config.html 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. <!-- 分类切换商品列表 -->
  2. <form>
  3. <input type="hidden" name="model_id" value="11" />
  4. <h2 class="attr-title">分类切换商品列表</h2>
  5. <div class="layui-form-item">
  6. <label class="layui-form-label sm">背景颜色</label>
  7. <div class="layui-input-block">
  8. <div class="color-wrapper">
  9. <input data-js="color" type="text" name="back_color" value="{$config_info.back_color|default=''}" />
  10. </div>
  11. </div>
  12. </div>
  13. <div class="layui-form-item">
  14. <label class="layui-form-label sm">上边距</label>
  15. <div class="layui-input-block">
  16. <div class="range-wrapper">
  17. <input type="range" name="padding_top" value="{$config_info.padding_top|default='0'}" onchange="$(this).next().text($(this).val())">
  18. <span>{$config_info.padding_top|default='0'}</span>
  19. </div>
  20. </div>
  21. </div>
  22. <div class="layui-form-item">
  23. <label class="layui-form-label sm">下边距</label>
  24. <div class="layui-input-block">
  25. <div class="range-wrapper">
  26. <input type="range" name="padding_bottom" value="{$config_info.padding_bottom|default='0'}" onchange="$(this).next().text($(this).val())">
  27. <span>{$config_info.padding_bottom|default='0'}</span>
  28. </div>
  29. </div>
  30. </div>
  31. {if isset($config_info['adv']) && !empty($config_info['adv'])}
  32. {foreach name='config_info.adv' item='item' key='key'}
  33. <div class="model-item"{if $key==0} id="adv_item"{/if}>
  34. <div class="layui-form-item">
  35. <label class="layui-form-label sm">切换图标</label>
  36. <div class="layui-input-block">
  37. <div class="uploader-wrapper">
  38. <div class="uploader-image-wrapper" {if !$item.image}style="display:none" {/if}>
  39. <img class='uploader-image' src='{$item.image|default=''}' />
  40. <div class="iconfont uploader-image-btn" onclick="delFile($(this))">&#xe696;</div>
  41. </div>
  42. <div class='uploader-content' {if $item.image}style="display:none" {/if}>
  43. <div class="uploader-icon iconfont">&#xe6bf;</div>
  44. <div class="uploader-text">点击上传</div>
  45. <div class="uploader-notice">90×90</div>
  46. <input type='file' class='uploader-file' onchange='uploadFile($(this))'>
  47. <input type='hidden' name='adv[i_{$key}][image]' value="{$item.image|default=''}">
  48. </div>
  49. </div>
  50. </div>
  51. </div>
  52. <div class="layui-form-item">
  53. <label class="layui-form-label sm">固定商品</label>
  54. <div class="layui-input-block">
  55. <div class="onoff">
  56. <label for="if_fixed_goods_11_{$key}_1" class="cb-enable{if !isset($item.if_fixed_goods) || $item.if_fixed_goods==1} selected{/if}" onclick="$(this).parents('form').find('[data-fixed=0]').hide();$(this).parents('form').find('[data-fixed=1]').show()">{$Think.lang.ds_yes}</label>
  57. <label for="if_fixed_goods_11_{$key}_0" class="cb-disable{if isset($item.if_fixed_goods) && $item.if_fixed_goods==0} selected{/if}" onclick="$(this).parents('form').find('[data-fixed=0]').show();$(this).parents('form').find('[data-fixed=1]').hide()">{$Think.lang.ds_no}</label>
  58. <input id="if_fixed_goods_11_{$key}_1"{if !isset($item.if_fixed_goods) || $item.if_fixed_goods==1} checked="checked"{/if} name="adv[i_{$key}][if_fixed_goods]" value="1" type="radio">
  59. <input id="if_fixed_goods_11_{$key}_0"{if isset($item.if_fixed_goods) && $item.if_fixed_goods==0} checked="checked"{/if} name="adv[i_{$key}][if_fixed_goods]" value="0" type="radio">
  60. </div>
  61. </div>
  62. </div>
  63. <div class="layui-form-item" data-fixed="1"{if isset($item.if_fixed_goods) && $item.if_fixed_goods==0} style="display:none"{/if}>
  64. <label class="layui-form-label sm">选择商品</label>
  65. <div class="layui-input-block">
  66. <div class="select-wrapper" data-select="goods" data-name="adv[i_{$key}][goods_id]">
  67. <span class="text" data-count>请选择</span>
  68. <span class="icon iconfont">&#xe687;</span>
  69. </div>
  70. <div data-content="goods_ids" style="display:none">
  71. {if isset($item['goods_id']) && !empty($item['goods_id'])}
  72. {foreach name='item.goods_id' item='v' key='k'}
  73. <input data-goods="{$k}" type="number" min="0" max="255" size="1" name="adv[i_{$key}][goods_id][{$k}][sort]" value="{$v.sort}" />
  74. {/foreach}
  75. {/if}
  76. </div>
  77. </div>
  78. </div>
  79. <div class="layui-form-item" data-fixed="0"{if !isset($item.if_fixed_goods) || $item.if_fixed_goods==1} style="display:none"{/if}>
  80. <label class="layui-form-label sm">商品数量</label>
  81. <div class="layui-input-block">
  82. <div class="range-wrapper">
  83. <input type="range" name="adv[i_{$key}][goods_count]" value="{$item.goods_count|default='1'}" min="1" onchange="$(this).next().text($(this).val())">
  84. <span>{$item.goods_count|default='1'}</span>
  85. </div>
  86. </div>
  87. </div>
  88. <div class="layui-form-item" data-fixed="0"{if !isset($item.if_fixed_goods) || $item.if_fixed_goods==1} style="display:none"{/if}>
  89. <label class="layui-form-label sm">商品分类</label>
  90. <div class="layui-input-block">
  91. <div data-js="goods_class"><div data-select></div><input type="hidden" name="adv[i_{$key}][goods_class]" data-input value="{$item.goods_class|default='0'}" /></div>
  92. </div>
  93. </div>
  94. <div class="layui-form-item" data-fixed="0"{if !isset($item.if_fixed_goods) || $item.if_fixed_goods==1} style="display:none"{/if}>
  95. <label class="layui-form-label sm">商品排序</label>
  96. <div class="layui-input-block">
  97. <select name="adv[i_{$key}][goods_sort]">
  98. <option value="1"{if !isset($item.goods_sort) || $item.goods_sort==1} selected="selected"{/if}>按新品</option>
  99. <option value="2"{if isset($item.goods_sort) && $item.goods_sort==2} selected="selected"{/if}>按热销</option>
  100. <option value="3"{if isset($item.goods_sort) && $item.goods_sort==3} selected="selected"{/if}>按好评</option>
  101. </select>
  102. </div>
  103. </div>
  104. </div>
  105. {/foreach}
  106. {else}
  107. <div class="model-item" id="adv_item">
  108. <div class="layui-form-item">
  109. <label class="layui-form-label sm">切换图标</label>
  110. <div class="layui-input-block">
  111. <div class="uploader-wrapper">
  112. <div class="uploader-image-wrapper" style="display:none">
  113. <img class='uploader-image' src='' />
  114. <div class="iconfont uploader-image-btn" onclick="delFile($(this))">&#xe696;</div>
  115. </div>
  116. <div class='uploader-content'>
  117. <div class="uploader-icon iconfont">&#xe6bf;</div>
  118. <div class="uploader-text">点击上传</div>
  119. <div class="uploader-notice">90×90</div>
  120. <input type='file' class='uploader-file' onchange='uploadFile($(this))'>
  121. <input type='hidden' name='adv[i_0][image]' value="">
  122. </div>
  123. </div>
  124. </div>
  125. </div>
  126. <div class="layui-form-item">
  127. <label class="layui-form-label sm">固定商品</label>
  128. <div class="layui-input-block">
  129. <div class="onoff">
  130. <label for="if_fixed_goods_11_0_1" class="cb-enable selected" onclick="$(this).parents('form').find('[data-fixed=0]').hide();$(this).parents('form').find('[data-fixed=1]').show()">{$Think.lang.ds_yes}</label>
  131. <label for="if_fixed_goods_11_0_0" class="cb-disable" onclick="$(this).parents('form').find('[data-fixed=0]').show();$(this).parents('form').find('[data-fixed=1]').hide()">{$Think.lang.ds_no}</label>
  132. <input id="if_fixed_goods_11_0_1" checked="checked" name="adv[i_0][if_fixed_goods]" value="1" type="radio">
  133. <input id="if_fixed_goods_11_0_0" name="adv[i_0][if_fixed_goods]" value="0" type="radio">
  134. </div>
  135. </div>
  136. </div>
  137. <div class="layui-form-item" data-fixed="1">
  138. <label class="layui-form-label sm">选择商品</label>
  139. <div class="layui-input-block">
  140. <div class="select-wrapper" data-select="goods" data-name="adv[i_0][goods_id]">
  141. <span class="text" data-count>请选择</span>
  142. <span class="icon iconfont">&#xe687;</span>
  143. </div>
  144. <div data-content="goods_ids" style="display:none">
  145. </div>
  146. </div>
  147. </div>
  148. <div class="layui-form-item" data-fixed="0" style="display:none">
  149. <label class="layui-form-label sm">商品数量</label>
  150. <div class="layui-input-block">
  151. <div class="range-wrapper">
  152. <input type="range" name="adv[i_0][goods_count]" value="1" min="1" onchange="$(this).next().text($(this).val())">
  153. <span>1</span>
  154. </div>
  155. </div>
  156. </div>
  157. <div class="layui-form-item" data-fixed="0" style="display:none">
  158. <label class="layui-form-label sm">商品分类</label>
  159. <div class="layui-input-block">
  160. <div data-js="goods_class"><div data-select></div><input type="hidden" name="adv[i_0][goods_class]" data-input value="0" /></div>
  161. </div>
  162. </div>
  163. <div class="layui-form-item" data-fixed="0" style="display:none">
  164. <label class="layui-form-label sm">商品排序</label>
  165. <div class="layui-input-block">
  166. <select name="adv[i_0][goods_sort]">
  167. <option value="1" selected="selected">按新品</option>
  168. <option value="2">按热销</option>
  169. <option value="3">按好评</option>
  170. </select>
  171. </div>
  172. </div>
  173. </div>
  174. {/if}
  175. <div class="model-btn" onclick="addModel($(this),11)">
  176. <span>+</span>
  177. <span>添加一个切换商品</span>
  178. </div>
  179. </form>
  180. <script>
  181. if(typeof(loadConfig11)=='undefined'){
  182. function loadConfig11(obj){
  183. obj.find('[data-js="color"]').colorpicker({showOn: 'both'});
  184. var id=obj.attr('data-id')
  185. var i=0
  186. obj.find('[data-js="goods_class"]').each(function(){
  187. $(this).attr('id','goods_class_'+i+'_'+id)
  188. var gc_id=parseInt($('#goods_class_'+i+'_'+id).find('*[data-input]').val())
  189. if(gc_id){
  190. getGoodsClass(gc_id,'goods_class_'+i+'_'+id)
  191. }else{
  192. loadGoodsClass(1,0,'goods_class_'+i+'_'+id)
  193. }
  194. i++
  195. })
  196. var i=0
  197. obj.find('[data-select="goods"]').each(function(){
  198. $(this).attr('id','select_goods_'+i+'_'+id)
  199. i++
  200. })
  201. obj.find('*[data-select="goods"]').click(function(){
  202. var goods_id=''
  203. $(this).parent().find('*[data-content="goods_ids"] input').each(function(){
  204. goods_id+='&goods_id['+$(this).attr('data-goods')+'][sort]='+$(this).val()
  205. })
  206. dsLayerOpen('{:url(request()->controller()."/search_goods")}?id='+$(this).attr('id')+goods_id+'&name='+$(this).attr('data-name'),'选择商品')
  207. })
  208. obj.find('.onoff').each(function(){
  209. $(this).find(".cb-enable").click(function() {
  210. var parent = $(this).parents('.onoff');
  211. $('.cb-disable', parent).removeClass('selected');
  212. $(this).addClass('selected');
  213. $('.checkbox', parent).prop('checked', true);
  214. });
  215. $(this).find(".cb-disable").click(function() {
  216. var parent = $(this).parents('.onoff');
  217. $('.cb-enable', parent).removeClass('selected');
  218. $(this).addClass('selected');
  219. $('.checkbox', parent).prop('checked', false);
  220. });
  221. })
  222. }
  223. }
  224. $(function(){
  225. if(typeof(index['i_11'])=='undefined'){
  226. index['i_11']={if isset($config_info['adv'])}{:count($config_info['adv'])}{else}0{/if};
  227. html['i_11']=$('#adv_item').html()
  228. }
  229. })
  230. if(typeof(saveGoods)=='undefined'){
  231. function saveGoods(html,id,count){
  232. $('#'+id).parent().find('[data-content="goods_ids"]').html(html)
  233. $('#'+id).parent().find('[data-count]').text(count?('已选择'+count+'个'):'请选择')
  234. $('#'+id).parents('form').change()
  235. }
  236. }
  237. </script>