修复问题

master
yulingwei 5 years ago
parent 56b0216ff0
commit 7ea2a465bf

@ -930,7 +930,7 @@ class ArticleController extends AdminController {
$data['operater_id'] = is_login(); $data['operater_id'] = is_login();
$data['status'] = 1; $data['status'] = 1;
$res = $pop_rules_model->add($data); $res = $pop_rules_model->add($data);
return $res ? $this->success("新增完成") : $this->error("新增失败"); return $res ? $this->success("新增完成", U('Article/pop_rules')) : $this->error("新增失败");
} }
} else { } else {
if($id) { if($id) {
@ -943,7 +943,7 @@ class ArticleController extends AdminController {
if (!$rule) { if (!$rule) {
return $this->error('记录不存在'); return $this->error('记录不存在');
} }
$rule['pop_time'] = date("Y-m-d", ($rule['pop_time'] <= 10 ? time() : $rule['pop_time'])); $rule['pop_time'] = $rule['type'] == 1 ? date("Y-m-d", $rule['pop_time']) : $rule['pop_time'];
$this->assign('rule', $rule); $this->assign('rule', $rule);
} }
} }

@ -21,7 +21,7 @@
</li> </li>
<li> <li>
<label>类型</label> <label>类型</label>
<select id="type" name="type" class="select_gallery" onchange="checkPopTime();"> <select id="type" name="type" class="select_gallery" onchange="checkPopTime(0);">
<option value="0" <?php if ($rule['type'] == 0):?>selected<?php endif;?>>不弹窗</option> <option value="0" <?php if ($rule['type'] == 0):?>selected<?php endif;?>>不弹窗</option>
<option value="1" <?php if ($rule['type'] == 1):?>selected<?php endif;?>>单次弹窗</option> <option value="1" <?php if ($rule['type'] == 1):?>selected<?php endif;?>>单次弹窗</option>
<option value="2" <?php if ($rule['type'] == 2):?>selected<?php endif;?>>循环弹窗</option> <option value="2" <?php if ($rule['type'] == 2):?>selected<?php endif;?>>循环弹窗</option>
@ -37,6 +37,7 @@
</li> </li>
<li> <li>
<label>&nbsp;</label><input type="submit" id="submit" value="确认保存" target-form="form-horizontal" class="form_btn ajax-post"> <label>&nbsp;</label><input type="submit" id="submit" value="确认保存" target-form="form-horizontal" class="form_btn ajax-post">
<input type="button" value="返 回" target-form="form-horizontal" class="form_btn ajax-post" onclick="javascript:void(window.history.go(-1))">
</li> </li>
</ul> </ul>
</form> </form>
@ -65,27 +66,33 @@
<script type="text/javascript"> <script type="text/javascript">
</script> </script>
<script type="text/javascript"> <script type="text/javascript">
highlight_subnav('{:U('Article/pop_rule_edit')}'); highlight_subnav('{:U('Article/pop_rules')}');
function checkPopTime() function checkPopTime(first)
{ {
$("#li-pop-time").html(""); $("#li-pop-time").html("");
$('#pop_time').val('');
var type_val = $("#type").val(); var type_val = $("#type").val();
if (type_val == 0) { if (type_val == 0) {
//$('#li-pop-time').hide(); //$('#li-pop-time').hide();
} else if (type_val == 1) { } else if (type_val == 1) {
$("#li-pop-time").html('<label>弹窗时间</label><input type="text" id="pop_time" name="pop_time" class="" value="{$rule.pop_time}" placeholder="弹窗时间" />'); if (first || '{$rule["type"]}' == 1) {
$("#li-pop-time").html('<label>弹窗时间</label><input type="text" id="pop_time" readonly name="pop_time" class="" value="{$rule.pop_time}" placeholder="弹窗时间" />');
} else {
$("#li-pop-time").html('<label>弹窗时间</label><input type="text" id="pop_time" readonly name="pop_time" class="" value="" placeholder="弹窗时间" />');
}
$('#pop_time').datetimepicker({ $('#pop_time').datetimepicker({
format: 'yyyy-mm-dd', format: 'yyyy-mm-dd',
language:"zh-CN", language:"zh-CN",
minView:2, minView:2,
autoclose:true autoclose:true
}); });
} else if (type_val == 2) { } else if (type_val == 2) {
//$('#li-pop-time').show(); //$('#li-pop-time').show();
$("#li-pop-time").html('<label>弹窗时间</label><select id="pop_time" name="pop_time" class="select_gallery"><option value="1" <?php if ($rule["pop_time"] == 1):?>selected<?php endif;?>>周一</option><option value="2" <?php if ($rule["pop_time"] == 2):?>selected<?php endif;?> >周二</option><option value="3" <?php if ($rule["pop_time"] == 3):?>selected<?php endif;?> >周三</option><option value="4" <?php if ($rule["pop_time"] == 4):?>selected<?php endif;?> >周四</option><option value="5" <?php if ($rule["pop_time"] == 5):?>selected<?php endif;?> >周五</option><option value="6" <?php if ($rule["pop_time"] == 6):?>selected<?php endif;?> >周六</option><option value="7" <?php if ($rule["pop_time"] == 7):?>selected<?php endif;?> >周日</option></select>'); $("#li-pop-time").html('<label>弹窗时间</label><select id="pop_time" name="pop_time" class="select_gallery"><option value="1" <?php if ($rule["pop_time"] == 1):?>selected<?php endif;?>>周一</option><option value="2" <?php if ($rule["pop_time"] == 2):?>selected<?php endif;?> >周二</option><option value="3" <?php if ($rule["pop_time"] == 3):?>selected<?php endif;?> >周三</option><option value="4" <?php if ($rule["pop_time"] == 4):?>selected<?php endif;?> >周四</option><option value="5" <?php if ($rule["pop_time"] == 5):?>selected<?php endif;?> >周五</option><option value="6" <?php if ($rule["pop_time"] == 6):?>selected<?php endif;?> >周六</option><option value="7" <?php if ($rule["pop_time"] == 7):?>selected<?php endif;?> >周日</option></select>');
} }
} }
checkPopTime(); checkPopTime(1);
</script> </script>
</block> </block>

