couponsend.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  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. <body layadmin-themealias="default">
  46. <div class="layui-fluid">
  47. <div class="layui-card">
  48. <div class="layui-card-header layui-elem-quote">当前位置:<span class="line-text">手动发送优惠券</small></span></div>
  49. <div class="layui-card-body" style="padding:15px;">
  50. <form action="" method="post" class="layui-form" enctype="multipart/form-data" >
  51. <div class="layui-form-item">
  52. <label class="layui-form-label">选择优惠券</label>
  53. <div class="layui-input-block">
  54. <select name='voucher_id' id="voucher_id" class="layui-input layui-unselect">
  55. <option value=''></option>
  56. <?php foreach($quan_list as $c){ ?>
  57. <option value="{$c['id']}" person_limit_count="{$c['person_limit_count']}" total_count="{$c['total_count']}" send_count="{$c['send_count']}">{$c['voucher_title']}</option>
  58. <?php } ?>
  59. </select>
  60. </div>
  61. </div>
  62. <div class="layui-form-item">
  63. <label class="layui-form-label">每人发送张数</label>
  64. <div class="layui-input-block">
  65. <input type="text" name="send_count" id="send_count" class="form-control" value="1" />
  66. <span class='help-block'>此处受总数限制,如果剩余张数不足以发放给选定会员数量,则无法发放</span>
  67. </div>
  68. </div>
  69. <div class="layui-form-item">
  70. <label class="layui-form-label">首页领取</label>
  71. <div class="layui-input-block" >
  72. <input type="radio" lay-filter="is_limit_goodsbuy" name="send_person" value="1" checked="true" title="指定用户发送" />
  73. <input type="radio" lay-filter="is_limit_goodsbuy" name="send_person" value="2" title="按用户分组等级发送" />
  74. <input type="radio" lay-filter="is_limit_goodsbuy" name="send_person" value="3" title="全部发送({$membercount}人)" />
  75. <input type="hidden" id="member_all_count" name="member_all_count" value="{$membercount}"/>
  76. </div>
  77. </div>
  78. <div class="layui-form-item" id="type_1">
  79. <label class="layui-form-label">关联会员</label>
  80. <div class="layui-input-block">
  81. <div class="input-group " style="margin: 0;">
  82. <input type="text" disabled value="" class="form-control valid" name="" placeholder="" id="agent_id">
  83. <span class="input-group-btn">
  84. <span data-input="#agent_id" id="chose_agent_id" class="btn btn-default">选择会员</span>
  85. </span>
  86. </div>
  87. </div>
  88. </div>
  89. <div class="layui-form-item" id="type_2" style="display:none;">
  90. <label class="layui-form-label must">会员组</label>
  91. <div class="layui-input-block">
  92. <select name="member_group_id" id="member_group_id">
  93. <?php foreach($list as $val){ ?>
  94. <option value="{$val['id']}" member_count="{$val['membercount']}">{$val['groupname']}({$val['membercount']}人)</option>
  95. <?php } ?>
  96. </select>
  97. </div>
  98. </div>
  99. <div class="layui-form-item">
  100. <label class="layui-form-label"></label>
  101. <div class="layui-input-block">
  102. <input type="hidden" name="limit_goods_list" value="{$item['limit_goods_list']}" id="limit_goods_list" />
  103. <input type="submit" name="submit" value="确认发送" lay-submit lay-filter="formDemo" class="btn btn-primary col-lg-1"/>
  104. </div>
  105. </div>
  106. </form>
  107. </div>
  108. </div>
  109. </div>
  110. <script src="/layuiadmin/layui/layui.js"></script>
  111. <script>
  112. layui.config({
  113. base: '/layuiadmin/' //静态资源所在路径
  114. }).extend({
  115. index: 'lib/index' //主入口模块
  116. }).use('index');
  117. </script>
  118. <script>
  119. //由于模块都一次性加载,因此不用执行 layui.use() 来加载对应模块,直接使用即可:
  120. var layer = layui.layer;
  121. var $;
  122. var cur_open_div;
  123. layui.use(['jquery', 'layer','form'], function(){
  124. $ = layui.$;
  125. var form = layui.form;
  126. form.on('radio(is_limit_goodsbuy)', function(data){
  127. if(data.value == 1)
  128. {
  129. $('#type_1').show();
  130. $('#type_2').hide();
  131. }else if(data.value == 2)
  132. {
  133. $('#type_1').hide();
  134. $('#type_2').show();
  135. }
  136. else{
  137. $('#type_1').hide();
  138. $('#type_2').hide();
  139. }
  140. });
  141. $('#chose_agent_id').click(function(){
  142. cur_open_div = $(this).attr('data-input');
  143. $.post("{:U('user/zhenquery_many', array('template' => 'mult'))}", {}, function(shtml){
  144. layer.open({
  145. type: 1,
  146. area: '930px',
  147. content: shtml //注意,如果str是object,那么需要字符拼接。
  148. });
  149. });
  150. })
  151. $('#chose_member_id').click(function(){
  152. cur_open_div = $(this).attr('data-input');
  153. $.post("{:U('user/query', array('is_quan' => 1))}", {}, function(shtml){
  154. layer.open({
  155. type: 1,
  156. area: '930px',
  157. content: shtml //注意,如果str是object,那么需要字符拼接。
  158. });
  159. });
  160. })
  161. $('#chose_link').click(function(){
  162. cur_open_div = $(this).attr('data-input');
  163. $.post("{:U('util.selecturl', array('ok' => 1))}", {}, function(shtml){
  164. layer.open({
  165. type: 1,
  166. area: '930px',
  167. content: shtml //注意,如果str是object,那么需要字符拼接。
  168. });
  169. });
  170. })
  171. //监听提交
  172. form.on('submit(formDemo)', function(data){
  173. var gd_ar = [];
  174. var gd_str = '';
  175. var member_count = 0;
  176. $('.mult_choose_member_id').each(function(){
  177. gd_ar.push( $(this).attr('data-member-id') );
  178. member_count++;
  179. })
  180. gd_str = gd_ar.join(',');
  181. data.field.limit_user_list = gd_str;
  182. if(data.field.voucher_id == ''){
  183. layer.msg('请选择优惠券');
  184. return false;
  185. }
  186. if(data.field.send_count <= 0 )
  187. {
  188. layer.msg('请填写发送数量');
  189. return false;
  190. }
  191. if(data.field.send_person == 1 )
  192. {
  193. if(gd_str == '')
  194. {
  195. layer.msg('请选择发送人');
  196. return false;
  197. }
  198. }
  199. var person_limit_count = $('#voucher_id').find("option:selected").attr("person_limit_count");
  200. if(parseInt(data.field.send_count) > parseInt(person_limit_count) && parseInt(person_limit_count)!=0 ){
  201. layer.msg('每人发送张数不能超过优惠券设定的每人限领');
  202. return false;
  203. }
  204. var total_count = $('#voucher_id').find("option:selected").attr("total_count");
  205. var send_count = $('#voucher_id').find("option:selected").attr("send_count");
  206. var sy_count = parseInt(total_count)-parseInt(send_count);
  207. var send_total_count = 0;
  208. if(data.field.send_person == 1 ){
  209. send_total_count = parseInt(member_count)*parseInt(data.field.send_count);
  210. }else if(data.field.send_person == 2 ){
  211. var member_group_count = $('#member_group_id').find("option:selected").attr("member_count");
  212. send_total_count = parseInt(member_group_count)*parseInt(data.field.send_count);
  213. }else if(data.field.send_person == 3 ){
  214. send_total_count = $('#member_all_count').val();
  215. }
  216. if(parseInt(total_count) != -1 ){
  217. if(parseInt(send_total_count) > parseInt(sy_count)){
  218. layer.msg('发放总数(发放人数*每人张数)必须小于或等于优惠券剩余的数量');
  219. return false;
  220. }
  221. }
  222. layer.confirm('确认发送吗?', function(index){
  223. $.post("{:U('marketing/couponsend_do')}", data.field, function(shtml){
  224. layer.open({
  225. type: 1,
  226. area: '930px',
  227. content: shtml //注意,如果str是object,那么需要字符拼接。
  228. });
  229. });
  230. })
  231. return false;
  232. //mult_choose_goodsid limit_goods_list
  233. var gd_ar = [];
  234. var gd_str = '';
  235. $('.mult_choose_goodsid').each(function(){
  236. gd_ar.push( $(this).attr('data-gid') );
  237. })
  238. gd_str = gd_ar.join(',');
  239. data.field.limit_goods_list = gd_str;
  240. $.ajax({
  241. url: data.form.action,
  242. type: data.form.method,
  243. data: data.field,
  244. dataType:'json',
  245. success: function (info) {
  246. if(info.status == 0)
  247. {
  248. layer.msg(info.result.message,{icon: 1,time: 2000});
  249. }else if(info.status == 1){
  250. var go_url = location.href;
  251. if( info.result.hasOwnProperty("url") )
  252. {
  253. go_url = info.result.url;
  254. }
  255. layer.msg('操作成功',{time: 1000,
  256. end:function(){
  257. var backurl = "{:U('marketing',array('ok'=>'1'))}";
  258. location.href = backurl;
  259. // location.href = info.result.url;
  260. }
  261. });
  262. }
  263. }
  264. });
  265. return false;
  266. });
  267. })
  268. function cancle_bind(obj,sdiv)
  269. {
  270. $('#'+sdiv).val('');
  271. $(obj).parent().parent().remove();
  272. }
  273. </script>
  274. </body>
  275. </html>