master
yulingwei 5 years ago
parent aafc877e71
commit 076b4393eb

@ -783,13 +783,42 @@ class GameController extends ThinkController
public function devide_warn_edit($id=0)
{
if (IS_POST) {
if ($_POST['phones']) {
$_POST['phones'] = array_unique($_POST['phones']);
foreach ($_POST['phones'] as $phone) {
if (!preg_match('/^(13[0-9]|14[5|7]|15[0|1|2|3|4|5|6|7|8|9]|18[0|1|2|3|5|6|7|8|9])\d{8}$/', $phone)) {
return $this->error("请输入正确的手机号码:{$phone}");
}
}
$_POST['phones'] = json_encode($_POST['phones']);
} else {
$_POST['phones'] = '[]';
}
if (!is_numeric($_POST['advance_amount']) || !is_numeric($_POST['warming_amount']) || !is_numeric($_POST['warn_frequency'])) {
return $this->error("金额需为数字!");
}
if ($_POST['advance_amount'] < $_POST['warming_amount']) {
return $this->error("预警金额不能大于预付金额");
}
if ($_POST['warming_amount'] < $_POST['warn_frequency']) {
return $this->error("预警金额频率不能大于预警金额");
}
if ($id) {
$upt = M('partner_divide_warn', 'tab_')->where(['id'=>$id])->save($_POST);
return $upt ? $this->success("更新成功") : $this->error("更新失败");
} else {
if (M('partner_divide_warn', 'tab_')->where(['partner_id'=>$_POST['partner_id']]))
$ins = M('partner_divide_warn', 'tab_')->add($_POST);
return $ins ? $this->success("新增成功") : $this->error("新增失败");
}
} else {
$partners = M('partner', 'tab_')->field("id, partner")->where(['status'=>1])->order('last_up_time desc')->select();
$this->assign('partners', $partners);
if ($id) {
$warnInfo = M('partner_divide_warn', 'tab_')->where(['id'=>$id])->find();
if (!$warnInfo) return $this->error('未找到该记录');
$warnInfo['phones'] = json_decode($warnInfo['phones'], true);
$this->assign('warnInfo', $warnInfo);
}
$this->display();

@ -1,14 +1,43 @@
<extend name="Public/base" />
<block name="css">
<link rel="stylesheet" type="text/css" href="__CSS__/admin_table.css" media="all">
<link rel="stylesheet" type="text/css" href="__STATIC__/webuploader/webuploader.css" media="all">
<style>
#form .txt_area.download_url {width:400px;}
.tabcon1711 .table_radio2 .table_btn {width:215px;}
.bnt_add,.bnt_remove,.bnt_save{
height: 30px;
width: 20px;
font-size: 20px;
line-height: 10px;
color: #3399ff;
background: none;
border: none;
margin-left: 20px;
cursor: pointer;
}
.bnt_remove{
color: #F70909;
}
.bnt_save{
color: #4DB361;
}
</style>
</block>
<!-- 管理员用户组新增和编辑页面 -->
<block name="body">
<form action="{:U('Member/save_device_bans')}" enctype="application/x-www-form-urlencoded" method="POST"
<script src="__STATIC__/layer/layer.js" type="text/javascript"></script>
<script src="__STATIC__/layer/extend/layer.ext.js" type="text/javascript"></script>
<script type="text/javascript" src="__STATIC__/uploadify/jquery.uploadify.min.js"></script>
<form action="{:U('Game/devide_warn_edit')}" enctype="application/x-www-form-urlencoded" method="POST"
class="form-horizontal form_info_ml">
<div class="formtitle"><span>预警编辑</span></div>
<ul class="form_info ">
<input type="hidden" name="id" value="{$auth_group.id}" />
<input type="hidden" name="id" value="{$warnInfo.id}" />
<li>
<label>预警对象</label>
<select id="type" name="type" class="select_gallery">
<select id="partner_id" name="partner_id" class="select_gallery">
<?php foreach ($partners as $p):?>
<option value="{$p['id']}" >{$p.partner}</option>
<?php endforeach;?>
@ -23,15 +52,32 @@
<input name="warming_amount" type="text" class="txt" placeholder="预警金额" value="{$warnInfo.warming_amount}" />
</li>
<li>
<label>预警金额频率</label>
<input name="warn_frequency" type="text" class="txt" placeholder="当达到预警值时,每扣除多少流水短信提醒一次" value="{$warnInfo.warn_frequency}" />
</li>
<?php if ($warnInfo['phones']):?>
<?php foreach ($warnInfo['phones'] as $k => $phone):?>
<?php if ($k == 0):?>
<li class="warn-phone">
<label>手机号</label>
<input type="text" class="txt table_text_input" name="phones[]" value="{$phone}" placeholder="">
<button type="button" class="bnt_add"></button>
</li>
<?php else:?>
<li class="warn-phone">
<label>通知手机号</label>
<td class="r">
<input type="text" class="txt table_text_input" name="game_amount" value="10000.00" placeholder="" style="width: 55px"><span class="form_unit" style="margin: 0 10px">分成比例</span>
<input type="text" class="txt table_text_input" name="game_ratio" value="10.00" placeholder="" style="width: 50px"><span class="form_unit">%</span>
<button type="button" class="bnt_add"></button>
<button type="button" class="bnt_remove" data-id="24"></button>
<button type="button" class="bnt_save" data-id="24" data-type="ladder" style="display: none"></button>
</td>
<input type="text" class="txt table_text_input" name="phones[]" value="{$phone}" placeholder="">
<button type="button" class="bnt_remove"></button>
</li>
<?php endif;?>
<?php endforeach;?>
<?php else:?>
<li class="warn-phone">
<label>手机号</label>
<input type="text" class="txt table_text_input" name="phones[]" value="" placeholder="">
<button type="button" class="bnt_add"></button>
</li>
<?php endif;?>
<li>
<label>&nbsp;</label><input type="submit" id="submit" value="确认保存" target-form="form-horizontal" class="form_btn ajax-post">
</li>
@ -51,5 +97,12 @@
<block name="script">
<script type="text/javascript">
highlight_subnav('{:U('Game/devide_warn_edit')}');
$(".bnt_add").bind("click",function(){
var a= '<li class="warn-phone"><label>手机号</label><input type="text" class="txt table_text_input" name="phones[]" value="" placeholder=""><button type="button" class="bnt_remove"></button></li>';
$(".warn-phone:last").after(a);
});
$(document).on('click', '.bnt_remove', function(){
$(this).parents('li').remove();
});
</script>
</block>
Loading…
Cancel
Save