@ -26,6 +26,8 @@ use Home\Model\PromoteModel;
use Base\Service\PromoteService; use Base\Service\PromoteService;
use Base\Service\ApplyService; use Base\Service\ApplyService;
use Org\RedisSDK\Redis;
/** /**
* 前台首页控制器 * 前台首页控制器
* 主要获取首页聚合数据 * 主要获取首页聚合数据
@ -222,6 +224,9 @@ class PromoteController extends BaseController
$this->assign("rules", $rules); $this->assign("rules", $rules);
$this->assign("rules_count", count($rules)); $this->assign("rules_count", count($rules));
$redis = new \Org\RedisSDK\Redis(['host'=>'127.0.0.1','port'=>6379],[]);
$cacheKey = "pop:rule:set";
if (!$redis->sIsMember($cacheKey, get_pid())) {
$currentTime = strtotime(date('Y-m-d')); $currentTime = strtotime(date('Y-m-d'));
$weekArray = [7,1,2,3,4,5,6]; $weekArray = [7,1,2,3,4,5,6];
$week = $weekArray[date("w")]; $week = $weekArray[date("w")];
@ -230,6 +235,11 @@ class PromoteController extends BaseController
->where("(type = 1 and pop_time = {$currentTime}) or (type = 2 and pop_time = {$week})") ->where("(type = 1 and pop_time = {$currentTime}) or (type = 2 and pop_time = {$week})")
->order("sort asc, id desc") ->order("sort asc, id desc")
->select(); ->select();
} else {
$match_rules = [];
}
$this->assign("match_rules_id", $match_rules ? json_encode(array_column($match_rules, 'id')) : 'null'); $this->assign("match_rules_id", $match_rules ? json_encode(array_column($match_rules, 'id')) : 'null');
$this->assign("user_count", $user_count); $this->assign("user_count", $user_count);
@ -280,6 +290,19 @@ class PromoteController extends BaseController
$this->display('pop_rule_detail'); $this->display('pop_rule_detail');
} }
public function popRuleFinish()
{
$redis = new \Org\RedisSDK\Redis(['host'=>'127.0.0.1','port'=>6379],[]);
$cacheKey = "pop:rule:set";
if ($redis->exists($cacheKey)) {
$redis->sadd($cacheKey, get_pid());
} else {
$redis->sadd($cacheKey, get_pid());
$redis->exprieAt($cacheKey, strtotime(date('Y-m-d')) + 86400);
}
return $this->success("成功", [], true);
}
private function caculateSpend($pay_time, $condition, $create = [], $type = 0) private function caculateSpend($pay_time, $condition, $create = [], $type = 0)
{ {
$map['promote_id'] = array('egt', 0); $map['promote_id'] = array('egt', 0);

@ -90,6 +90,8 @@
<script src="__STATIC__/layer/layer.js" type="text/javascript"></script> <script src="__STATIC__/layer/layer.js" type="text/javascript"></script>
<script> <script>
var isAble = false; var isAble = false;
var force = '{$force}';
setTimeout(function (){ setTimeout(function (){
isAble = true; isAble = true;
}, 5000); }, 5000);
@ -100,19 +102,17 @@
layer.msg("请浏览5秒后再点击"); layer.msg("请浏览5秒后再点击");
return false; return false;
} else { } else {
setCookie(); // 查看完成
$.ajax({
url:"{:U('Promote/popRuleFinish')}",
method : "POST",
success:function(){
parent.layer.closeAll(); parent.layer.closeAll();
return true;
}
} }
});
function setCookie() return true;
{ }
var name = 'pop_over';
var value = '1';
var expires = new Date(new Date(new Date().getTime() + 24 * 60 * 60 * 1000).setHours(0, 0, 0, 0));
document.cookie = name + "=" + escape(value) + ";expires=" + expires.toGMTString();
console.log(name + "=" + escape(value) + ";expires=" + expires.toGMTString());
} }
function checkJump(url) function checkJump(url)

@ -611,6 +611,11 @@ class Redis
return $this->redis->sMembers($key); return $this->redis->sMembers($key);
} }
public function sIsMember($key, $v)
{
return $this->redis->sIsMember($key, $v);
}
/** /**
* 求2个集合的差集 * 求2个集合的差集
* @param unknown $key1 * @param unknown $key1

Loading…
Cancel
Save