config.html 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <!-- 一个商品 -->
  2. <form>
  3. <input type="hidden" name="model_id" value="7" />
  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. <div class="layui-form-item">
  32. <label class="layui-form-label sm">固定商品</label>
  33. <div class="layui-input-block">
  34. <div class="onoff">
  35. <label for="if_fixed_goods_7_1" class="cb-enable{if !isset($config_info.if_fixed_goods) || $config_info.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>
  36. <label for="if_fixed_goods_7_0" class="cb-disable{if isset($config_info.if_fixed_goods) && $config_info.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>
  37. <input id="if_fixed_goods_7_1"{if !isset($config_info.if_fixed_goods) || $config_info.if_fixed_goods==1} checked="checked"{/if} name="if_fixed_goods" value="1" type="radio">
  38. <input id="if_fixed_goods_7_0"{if isset($config_info.if_fixed_goods) && $config_info.if_fixed_goods==0} checked="checked"{/if} name="if_fixed_goods" value="0" type="radio">
  39. </div>
  40. </div>
  41. </div>
  42. <div class="layui-form-item" data-fixed="1"{if isset($config_info.if_fixed_goods) && $config_info.if_fixed_goods==0} style="display:none"{/if}>
  43. <label class="layui-form-label sm">选择商品</label>
  44. <div class="layui-input-block">
  45. <div class="select-wrapper" data-select="goods">
  46. <span class="text" data-count>请选择</span>
  47. <span class="icon iconfont">&#xe687;</span>
  48. </div>
  49. <div data-content="goods_ids" style="display:none">
  50. {if isset($config_info['goods_id']) && !empty($config_info['goods_id'])}
  51. {foreach name='config_info.goods_id' item='item' key='key'}
  52. <input data-goods="{$key}" type="number" min="0" max="255" size="1" name="goods_id[{$key}][sort]" value="{$item.sort}" />
  53. {/foreach}
  54. {/if}
  55. </div>
  56. </div>
  57. </div>
  58. <div class="layui-form-item" data-fixed="0"{if !isset($config_info.if_fixed_goods) || $config_info.if_fixed_goods==1} style="display:none"{/if}>
  59. <label class="layui-form-label sm">商品数量</label>
  60. <div class="layui-input-block">
  61. <div class="range-wrapper">
  62. <input type="range" name="goods_count" value="{$config_info.goods_count|default='1'}" min="1" onchange="$(this).next().text($(this).val())">
  63. <span>{$config_info.goods_count|default='1'}</span>
  64. </div>
  65. </div>
  66. </div>
  67. <div class="layui-form-item" data-fixed="0"{if !isset($config_info.if_fixed_goods) || $config_info.if_fixed_goods==1} style="display:none"{/if}>
  68. <label class="layui-form-label sm">商品分类</label>
  69. <div class="layui-input-block">
  70. <div data-js="goods_class"><div data-select></div><input type="hidden" name="goods_class" data-input value="{$config_info.goods_class|default='0'}" /></div>
  71. </div>
  72. </div>
  73. <div class="layui-form-item" data-fixed="0"{if !isset($config_info.if_fixed_goods) || $config_info.if_fixed_goods==1} style="display:none"{/if}>
  74. <label class="layui-form-label sm">商品排序</label>
  75. <div class="layui-input-block">
  76. <select name="goods_sort">
  77. <option value="1"{if !isset($config_info.goods_sort) || $config_info.goods_sort==1} selected="selected"{/if}>按新品</option>
  78. <option value="2"{if isset($config_info.goods_sort) && $config_info.goods_sort==2} selected="selected"{/if}>按热销</option>
  79. <option value="3"{if isset($config_info.goods_sort) && $config_info.goods_sort==3} selected="selected"{/if}>按好评</option>
  80. </select>
  81. </div>
  82. </div>
  83. </form>
  84. <script>
  85. if(typeof(loadConfig7)=='undefined'){
  86. function loadConfig7(obj){
  87. obj.find('[data-js="color"]').colorpicker({showOn: 'both'});
  88. var id=obj.attr('data-id')
  89. obj.find('[data-js="goods_class"]').attr('id','goods_class_'+id)
  90. var gc_id=parseInt(obj.find('*[data-input]').val())
  91. if(gc_id){
  92. getGoodsClass(gc_id,'goods_class_'+id)
  93. }else{
  94. loadGoodsClass(1,0,'goods_class_'+id)
  95. }
  96. var i=0
  97. obj.find('[data-select="goods"]').each(function(){
  98. $(this).attr('id','select_goods_'+i+'_'+id)
  99. i++
  100. })
  101. obj.find('*[data-select="goods"]').click(function(){
  102. var goods_id=''
  103. $(this).parent().find('*[data-content="goods_ids"] input').each(function(){
  104. goods_id+='&goods_id['+$(this).attr('data-goods')+'][sort]='+$(this).val()
  105. })
  106. dsLayerOpen('{:url(request()->controller()."/search_goods")}?id='+$(this).attr('id')+goods_id,'选择商品')
  107. })
  108. obj.find('.onoff').each(function(){
  109. $(this).find(".cb-enable").click(function() {
  110. var parent = $(this).parents('.onoff');
  111. $('.cb-disable', parent).removeClass('selected');
  112. $(this).addClass('selected');
  113. $('.checkbox', parent).prop('checked', true);
  114. });
  115. $(this).find(".cb-disable").click(function() {
  116. var parent = $(this).parents('.onoff');
  117. $('.cb-enable', parent).removeClass('selected');
  118. $(this).addClass('selected');
  119. $('.checkbox', parent).prop('checked', false);
  120. });
  121. })
  122. }
  123. }
  124. if(typeof(saveGoods)=='undefined'){
  125. function saveGoods(html,id,count){
  126. $('#'+id).parent().find('[data-content="goods_ids"]').html(html)
  127. $('#'+id).parent().find('[data-count]').text(count?('已选择'+count+'个'):'请选择')
  128. $('#'+id).parents('form').change()
  129. }
  130. }
  131. </script>