addcategory.html 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <?php $shoname_name = D('Home/Front')->get_config_by_name('shoname'); ?>
  6. <title><?php echo $shoname; ?></title>
  7. <link rel="shortcut icon" href="" />
  8. <meta name="renderer" content="webkit">
  9. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  10. <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  11. <link rel="stylesheet" href="/layuiadmin/style/admin.css" media="all">
  12. <!-- 让IE8/9支持媒体查询,从而兼容栅格 -->
  13. <!--[if lt IE 9]>
  14. <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
  15. <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
  16. <![endif]-->
  17. <link href="./resource/css/bootstrap.min.css?v=201903260001" rel="stylesheet">
  18. <link href="./resource/css/common.css?v=201903260001" rel="stylesheet">
  19. <script type="text/javascript">
  20. window.sysinfo = {
  21. <?php if (!empty($_W['uniacid']) ){ ?>'uniacid': '{$_W['uniacid']}',<?php } ?>
  22. <?php if( !empty($_W['acid']) ){ ?>'acid': '{$_W['acid']}',<?php } ?>
  23. <?php if (!empty($_W['openid']) ) { ?>'openid': '{$_W['openid']}',<?php } ?>
  24. <?php if( !empty($_W['uid']) ) { ?>'uid': '{$_W['uid']}',<?php } ?>
  25. 'isfounder': <?php if (!empty($_W['isfounder']) ) { ?>1<?php }else{ ?>0<?php } ?>,
  26. 'siteroot': '{$_W['siteroot']}',
  27. 'siteurl': '{$_W['siteurl']}',
  28. 'attachurl': '{$_W['attachurl']}',
  29. 'attachurl_local': '{$_W['attachurl_local']}',
  30. 'attachurl_remote': '{$_W['attachurl_remote']}',
  31. 'module' : {'url' : '<?php if( defined('MODULE_URL') ) { ?>{MODULE_URL}<?php } ?>', 'name' : '<?php if (defined('IN_MODULE') ) { ?>{IN_MODULE}<?php } ?>'},
  32. 'cookie' : {'pre': ''},
  33. 'account' : {:json_encode($_W['account'])},
  34. };
  35. </script>
  36. <script type="text/javascript" src="./resource/js/lib/jquery-1.11.1.min.js"></script>
  37. <script type="text/javascript" src="./resource/js/lib/bootstrap.min.js"></script>
  38. <script type="text/javascript" src="./resource/js/app/util.js?v=201903260001"></script>
  39. <script type="text/javascript" src="./resource/js/app/common.min.js?v=201903260001"></script>
  40. <script type="text/javascript" src="./resource/js/require.js?v=201903260001"></script>
  41. <script type="text/javascript" src="./resource/js/lib/jquery.nice-select.js?v=201903260001"></script>
  42. <link rel="stylesheet" href="/layuiadmin/layui/css/layui.css" media="all">
  43. <link href="/static/css/snailfish.css" rel="stylesheet">
  44. </head>
  45. <style>
  46. .input-group .form-control{min-width:600px;}
  47. .multi-audio-details .multi-audio-item {
  48. width: 155px;
  49. height: 40px;
  50. position: relative;
  51. float: left;
  52. margin-right: 5px;
  53. }
  54. .multi-audio-details .input-group .form-control {
  55. min-width: auto;
  56. }
  57. </style>
  58. <body layadmin-themealias="default">
  59. <div class="layui-fluid">
  60. <div class="layui-card">
  61. <div class="layui-card-header layui-elem-quote">当前位置:<span class="line-text"><?php if( !empty($item['id'])){ ?>编辑<?php }else{ ?>添加<?php } ?>广告<?php if( !empty($item['id'])){ ?>({$item['advname']})<?php } ?></span></div>
  62. <div class="layui-card-body" style="padding:15px;">
  63. <form action="" method="post" class="layui-form" lay-filter="component-layui-form-item" enctype="multipart/form-data" >
  64. <input type="hidden" name="data[id]" value="{$item['id']}"/>
  65. <div class="layui-form-item">
  66. <label class="layui-form-label">广告名称</label>
  67. <div class="layui-input-block ">
  68. <input type="text" id='advname' lay-verify="required" name="data[advname]" class="form-control" value="{$item['advname']}"/>
  69. </div>
  70. </div>
  71. <div class="layui-form-item">
  72. <label class="layui-form-label">商品分类</label>
  73. <div class="layui-input-block ">
  74. <select name="data[cate_id]">
  75. <?php foreach($goods_category_list as $goods_category ){ ?>
  76. <option value="<?php echo $goods_category['id']; ?>" <?php if( $goods_category['id'] == $item['cate_id'] ){ ?> selected <?php } ?> ><?php echo $goods_category['name']; ?></option>
  77. <?php } ?>
  78. </select>
  79. </div>
  80. </div>
  81. <div class="layui-form-item">
  82. <label class="layui-form-label">图片</label>
  83. <div class="layui-input-block">
  84. {:tpl_form_field_image2('data[thumb]', $item['thumb'])}
  85. <span class='help-block'>推荐分类的广告图,建议尺寸:750 * 250或比例为3:1的图片</span>
  86. </div>
  87. </div>
  88. <div class="layui-form-item">
  89. <label class="layui-form-label">链接类型</label>
  90. <div class="layui-input-block">
  91. <label class='radio-inline'>
  92. <input type='radio' name='data[linktype]' lay-filter="linktype" title="本小程序链接" value=1 <?php if($item['linktype']==1 || empty($item)){ ?>checked<?php } ?> />
  93. </label>
  94. <label class='radio-inline'>
  95. <input type='radio' name='data[linktype]' lay-filter="linktype" title="webview外链" value=0 <?php if( $item['linktype']==0 && !empty($item) ){ ?>checked<?php } ?> />
  96. </label>
  97. <label class='radio-inline'>
  98. <input type='radio' name='data[linktype]' lay-filter="linktype" title="外部小程序链接" value=2 <?php if( $item['linktype']==2 && !empty($item) ){ ?>checked<?php } ?> />
  99. </label>
  100. <label class='radio-inline'>
  101. <input type='radio' name='data[linktype]' title="客服" lay-filter="linktype" value=5 <?php if( $item['linktype']==5 && !empty($item) ){ ?>checked<?php } ?> />
  102. </label>
  103. <label class='radio-inline'>
  104. <input type='radio' name='data[linktype]' title="优惠券" lay-filter="linktype" value=6 <?php if( $item['linktype']==6 && !empty($item) ){ ?>checked<?php } ?> />
  105. </label>
  106. </div>
  107. </div>
  108. <!-- 优惠券 -->
  109. <div class="layui-form-item" id="couponId" style="<?php if( $item['linktype']!=6 ){ ?>display: none;<?php } ?>">
  110. <label class="layui-form-label must">优惠券</label>
  111. <div class="layui-input-block">
  112. <div class="input-group " style="margin: 0;">
  113. <input type="text" disabled value="" class="form-control valid" name="coupon_dan_id" placeholder="" id="coupon_id">
  114. <span class="input-group-btn">
  115. <span data-input="#coupon_id_box" data-name="coupon_id" id="chose_coupon_id" class="btn btn-default">选择优惠券</span>
  116. </span>
  117. </div>
  118. <div class="multi-audio-details container" id="coupon_id_box" style="width:auto;">
  119. <?php if( !empty($couponinfo) ){ ?>
  120. <?php foreach($couponinfo as $c){ ?>
  121. <div class="multi-audio-item " data-id="{$c['id']}">
  122. <div class="input-group">
  123. <input type="text" class="form-control img-textname" readonly="" value="{$c['voucher_title']}">
  124. <input type="hidden" value="{$c['id']}" name="coupon_id[]">
  125. <div class="input-group-btn">
  126. <button class="btn btn-default" data-id="{$c['id']}" onclick="cancle_coupon(this, {$c['id']})" type="button"><i class="fa fa-remove"></i></button>
  127. </div>
  128. </div>
  129. </div>
  130. <?php } ?>
  131. <?php } ?>
  132. </div>
  133. </div>
  134. </div>
  135. <div class="layui-form-item" style="<?php if( $item['linktype']!=2){ ?>display: none;<?php } ?>" id="typeGroup">
  136. <label class="layui-form-label">外链小程序appid</label>
  137. <div class="layui-input-block ">
  138. <input type="text" id='appid' name="data[appid]" class="form-control" value="{$item['appid']}" maxlength="32"/>
  139. </div>
  140. </div>
  141. <div class="layui-form-item" style="<?php if($item['linktype']==5||$item['linktype']==6){ ?>display: none;<?php } ?>" id="typeUrl">
  142. <label class="layui-form-label">链接</label>
  143. <div class="layui-input-block">
  144. <div class="input-group " style="margin: 0;">
  145. <input type="text" value="{$item['link']}" class="form-control valid" name="data[link]" placeholder="" id="advlink">
  146. <span class="input-group-btn" id="chose_link_box" <?php if( $item['linktype']==0 && !empty($item) ){ ?> style="display:none;" <?php } ?> >
  147. <span data-input="#advlink" id="chose_link" class="btn btn-default">选择链接</span>
  148. </span>
  149. </div>
  150. <span class='help-block' <?php if( $item['linktype']==0 && !empty($item) ){ ?> <?php }else{ ?>style="display:none;"<?php } ?> id="chose_link_tip">备注:请使用http或https链接,需要在<a href="http://mp.weixin.qq.com" target="_blank">mp.weixin.qq.com</a>开发-开发设置-业务域名添加上此域名</span>
  151. </div>
  152. </div>
  153. <div class="layui-form-item" style="display:none;">
  154. <label class="layui-form-label">排序</label>
  155. <div class="layui-input-block">
  156. <input type="text" name="data[displayorder]" class="form-control" value="0"/>
  157. <span class='help-block'>数字越大,排名越靠前</span>
  158. </div>
  159. </div>
  160. <div class="layui-form-item">
  161. <label class="layui-form-label">状态</label>
  162. <div class="layui-input-block">
  163. <label class='radio-inline'>
  164. <input type='radio' name='data[enabled]' title="显示" value=1 <?php if( $item['enabled']==1 || empty($item)){ ?>checked<?php } ?> />
  165. </label>
  166. <label class='radio-inline'>
  167. <input type='radio' name='data[enabled]' title="隐藏" value=0 <?php if( $item['enabled']==0 && !empty($item) ){ ?>checked<?php } ?> />
  168. </label>
  169. </div>
  170. </div>
  171. <div class="layui-form-item">
  172. <label class="layui-form-label"> </label>
  173. <div class="layui-input-block">
  174. <input type="submit" value="提交" lay-submit lay-filter="formDemo" class="btn btn-primary" />
  175. </div>
  176. </div>
  177. </form>
  178. </div>
  179. </div>
  180. </div>
  181. <script src="/layuiadmin/layui/layui.js"></script>
  182. <script>
  183. layui.config({
  184. base: '/layuiadmin/' //静态资源所在路径
  185. }).extend({
  186. index: 'lib/index' //主入口模块
  187. }).use('index');
  188. </script>
  189. <script>
  190. //由于模块都一次性加载,因此不用执行 layui.use() 来加载对应模块,直接使用即可:
  191. var layer = layui.layer;
  192. var $;
  193. var cur_open_div;
  194. var iptname;
  195. layui.use(['jquery', 'layer','form'], function(){
  196. $ = layui.$;
  197. var form = layui.form;
  198. form.on('radio(linktype)', function(data){
  199. if (data.value == 2) {
  200. $('#typeGroup').show();
  201. $('#couponId').hide();
  202. $('#typeUrl').show();
  203. }
  204. else if( data.value == 0 )
  205. {
  206. $('#typeGroup').hide();
  207. $('#chose_link_box').hide();
  208. $('#chose_link_tip').show();
  209. $('#couponId').hide();
  210. $('#typeUrl').show();
  211. }
  212. else if(data.value == 5){
  213. $('#typeGroup').hide();
  214. $('#chose_link_box').hide();
  215. $('#chose_link_tip').hide();
  216. $('#typeUrl').hide();
  217. $('#couponId').hide();
  218. }
  219. else if( data.value == 6 )
  220. {
  221. $('#typeGroup').hide();
  222. $('#chose_link_box').hide();
  223. $('#chose_link_tip').hide();
  224. $('#typeUrl').hide();
  225. $('#couponId').show();
  226. }
  227. else {
  228. $('#typeGroup').hide();
  229. $('#chose_link_box').show();
  230. $('#chose_link_tip').hide();
  231. $('#couponId').hide();
  232. $('#typeUrl').show();
  233. }
  234. });
  235. $('#chose_link').click(function(){
  236. cur_open_div = $(this).attr('data-input');
  237. $.post("{:U('util/selecturl', array('ok' => 1))}", {}, function(shtml){
  238. layer.open({
  239. type: 1,
  240. area: '930px',
  241. content: shtml //注意,如果str是object,那么需要字符拼接。
  242. });
  243. });
  244. })
  245. $('#chose_coupon_id').click(function(){
  246. cur_open_div = $(this).attr('data-input');
  247. iptname = $(this).data('name');
  248. var coupon_ids = [];
  249. $('.multi-audio-item').each(function(){
  250. coupon_ids.push( $(this).attr("data-id") );
  251. })
  252. $.post("{:U('Marketing/couponquery', array('ok' => 1))}", {coupon_ids:coupon_ids}, function(shtml){
  253. layer.open({
  254. type: 1,
  255. area: '930px',
  256. content: shtml //注意,如果str是object,那么需要字符拼接。
  257. });
  258. })
  259. })
  260. //监听提交
  261. form.on('submit(formDemo)', function(data){
  262. $.ajax({
  263. url: data.form.action,
  264. type: data.form.method,
  265. data: data.field,
  266. dataType:'json',
  267. success: function (info) {
  268. if(info.status == 0)
  269. {
  270. layer.msg(info.result.message,{icon: 1,time: 2000});
  271. }else if(info.status == 1){
  272. var go_url = location.href;
  273. if( info.result.hasOwnProperty("url") )
  274. {
  275. go_url = info.result.url;
  276. }
  277. layer.msg('操作成功',{time: 1000,
  278. end:function(){
  279. //var backurl = "{php echo shopUrl('Configindex/slider',array('ok'=>'1'))}";
  280. var backurl = "seller.php?s=/configindex/category";
  281. location.href = backurl;
  282. // location.href = info.result.url;
  283. }
  284. });
  285. }
  286. }
  287. });
  288. return false;
  289. });
  290. })
  291. function cancle_coupon(obj,sdiv)
  292. {
  293. $('#coupon_id').val('');
  294. $('#'+sdiv).val('');
  295. $(obj).parents('.multi-audio-item').remove();
  296. var coupon_id = "";
  297. var head_arr = [];
  298. $('.mult_heads').each(function(){
  299. head_arr.push( $(this).val() );
  300. })
  301. coupon_id = head_arr.join(',');
  302. $('#coupon_id').val(coupon_id);
  303. //$('.mult_choose_goodsid').remove();
  304. }
  305. </script>
  306. </body>