addcoupon.html 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  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. <style type="text/css">
  45. .input-group .input-group-addon { padding: 0 5px; }
  46. </style>
  47. </head>
  48. <body layadmin-themealias="default">
  49. <div class="layui-fluid">
  50. <div class="layui-card">
  51. <div class="layui-card-header layui-elem-quote">当前位置:<span class="line-text"><?php if( !empty($item['id'])){ ?>编辑<?php }else{ ?>添加<?php } ?>优惠券 <small><?php if( !empty($item['id'])){ ?>修改【{$item['voucher_title']}】<?php } ?></small></span></div>
  52. <div class="layui-card-body" style="padding:15px;">
  53. <form action="" method="post" class="layui-form" enctype="multipart/form-data" >
  54. <input type="hidden" name="id" value="{$item['id']}">
  55. <div class="layui-form-item">
  56. <label class="layui-form-label">排序</label>
  57. <div class="layui-input-block">
  58. <input type="text" name="displayorder" class="form-control" value="{$item['displayorder']}" />
  59. <span class='help-block'>数字越大越靠前</span>
  60. </div>
  61. </div>
  62. <div class="layui-form-item">
  63. <label class="layui-form-label must"> 优惠券名称</label>
  64. <div class="layui-input-block">
  65. <input type="text" name="voucher_title" class="form-control" value="{$item['voucher_title']}" data-rule-required="true" />
  66. </div>
  67. </div>
  68. <div class="layui-form-item">
  69. <label class="layui-form-label">分类</label>
  70. <div class="layui-input-block">
  71. <select name='catid' class="layui-input layui-unselect">
  72. <option value=''></option>
  73. <?php foreach( $category as $k => $c ){ ?>
  74. <option value='{$k}' <?php if( $item['catid']==$k){ ?>selected<?php } ?>>{$c['name']}</option>
  75. <?php } ?>
  76. </select>
  77. </div>
  78. </div>
  79. <div class="layui-form-item" style="display:none;">
  80. <label class="layui-form-label">缩略图</label>
  81. <div class="layui-input-block">
  82. {:tpl_form_field_image2('thumb', $item['thumb'])}
  83. </div>
  84. </div>
  85. <div class="layui-form-item">
  86. <label class="layui-form-label must">使用条件</label>
  87. <div class="layui-input-block">
  88. <input type="text" name="limit_money" lay-verify="require" class="form-control" value="<?php if( empty($item)){ ?><?php }else{ ?>{$item['limit_money']}<?php } ?>" />
  89. <span class='help-block' >消费满多少可用, 空或0 不限制</span>
  90. </div>
  91. </div>
  92. <div class="layui-form-item">
  93. <label class="layui-form-label">使用时间限制</label>
  94. <div class="layui-input-block" style="width: 520px;">
  95. <div class='input-group'>
  96. <span class='input-group-addon'>
  97. <label class="radio-inline" style='margin-top:-5px;' ><input type="radio" name="timelimit" value="0" <?php if( $item['timelimit']==0){ ?>checked<?php } ?> title="获得后"></label>
  98. </span>
  99. <input type='text' class='form-control' name='get_over_hour' value="<?php if( empty($item) ){ ?>1<?php }else{ ?>{$item['get_over_hour']}<?php } ?>" />
  100. <span class='input-group-addon'>天内有效(空为不限时间使用)</span>
  101. </div>
  102. </div>
  103. </div>
  104. <div class="layui-form-item">
  105. <label class="layui-form-label"></label>
  106. <div class="layui-input-block" style="width: 364px;">
  107. <div class='input-group'>
  108. <span class='input-group-addon'>
  109. <label class="radio-inline" style='margin-top:-5px;' ><input type="radio" name="timelimit" value="1" <?php if( $item['timelimit']==1){ ?>checked<?php } ?> title="在日期"></label>
  110. </span>
  111. {:tpl_form_field_daterange('time', array('starttime'=>date('Y-m-d', $starttime),'endtime'=>date('Y-m-d', $endtime)));}
  112. <span class='input-group-addon'>内有效</span>
  113. </div>
  114. </div>
  115. </div>
  116. <!--
  117. <div class="layui-form-item">
  118. <label class="layui-form-label">首页弹窗</label>
  119. <div class="layui-input-block" >
  120. <input type="radio" name="is_index_alert" value="1" <?php if(!empty($item) && $item['is_index_alert'] == 1){ ?>checked="true"<?php } ?> title="是" />
  121. <input type="radio" name="is_index_alert" value="0" <?php if(empty($item) || $item['is_index_alert'] == 0){ ?>checked="true"<?php } ?> title="否" />
  122. </div>
  123. </div>
  124. <div class="layui-form-item">
  125. <label class="layui-form-label">首页领取</label>
  126. <div class="layui-input-block" >
  127. <input type="radio" name="is_index_show" value="1" <?php if( empty($item) || $item['is_index_show'] == 1){ ?>checked="true"<?php } ?> title="是" />
  128. <input type="radio" name="is_index_show" value="0" <?php if( !empty($item) && $item['is_index_show'] == 0){ ?>checked="true"<?php } ?> title="否" />
  129. </div>
  130. </div>
  131. -->
  132. <div class="layui-form-item">
  133. <label class="layui-form-label">领取方式</label>
  134. <div class="layui-input-block" >
  135. <input type="checkbox" id="is_index_alert" lay-skin="primary" value="1" name="is_index_alert" lay-filter="is_index_alert" title="首页弹窗领取"
  136. <?php if( !empty($item) && $item['is_index_alert'] == 1 ){ ?>checked="true"<?php } ?>
  137. >
  138. <input type="checkbox" id="is_index_show" lay-skin="primary" value="1" name="is_index_show" lay-filter="is_index_show" title="首页领取"
  139. <?php if( !empty($item) && $item['is_index_show'] == 1 ){ ?>checked="true"<?php } ?>
  140. >
  141. <span class='help-block'>首页弹窗领取和首页领取两个同时选中的时候,优先使用首页弹窗领取,首页弹窗领取为优惠券首页弹窗用户默认直接领取,首页领取需要用户在首页优惠券展示的地方进行点击领取</span>
  142. <!--
  143. <input type="radio" name="coupon_collection_method" value="0" <?php if( empty($item) || $item['coupon_collection_method'] == 0 ){ ?>checked="true"<?php } ?> title="首页弹窗领取" />
  144. <input type="radio" name="coupon_collection_method" value="1" <?php if( !empty($item) && $item['coupon_collection_method'] == 1 ){ ?>checked="true"<?php } ?> title="首页领取" />
  145. <span class='help-block' >首页弹窗领取为优惠券首页弹窗用户默认直接领取,首页领取需要用户在首页优惠券展示的地方进行点击领取</span>-->
  146. </div>
  147. </div>
  148. <div class="layui-form-item">
  149. <label class="layui-form-label">新人券</label>
  150. <div class="layui-input-block" >
  151. <input type="radio" name="is_new_man" value="0" <?php if( empty($item) || $item['is_new_man'] == 0 ){ ?>checked="true"<?php } ?> title="否" />
  152. <input type="radio" name="is_new_man" value="1" <?php if( !empty($item) && $item['is_new_man'] == 1 ){ ?>checked="true"<?php } ?> title="是" />
  153. <span class='help-block' >商城没有进行支付过的用户可领取,领取后在设置的有效期内可使用</span>
  154. </div>
  155. </div>
  156. <div class="layui-form-item">
  157. <label class="layui-form-label">优惠方式</label>
  158. <div class="layui-input-block">
  159. <input type="hidden" name="coupontype" value="0"/>
  160. <input type="radio" name="backtype" checked title="立减">
  161. </div>
  162. </div>
  163. <div class="layui-form-item">
  164. <label class="layui-form-label"></label>
  165. <div class="layui-input-block backtype backtype0" style="width: 300px;" >
  166. <div class='input-group fixsingle-input-group'>
  167. <span class='input-group-addon'>立减</span>
  168. <input type='text' class='form-control' name='credit' value="<?php if( empty($item)){ ?>1<?php }else{ ?>{$item['credit']}<?php } ?>"/>
  169. <span class='input-group-addon'>元</span>
  170. </div>
  171. </div>
  172. </div>
  173. <div class="layui-form-item">
  174. <label class="layui-form-label">每人限领</label>
  175. <div class="layui-input-block">
  176. <input type="text" name="person_limit_count" class="form-control" value="<?php if( empty($item)){ ?>1<?php }else{ ?>{$item['person_limit_count']}<?php } ?>" />
  177. <span class='help-block' >限制每人“首页领取”和“首页弹窗”领取数量,后台手动发送不受此限制,发多少到多少。设置0为不限。</span>
  178. </div>
  179. </div>
  180. <div class="layui-form-item">
  181. <label class="layui-form-label">发放总数</label>
  182. <div class="layui-input-block">
  183. <input type="text" name="total_count" class="form-control" value="<?php if( empty($item)){ ?>1<?php }else{ ?>{$item['total_count']}<?php } ?>" />
  184. <span class='help-block' >优惠券总数量,没有不能领取或发放,-1 为不限制张数</span>
  185. </div>
  186. </div>
  187. <div class="layui-form-item">
  188. <label class="layui-form-label">可使用商品</label>
  189. <div class="layui-input-block" >
  190. <input type="radio" lay-filter="is_limit_goodsbuy" name="is_limit_goodsbuy" value="0" <?php if(empty($item) || $item['is_limit_goods_buy'] == 0){ ?>checked="true"<?php } ?> title="商城所有商品" />
  191. <input type="radio" lay-filter="is_limit_goodsbuy" name="is_limit_goodsbuy" value="1" <?php if(!empty($item) && $item['is_limit_goods_buy'] == 1){ ?>checked="true"<?php } ?> title="指定商品" />
  192. <input type="radio" lay-filter="is_limit_goodsbuy" name="is_limit_goodsbuy" value="2" <?php if(!empty($item) && $item['is_limit_goods_buy'] == 2){ ?>checked="true"<?php } ?> title="商品分类" />
  193. </div>
  194. </div>
  195. <div class="layui-form-item" id="goods_form_item" style="<?php if(!empty($item) && $item['is_limit_goods_buy'] == 1){ ?><?php }else{ ?>display:none;<?php } ?>">
  196. <label class="layui-form-label">选择商品</label>
  197. <div class="layui-input-block">
  198. <div class="input-group " style="margin: 0;">
  199. <input type="text" disabled value="" class="form-control valid" name="" placeholder="" id="agent_id">
  200. <span class="input-group-btn">
  201. <span data-input="#agent_id" id="chose_agent_id" class="btn btn-default">选择商品</span>
  202. </span>
  203. </div>
  204. <?php if(!empty($limit_goods)){ ?>
  205. <?php foreach( $limit_goods as $goods ){ ?>
  206. <div class="input-group mult_choose_goodsid" data-gid="{$goods['gid']}" style="border-radius: 0;float: left;margin: 10px;margin-left:0px;width: 22%;">
  207. <div class="layadmin-text-center choose_user">
  208. <img style="" src="{$goods['image']}">
  209. <div class="layadmin-maillist-img" style="">{$goods['goodsname']}</div>
  210. <button type="button" class="layui-btn layui-btn-sm" onclick="cancle_bind(this)">
  211. <i class="layui-icon"></i>
  212. </button>
  213. </div>
  214. </div>
  215. <?php }} ?>
  216. </div>
  217. </div>
  218. <div class="layui-form-item" id="goods_form_category" style="<?php if(!empty($item) && $item['is_limit_goods_buy'] == 2){ ?><?php }else{ ?>display:none;<?php } ?>">
  219. <label class="layui-form-label">商品分类</label>
  220. <div class="layui-input-block">
  221. <select id="cates" name='goodscates' class="form-control select2" >
  222. <?php foreach($goods_category as $c){ ?>
  223. <option value="{$c['id']}" <?php if(!empty($item['goodscates']) && $c['id']==$item['goodscates']){ ?>selected<?php } ?> >{$c['name']}</option>
  224. <?php } ?>
  225. </select>
  226. </div>
  227. </div>
  228. <div class="layui-form-item">
  229. <label class="layui-form-label"></label>
  230. <div class="layui-input-block">
  231. <input type="submit" name="submit" value="提交" lay-submit lay-filter="formDemo" class="btn btn-primary col-lg-1" />
  232. </div>
  233. </div>
  234. </form>
  235. </div>
  236. </div>
  237. </div>
  238. <script src="/layuiadmin/layui/layui.js"></script>
  239. <script>
  240. layui.config({
  241. base: '/layuiadmin/' //静态资源所在路径
  242. }).extend({
  243. index: 'lib/index' //主入口模块
  244. }).use('index');
  245. </script>
  246. <script>
  247. //由于模块都一次性加载,因此不用执行 layui.use() 来加载对应模块,直接使用即可:
  248. var layer = layui.layer;
  249. var $;
  250. var cur_open_div;
  251. layui.use(['jquery', 'layer','form'], function(){
  252. $ = layui.$;
  253. var form = layui.form;
  254. form.on('radio(is_limit_goodsbuy)', function(data){
  255. if(data.value == 1)
  256. {
  257. $('#goods_form_item').show();
  258. $('#goods_form_category').hide();
  259. }else if(data.value == 2)
  260. {
  261. $('#goods_form_category').show();
  262. $('#goods_form_item').hide();
  263. }
  264. else{
  265. $('#goods_form_item').hide();
  266. $('#goods_form_category').hide();
  267. }
  268. });
  269. $('#chose_member_id').click(function(){
  270. cur_open_div = $(this).attr('data-input');
  271. $.post("{:U('user/query', array('is_quan' => 1))}", {}, function(shtml){
  272. layer.open({
  273. type: 1,
  274. area: '930px',
  275. content: shtml //注意,如果str是object,那么需要字符拼接。
  276. });
  277. });
  278. })
  279. $('#chose_agent_id').click(function(){
  280. cur_open_div = $(this).attr('data-input');
  281. $.post("{:U('goods/query_normal', array('template' => 'mult'))}", {}, function(shtml){
  282. layer.open({
  283. type: 1,
  284. area: '930px',
  285. content: shtml //注意,如果str是object,那么需要字符拼接。
  286. });
  287. });
  288. })
  289. $('#chose_link').click(function(){
  290. cur_open_div = $(this).attr('data-input');
  291. $.post("{:U('util/selecturl', array('ok' => 1))}", {}, function(shtml){
  292. layer.open({
  293. type: 1,
  294. area: '930px',
  295. content: shtml //注意,如果str是object,那么需要字符拼接。
  296. });
  297. });
  298. })
  299. //监听提交
  300. form.on('submit(formDemo)', function(data){
  301. var gd_ar = [];
  302. var gd_str = '';
  303. $('.mult_choose_goodsid').each(function(){
  304. gd_ar.push( $(this).attr('data-gid') );
  305. })
  306. gd_str = gd_ar.join(',');
  307. var is_index_alert = 0;
  308. var is_index_show = 0;
  309. if($('input[name="is_index_alert"]').is(':checked')){
  310. is_index_alert = 1;
  311. }
  312. if($('input[name="is_index_show"]').is(':checked')){
  313. is_index_show = 1;
  314. }
  315. data.field.is_index_alert = is_index_alert;
  316. data.field.is_index_show = is_index_show;
  317. data.field.limit_goods_list = gd_str;
  318. console.log(data.field);
  319. $.ajax({
  320. url: data.form.action,
  321. type: data.form.method,
  322. data: data.field,
  323. dataType:'json',
  324. success: function (info) {
  325. if(info.status == 0)
  326. {
  327. layer.msg(info.result.message,{icon: 1,time: 2000});
  328. }else if(info.status == 1){
  329. var go_url = location.href;
  330. if( info.result.hasOwnProperty("url") )
  331. {
  332. go_url = info.result.url;
  333. }
  334. layer.msg('操作成功',{time: 1000,
  335. end:function(){
  336. location.href = info.result.url;
  337. var backurl = "{:U('marketing/coupon',array('ok'=>'1'))}";
  338. location.href = backurl;
  339. // location.href = info.result.url;
  340. }
  341. });
  342. }
  343. }
  344. });
  345. return false;
  346. });
  347. })
  348. function cancle_bind(obj,sdiv)
  349. {
  350. $('#'+sdiv).val('');
  351. $(obj).parent().parent().remove();
  352. }
  353. </script>
  354. </body>
  355. </html>