popadv_edit.html 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502
  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. <link rel="stylesheet" href="/layuiadmin/layui/css/layui.css" media="all">
  42. <link href="/static/css/snailfish.css" rel="stylesheet">
  43. <style>
  44. .content{
  45. display:none;
  46. width:200px;
  47. height:200px;
  48. border-radius:10px;
  49. padding:20px;
  50. position:relative;
  51. top:15px;
  52. left:50%;
  53. background-color:FFFFFF;
  54. border:1px solid;
  55. }
  56. </style>
  57. <script src="/layuiadmin/layui/layui.js"></script>
  58. <script>
  59. layui.config({
  60. base: '/layuiadmin/' //静态资源所在路径
  61. }).extend({
  62. index: 'lib/index' //主入口模块
  63. }).use('index');
  64. //由于模块都一次性加载,因此不用执行 layui.use() 来加载对应模块,直接使用即可:
  65. var layer = layui.layer;
  66. var $;
  67. var cur_open_div;
  68. </script>
  69. </head>
  70. <body layadmin-themealias="default">
  71. <div class="layui-fluid">
  72. <div class="layui-card">
  73. <div class="layui-card-header layui-elem-quote">当前位置:<span class="line-text">编辑弹窗广告</span></div>
  74. <div class="layui-card-body" style="padding:15px;">
  75. <form action="" method="post" class="layui-form" lay-filter="component-layui-form-item">
  76. <input type="hidden" name="data[id]" value="{$item[id]}" />
  77. <div class="layui-form-item">
  78. <label class="layui-form-label mustl"></label>
  79. <div class="layui-input-block">
  80. <span class='help-block'>使用弹窗广告请<span style="color:red;">开启redis服务</span>,否则无法使用</span>
  81. </div>
  82. </div>
  83. <div class="layui-form-item">
  84. <label class="layui-form-label mustl">活动名称</label>
  85. <div class="layui-input-block">
  86. <input type="text" name="data[adv_name]" class="form-control" value="{$item[adv_name]}" lay-verify='true' style="width: 50%;display: inline-block;" placeholder="请输入20个字以内名称" maxlength="20"/>
  87. </div>
  88. </div>
  89. <div class="layui-form-item">
  90. <label class="layui-form-label">全部广告</label>
  91. <div class="layui-input-block" style="width: 100%;">
  92. <a href="javascript:void(0)" id="addAdv" style="display:inline-block;color: #428bca;margin-top: 5px;">添加广告</a>
  93. &nbsp;&nbsp;&nbsp;&nbsp;
  94. <a href="javascript:void(0)" id="delAdv" style="display:inline-block;color: #428bca;margin-top: 5px;">删除广告</a>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #98999a;">(删除广告从最后一个开始删除,第一个广告无法删除)</span>
  95. </div>
  96. </div>
  97. <?php
  98. $i = 0;
  99. foreach($adv_list as $k=>$v){
  100. $i++;
  101. ?>
  102. <div class="adv_list" id="adv_list_<?php echo $i;?>">
  103. <input type="hidden" name="aid[]" value="<?php echo $i;?>"/>
  104. <input type="hidden" name="adv_id[]" value="<?php echo $v['id'];?>"/>
  105. <div class="layui-form-item">
  106. <label class="layui-form-label">广告<span class="adv_num"><?php echo $i;?></span>图片</label>
  107. <div class="layui-input-block">
  108. {:tpl_form_field_image2('thumb[]', $v['thumb'])}
  109. <span class='help-block'>建议尺寸:710 * 320或同比例, 请将所有幻灯片图片尺寸保持一致</span>
  110. </div>
  111. </div>
  112. <div class="layui-form-item">
  113. <label class="layui-form-label">广告<span class="adv_linkurl"><?php echo $i;?></span>跳转</label>
  114. <div class="layui-input-block">
  115. <label class='radio-inline'>
  116. <input type='radio' name='data[linktype_<?php echo $i;?>]' lay-filter="linktype_<?php echo $i;?>" title="本小程序链接" value="1" <?php if($v['linktype'] == 1){?>checked="checked"<?php }?>/>
  117. </label>
  118. <label class='radio-inline'>
  119. <input type='radio' name='data[linktype_<?php echo $i;?>]' lay-filter="linktype_<?php echo $i;?>" title="webview外链" value="0" <?php if($v['linktype'] == 0){?>checked="checked"<?php }?>/>
  120. </label>
  121. <label class='radio-inline'>
  122. <input type='radio' name='data[linktype_<?php echo $i;?>]' lay-filter="linktype_<?php echo $i;?>" title="外部小程序链接" value="2" <?php if($v['linktype'] == 2){?>checked="checked"<?php }?>/>
  123. </label>
  124. </div>
  125. </div>
  126. <div class="layui-form-item" style="<?php if($v['linktype'] != 2){?>display:none;<?php }?>" id="typeGroup_<?php echo $i;?>">
  127. <div class="layui-input-block " style="text-align: left;">
  128. <label class="layui-form-label" style="text-align: left;">外链小程序appid</label>
  129. <input type="text" name="data[appid_<?php echo $i;?>]" class="form-control" value="<?php echo $v['appid'];?>" maxlength="32" style="width:70%;"/>
  130. </div>
  131. </div>
  132. <div class="layui-form-item">
  133. <div class="layui-input-block" style="text-align: left;">
  134. <label class="layui-form-label" style="text-align: left;">链接</label>
  135. <div class="input-group " style="margin: 0;width:50%;">
  136. <input type="text" value="<?php echo $v['link'];?>" class="form-control valid" name="data[link_<?php echo $i;?>]" placeholder="" id="advlink_<?php echo $i;?>">
  137. <span class="input-group-btn" id="chose_link_box_<?php echo $i;?>" <?php if($v['linktype'] != 1){?>style="display:none;"<?php }?>>
  138. <span data-input="#advlink_<?php echo $i;?>" id="chose_link_<?php echo $i;?>" class="btn btn-default">选择链接</span>
  139. </span>
  140. </div>
  141. <span class='help-block' style="display:none;" id="chose_link_tip_1">备注:请使用http或https链接,需要在<a href="http://mp.weixin.qq.com" target="_blank">mp.weixin.qq.com</a>开发-开发设置-业务域名添加上此域名</span>
  142. </div>
  143. </div>
  144. </div>
  145. <?php if($i > 1){ ?>
  146. <script>
  147. layui.use(['jquery', 'layer','form'], function() {
  148. $ = layui.$;
  149. var form = layui.form;
  150. layui.form.render();
  151. form.on('radio(linktype_{$i})', function (data) {
  152. if (data.value == 2) {
  153. $('#typeGroup_{$i}').show();
  154. $('#chose_link_box_{$i}').hide();
  155. }
  156. else if (data.value == 0) {
  157. $('#typeGroup_{$i}').hide();
  158. $('#chose_link_box_{$i}').hide();
  159. $('#chose_link_tip_{$i}').show();
  160. }
  161. else {
  162. $('#typeGroup_{$i}').hide();
  163. $('#chose_link_box_{$i}').show();
  164. $('#chose_link_tip_{$i}').hide();
  165. }
  166. });
  167. $('#chose_link_{$i}').click(function(){
  168. cur_open_div = $(this).attr('data-input');
  169. $.post("/seller.php?s=/util/selecturl/ok/1", {}, function(shtml){
  170. layer.open({
  171. type: 1,
  172. area: '930px',
  173. content: shtml //注意,如果str是object,那么需要字符拼接。
  174. });
  175. });
  176. })
  177. });
  178. </script>
  179. <?php } ?>
  180. <?php } ?>
  181. <div id="adv_end_list"></div>
  182. <div class="layui-form-item">
  183. <label class="layui-form-label mustl">广告时间</label>
  184. <div class="layui-input-block">
  185. {:tpl_form_field_daterange('time', array('starttime'=>date('Y-m-d H:i', $item['begin_time']),'endtime'=>date('Y-m-d H:i', $item['end_time'])),true);}
  186. </div>
  187. </div>
  188. <div class="layui-form-item">
  189. <label class="layui-form-label">投放会员</label>
  190. <div class="layui-input-block" >
  191. <input type="radio" lay-filter="is_limit_goodsbuy" name="data[send_person]" value="1" <?php if( (!empty($item['send_person']) && $item['send_person'] == 1) || empty($item['send_person'])){ ?>checked<?php } ?> title="指定用户发送" />
  192. <input type="radio" lay-filter="is_limit_goodsbuy" name="data[send_person]" value="2" <?php if( !empty($item['send_person']) && $item['send_person'] == 2){ ?>checked<?php } ?> title="按用户分组等级发送" />
  193. <input type="radio" lay-filter="is_limit_goodsbuy" name="data[send_person]" value="3" <?php if( !empty($item['send_person']) && $item['send_person'] == 3){ ?>checked<?php } ?> title="全部发送({$membercount}人)" />
  194. </div>
  195. </div>
  196. <div class="layui-form-item" id="type_1" style="<?php if($item['send_person'] != 1){ ?>display:none;<?php }?>">
  197. <label class="layui-form-label">关联会员</label>
  198. <div class="layui-input-block">
  199. <div class="input-group " style="margin: 0;">
  200. <input type="text" disabled value="" class="form-control valid" name="" placeholder="" id="agent_id">
  201. <span class="input-group-btn">
  202. <span data-input="#agent_id" id="chose_agent_id" class="btn btn-default">选择会员</span>
  203. </span>
  204. </div>
  205. <?php if(!empty($user_list)){ ?>
  206. <?php foreach( $user_list as $a ){ ?>
  207. <div class="input-group mult_choose_member_id" data-member-id="{$a['member_id']}" style="border-radius: 0;float: left;margin: 10px;margin-left:0px;width: 22%;">
  208. <div class="layadmin-text-center choose_user">
  209. <img style="" src="{$a['avatar']}">
  210. <div class="layadmin-maillist-img" style="">{$a['username']}</div>
  211. <button type="button" class="layui-btn layui-btn-sm" onclick="cancle_bind(this)">
  212. <i class="layui-icon"></i>
  213. </button>
  214. </div>
  215. </div>
  216. <?php }} ?>
  217. </div>
  218. </div>
  219. <div class="layui-form-item" id="type_2" style="<?php if($item['send_person'] != 2){ ?>display:none;<?php }?>">
  220. <label class="layui-form-label must">会员组</label>
  221. <div class="layui-input-block">
  222. <select name="data[member_group_id]">
  223. <?php foreach($list as $val){ ?>
  224. <option value="{$val['id']}" <?php if($item['member_group_id'] == $val['id']){ ?>selected="selected"<?php }?>>{$val['groupname']}({$val['membercount']}人)</option>
  225. <?php } ?>
  226. </select>
  227. </div>
  228. </div>
  229. <div class="layui-form-item">
  230. <label class="layui-form-label mustl">投放页面</label>
  231. <div class="layui-input-block" id="param-items">
  232. <label class="radio-inline">
  233. <input type="radio" name='data[pop_page]' lay-filter="pop_page" value="0" <?php if( empty($item['pop_page']) && $item['pop_page'] == 0){ ?>checked<?php } ?> title="商城首页" />
  234. </label>
  235. <label class="radio-inline">
  236. <input type="radio" name='data[pop_page]' lay-filter="pop_page" value="1" <?php if( !empty($item['pop_page']) && $item['pop_page'] == 1){ ?>checked<?php } ?> title="商城分类" />
  237. </label>
  238. <label class="radio-inline">
  239. <input type="radio" name='data[pop_page]' lay-filter="pop_page" value="2" <?php if( !empty($item['pop_page']) && $item['pop_page'] == 2){ ?>checked<?php } ?> title="商城购物车" />
  240. </label>
  241. <label class="radio-inline">
  242. <input type="radio" name='data[pop_page]' lay-filter="pop_page" value="3" <?php if( !empty($item['pop_page']) && $item['pop_page'] == 3){ ?>checked<?php } ?> title="商城个人中心" />
  243. </label>
  244. </div>
  245. </div>
  246. <?php
  247. $index_show_txt = "首页";
  248. if(!empty($item['pop_page'])){
  249. if($item['pop_page'] == 1){
  250. $index_show_txt = "商城分类";
  251. }else if($item['pop_page'] == 2){
  252. $index_show_txt = "商城购物车";
  253. }else if($item['pop_page'] == 3){
  254. $index_show_txt = "商城个人中心";
  255. }
  256. }
  257. ?>
  258. <div class="layui-form-item">
  259. <label class="layui-form-label mustl">出现次数</label>
  260. <div class="layui-input-block" id="param-items">
  261. <div class="input-group">
  262. <input type="radio" name='data[is_index_show]' value="0" <?php if( empty($item['is_index_show']) && $item['is_index_show'] == 0){ ?>checked<?php } ?> title='<font id="index_show_txt_1"><?php echo $index_show_txt;?></font><font>访问页面时出现,之后不再出现</font>'/>
  263. </div>
  264. <div class="input-group">
  265. <input type="radio" name='data[is_index_show]' value="1" <?php if( !empty($item['is_index_show']) && $item['is_index_show']==1){ ?>checked<?php } ?> title='<font id="index_show_txt"><?php echo $index_show_txt;?></font><font>访问页面时出现,之后每</font>&nbsp;&nbsp;<input type="text" value="{$item['show_hour']}" class="" name="data[show_hour]" style="width: 100px;" maxlength="10">&nbsp;&nbsp;<font>小时出现1次</font>' />
  266. </div>
  267. <span class='help-block'>出现频次时间间隔不能大于投放时间,在广告投放时间内,用户访问投放页面会弹出广告,请设置广告出现的频次</span>
  268. </div>
  269. </div>
  270. <div class="layui-form-item">
  271. <label class="layui-form-label">排序</label>
  272. <div class="layui-input-block">
  273. <input type="text" name="data[sort_order]" class="form-control" value="{$item['sort_order']}"/>
  274. <span class='help-block'>数字越大,排名越靠前</span>
  275. </div>
  276. </div>
  277. <div class="layui-form-item">
  278. <label class="layui-form-label">状态</label>
  279. <div class="layui-input-block">
  280. <label class='radio-inline'>
  281. <input type='radio' name='data[status]' title="开启" value="1" <?php if( $item['status']==1 || empty($item)){ ?>checked<?php } ?> />
  282. </label>
  283. <label class='radio-inline'>
  284. <input type='radio' name='data[status]' title="关闭" value="0" <?php if( $item['status']==0 && !empty($item) ){ ?>checked<?php } ?> />
  285. </label>
  286. </div>
  287. </div>
  288. <div class="layui-form-item">
  289. <label class="layui-form-label"> </label>
  290. <div class="layui-input-block">
  291. <input type="submit" value="提交" lay-submit lay-filter="formDemo" class="btn btn-primary" />
  292. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  293. <a class="btn btn-default" style='margin-left:10px;' href="{:U('popadv/index',array('ok'=>'1'))}">返回列表</a>
  294. </div>
  295. </div>
  296. </form>
  297. </div>
  298. </div>
  299. </div>
  300. <script>
  301. $(document).ready(function(){
  302. $(".contact").mouseover(function(){
  303. $(".content").show("slow");
  304. $(".contact").mouseout(function(){
  305. $(".content").hide("slow");
  306. });
  307. });
  308. })
  309. layui.use(['jquery', 'layer','form'], function(){
  310. $ = layui.$;
  311. var form = layui.form;
  312. layui.form.render();
  313. form.on('radio(pop_page)', function(data){
  314. if (data.value == 1) {
  315. $('#index_show_txt').html('商城分类');
  316. $('#index_show_txt_1').html('商城分类');
  317. } else if (data.value == 2) {
  318. $('#index_show_txt').html('商城购物车');
  319. $('#index_show_txt_1').html('商城购物车');
  320. } else if (data.value == 3) {
  321. $('#index_show_txt').html('商城个人中心');
  322. $('#index_show_txt_1').html('商城个人中心');
  323. } else{
  324. $('#index_show_txt').html('首页');
  325. $('#index_show_txt_1').html('首页');
  326. }
  327. });
  328. form.on('radio(linktype_1)', function(data){
  329. if (data.value == 2) {
  330. $('#typeGroup_1').show();
  331. $('#chose_link_box_1').hide();
  332. }
  333. else if( data.value == 0 )
  334. {
  335. $('#typeGroup_1').hide();
  336. $('#chose_link_box_1').hide();
  337. $('#chose_link_tip_1').show();
  338. }
  339. else {
  340. $('#typeGroup_1').hide();
  341. $('#chose_link_box_1').show();
  342. $('#chose_link_tip_1').hide();
  343. }
  344. });
  345. form.on('radio(is_limit_goodsbuy)', function(data){
  346. if(data.value == 1)
  347. {
  348. $('#type_1').show();
  349. $('#type_2').hide();
  350. }else if(data.value == 2)
  351. {
  352. $('#type_1').hide();
  353. $('#type_2').show();
  354. }
  355. else{
  356. $('#type_1').hide();
  357. $('#type_2').hide();
  358. }
  359. });
  360. $('#chose_link_1').click(function(){
  361. cur_open_div = $(this).attr('data-input');
  362. $.post("/seller.php?s=/util/selecturl/ok/1", {}, function(shtml){
  363. layer.open({
  364. type: 1,
  365. area: '930px',
  366. content: shtml //注意,如果str是object,那么需要字符拼接。
  367. });
  368. });
  369. })
  370. $('#chose_agent_id').click(function(){
  371. cur_open_div = $(this).attr('data-input');
  372. $.post("/seller.php?s=/user/zhenquery_many/template/mult", {}, function(shtml){
  373. layer.open({
  374. type: 1,
  375. area: '930px',
  376. content: shtml //注意,如果str是object,那么需要字符拼接。
  377. });
  378. });
  379. })
  380. $('#chose_member_id').click(function(){
  381. cur_open_div = $(this).attr('data-input');
  382. $.post("/seller.php?s=/user/query/is_quan/1", {}, function(shtml){
  383. layer.open({
  384. type: 1,
  385. area: '930px',
  386. content: shtml //注意,如果str是object,那么需要字符拼接。
  387. });
  388. });
  389. })
  390. $('#addAdv').click(function(){
  391. var count = $('.adv_list').length;
  392. if(count < 5){
  393. $.ajax({
  394. url: "/seller.php?s=/popadv/add_adv",
  395. type: "post",
  396. data: {num:count+1},
  397. dataType:'json',
  398. success: function (info) {
  399. $('#adv_end_list').before(info.html);
  400. layui.form.render();
  401. }
  402. });
  403. }else{
  404. layer.msg('广告最多添加5条',{icon:5});
  405. }
  406. })
  407. $('#delAdv').click(function(){
  408. var count = $('.adv_list').length;
  409. if(count > 1){
  410. $('.adv_list')[count-1].remove();
  411. }else{
  412. layer.msg('广告不能少于1条',{icon:5});
  413. }
  414. });
  415. //监听提交
  416. form.on('submit(formDemo)', function(data){
  417. var loadingIndex = layer.load();
  418. var member_id_ar = [];
  419. var member_id_str = '';
  420. $('.mult_choose_member_id').each(function(){
  421. member_id_ar.push( $(this).attr('data-member-id') );
  422. });
  423. member_id_str = member_id_ar.join(',');
  424. data.field.member_id = member_id_str;
  425. console.log(data.field);
  426. $.ajax({
  427. url: data.form.action,
  428. type: data.form.method,
  429. data: data.field,
  430. dataType:'json',
  431. success: function (info) {
  432. if(info.status == 0)
  433. {
  434. layer.msg(info.result.message,{icon: 1,time: 2000});
  435. layer.close(loadingIndex);
  436. }else if(info.status == 1){
  437. var go_url = location.href;
  438. if( info.result.hasOwnProperty("url") )
  439. {
  440. go_url = info.result.url;
  441. }
  442. layer.msg('操作成功',{time: 1000,
  443. end:function(){
  444. location.href = info.result.url;
  445. }
  446. });
  447. }
  448. }
  449. });
  450. return false;
  451. });
  452. })
  453. function cancle_bind(obj,sdiv)
  454. {
  455. $('#'+sdiv).val('');
  456. $(obj).parent().parent().remove();
  457. }
  458. </script>
  459. </body>